<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Sam&#39;s Notebook</title>
<link>https://robertslab.github.io/sams-notebook/</link>
<atom:link href="https://robertslab.github.io/sams-notebook/index.xml" rel="self" type="application/rss+xml"/>
<description></description>
<generator>quarto-1.6.42</generator>
<lastBuildDate>Tue, 08 Sep 2026 07:00:00 GMT</lastBuildDate>
<item>
  <title>Gape Monitoring - Initial Configuration and Simulations</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-09-08-Gape-Monitoring---Initial-Configuration-and-Simulations/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>A while ago, <a href="https://github.com/RobertsLab/resources/issues/2327">Steven asked me to spec out a gape monitoring system</a> (GitHub Issue). The idea was based on the <a href="https://www.sciencedirect.com/science/article/pii/S1470160X24005429">valve gape monitoring system</a> (ScienceDirect) described in the paper by H. M. Stokes et al., 2024. In that paper, they set up a small Arduino-based system to monitor the valve gape of bivalves. The system used a small data logger, magnets and a three-axis magnetometer to measure assess frequency, duration, and the amplitude of the gape movements.</p>
<p>A primary advantage of this system is that it is relatively inexpensive (for example, the Arduino units only cost ~$13 each) and can be easily deployed in the field.</p>
<p>We’ve purchased something similar to the system described in the paper, and I was tasked with setting up the initial configuration and running some simulations to test the system’s performance.</p>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<p>I used the following materials to set up the initial configuration of the gape monitoring system:</p>
<ul>
<li><p>Adafruit RP2040 Feather Adalogger (Arduino-based data logger)</p></li>
<li><p>Adafruit TLV493D 3-Axis Magnetometer</p></li>
<li><p>4mm x 2mm neodymium magnets</p></li>
<li><p>one dead oyster</p></li>
</ul>
<section id="initial-configuration" class="level2">
<h2 class="anchored" data-anchor-id="initial-configuration">Initial Configuration</h2>
<p>First, I installed the CircuitPython extension for VS Code. The primary advantage of this is being able to view/use the Serial console directly in VS Code, which makes it easier to debug and test the code.</p>
<p>The CircuitPython extension for VS Code is available in the VS Code marketplace. Briefly, once it’s installed, connect the Adafruit RP2040 Feather Adalogger to your computer via USB, and then Open the the CICRUITPY folder in VS Code. The CircuitPython extension will automatically detect the Adafruit RP2040 Feather Adalogger. Then, you can open the Serial console in VS Code by clicking on the “CircuitPython: Open Serial Console” button in the bottom right corner of VS Code. This will open a terminal window that allows you to view the output from the Adafruit RP2040 Feather Adalogger.</p>
<p>The Adfruit website has a <a href="https://learn.adafruit.com/adafruit-feather-rp2040-adalogger/install-circuitpython">great tutorial</a> (Adafruit website) on how to set up the Adafruit RP2040 Feather Adalogger with CircuitPython. I followed the steps in that tutorial to get the data logger up and running.</p>
<p>The initial configuration involved the following steps:</p>
<ol type="1">
<li><p><a href="https://learn.adafruit.com/adafruit-feather-rp2040-adalogger/install-circuitpython">Initialize the Adafruit RP2040 Feather Adalogger with CircuitPython</a> (Adafruit website).</p></li>
<li><p>Install the CircuitPython libraries, using the <a href="https://circuitpython.org/libraries">entire Adafruit CircuitPython Bundle for Version 10.x</a>, on the Adafruit RP2040 Feather Adalogger.</p></li>
<li><p>Attach the Adafruit TLV493D 3-Axis Magnetometer to the Adafruit RP2040 Feather Adalogger via the STEMMA QT connection.</p></li>
</ol>
<p>After that was setup, I used some <a href="https://learn.adafruit.com/adafruit-tlv493-triple-axis-magnetometer?view=all#example-code-3039148">basic code provided by Adafruit</a> to test the magnetometer and ensure that I could get readings. The code was able to read the magnetic field values from the magnetometer and print them to the console.</p>
</section>
<section id="code" class="level2">
<h2 class="anchored" data-anchor-id="code">Code</h2>
<p>With the assistance Claude Science, I was able to modify the code to log the magnetic field values to a CSV file on the Adafruit RP2040 Feather Adalogger. The code is available in <a href="https://github.com/RobertsLab/code/blob/master/gape_monitoring/time-elapsed/code.py"><code>code.py</code></a> (GitHub). The code logs the magnetic field values to a CSV file every 1 second. The CSV file is saved to the Adafruit RP2040 Feather Adalogger’s SD card. Currently, the code only logs cumulative time elapsed since the start of the program (e.g.&nbsp;when the Adafruit RP2040 Feather Adalogger is powered on) due to the fact that the Adafruit RP2040 Feather Adalogger does not have a real-time clock. However, I plan to add a real-time clock to the system in the future, which will allow me to log the actual date and time of each reading.</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p>The code will be continually updated and improved over time. Please check the GitHub repository for the latest version of the code. For example, currently the code does not perform any calibration adjustments for the magnetometer and does not assess gape distance. Additionally, the code does not assess whether or not the changes in the magnetic field values identified as gape events are statistically significantly different from the background noise. These are all things that will be added in the future.</p>
</div>
</div>
</section>
<section id="simulations" class="level2">
<h2 class="anchored" data-anchor-id="simulations">Simulations</h2>
<p>I used masking tape to attache the magnetometer to the leading edge of the bottom valve of the dead oyster. Initially, I attached a single magnet to the leading edge of the top valve of the dead oyster. The magnetic field that was able to be detected from a single magnet was very weak and had me concerned that they would be indistinguishable from the background noise. I then <em>stacked</em> (side-by-side seemed to cancel out the magnetic field) a second magnet to the leading edge of the top valve of the dead oyster, and this increased the magnetic field strength that was detected by the magnetometer.</p>
<p>I used small piece of plastic to keep the shell open ~5mm for various durations and recorded the data from the magnetometer. The data was logged to a CSV file on the Adafruit RP2040 Feather Adalogger’s SD card. I then used R to read in the CSV file and plot the magnetic field values over time.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-09-08-Gape-Monitoring---Initial-Configuration-and-Simulations/gape_monitoring_testing-01.jpg2026-09-08-gape-monitoring-setup.jpg" class="img-fluid figure-img"></p>
<figcaption>Pacific oyster with green masking tape on the leading edge of the bottom valve to hold magnetometer, and two neodymium magnets stacked on the leading edge of the top valve. The light on the RP2040 Adalogger is illuminated, indicating it’s capturing data at that moment.</figcaption>
</figure>
</div>
</section>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<p>Using Claude Science, <a href="https://github.com/RobertsLab/code/blob/master/gape_monitoring/time-elapsed/gaping_analysis-time-elapsed.Rmd">I produced an R Markdown file</a> (GitHub) was able to analyze the data from the CSV file and plot the magnetic field values over time, while also highlighting the periods of time when the shell was open.</p>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Data analysis seems to work as desired. The magnetic field values are clearly distinguishable from the background noise, and the periods of time when the shell was open are clearly visible in the plots.</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-09-08-Gape-Monitoring---Initial-Configuration-and-Simulations/gape_monitoring_analysis-01.jpg" class="img-fluid figure-img"></p>
<figcaption>Magnetic field magnitude over time shown for three data sets. The 3rd data set spans ~6000 seconds and highlights the periods when the shell was open in grey.</figcaption>
</figure>
</div>
</section>
<section id="summary" class="level1">
<h1>SUMMARY</h1>
<p>Overall, this is a promising start to the gape monitoring system. The initial configuration and simulations have shown that the system is capable of detecting the valve gape of bivalves, and the data analysis has been successful in identifying the periods of time when the shell was open.</p>
<p>Next, I plan to add a real-time clock to the system, which will allow me to log the actual date and time of each reading. Additionally, I plan to determine calibration values (e.g.&nbsp;correlate magnetic field values with known gape measurements) for all three magnetometers, which will allow me to convert the magnetic field values to actual gape measurements. Once these are completed, I’ll test out on live oysters in the lab.</p>


</section>

 ]]></description>
  <category>2026</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-09-08-Gape-Monitoring---Initial-Configuration-and-Simulations/</guid>
  <pubDate>Tue, 08 Sep 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Resazurin Assays - USDA M.gigas Juveniles OAE Preconditioning Effect on 36C Heat Stress Response</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-31-Resazurin-Assays---USDA-M.gigas-Juveniles-OAE-Preconditioning-Effect-on-36C-Heat-Stress-Response/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Steven wanted to assess metabolism of juvenile <em>Magallana gigas</em> (Pacific oyster) after ocean alkalinity enhancement (OAE) preconditioning and subsequent heat stress. The goal was to determine whether OAE preconditioning would affect metabolic response to 36°C heat stress.</p>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<p>Juvenile <em>Magallana gigas</em> (Pacific oyster) were subjected to OAE preconditioning at 10°C for 6 hours on 20260828. After exposure, oysters were returned to standard seawater conditions. This was performed by Steven.</p>
<p>Today, 46 OAE-preconditioned oysters and 46 control oysters were subjected to 36°C heat stress. Oysters were randomly distributed across four 48-well clear plates and submerged in 2mL of resazurin working solution, with fluorescence measured every 30 minutes in a Synergy HTX plate reader (Agilent).</p>
<p>Resazurin working solution was prepared from a stock solution made by me on 20260610. The working solution was made with Instant Ocean held at 10°C.</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>Reagent</th>
<th>Volume</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Instant Ocean</td>
<td>208mL</td>
</tr>
<tr class="even">
<td>resazurin stock solution</td>
<td>469uL</td>
</tr>
<tr class="odd">
<td>DMSO</td>
<td>211uL</td>
</tr>
<tr class="even">
<td>100x Penn/Strep &amp; 100x Fungizone</td>
<td>2.11mL</td>
</tr>
</tbody>
</table>
<p>Resazurin working-solution temperatures were recorded by the plate reader at each read (mean across the four plates):</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Timepoint (hrs)</th>
<th style="text-align: left;">Temp (C)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">0</td>
<td style="text-align: left;">22.2</td>
</tr>
<tr class="even">
<td style="text-align: left;">0.5</td>
<td style="text-align: left;">23.0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1</td>
<td style="text-align: left;">23.7</td>
</tr>
<tr class="even">
<td style="text-align: left;">1.5</td>
<td style="text-align: left;">24.4</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2</td>
<td style="text-align: left;">24.7</td>
</tr>
<tr class="even">
<td style="text-align: left;">2.5</td>
<td style="text-align: left;">25.1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">3</td>
<td style="text-align: left;">25.5</td>
</tr>
</tbody>
</table>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Treatment significantly affected size-normalized metabolic rate (AUC ANOVA: F = 4.33, p = 0.0403). OAE-preconditioned oysters had higher mean metabolic activity than controls (Tukey: estimate = -9e-04, p = 0.0403).</p>
<p>Markdown below was knitted from <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Resazurin/code/01.00-resazurin-20260831-mgig-OAE-36C.Rmd">01.00-resazurin-20260831-mgig-OAE-36C.Rmd</a> (GitHub).</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
</section>
<section id="background" class="level1">
<h1>1 Background</h1>
<p>Juvenile oysters were subjected to OAE conditions (10°C) for 6hrs on 20260828. After exposure, oysters were transferred to standard sea water conditions. On 20260831, 46 OAE oysters and 46 control oysters were subjected to 36°C heat stress. Oysters were randomly distributed across four, 48-well clear plates and submerged in 2mL of resazurin working solution. Fluorescence was measured every 30mins in a Synergy HTX (Agilent) plate reader.</p>
<p>Resazurin working-solution temperatures were recorded by the plate reader at each read (mean across the four plates):</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Timepoint (hrs)</th>
<th style="text-align: left;">Temp (C)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">0</td>
<td style="text-align: left;">22.2</td>
</tr>
<tr class="even">
<td style="text-align: left;">0.5</td>
<td style="text-align: left;">23.0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1</td>
<td style="text-align: left;">23.7</td>
</tr>
<tr class="even">
<td style="text-align: left;">1.5</td>
<td style="text-align: left;">24.4</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2</td>
<td style="text-align: left;">24.7</td>
</tr>
<tr class="even">
<td style="text-align: left;">2.5</td>
<td style="text-align: left;">25.1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">3</td>
<td style="text-align: left;">25.5</td>
</tr>
</tbody>
</table>
<p>See <code>Resazurin/data/20260831-mgig-OAE-36C/README.md</code> for full experimental notes.</p>
<section id="expected-inputs" class="level2">
<h2 class="anchored" data-anchor-id="expected-inputs">1.1 Expected inputs</h2>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Path</th>
<th style="text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>Resazurin/data/20260831-mgig-OAE-36C/plate-*-T*.txt</code></td>
<td style="text-align: left;">Plate reader fluorescence exports (one file per plate per timepoint)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>Resazurin/data/20260831-mgig-OAE-36C/layout.csv</code></td>
<td style="text-align: left;">Well metadata: plate ID, well ID, blank flag, treatment group (OAE vs.&nbsp;control), sample IDs, area measurements (mm², from ImageJ)</td>
</tr>
</tbody>
</table>
</section>
<section id="expected-outputs" class="level2">
<h2 class="anchored" data-anchor-id="expected-outputs">1.2 Expected outputs</h2>
<p>All outputs are written to <code>Resazurin/outputs/01.00-resazurin-20260831-mgig-OAE-36C/</code>.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">File</th>
<th style="text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>figures/</code></td>
<td style="text-align: left;">All plots generated by this script</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>auc_all_metrics.csv</code></td>
<td style="text-align: left;">Per-individual AUC values for every active measurement metric</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>auc_summary.csv</code></td>
<td style="text-align: left;">Group-level AUC summary statistics (mean, SD, SE, median)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>metabolism.csv</code></td>
<td style="text-align: left;">Full per-well per-timepoint metabolism data frame</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>pairwise_stats.csv</code></td>
<td style="text-align: left;">Tukey-adjusted pairwise comparisons from AUC linear models</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="setup" class="level1">
<h1>2 Setup</h1>
<section id="knitr-options" class="level2">
<h2 class="anchored" data-anchor-id="knitr-options">2.1 Knitr options</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb1-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb1-8">)</span></code></pre></div>
</section>
<section id="load-libraries" class="level2">
<h2 class="anchored" data-anchor-id="load-libraries">2.2 Load libraries</h2>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb2-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(pracma)       <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># trapz()</span></span>
<span id="cb2-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(lme4)</span>
<span id="cb2-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(lmerTest)</span>
<span id="cb2-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(emmeans)</span>
<span id="cb2-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(multcompView)</span>
<span id="cb2-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(cowplot)</span>
<span id="cb2-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(colorspace)   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># qualitative_hcl() for large palettes</span></span></code></pre></div>
</section>
</section>
<section id="helper-functions" class="level1">
<h1>3 Helper Functions</h1>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">normalize_well_id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb3-2">  x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(x))</span>
<span id="cb3-3">  valid <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Z]+[0-9]+$"</span>)</span>
<span id="cb3-4">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(x))</span>
<span id="cb3-5">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(valid)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(out)</span>
<span id="cb3-6">  m <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(x[valid], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([A-Z]+)([0-9]+)$"</span>)</span>
<span id="cb3-7">  out[valid] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]))</span>
<span id="cb3-8">  out</span>
<span id="cb3-9">}</span>
<span id="cb3-10"></span>
<span id="cb3-11">parse_time_hr <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-12">  hit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path),</span>
<span id="cb3-13">                   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)-T([0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>)</span>
<span id="cb3-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(hit[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb3-15">}</span>
<span id="cb3-16"></span>
<span id="cb3-17">parse_plate_id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-18">  hit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path),</span>
<span id="cb3-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)^plate-([A-Za-z0-9-]+)-T[0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>)</span>
<span id="cb3-20">  id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> hit[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb3-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"unknown"</span>, id)</span>
<span id="cb3-22">}</span>
<span id="cb3-23"></span>
<span id="cb3-24">extract_results_block <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(lines) {</span>
<span id="cb3-25">  results_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(lines) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Results"</span>)</span>
<span id="cb3-26">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(results_idx) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stop</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No Results section found"</span>)</span>
<span id="cb3-27">  idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb3-28">  header_tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(lines[idx <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>()</span>
<span id="cb3-29">  col_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> header_tokens[</span>
<span id="cb3-30">    header_tokens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(header_tokens, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[0-9]+$"</span>)]</span>
<span id="cb3-31">  j <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> idx <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb3-32">  data_lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>()</span>
<span id="cb3-33">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> (j <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(lines)) {</span>
<span id="cb3-34">    line <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> lines[j]</span>
<span id="cb3-35">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(line) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span></span>
<span id="cb3-36">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(line, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Za-z]</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span></span>
<span id="cb3-37">    data_lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(data_lines, line)</span>
<span id="cb3-38">    j <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> j <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb3-39">  }</span>
<span id="cb3-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_ids =</span> col_ids, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data_lines =</span> data_lines)</span>
<span id="cb3-41">}</span>
<span id="cb3-42"></span>
<span id="cb3-43">parse_plate_export <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-44">  lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb3-45">  res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">extract_results_block</span>(lines)</span>
<span id="cb3-46"></span>
<span id="cb3-47">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data_lines, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(line) {</span>
<span id="cb3-48">    tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(line, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>()</span>
<span id="cb3-49">    tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tokens[tokens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>]</span>
<span id="cb3-50">    row_letter <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tokens[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb3-51">    nums <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(tokens[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]))</span>
<span id="cb3-52">    valid_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(nums))</span>
<span id="cb3-53">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(valid_idx) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>())</span>
<span id="cb3-54">    vals <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> nums[valid_idx]</span>
<span id="cb3-55">    n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(vals), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids))</span>
<span id="cb3-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb3-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(row_letter),</span>
<span id="cb3-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)]),</span>
<span id="cb3-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normalize_well_id</span>(</span>
<span id="cb3-60">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(row_letter), res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)])),</span>
<span id="cb3-61">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value   =</span> vals[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)]</span>
<span id="cb3-62">    )</span>
<span id="cb3-63">  }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-64">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb3-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_id</span>(path)),</span>
<span id="cb3-66">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_hr  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_time_hr</span>(path)</span>
<span id="cb3-67">    )</span>
<span id="cb3-68">}</span>
<span id="cb3-69"></span>
<span id="cb3-70">trapezoid_auc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(time_hr, value) {</span>
<span id="cb3-71">  ok <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)</span>
<span id="cb3-72">  t <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> time_hr[ok]</span>
<span id="cb3-73">  v <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> value[ok]</span>
<span id="cb3-74">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(t) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb3-75">  ord <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(t)</span>
<span id="cb3-76">  t <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t[ord]; v <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> v[ord]</span>
<span id="cb3-77">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(t) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(v, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tail</span>(v, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb3-78">}</span>
<span id="cb3-79"></span>
<span id="cb3-80"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Shared helper: extract display unit string from a measurement column name.</span></span>
<span id="cb3-81"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># e.g. "area_mm2_measurement" -&gt; "mm²", "weight_mg_measurement" -&gt; "mg"</span></span>
<span id="cb3-82">parse_meas_unit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col_name) {</span>
<span id="cb3-83">  unit_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> col_name <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-84">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-85">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_measurement$"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_extract</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^_]+$"</span>)</span>
<span id="cb3-87">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb3-88">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm2"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm²"</span>,</span>
<span id="cb3-89">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm2"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm²"</span>,</span>
<span id="cb3-90">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm3"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm³"</span>,</span>
<span id="cb3-91">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm3"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm³"</span>,</span>
<span id="cb3-92">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>              <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> unit_raw</span>
<span id="cb3-93">  )</span>
<span id="cb3-94">}</span>
<span id="cb3-95"></span>
<span id="cb3-96"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y-axis label for metabolism line plots: "fold change/mm²"</span></span>
<span id="cb3-97">metabolism_y_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col_name) {</span>
<span id="cb3-98">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Metabolism (fold change/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_meas_unit</span>(col_name), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>)</span>
<span id="cb3-99">}</span>
<span id="cb3-100"></span>
<span id="cb3-101"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y-axis label for AUC box plots: "Metabolism (AUC; mm²)"</span></span>
<span id="cb3-102">auc_y_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(metric_name) {</span>
<span id="cb3-103">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Metabolism (AUC; "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_meas_unit</span>(metric_name), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>)</span>
<span id="cb3-104">}</span></code></pre></div>
</section>
<section id="load-data" class="level1">
<h1>4 Load Data</h1>
<section id="plate-export-files" class="level2">
<h2 class="anchored" data-anchor-id="plate-export-files">4.1 Plate export files</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">proj_root <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> rprojroot<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">find_rstudio_root_file</span>()</span>
<span id="cb4-2">data_dir  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(proj_root, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resazurin"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"20260831-mgig-OAE-36C"</span>)</span>
<span id="cb4-3">out_dir   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(proj_root, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resazurin"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outputs"</span>,</span>
<span id="cb4-4">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01.00-resazurin-20260831-mgig-OAE-36C"</span>)</span>
<span id="cb4-5">fig_dir   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"figures"</span>)</span>
<span id="cb4-6"></span>
<span id="cb4-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(fig_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(out_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-9"></span>
<span id="cb4-10">plate_files <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list.files</span>(</span>
<span id="cb4-11">  data_dir,</span>
<span id="cb4-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)^plate-.*-T[0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>,</span>
<span id="cb4-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">full.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb4-14">)</span>
<span id="cb4-15"></span>
<span id="cb4-16">plate_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(plate_files, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatch</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_export</span>(path),</span>
<span id="cb4-18">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">error =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(e) {</span>
<span id="cb4-19">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Parse error in "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">": "</span>, e<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>message)</span>
<span id="cb4-20">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb4-21">           })</span>
<span id="cb4-22">})</span>
<span id="cb4-23"></span>
<span id="cb4-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_raw)</span></code></pre></div>
<pre><code>tibble [672 × 6] (S3: tbl_df/tbl/data.frame)
 $ row_id  : chr [1:672] "A" "A" "A" "A" ...
 $ col_id  : int [1:672] 1 2 3 4 5 6 1 2 3 4 ...
 $ well_id : chr [1:672] "A1" "A2" "A3" "A4" ...
 $ value   : num [1:672] 202 195 244 211 178 222 204 187 232 207 ...
 $ plate_id: chr [1:672] "a" "a" "a" "a" ...
 $ time_hr : num [1:672] 0 0 0 0 0 0 0 0 0 0 ...</code></pre>
</section>
<section id="plate-consistency-check" class="level2">
<h2 class="anchored" data-anchor-id="plate-consistency-check">4.2 Plate consistency check</h2>
<p>Checks that every plate has the same number of wells at every timepoint. The expected well count is the mode across all plate × timepoint reads. Any plate with at least one deviating read is flagged and dropped entirely before any further analysis — removing only the aberrant timepoint would break the fold-change baseline calculation.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">well_counts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(plate_id, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(well_id), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb6-4"></span>
<span id="cb6-5">expected_n_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(</span>
<span id="cb6-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(well_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells)))</span>
<span id="cb6-7">)</span>
<span id="cb6-8"></span>
<span id="cb6-9">inconsistent_reads <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_counts <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_wells <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> expected_n_wells) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_id, time_hr)</span>
<span id="cb6-12"></span>
<span id="cb6-13">inconsistent_plate_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(inconsistent_reads<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_id)</span>
<span id="cb6-14"></span>
<span id="cb6-15"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(inconsistent_reads) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb6-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Plate consistency check FAILED.**"</span>,</span>
<span id="cb6-17">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected"</span>, expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells per plate-timepoint read."</span>,</span>
<span id="cb6-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(inconsistent_plate_ids),</span>
<span id="cb6-19">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate(s) have at least one deviating read and are excluded"</span>,</span>
<span id="cb6-20">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"from all analyses:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(</span>
<span id="cb6-22">    inconsistent_reads,</span>
<span id="cb6-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells read"</span>),</span>
<span id="cb6-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected:"</span>, expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells per read"</span>)</span>
<span id="cb6-25">  ), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-27">  plate_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>plate_id <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> inconsistent_plate_ids)</span>
<span id="cb6-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(inconsistent_plate_ids),</span>
<span id="cb6-30">          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" plate(s) removed from plate_raw: "</span>,</span>
<span id="cb6-31">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(inconsistent_plate_ids, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb6-32">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb6-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate consistency check passed: all"</span>,</span>
<span id="cb6-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(well_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plates have"</span>,</span>
<span id="cb6-35">      expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells at every timepoint.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-36">}</span></code></pre></div>
<p>Plate consistency check passed: all 4 plates have 24 wells at every timepoint.</p>
</section>
<section id="layout-file" class="level2">
<h2 class="anchored" data-anchor-id="layout-file">4.3 Layout file</h2>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">layout_path <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout.csv"</span>)</span>
<span id="cb7-2"></span>
<span id="cb7-3">layout_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_csv</span>(layout_path,</span>
<span id="cb7-4">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_types =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cols</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.default =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>),</span>
<span id="cb7-5">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">show_col_types =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb7-6"></span>
<span id="cb7-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standardise column names to snake_case</span></span>
<span id="cb7-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^a-z0-9]+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb7-13"></span>
<span id="cb7-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalise plate_id to match plate file ids (strip "plate-" prefix)</span></span>
<span id="cb7-15">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(plate_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^plate-"</span>),</span>
<span id="cb7-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normalize_well_id</span>(plate_well),</span>
<span id="cb7-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_blank =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"is_blank"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw))</span>
<span id="cb7-20">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(is_blank)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"YES"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Y"</span>)</span>
<span id="cb7-21">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-22">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb7-23">  )</span>
<span id="cb7-24"></span>
<span id="cb7-25">found_exclude_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb7-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_from_analysis"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"omit"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"not_analyzed"</span>),</span>
<span id="cb7-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)</span>
<span id="cb7-28">)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb7-29">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-31">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exclude_from_analysis =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(found_exclude_col))</span>
<span id="cb7-32">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(.data[[found_exclude_col]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span></span>
<span id="cb7-33">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"YES"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Y"</span>)</span>
<span id="cb7-34">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-35">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb7-36">  )</span>
<span id="cb7-37"></span>
<span id="cb7-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Identify measurement columns and group columns</span></span>
<span id="cb7-39">measurement_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)[</span>
<span id="cb7-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_measurement$"</span>)]</span>
<span id="cb7-41">group_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)[</span>
<span id="cb7-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_group$"</span>)]</span>
<span id="cb7-43"></span>
<span id="cb7-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cast measurement columns to numeric</span></span>
<span id="cb7-45">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-46">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(measurement_cols),</span>
<span id="cb7-47">                <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(.x))))</span>
<span id="cb7-48"></span>
<span id="cb7-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Determine which measurement columns actually contain finite data</span></span>
<span id="cb7-50">active_meas_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> measurement_cols[</span>
<span id="cb7-51">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(measurement_cols, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col)</span>
<span id="cb7-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(layout_clean[[col]]), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))]</span>
<span id="cb7-53"></span>
<span id="cb7-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalise group values to lowercase so they match colour scale definitions</span></span>
<span id="cb7-55">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_cols),</span>
<span id="cb7-57">                <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(.x)))))</span>
<span id="cb7-58"></span>
<span id="cb7-59"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group columns: "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(group_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb7-60"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Active measurement columns: "</span>,</span>
<span id="cb7-61">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(active_meas_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb7-62"></span>
<span id="cb7-63"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(layout_clean)</span></code></pre></div>
<pre><code>tibble [96 × 14] (S3: tbl_df/tbl/data.frame)
 $ plate_id             : chr [1:96] "a" "a" "a" "a" ...
 $ plate_well           : chr [1:96] "A01" "A02" "A03" "A04" ...
 $ is_blank             : logi [1:96] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ family_id_group      : chr [1:96] NA NA NA NA ...
 $ sample_id_group      : chr [1:96] "c-01" "c-25" "oae-03" "oae-27" ...
 $ treatment_group      : chr [1:96] "control" "control" "oae" "oae" ...
 $ exclude_from_analysis: logi [1:96] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:96] NA NA NA NA ...
 $ width_mm_measurement : num [1:96] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:96] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:96] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:96] 7395 7340 6008 8749 8809 ...
 $ imagej_id            : chr [1:96] "8" "24" "1" "39" ...
 $ well_id              : chr [1:96] "A1" "A2" "A3" "A4" ...</code></pre>
</section>
</section>
<section id="merge-plate-data-with-layout" class="level1">
<h1>5 Merge Plate Data with Layout</h1>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(</span>
<span id="cb9-3">    layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-4">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(plate_id, well_id, is_blank, exclude_from_analysis,</span>
<span id="cb9-5">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any_of</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span>),</span>
<span id="cb9-6">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_cols), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(measurement_cols)),</span>
<span id="cb9-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span>)</span>
<span id="cb9-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb9-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_blank =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace_na</span>(is_blank, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>),</span>
<span id="cb9-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exclude_from_analysis =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace_na</span>(exclude_from_analysis, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb9-12">  )</span>
<span id="cb9-13"></span>
<span id="cb9-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(dat)</span></code></pre></div>
<pre><code>tibble [672 × 16] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:672] "A" "A" "A" "A" ...
 $ col_id               : int [1:672] 1 2 3 4 5 6 1 2 3 4 ...
 $ well_id              : chr [1:672] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:672] 202 195 244 211 178 222 204 187 232 207 ...
 $ plate_id             : chr [1:672] "a" "a" "a" "a" ...
 $ time_hr              : num [1:672] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:672] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:672] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:672] NA NA NA NA ...
 $ family_id_group      : chr [1:672] NA NA NA NA ...
 $ sample_id_group      : chr [1:672] "c-01" "c-25" "oae-03" "oae-27" ...
 $ treatment_group      : chr [1:672] "control" "control" "oae" "oae" ...
 $ width_mm_measurement : num [1:672] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:672] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:672] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:672] 7395 7340 6008 8749 8809 ...</code></pre>
</section>
<section id="raw-fluorescence" class="level1">
<h1>6 Raw Fluorescence</h1>
<section id="data-frame" class="level2">
<h2 class="anchored" data-anchor-id="data-frame">6.1 Data frame</h2>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Wells in the plate reader output that have no layout entry get all-NA group</span></span>
<span id="cb11-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># columns after the join. Keep only wells assigned to at least one group.</span></span>
<span id="cb11-3">active_gc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(group_cols, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(dat))</span>
<span id="cb11-4"></span>
<span id="cb11-5">raw_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(</span>
<span id="cb11-7">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank,</span>
<span id="cb11-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(active_gc) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb11-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(active_gc), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(.))</span>
<span id="cb11-10">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb11-11">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb11-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb11-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb11-15">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb11-16">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb11-17">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb11-18">    )</span>
<span id="cb11-19">  )</span>
<span id="cb11-20"></span>
<span id="cb11-21">families   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(raw_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb11-22">treatments <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(raw_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group)))</span>
<span id="cb11-23"></span>
<span id="cb11-24">n_fam <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(families)</span>
<span id="cb11-25">n_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(treatments)</span>
<span id="cb11-26"></span>
<span id="cb11-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Palette strategy:</span></span>
<span id="cb11-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   &lt;= 7 groups : Okabe-Ito (gold standard for colorblind-safe figures).</span></span>
<span id="cb11-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   &gt;  7 groups : colorspace::qualitative_hcl("Dynamic") scales to any N</span></span>
<span id="cb11-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                 using perceptually uniform HCL space — no colour collisions.</span></span>
<span id="cb11-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Black (#000000) is excluded from both and reserved for blank wells.</span></span>
<span id="cb11-32">okabe_ito_7 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb11-33">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#E69F00"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#56B4E9"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#009E73"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#F0E442"</span>,</span>
<span id="cb11-34">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0072B2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D55E00"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#CC79A7"</span></span>
<span id="cb11-35">)</span>
<span id="cb11-36">make_palette <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n) {</span>
<span id="cb11-37">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>L) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb11-38">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(okabe_ito_7)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(okabe_ito_7[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)])</span>
<span id="cb11-39">  colorspace<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qualitative_hcl</span>(n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">palette =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dynamic"</span>)</span>
<span id="cb11-40">}</span>
<span id="cb11-41"></span>
<span id="cb11-42">all_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">make_palette</span>(n_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> n_trt)</span>
<span id="cb11-43">fam_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(all_colours[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_fam)], families)</span>
<span id="cb11-44">trt_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(all_colours[n_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_trt)], treatments)</span>
<span id="cb11-45"></span>
<span id="cb11-46">lty_pool <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"solid"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotdash"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"longdash"</span>)</span>
<span id="cb11-47">trt_linetypes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(</span>
<span id="cb11-48">  lty_pool[(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_trt) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(lty_pool) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L],</span>
<span id="cb11-49">  treatments</span>
<span id="cb11-50">)</span>
<span id="cb11-51">plate_well_colours <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blank =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, fam_colours)</span>
<span id="cb11-52"></span>
<span id="cb11-53">has_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> n_trt <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb11-54">has_fam <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> n_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb11-55"></span>
<span id="cb11-56"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(raw_df)</span></code></pre></div>
<pre><code>tibble [644 × 17] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:644] "A" "A" "A" "A" ...
 $ col_id               : int [1:644] 1 2 3 4 5 6 1 2 3 4 ...
 $ well_id              : chr [1:644] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:644] 202 195 244 211 178 222 204 187 232 207 ...
 $ plate_id             : chr [1:644] "a" "a" "a" "a" ...
 $ time_hr              : num [1:644] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:644] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:644] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:644] NA NA NA NA ...
 $ family_id_group      : chr [1:644] NA NA NA NA ...
 $ sample_id_group      : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...
 $ treatment_group      : chr [1:644] "control" "control" "oae" "oae" ...
 $ width_mm_measurement : num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:644] 7395 7340 6008 8749 8809 ...
 $ trace_id             : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...</code></pre>
</section>
<section id="raw-fluorescence-by-plate-including-blanks" class="level2">
<h2 class="anchored" data-anchor-id="raw-fluorescence-by-plate-including-blanks">6.2 Raw fluorescence by plate (including blanks)</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Colour wells by family when family groups exist; otherwise fall back to</span></span>
<span id="cb13-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># treatment, or a flat "sample" bucket when neither grouping is populated.</span></span>
<span id="cb13-3">plate_group_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb13-4">plate_group_colours <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blank =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, fam_colours) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blank =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, trt_colours) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blank =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>)</span>
<span id="cb13-5">plate_group_name <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span></span>
<span id="cb13-6"></span>
<span id="cb13-7">p_raw_plates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb13-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour_group =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb13-11">      is_blank, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank"</span>,</span>
<span id="cb13-12">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(plate_group_col)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coalesce</span>(.data[[plate_group_col]], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb13-13">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span></span>
<span id="cb13-14">    ),</span>
<span id="cb13-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb13-16">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value,</span>
<span id="cb13-18">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> colour_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> plate_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb13-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values   =</span> plate_group_colours,</span>
<span id="cb13-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name     =</span> plate_group_name,</span>
<span id="cb13-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(plate_group_colours),</span>
<span id="cb13-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.value =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey80"</span></span>
<span id="cb13-27">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb13-31">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb13-32"></span>
<span id="cb13-33">p_raw_plates</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-31-Resazurin-Assays---USDA-M.gigas-Juveniles-OAE-Preconditioning-Effect-on-36C-Heat-Stress-Response/01.00-resazurin-20260831-mgig-OAE-36C_files/figure-gfm/raw-fluor-by-plate-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_fluor_by_plate.png"</span>),</span>
<span id="cb14-2">       p_raw_plates, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)</span></code></pre></div>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"## Mean raw fluorescence by family</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) {</span>
<span id="cb16-2">  raw_family_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb16-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_fluor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb16-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_fluor   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb16-8">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(value))),</span>
<span id="cb16-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(value)),</span>
<span id="cb16-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups    =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb16-11">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb16-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb16-14">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb16-15">      family_id_group)</span>
<span id="cb16-16"></span>
<span id="cb16-17">  p_raw_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(raw_family_summary,</span>
<span id="cb16-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_fluor,</span>
<span id="cb16-19">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb16-20">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_fluor <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_fluor,</span>
<span id="cb16-22">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_fluor <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_fluor,</span>
<span id="cb16-23">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb16-24">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb16-26">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb16-27">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb16-30">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-31">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb16-32">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean raw fluorescence (RFU ± SE)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-34">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb16-35">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb16-36"></span>
<span id="cb16-37">  p_raw_mean</span>
<span id="cb16-38">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_mean_by_family.png"</span>),</span>
<span id="cb16-39">         p_raw_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb16-40">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb16-41">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No family groups present: skipping mean raw fluorescence by family."</span>)</span>
<span id="cb16-42">}</span></code></pre></div>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"## Individual raw fluorescence traces by family</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) {</span>
<span id="cb18-2">  p_raw_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb18-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb18-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb18-5">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb18-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb18-11">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb18-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb18-16">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb18-17"></span>
<span id="cb18-18">  p_raw_by_family</span>
<span id="cb18-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_individual_by_family.png"</span>),</span>
<span id="cb18-20">         p_raw_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb18-21">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb18-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No family groups present: skipping individual raw fluorescence traces by family."</span>)</span>
<span id="cb18-23">}</span></code></pre></div>
</section>
<section id="individual-raw-fluorescence-traces-by-treatment" class="level2">
<h2 class="anchored" data-anchor-id="individual-raw-fluorescence-traces-by-treatment">6.3 Individual raw fluorescence traces by treatment</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb19-2">  colour_var   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span></span>
<span id="cb19-3">  colour_vals  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) fam_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> trt_colours</span>
<span id="cb19-4">  colour_brks  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) families <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> treatments</span>
<span id="cb19-5">  colour_name  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span></span>
<span id="cb19-6"></span>
<span id="cb19-7">  p_raw_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value,</span>
<span id="cb19-9">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[colour_var]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> colour_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> colour_name,</span>
<span id="cb19-14">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> colour_brks) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb19-18">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb19-19"></span>
<span id="cb19-20">  p_raw_by_treatment</span>
<span id="cb19-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_individual_by_treatment.png"</span>),</span>
<span id="cb19-22">         p_raw_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb19-23">}</span></code></pre></div>
</section>
<section id="excluded-samples" class="level2">
<h2 class="anchored" data-anchor-id="excluded-samples">6.4 Excluded samples</h2>
<p>Wells flagged <code>exclude_from_analysis = TRUE</code> appear in the raw fluorescence plots above but are omitted from all analyses that follow.</p>
<div class="sourceCode" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">excl_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb20-2">               <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>,</span>
<span id="cb20-3">               <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span>)</span>
<span id="cb20-4"></span>
<span id="cb20-5">excluded_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb20-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb20-9">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb20-10">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb20-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb20-12">    )</span>
<span id="cb20-13">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(excl_cols), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any_of</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_id, well_id)</span>
<span id="cb20-17"></span>
<span id="cb20-18"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(excluded_wells) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb20-19">  col_names <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>,</span>
<span id="cb20-20">                 <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb20-21">                 <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>)</span>
<span id="cb20-22">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(excluded_wells))</span>
<span id="cb20-23">    col_names <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(col_names, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Reason"</span>)</span>
<span id="cb20-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> col_names), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-25">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb20-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No wells are excluded from analysis.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-27">}</span></code></pre></div>
<p>No wells are excluded from analysis.</p>
</section>
</section>
<section id="blank-correction-via-fold-change-normalization" class="level1">
<h1>7 Blank Correction via Fold-Change Normalization</h1>
<p>T0 is the earliest timepoint present in the dataset (not necessarily 0 hr). Sample fold-change is expressed relative to each individual’s T0 reading, resolved by <code>sample_id_group</code> when that column is populated — allowing the same animal to be tracked across plates — or by <code>plate_id + well_id</code> when no sample IDs exist (backward-compatible with single-plate, multi-timepoint designs). Blank fold-change is the per-plate mean blank RFU at each timepoint divided by the pooled mean blank RFU at T0. Subtracting blank fold-change from sample fold-change removes background fluorescence drift; all samples start at exactly 0 at T0 by construction.</p>
<section id="step-1-identify-t0-and-compute-per-sample-fold-change" class="level2">
<h2 class="anchored" data-anchor-id="step-1-identify-t0-and-compute-per-sample-fold-change">7.1 Step 1 – Identify T0 and compute per-sample fold-change</h2>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># T0 = earliest timepoint present in the dataset</span></span>
<span id="cb21-2">t0_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_hr[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_hr)], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb21-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T0 timepoint: "</span>, t0_time, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" hr"</span>)</span>
<span id="cb21-4"></span>
<span id="cb21-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># T0 reference value per individual.</span></span>
<span id="cb21-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Resolved by sample_id_group (cross-plate tracking) when available;</span></span>
<span id="cb21-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># falls back to plate+well for layouts without explicit sample IDs.</span></span>
<span id="cb21-8">t0_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(time_hr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> t0_time, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_key =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-11">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb21-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb21-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb21-14">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_key) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value_t0 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb21-17"></span>
<span id="cb21-18">dat_fc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_key =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-20">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb21-21">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb21-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb21-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb21-24">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(t0_all, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_key"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fold_change =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-27">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value_t0) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> value_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb21-28">    value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> value_t0,</span>
<span id="cb21-29">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb21-30">  ))</span>
<span id="cb21-31"></span>
<span id="cb21-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(dat_fc)</span></code></pre></div>
<pre><code>tibble [672 × 19] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:672] "A" "A" "A" "A" ...
 $ col_id               : int [1:672] 1 2 3 4 5 6 1 2 3 4 ...
 $ well_id              : chr [1:672] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:672] 202 195 244 211 178 222 204 187 232 207 ...
 $ plate_id             : chr [1:672] "a" "a" "a" "a" ...
 $ time_hr              : num [1:672] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:672] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:672] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:672] NA NA NA NA ...
 $ family_id_group      : chr [1:672] NA NA NA NA ...
 $ sample_id_group      : chr [1:672] "c-01" "c-25" "oae-03" "oae-27" ...
 $ treatment_group      : chr [1:672] "control" "control" "oae" "oae" ...
 $ width_mm_measurement : num [1:672] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:672] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:672] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:672] 7395 7340 6008 8749 8809 ...
 $ sample_key           : chr [1:672] "c-01" "c-25" "oae-03" "oae-27" ...
 $ value_t0             : num [1:672] 202 195 244 211 178 222 204 187 232 207 ...
 $ fold_change          : num [1:672] 1 1 1 1 1 1 1 1 1 1 ...</code></pre>
</section>
<section id="step-2-blank-fold-change-reference-per-plate-per-timepoint" class="level2">
<h2 class="anchored" data-anchor-id="step-2-blank-fold-change-reference-per-plate-per-timepoint">7.2 Step 2 – Blank fold-change reference per plate per timepoint</h2>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pooled mean blank RFU at T0 across all T0 plates</span></span>
<span id="cb23-2">mean_blank_t0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_blank, time_hr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> t0_time, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(value) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb23-6"></span>
<span id="cb23-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(mean_blank_t0))</span>
<span id="cb23-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No blank readings found at T0 ("</span>, t0_time,</span>
<span id="cb23-9">          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" hr); blank correction will produce NA."</span>)</span>
<span id="cb23-10"></span>
<span id="cb23-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Per-plate per-timepoint mean blank expressed as fold-change relative to T0</span></span>
<span id="cb23-12">blank_fc_ref <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_blank, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(plate_id, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_blank_rfu =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_blank_fc =</span> mean_blank_rfu <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_blank_t0)</span>
<span id="cb23-17"></span>
<span id="cb23-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(blank_fc_ref)</span></code></pre></div>
<pre><code>tibble [28 × 4] (S3: tbl_df/tbl/data.frame)
 $ plate_id      : chr [1:28] "a" "a" "a" "a" ...
 $ time_hr       : num [1:28] 0 0.5 1 1.5 2 2.5 3 0 0.5 1 ...
 $ mean_blank_rfu: num [1:28] 168 167 169 171 172 172 173 161 165 165 ...
 $ mean_blank_fc : num [1:28] 0.973 0.967 0.978 0.99 0.996 ...</code></pre>
</section>
<section id="step-3-subtract-blank-fold-change-from-sample-fold-change" class="level2">
<h2 class="anchored" data-anchor-id="step-3-subtract-blank-fold-change-from-sample-fold-change">7.3 Step 3 – Subtract blank fold-change from sample fold-change</h2>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb25-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb25-5">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb25-6">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb25-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb25-8">    )</span>
<span id="cb25-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(blank_fc_ref, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"time_hr"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">corrected_fc =</span> fold_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean_blank_fc)</span>
<span id="cb25-12"></span>
<span id="cb25-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples)</span></code></pre></div>
<pre><code>tibble [644 × 23] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:644] "A" "A" "A" "A" ...
 $ col_id               : int [1:644] 1 2 3 4 5 6 1 2 3 4 ...
 $ well_id              : chr [1:644] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:644] 202 195 244 211 178 222 204 187 232 207 ...
 $ plate_id             : chr [1:644] "a" "a" "a" "a" ...
 $ time_hr              : num [1:644] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:644] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:644] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:644] NA NA NA NA ...
 $ family_id_group      : chr [1:644] NA NA NA NA ...
 $ sample_id_group      : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...
 $ treatment_group      : chr [1:644] "control" "control" "oae" "oae" ...
 $ width_mm_measurement : num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:644] 7395 7340 6008 8749 8809 ...
 $ sample_key           : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...
 $ value_t0             : num [1:644] 202 195 244 211 178 222 204 187 232 207 ...
 $ fold_change          : num [1:644] 1 1 1 1 1 1 1 1 1 1 ...
 $ trace_id             : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...
 $ mean_blank_rfu       : num [1:644] 168 168 168 168 168 168 168 168 168 168 ...
 $ mean_blank_fc        : num [1:644] 0.973 0.973 0.973 0.973 0.973 ...
 $ corrected_fc         : num [1:644] 0.0275 0.0275 0.0275 0.0275 0.0275 ...</code></pre>
</section>
</section>
<section id="blank-corrected-fold-change" class="level1">
<h1>8 Blank-Corrected Fold-Change</h1>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"## Mean by family</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) {</span>
<span id="cb28-2">  bc_fc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb28-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_val =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb28-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_val   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb28-8">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(corrected_fc))),</span>
<span id="cb28-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(corrected_fc)),</span>
<span id="cb28-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb28-11">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb28-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb28-14">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb28-15">      family_id_group)</span>
<span id="cb28-16"></span>
<span id="cb28-17">  p_bc_fc_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(bc_fc_summary,</span>
<span id="cb28-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_val,</span>
<span id="cb28-19">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb28-20">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_val,</span>
<span id="cb28-22">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_val,</span>
<span id="cb28-23">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb28-24">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb28-26">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb28-27">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb28-30">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-31">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb28-32">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>,</span>
<span id="cb28-34">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean blank-corrected fold-change (± SE)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-35">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb28-36">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb28-37"></span>
<span id="cb28-38">  p_bc_fc_mean</span>
<span id="cb28-39">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_mean_by_family.png"</span>),</span>
<span id="cb28-40">         p_bc_fc_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb28-41">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb28-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No family groups present: skipping mean blank-corrected fold-change by family."</span>)</span>
<span id="cb28-43">}</span></code></pre></div>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"## Individual traces by family</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) {</span>
<span id="cb30-2">  p_bc_fc_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb30-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb30-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb30-5">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb30-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb30-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb30-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb30-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb30-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb30-11">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb30-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb30-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Blank-corrected fold-change"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb30-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb30-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb30-16">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb30-17"></span>
<span id="cb30-18">  p_bc_fc_by_family</span>
<span id="cb30-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_by_family.png"</span>),</span>
<span id="cb30-20">         p_bc_fc_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb30-21">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb30-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No family groups present: skipping individual blank-corrected fold-change traces by family."</span>)</span>
<span id="cb30-23">}</span></code></pre></div>
<section id="individual-blank-corrected-fold-change-traces-by-treatment" class="level2">
<h2 class="anchored" data-anchor-id="individual-blank-corrected-fold-change-traces-by-treatment">8.1 Individual blank-corrected fold-change traces by treatment</h2>
<div class="sourceCode" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb31-2">  colour_var  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span></span>
<span id="cb31-3">  colour_vals <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) fam_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> trt_colours</span>
<span id="cb31-4">  colour_brks <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) families <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> treatments</span>
<span id="cb31-5">  colour_name <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span></span>
<span id="cb31-6"></span>
<span id="cb31-7">  p_bc_fc_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb31-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> corrected_fc,</span>
<span id="cb31-9">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[colour_var]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> colour_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> colour_name,</span>
<span id="cb31-14">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> colour_brks) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Blank-corrected fold-change"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb31-18">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb31-19"></span>
<span id="cb31-20">  p_bc_fc_by_treatment</span>
<span id="cb31-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_by_treatment.png"</span>),</span>
<span id="cb31-22">         p_bc_fc_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb31-23">}</span></code></pre></div>
</section>
</section>
<section id="metabolism-size-normalised-fold-change" class="level1">
<h1>9 Metabolism (Size-Normalised Fold-Change)</h1>
<p>Blank-corrected fold-change divided by each active measurement column. This is “metabolism” as defined in Huffmyer et al.</p>
<div class="sourceCode" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(active_meas_cols) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb32-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No active measurement columns: skipping metabolism calculation."</span>)</span>
<span id="cb32-3">  metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb32-4">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb32-5">  metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples</span>
<span id="cb32-6">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb32-7">    out_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb32-8">    metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!!</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">out_col :=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb32-10">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[mc]]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> .data[[mc]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb32-11">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(corrected_fc),</span>
<span id="cb32-12">        corrected_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> .data[[mc]],</span>
<span id="cb32-13">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb32-14">      ))</span>
<span id="cb32-15">  }</span>
<span id="cb32-16">}</span>
<span id="cb32-17"></span>
<span id="cb32-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(metabolism_df)</span></code></pre></div>
<pre><code>tibble [644 × 24] (S3: tbl_df/tbl/data.frame)
 $ row_id                             : chr [1:644] "A" "A" "A" "A" ...
 $ col_id                             : int [1:644] 1 2 3 4 5 6 1 2 3 4 ...
 $ well_id                            : chr [1:644] "A1" "A2" "A3" "A4" ...
 $ value                              : num [1:644] 202 195 244 211 178 222 204 187 232 207 ...
 $ plate_id                           : chr [1:644] "a" "a" "a" "a" ...
 $ time_hr                            : num [1:644] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank                           : logi [1:644] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis              : logi [1:644] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason                     : chr [1:644] NA NA NA NA ...
 $ family_id_group                    : chr [1:644] NA NA NA NA ...
 $ sample_id_group                    : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...
 $ treatment_group                    : chr [1:644] "control" "control" "oae" "oae" ...
 $ width_mm_measurement               : num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement              : num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement              : num [1:644] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement               : num [1:644] 7395 7340 6008 8749 8809 ...
 $ sample_key                         : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...
 $ value_t0                           : num [1:644] 202 195 244 211 178 222 204 187 232 207 ...
 $ fold_change                        : num [1:644] 1 1 1 1 1 1 1 1 1 1 ...
 $ trace_id                           : chr [1:644] "c-01" "c-25" "oae-03" "oae-27" ...
 $ mean_blank_rfu                     : num [1:644] 168 168 168 168 168 168 168 168 168 168 ...
 $ mean_blank_fc                      : num [1:644] 0.973 0.973 0.973 0.973 0.973 ...
 $ corrected_fc                       : num [1:644] 0.0275 0.0275 0.0275 0.0275 0.0275 ...
 $ metabolism_per_area_mm2_measurement: num [1:644] 3.72e-06 3.75e-06 4.58e-06 3.14e-06 3.12e-06 ...</code></pre>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"## Mean metabolism by family</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_fam) {</span>
<span id="cb35-2"></span>
<span id="cb35-3">  metab_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, active_meas_cols)</span>
<span id="cb35-4"></span>
<span id="cb35-5">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metab_cols) {</span>
<span id="cb35-6">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb35-7">    mc_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>)</span>
<span id="cb35-8"></span>
<span id="cb35-9">    metab_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-10">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb35-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_val =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(.data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb35-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_val   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(.data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb35-15">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(.data[[col]]))),</span>
<span id="cb35-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb35-17">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb35-19">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb35-20">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb35-21">        family_id_group)</span>
<span id="cb35-22"></span>
<span id="cb35-23">    p_metab_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(metab_summary,</span>
<span id="cb35-24">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_val,</span>
<span id="cb35-25">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb35-26">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-27">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_val,</span>
<span id="cb35-28">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_val,</span>
<span id="cb35-29">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb35-30">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-31">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb35-32">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb35-33">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-35">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb35-36">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-37">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb35-38">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-39">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>,</span>
<span id="cb35-40">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" (± SE)"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-41">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-42">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb35-43"></span>
<span id="cb35-44">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_mean)</span>
<span id="cb35-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb35-46">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb35-47">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_mean_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb35-48">      p_metab_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb35-49">  }</span>
<span id="cb35-50">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb35-51">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No family groups present: skipping mean metabolism by family."</span>)</span>
<span id="cb35-52">}</span></code></pre></div>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">metab_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, active_meas_cols)</span></code></pre></div>
<div class="sourceCode" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"## Individual metabolism traces by family</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_fam) {</span>
<span id="cb38-2">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metab_cols) {</span>
<span id="cb38-3">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb38-4">    mc_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>)</span>
<span id="cb38-5"></span>
<span id="cb38-6">    p_metab_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-8">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> .data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb38-9">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-10">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb38-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb38-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb38-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-17">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-19">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb38-20">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb38-21"></span>
<span id="cb38-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_by_family)</span>
<span id="cb38-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb38-24">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb38-25">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_individual_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_by_family.png"</span>)),</span>
<span id="cb38-26">      p_metab_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb38-27">  }</span>
<span id="cb38-28">}</span></code></pre></div>
<div class="sourceCode" id="cb39" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"## Individual metabolism traces by treatment</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<section id="individual-metabolism-traces-by-treatment" class="level2">
<h2 class="anchored" data-anchor-id="individual-metabolism-traces-by-treatment">9.1 Individual metabolism traces by treatment</h2>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_trt) {</span>
<span id="cb40-2">  colour_var  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span></span>
<span id="cb40-3">  colour_vals <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) fam_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> trt_colours</span>
<span id="cb40-4">  colour_brks <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) families <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> treatments</span>
<span id="cb40-5">  colour_name <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span></span>
<span id="cb40-6"></span>
<span id="cb40-7">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metab_cols) {</span>
<span id="cb40-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb40-9">    mc_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>)</span>
<span id="cb40-10"></span>
<span id="cb40-11">    p_metab_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb40-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> .data[[col]],</span>
<span id="cb40-13">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[colour_var]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-14">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-15">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-16">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-17">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> colour_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> colour_name,</span>
<span id="cb40-18">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> colour_brks) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-19">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-20">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-21">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb40-22">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb40-23"></span>
<span id="cb40-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_by_treatment)</span>
<span id="cb40-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb40-26">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb40-27">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_individual_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_by_treatment.png"</span>)),</span>
<span id="cb40-28">      p_metab_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb40-29">  }</span>
<span id="cb40-30">}</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-31-Resazurin-Assays---USDA-M.gigas-Juveniles-OAE-Preconditioning-Effect-on-36C-Heat-Stress-Response/01.00-resazurin-20260831-mgig-OAE-36C_files/figure-gfm/metabolism-individual-by-treatment-1.png" class="img-fluid"><!-- --></p>
</section>
</section>
<section id="time-series-statistical-analysis" class="level1">
<h1>10 Time-Series Statistical Analysis</h1>
<p>Linear mixed effects models test the effect of experimental variables on metabolism over time. Individual (<code>sample_id_group</code>) is included as a random intercept to account for repeated measures across timepoints. Type III ANOVA with Satterthwaite’s approximation (lmerTest) assesses significance; post-hoc pairwise comparisons use estimated marginal means (emmeans, Tukey adjustment).</p>
<div class="sourceCode" id="cb41" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1">run_ts_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(df, value_col) {</span>
<span id="cb41-2">  has_family    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb41-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb41-4">  has_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb41-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb41-6"></span>
<span id="cb41-7">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_treatment) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb41-8"></span>
<span id="cb41-9">  df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb41-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[value_col]]), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb41-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb41-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_f     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(time_hr),</span>
<span id="cb41-13">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(trace_id)</span>
<span id="cb41-14">    )</span>
<span id="cb41-15"></span>
<span id="cb41-16">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb41-17"></span>
<span id="cb41-18">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family)    df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family_id_group))</span>
<span id="cb41-19">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment) df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(treatment_group))</span>
<span id="cb41-20"></span>
<span id="cb41-21">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family)))    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb41-22">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb41-23"></span>
<span id="cb41-24">  fixed <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb41-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * family * treatment"</span>)</span>
<span id="cb41-26">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb41-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * family"</span>)</span>
<span id="cb41-28">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb41-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * treatment"</span>)</span>
<span id="cb41-30">  }</span>
<span id="cb41-31"></span>
<span id="cb41-32">  model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lmer</span>(</span>
<span id="cb41-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.formula</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(fixed, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" + (1 | individual)"</span>)),</span>
<span id="cb41-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df</span>
<span id="cb41-35">  )</span>
<span id="cb41-36"></span>
<span id="cb41-37">  anova_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ddf =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Satterthwaite"</span>)</span>
<span id="cb41-38"></span>
<span id="cb41-39">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pairwise comparisons of group combinations at each timepoint</span></span>
<span id="cb41-40">  emm_spec <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb41-41">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb41-42">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb41-43">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb41-44">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb41-45">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb41-46">  }</span>
<span id="cb41-47"></span>
<span id="cb41-48">  emm       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, emm_spec)</span>
<span id="cb41-49">  pairs_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(emm, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb41-50"></span>
<span id="cb41-51">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Main-effect marginal means (collapsed across time)</span></span>
<span id="cb41-52">  emm_main <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb41-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment)</span>
<span id="cb41-54">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb41-55">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family)</span>
<span id="cb41-56">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb41-57">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment)</span>
<span id="cb41-58">  }</span>
<span id="cb41-59"></span>
<span id="cb41-60">  pairs_main <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(emm_main, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb41-61"></span>
<span id="cb41-62">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb41-63">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model         =</span> model,</span>
<span id="cb41-64">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anova         =</span> anova_res,</span>
<span id="cb41-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_by_time =</span> pairs_res,</span>
<span id="cb41-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_main    =</span> pairs_main,</span>
<span id="cb41-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_family    =</span> has_family,</span>
<span id="cb41-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_treatment =</span> has_treatment</span>
<span id="cb41-69">  )</span>
<span id="cb41-70">}</span>
<span id="cb41-71"></span>
<span id="cb41-72">ts_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb41-73"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb41-74">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb41-75">    col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb41-76">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df))</span>
<span id="cb41-77">      ts_stats[[col]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">run_ts_stats</span>(metabolism_df, col)</span>
<span id="cb41-78">  }</span>
<span id="cb41-79">}</span></code></pre></div>
<section id="results-1" class="level2">
<h2 class="anchored" data-anchor-id="results-1">10.1 Results</h2>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(ts_stats)) {</span>
<span id="cb42-2">  res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ts_stats[[col]]</span>
<span id="cb42-3">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(res)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb42-4"></span>
<span id="cb42-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">### Metric:"</span>, col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-6"></span>
<span id="cb42-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Type III ANOVA (Satterthwaite approximation):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>anova), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-10"></span>
<span id="cb42-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Marginal means – main effects (collapsed across time):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_main), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-14"></span>
<span id="cb42-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise comparisons by timepoint (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_by_time), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-18">}</span></code></pre></div>
<section id="metric-metabolism_per_area_mm2_measurement" class="level3">
<h3 class="anchored" data-anchor-id="metric-metabolism_per_area_mm2_measurement">10.1.1 Metric: metabolism_per_area_mm2_measurement</h3>
<p><strong>Type III ANOVA (Satterthwaite approximation):</strong></p>
<table class="caption-top table">
<colgroup>
<col style="width: 26%">
<col style="width: 11%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 13%">
</colgroup>
<thead>
<tr class="header">
<th></th>
<th style="text-align: right;">Sum Sq</th>
<th style="text-align: right;">Mean Sq</th>
<th style="text-align: right;">NumDF</th>
<th style="text-align: right;">DenDF</th>
<th style="text-align: right;">F value</th>
<th style="text-align: right;">Pr(&gt;F)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>time_f</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">540</td>
<td style="text-align: right;">60.5478</td>
<td style="text-align: right;">0.0000</td>
</tr>
<tr class="even">
<td>treatment</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">90</td>
<td style="text-align: right;">4.1251</td>
<td style="text-align: right;">0.0452</td>
</tr>
<tr class="odd">
<td>time_f:treatment</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">540</td>
<td style="text-align: right;">2.4688</td>
<td style="text-align: right;">0.0230</td>
</tr>
</tbody>
</table>
<p><strong>Marginal means – main effects (collapsed across time):</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">control - oae</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">90</td>
<td style="text-align: right;">-2.031</td>
<td style="text-align: right;">0.0452</td>
</tr>
</tbody>
</table>
<p><strong>Pairwise comparisons by timepoint (Tukey):</strong></p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 11%">
<col style="width: 14%">
<col style="width: 10%">
<col style="width: 14%">
<col style="width: 13%">
<col style="width: 13%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: left;">time_f</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">control - oae</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">168.2944</td>
<td style="text-align: right;">0.0045</td>
<td style="text-align: right;">0.9964</td>
</tr>
<tr class="even">
<td style="text-align: left;">control - oae</td>
<td style="text-align: left;">0.5</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">168.2944</td>
<td style="text-align: right;">-1.0383</td>
<td style="text-align: right;">0.3006</td>
</tr>
<tr class="odd">
<td style="text-align: left;">control - oae</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">168.2944</td>
<td style="text-align: right;">-2.1690</td>
<td style="text-align: right;">0.0315</td>
</tr>
<tr class="even">
<td style="text-align: left;">control - oae</td>
<td style="text-align: left;">1.5</td>
<td style="text-align: right;">-4e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">168.2944</td>
<td style="text-align: right;">-2.5397</td>
<td style="text-align: right;">0.0120</td>
</tr>
<tr class="odd">
<td style="text-align: left;">control - oae</td>
<td style="text-align: left;">2</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">168.2944</td>
<td style="text-align: right;">-2.1645</td>
<td style="text-align: right;">0.0318</td>
</tr>
<tr class="even">
<td style="text-align: left;">control - oae</td>
<td style="text-align: left;">2.5</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">168.2944</td>
<td style="text-align: right;">-2.0021</td>
<td style="text-align: right;">0.0469</td>
</tr>
<tr class="odd">
<td style="text-align: left;">control - oae</td>
<td style="text-align: left;">3</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">168.2944</td>
<td style="text-align: right;">-2.1752</td>
<td style="text-align: right;">0.0310</td>
</tr>
</tbody>
</table>
</section>
</section>
</section>
<section id="area-under-the-curve-auc" class="level1">
<h1>11 Area Under the Curve (AUC)</h1>
<p>AUC computed per individual via the trapezoid rule across all timepoints. <code>metabolism_per_*</code> is the primary metric matching the paper; <code>corrected_fc</code> and <code>raw_fluorescence</code> are retained for reference.</p>
<div class="sourceCode" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1">compute_auc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(df, value_col, group_vars) {</span>
<span id="cb43-2">  df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb43-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[value_col]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb43-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_vars))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb43-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb43-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">AUC          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trapezoid_auc</span>(time_hr, .data[[value_col]]),</span>
<span id="cb43-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_timepoints =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb43-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups      =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb43-9">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb43-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(AUC))</span>
<span id="cb43-11">}</span>
<span id="cb43-12"></span>
<span id="cb43-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Only include grouping columns that are actually present in the data</span></span>
<span id="cb43-14">individual_vars <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb43-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"trace_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span>),</span>
<span id="cb43-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)</span>
<span id="cb43-17">)</span>
<span id="cb43-18"></span>
<span id="cb43-19">auc_metab_list <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb43-20"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb43-21">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb43-22">    col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb43-23">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) {</span>
<span id="cb43-24">      auc_metab_list[[col]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb43-25">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_auc</span>(metabolism_df, col, individual_vars) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb43-26">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">metric =</span> col)</span>
<span id="cb43-27">    }</span>
<span id="cb43-28">  }</span>
<span id="cb43-29">}</span>
<span id="cb43-30"></span>
<span id="cb43-31">auc_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(auc_metab_list)</span>
<span id="cb43-32"></span>
<span id="cb43-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(auc_all)</span></code></pre></div>
<pre><code>tibble [92 × 6] (S3: tbl_df/tbl/data.frame)
 $ trace_id       : chr [1:92] "c-01" "c-02" "c-03" "c-04" ...
 $ family_id_group: chr [1:92] NA NA NA NA ...
 $ treatment_group: chr [1:92] "control" "control" "control" "control" ...
 $ AUC            : num [1:92] 0.000988 0.000663 0.001028 0.001147 0.001497 ...
 $ n_timepoints   : int [1:92] 7 7 7 7 7 7 7 7 7 7 ...
 $ metric         : chr [1:92] "metabolism_per_area_mm2_measurement" "metabolism_per_area_mm2_measurement" "metabolism_per_area_mm2_measurement" "metabolism_per_area_mm2_measurement" ...</code></pre>
<section id="auc-summary-tables" class="level2">
<h2 class="anchored" data-anchor-id="auc-summary-tables">11.1 AUC summary tables</h2>
<div class="sourceCode" id="cb45" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb45-1">sum_vars <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb45-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metric"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span>),</span>
<span id="cb45-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(auc_all)</span>
<span id="cb45-4">)</span>
<span id="cb45-5">auc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(sum_vars))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb45-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb45-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb45-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb45-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se     =</span> sd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(n),</span>
<span id="cb45-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb45-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb45-14">  )</span>
<span id="cb45-15"></span>
<span id="cb45-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(auc_summary)</span></code></pre></div>
<pre><code># A tibble: 2 × 8
  metric   family_id_group treatment_group     n    mean      sd      se  median
  &lt;chr&gt;    &lt;chr&gt;           &lt;chr&gt;           &lt;int&gt;   &lt;dbl&gt;   &lt;dbl&gt;   &lt;dbl&gt;   &lt;dbl&gt;
1 metabol… &lt;NA&gt;            control            46 0.00129 0.00155 2.29e-4 7.96e-4
2 metabol… &lt;NA&gt;            oae                46 0.00215 0.00233 3.43e-4 9.93e-4</code></pre>
</section>
</section>
<section id="statistical-analysis" class="level1">
<h1>12 Statistical Analysis</h1>
<p>Each individual oyster (<code>sample_id_group</code>) is the observational unit. The model is built from whichever grouping factors are present: both family and treatment (with interaction) when both exist, or a one-way model when only one factor is available.</p>
<div class="sourceCode" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">run_auc_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(auc_df) {</span>
<span id="cb47-2">  empty <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb47-3"></span>
<span id="cb47-4">  has_family    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(auc_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb47-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(auc_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb47-6">  has_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(auc_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb47-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(auc_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb47-8"></span>
<span id="cb47-9">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_treatment) {</span>
<span id="cb47-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anova =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb47-11">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_full =</span> empty, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_family =</span> empty,</span>
<span id="cb47-12">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_trt =</span> empty,</span>
<span id="cb47-13">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_family =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_treatment =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>))</span>
<span id="cb47-14">  }</span>
<span id="cb47-15"></span>
<span id="cb47-16">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family)    auc_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family_id_group))</span>
<span id="cb47-17">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment) auc_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(treatment_group))</span>
<span id="cb47-18"></span>
<span id="cb47-19">  formula_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb47-20">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AUC ~ family * treatment"</span></span>
<span id="cb47-21">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb47-22">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AUC ~ family"</span></span>
<span id="cb47-23">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb47-24">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AUC ~ treatment"</span></span>
<span id="cb47-25">  }</span>
<span id="cb47-26">  model     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.formula</span>(formula_str), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> auc_df)</span>
<span id="cb47-27">  anova_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(model)</span>
<span id="cb47-28"></span>
<span id="cb47-29">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb47-30">    pairs_full   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment),</span>
<span id="cb47-31">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb47-32">    pairs_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family),</span>
<span id="cb47-33">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb47-34">    pairs_trt    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment),</span>
<span id="cb47-35">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb47-36">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb47-37">    pairs_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family),</span>
<span id="cb47-38">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb47-39">    pairs_full   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_family</span>
<span id="cb47-40">    pairs_trt    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> empty</span>
<span id="cb47-41">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb47-42">    pairs_trt    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment),</span>
<span id="cb47-43">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb47-44">    pairs_full   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_trt</span>
<span id="cb47-45">    pairs_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> empty</span>
<span id="cb47-46">  }</span>
<span id="cb47-47"></span>
<span id="cb47-48">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb47-49">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model         =</span> model,</span>
<span id="cb47-50">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anova         =</span> anova_res,</span>
<span id="cb47-51">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_full    =</span> pairs_full,</span>
<span id="cb47-52">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_family  =</span> pairs_family,</span>
<span id="cb47-53">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_trt     =</span> pairs_trt,</span>
<span id="cb47-54">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_family    =</span> has_family,</span>
<span id="cb47-55">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_treatment =</span> has_treatment</span>
<span id="cb47-56">  )</span>
<span id="cb47-57">}</span>
<span id="cb47-58"></span>
<span id="cb47-59">metrics_to_test <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(auc_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>metric)</span>
<span id="cb47-60">stats_results   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map</span>(</span>
<span id="cb47-61">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set_names</span>(metrics_to_test),</span>
<span id="cb47-62">  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">run_auc_stats</span>(auc_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(metric <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> .x))</span>
<span id="cb47-63">)</span></code></pre></div>
<section id="results-by-metric" class="level2">
<h2 class="anchored" data-anchor-id="results-by-metric">12.1 Results by metric</h2>
<div class="sourceCode" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (met <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metrics_to_test) {</span>
<span id="cb48-2">  stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats_results[[met]]</span>
<span id="cb48-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">### Metric:"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**ANOVA:**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>anova), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-7">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_treatment) {</span>
<span id="cb48-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: family × treatment (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_full), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: family main effect:**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: treatment main effect:**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-17">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_family) {</span>
<span id="cb48-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: family (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-21">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_treatment) {</span>
<span id="cb48-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: treatment (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-25">  }</span>
<span id="cb48-26">}</span></code></pre></div>
<section id="metric-metabolism_per_area_mm2_measurement-1" class="level3">
<h3 class="anchored" data-anchor-id="metric-metabolism_per_area_mm2_measurement-1">12.1.1 Metric: metabolism_per_area_mm2_measurement</h3>
<p><strong>ANOVA:</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th></th>
<th style="text-align: right;">Df</th>
<th style="text-align: right;">Sum Sq</th>
<th style="text-align: right;">Mean Sq</th>
<th style="text-align: right;">F value</th>
<th style="text-align: right;">Pr(&gt;F)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>treatment</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">4.3289</td>
<td style="text-align: right;">0.0403</td>
</tr>
<tr class="even">
<td>Residuals</td>
<td style="text-align: right;">90</td>
<td style="text-align: right;">4e-04</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
</tbody>
</table>
<p><strong>Pairwise: treatment (Tukey):</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">control - oae</td>
<td style="text-align: right;">-9e-04</td>
<td style="text-align: right;">4e-04</td>
<td style="text-align: right;">90</td>
<td style="text-align: right;">-2.0806</td>
<td style="text-align: right;">0.0403</td>
</tr>
</tbody>
</table>
</section>
</section>
</section>
<section id="auc-box-plots-with-statistical-annotations" class="level1">
<h1>13 AUC Box Plots with Statistical Annotations</h1>
<p>Significance labels: <code>***</code> p &lt; 0.001, <code>**</code> p &lt; 0.01, <code>*</code> p &lt; 0.05. Brackets are drawn only for significant pairs (p &lt; 0.05). Plots are generated for whichever grouping factors are present: treatment-only, family-only, all-groups, within-family, and within-treatment.</p>
<div class="sourceCode" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1">sig_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb49-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"***"</span>, p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**"</span>, p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*"</span>,</span>
<span id="cb49-3">            <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ns"</span>)</span>
<span id="cb49-4">}</span>
<span id="cb49-5"></span>
<span id="cb49-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Add significance brackets to an existing ggplot.</span></span>
<span id="cb49-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># pairs_df   : data frame with $contrast and $p.value columns</span></span>
<span id="cb49-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># group_levels: ordered character vector matching x-axis factor levels</span></span>
<span id="cb49-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y_vals     : numeric vector of AUC values used to set bracket heights</span></span>
<span id="cb49-10">add_sig_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p, pairs_df, group_levels, y_vals) {</span>
<span id="cb49-11">  sig_pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb49-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sig_label</span>(p.value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb49-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ns"</span>)</span>
<span id="cb49-14">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_pairs) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(p)</span>
<span id="cb49-15"></span>
<span id="cb49-16">  y_max   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(y_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb49-17">  y_range <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(y_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb49-18">  step    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> y_range <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span></span>
<span id="cb49-19"></span>
<span id="cb49-20">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># emmeans prefixes factor levels with the variable name (e.g. "family7");</span></span>
<span id="cb49-21">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># resolve back to the bare level used on the x-axis.</span></span>
<span id="cb49-22">  resolve_level <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x, lvls) {</span>
<span id="cb49-23">    x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(x)</span>
<span id="cb49-24">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (x <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> lvls) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(x)</span>
<span id="cb49-25">    lvls_sorted <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> lvls[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nchar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(lvls)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">decreasing =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]</span>
<span id="cb49-26">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (lvl <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> lvls_sorted) {</span>
<span id="cb49-27">      lvl_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(lvl)</span>
<span id="cb49-28">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">endsWith</span>(x, lvl_str) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nchar</span>(x) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nchar</span>(lvl_str)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(lvl_str)</span>
<span id="cb49-29">    }</span>
<span id="cb49-30">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span></span>
<span id="cb49-31">  }</span>
<span id="cb49-32"></span>
<span id="cb49-33">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_pairs))) {</span>
<span id="cb49-34">    parts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sig_pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>contrast[i]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb49-35">    g1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">resolve_level</span>(parts[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], group_levels)</span>
<span id="cb49-36">    g2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">resolve_level</span>(parts[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], group_levels)</span>
<span id="cb49-37">    x1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(g1, group_levels)</span>
<span id="cb49-38">    x2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(g2, group_levels)</span>
<span id="cb49-39">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(x1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(x2)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb49-40">    bar_y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> y_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> step</span>
<span id="cb49-41">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb49-42">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x2,</span>
<span id="cb49-43">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> bar_y,</span>
<span id="cb49-44">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb49-45">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x1,</span>
<span id="cb49-46">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> bar_y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> step <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb49-47">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb49-48">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x2,</span>
<span id="cb49-49">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> bar_y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> step <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb49-50">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb49-51">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> (x1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> x2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb49-52">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> step <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,</span>
<span id="cb49-53">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> sig_pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label[i], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.5</span>)</span>
<span id="cb49-54">  }</span>
<span id="cb49-55">  p</span>
<span id="cb49-56">}</span></code></pre></div>
<div class="sourceCode" id="cb50" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (met <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metrics_to_test) {</span>
<span id="cb50-2">  df      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(metric <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> met)</span>
<span id="cb50-3">  stats   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats_results[[met]]</span>
<span id="cb50-4">  y_lab   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">auc_y_label</span>(met)</span>
<span id="cb50-5">  has_fam <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_family</span>
<span id="cb50-6">  has_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_treatment</span>
<span id="cb50-7"></span>
<span id="cb50-8">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Treatment main effect (x = treatment, tick = treatment name) ───────</span></span>
<span id="cb50-9">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb50-10">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(treatment_group))))</span>
<span id="cb50-12">    grps <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb50-13">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-14">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-15">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-16">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_colours[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-17">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb50-19">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb50-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb50-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_treatment_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb50-22">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb50-23">  }</span>
<span id="cb50-24"></span>
<span id="cb50-25">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Family main effect (x = family, tick = family name) ───────────────</span></span>
<span id="cb50-26">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) {</span>
<span id="cb50-27">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-28">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family_id_group,</span>
<span id="cb50-29">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(family_id_group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)))</span>
<span id="cb50-30">    grps <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb50-31">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-32">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-33">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-35">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-36">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb50-37">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb50-38">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb50-39">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_family_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb50-40">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb50-41">  }</span>
<span id="cb50-42"></span>
<span id="cb50-43">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Remaining plots require both factors</span></span>
<span id="cb50-44">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_trt) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb50-45"></span>
<span id="cb50-46">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── All family:treatment groups (x = family:treatment) ─────────────────</span></span>
<span id="cb50-47">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># emmeans contrasts use spaces; convert to colon to match tick labels</span></span>
<span id="cb50-48">  pairs_fc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_full <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-49">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">contrast =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(</span>
<span id="cb50-50">      contrast,</span>
<span id="cb50-51">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"([a-z]+) ([a-z]+)( - )([a-z]+) ([a-z]+)"</span>,</span>
<span id="cb50-52">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">3</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">4:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">5"</span></span>
<span id="cb50-53">    ))</span>
<span id="cb50-54">  df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-55">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(</span>
<span id="cb50-56">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>),</span>
<span id="cb50-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)),</span>
<span id="cb50-58">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb50-59">    ))</span>
<span id="cb50-60">  grps     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb50-61">  fill_map <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">make_palette</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(grps)), grps)</span>
<span id="cb50-62">  p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-63">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-64">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-65">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fill_map, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-66">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family : Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-67">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-68">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb50-69">  p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, pairs_fc, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb50-70">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb50-71">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_all_groups_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb50-72">         p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb50-73"></span>
<span id="cb50-74">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Within each family: treatment comparison (x = family:treatment) ────</span></span>
<span id="cb50-75">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Tick labels are family:treatment so these plots are visually distinct</span></span>
<span id="cb50-76">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># from the treatment main-effect plot above.</span></span>
<span id="cb50-77">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (fam <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)) {</span>
<span id="cb50-78">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-79">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(family_id_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> fam) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-80">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(</span>
<span id="cb50-81">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>),</span>
<span id="cb50-82">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)),</span>
<span id="cb50-83">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb50-84">      ))</span>
<span id="cb50-85">    grps     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb50-86">    pairs_sub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-87">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_count</span>(contrast, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(fam, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb50-88">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-89">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-90">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-91">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fill_map[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-92">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family : Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-93">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb50-94">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, pairs_sub, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb50-95">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb50-96">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_"</span>, fam, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_trt_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb50-97">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb50-98">  }</span>
<span id="cb50-99"></span>
<span id="cb50-100">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Within each treatment: family comparison (x = family:treatment) ────</span></span>
<span id="cb50-101">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Tick labels are family:treatment so these plots are visually distinct</span></span>
<span id="cb50-102">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># from the family main-effect plot above.</span></span>
<span id="cb50-103">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (trt <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group))) {</span>
<span id="cb50-104">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-105">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(treatment_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> trt) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-106">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(</span>
<span id="cb50-107">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>),</span>
<span id="cb50-108">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)),</span>
<span id="cb50-109">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb50-110">      ))</span>
<span id="cb50-111">    grps      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb50-112">    pairs_sub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-113">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_count</span>(contrast, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>, trt)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb50-114">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-115">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-116">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-117">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fill_map[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-118">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family : Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-119">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb50-120">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, pairs_sub, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb50-121">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb50-122">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_"</span>, trt, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_fam_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb50-123">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb50-124">  }</span>
<span id="cb50-125">}</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-31-Resazurin-Assays---USDA-M.gigas-Juveniles-OAE-Preconditioning-Effect-on-36C-Heat-Stress-Response/01.00-resazurin-20260831-mgig-OAE-36C_files/figure-gfm/auc-boxplots-1.png" class="img-fluid"><!-- --></p>
</section>
<section id="save-output-data" class="level1">
<h1>14 Save Output Data</h1>
<div class="sourceCode" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(auc_all,      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_all_metrics.csv"</span>))</span>
<span id="cb51-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(auc_summary,  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_summary.csv"</span>))</span>
<span id="cb51-3"></span>
<span id="cb51-4"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb51-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(metabolism_df,</span>
<span id="cb51-6">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism.csv"</span>))</span>
<span id="cb51-7"></span>
<span id="cb51-8">stats_compiled <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(metrics_to_test, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(met) {</span>
<span id="cb51-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb51-10">    stats_results[[met]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_full <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family:treatment"</span>),</span>
<span id="cb51-12">    stats_results[[met]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family"</span>),</span>
<span id="cb51-14">    stats_results[[met]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-15">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>)</span>
<span id="cb51-16">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">metric =</span> met)</span>
<span id="cb51-17">})</span>
<span id="cb51-18"></span>
<span id="cb51-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(stats_compiled,</span>
<span id="cb51-20">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pairwise_stats.csv"</span>))</span>
<span id="cb51-21"></span>
<span id="cb51-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Output files written to: "</span>, out_dir)</span></code></pre></div>


</section>

 ]]></description>
  <category>2026</category>
  <category>resazurin</category>
  <category>Magallana gigas</category>
  <category>Crassostrea gigas</category>
  <category>Pacific oyster</category>
  <category>heat stress</category>
  <category>OAE</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-31-Resazurin-Assays---USDA-M.gigas-Juveniles-OAE-Preconditioning-Effect-on-36C-Heat-Stress-Response/</guid>
  <pubDate>Mon, 31 Aug 2026 07:00:00 GMT</pubDate>
  <media:content url="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-31-Resazurin-Assays---USDA-M.gigas-Juveniles-OAE-Preconditioning-Effect-on-36C-Heat-Stress-Response/01.00-resazurin-20260831-mgig-OAE-36C_files/figure-gfm/auc-boxplots-1.png" medium="image" type="image/png" height="120" width="144"/>
</item>
<item>
  <title>Citrate Synthase Analysis - SORMI June 2026 M.gigas Family 5 vs Family 7 Temperature Response</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Cross-plate comparison of citrate synthase (CS) activity across <strong>two families</strong> (<code>F05</code>, <code>F07</code>) at <strong>two temperature exposures</strong> (ambient and 36°C), drawing on the finished per-plate results from three prior notebook entries: <a href="../../../posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/index.html">F05 ambient re-assay, 20260824</a>, <a href="../../../posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/index.html">F05 36°C, 20260814</a>, and <a href="../../../posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/index.html">F07 ambient + 36°C, 20260824</a> (Notebook entries). The <a href="../../../posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/index.html">2026-08-11 F05 ambient plate</a> (Notebook entry) is deliberately excluded — it required repeating for poor data quality — and its 20260824 re-assay is used in its place. All four family × temperature groups carry n = 8 individuals, a fully balanced 2 × 2 design across 32 individuals.</p>
<p>The question this analysis asks is whether CS activity responds to 36°C exposure, and whether that response differs between families (a family × temperature interaction).</p>
<p>Background luminescence is <strong>not subtracted from any activity value in this document</strong>. One retained plate (F07 ambient + 36°C) has no usable background estimate, so to treat every plate identically, the background correction is removed from all three source analyses before comparison. See the BACKGROUND REMOVAL section below for how small this correction was where it could be measured.</p>
<p>All data/code/analysis is available here:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase">https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase</a></li>
</ul>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<p>This is a downstream statistical analysis, not a new plate assay — it takes the finished <code>citrate_synthase_activity_results.csv</code> output of the three per-plate analyses linked above as its input. All individuals were originally assayed with the Citrate Synthase Assay Kit (ABCAM; cat: ab239712); see the linked per-plate entries for assay methods, and the <a href="../../../posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/index.html">homogenization</a> and <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">protein quantification</a> entries for upstream methods.</p>
<p>Individuals are treated as unpaired across temperature — an animal is assayed at one exposure only. Statistics are computed on log<sub>10</sub>(activity): a two-way ANOVA (family × temperature) on a balanced design (n = 8/cell), followed by Tukey HSD pairwise contrasts. The <code>F05</code> ambient-vs-36°C comparison spans two plates run ten days apart (20260814, 20260824); the <code>F07</code> comparison is made within a single plate (20260824) — cross-plate comparability is checked against standard-curve and positive-control calibration values in the PLATE PROVENANCE section below.</p>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<p>Data were analyzed in R. The Rmd file is here (GitHub):</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison.Rmd">Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison.Rmd</a></li>
</ul>
<p>Knitted markdown is below.</p>
</section>
<section id="data-files" class="level2">
<h2 class="anchored" data-anchor-id="data-files">Data files</h2>
<p>Output tables and figures from this analysis are here:</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/outputs/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison</li>
</ul>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p><strong>The temperature response differs between the two families.</strong> A two-way ANOVA on log<sub>10</sub>(activity) finds a significant family × temperature interaction (p = 1e-05), accounting for 23.0% of total variance:</p>
<ul>
<li><p><strong><code>F05</code> loses CS activity at 36°C</strong> — mean activity falls from 114.2 to 40.6 mU/mg protein, a 0.36-fold change (-64%), significant after Tukey adjustment (p = 2e-07).</p></li>
<li><p><strong><code>F07</code> shows essentially no temperature response</strong> — mean activity moves from 129.5 to 129.0 mU/mg protein (1.00-fold, p = 1); its 95% CI at 36°C overlaps its ambient CI substantially.</p></li>
<li><p><strong>The two families are indistinguishable at ambient temperature</strong> (1.10-fold, p = 0.9) — they differ only <em>after</em> heat exposure, which is what makes this an interaction rather than a baseline family difference.</p></li>
<li><p><strong>Removing the background correction does not drive any of this.</strong> Across all 32 individuals the correction was worth 0.0-11.3% of activity (median 0.8%), and both families’ ambient groups shift in the same direction.</p></li>
</ul>
<hr>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Cross-plate comparison of citrate synthase (CS) activity in ctenidia of <em>Magallana gigas</em> (Pacific oyster) from <strong>two families</strong> (<code>F05</code>, <code>F07</code>) at <strong>two temperature exposures</strong> (<strong>ambient</strong> and <strong>36 °C</strong>), assayed with the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">Abcam Citrate Synthase Assay Kit (ab239712), v4a</a>.</p>
<p>The question here is <strong>not</strong> how to compute activity – that was done, plate by plate, in the per-plate analyses listed below. This document takes those finished per-plate results as its input and asks:</p>
<ol type="1">
<li>Does CS activity respond to 36 °C exposure?</li>
<li><strong>Does that temperature response differ between families?</strong> – i.e.&nbsp;is there a family × temperature interaction?</li>
</ol>
<p>All four family × temperature groups carry <strong>n = 8</strong> individuals, giving a fully balanced 2 × 2 design (32 individuals total).</p>
<section id="inputs-which-plates-are-used" class="level2">
<h2 class="anchored" data-anchor-id="inputs-which-plates-are-used">1.1 Inputs: which plates are used</h2>
<p>This analysis reads the <code>citrate_synthase_activity_results.csv</code> output of <strong>three</strong> per-plate analyses:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: left;">Source analysis</th>
<th style="text-align: left;">Plate date</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>F05</code></td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;"><code>Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient</code></td>
<td style="text-align: left;">2026-08-24</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>F05</code></td>
<td style="text-align: left;">36 °C</td>
<td style="text-align: left;"><code>Gen5-20260814-mgig-citrate_synthase-F05-36C</code></td>
<td style="text-align: left;">2026-08-14</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>F07</code></td>
<td style="text-align: left;">ambient + 36 °C</td>
<td style="text-align: left;"><code>Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C</code></td>
<td style="text-align: left;">2026-08-24</td>
</tr>
</tbody>
</table>
<p><strong>The 2026-08-11 <code>F05</code> ambient plate is deliberately excluded</strong> (note 1).</p>
</section>
<section id="notes" class="level2">
<h2 class="anchored" data-anchor-id="notes">1.2 Notes</h2>
<ol type="1">
<li><strong>The 2026-08-11 <code>F05</code>-ambient plate is excluded from this analysis.</strong> That plate required repeating because of poor data quality across both its samples and its standard curve (standard-curve R<sup>2</sup> of 0.9678 after excluding 8 of 18 standard wells as outliers, 4 of 8 samples over the 15% technical-CV threshold, and one sample with all three replicates baseline-compromised). Those same <code>F05</code> ambient homogenates were re-assayed on 2026-08-24, and <strong>the 2026-08-24 re-assay is the <code>F05</code> ambient data used here.</strong></li>
<li><strong>Background luminescence is NOT subtracted from any activity value in this document.</strong> One retained plate (<code>Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C</code>) has no usable background estimate – Reaction Mix was added to all three of its pooled-background wells instead of Background Control Mix, so its background rate is unestimable and its per-plate analysis already fell back to a correction of 0. Rather than compare background-corrected values on two plates against uncorrected values on a third, <strong>the background correction is removed from all plates</strong> so every value is treated identically. This is a small change: where background <em>was</em> measurable it never exceeded ~10% of the raw rate (quantified in BACKGROUND REMOVAL).</li>
<li><strong>Activity is normalized to total extracted protein</strong> (mU per mg protein), carried through from the per-plate analyses, which measured protein directly by BCA/Bradford-style assay on 2026-08-13. Tissue weight is not used.</li>
<li><strong>The <code>F05</code> temperature contrast spans two plates and two days</strong> (36 °C on 2026-08-14, ambient on 2026-08-24), whereas the <code>F07</code> temperature contrast sits <strong>within a single plate</strong> (2026-08-24). Plate and instrument state are compared across plates in PLATE PROVENANCE.</li>
<li><strong>Individuals are treated as unpaired across temperature.</strong> An animal is assayed at one exposure only; <code>F05_01_ambient</code> and <code>F05_01_36C</code> are different individuals from the same family, so no paired/repeated-measures structure is used.</li>
<li><strong>Statistics are computed on log<sub>10</sub>(activity).</strong> Activity is a ratio-scale rate spanning roughly an order of magnitude across groups; the log scale makes the family × temperature interaction a test of <em>multiplicative</em> (fold-change) response, which is the biologically meaningful comparison for an enzyme rate, and it stabilizes the group-to-group spread in variance. Because the design is balanced, sequential (Type I) sums of squares from <code>aov()</code> are identical to Type II and Type III, so no special contrast handling is needed.</li>
</ol>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb3-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tibble)</span>
<span id="cb3-4"></span>
<span id="cb3-5">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-12">)</span></code></pre></div>
</section>
<section id="analysis-parameters" class="level2">
<h2 class="anchored" data-anchor-id="analysis-parameters">1.3 Analysis parameters</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">analysis_params <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtract_background =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># note 2: background is NOT subtracted anywhere</span></span>
<span id="cb4-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha               =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># significance level for ANOVA / Tukey</span></span>
<span id="cb4-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_threshold_pct    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>      <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># technical-CV threshold used by the per-plate analyses</span></span>
<span id="cb4-5">)</span>
<span id="cb4-6"></span>
<span id="cb4-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- analysis_params: settings governing this comparison ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb4-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(analysis_params)</span></code></pre></div>
<pre><code>--- analysis_params: settings governing this comparison ---
List of 3
 $ subtract_background: logi FALSE
 $ alpha              : num 0.05
 $ cv_threshold_pct   : num 15</code></pre>
</section>
<section id="input-paths" class="level2">
<h2 class="anchored" data-anchor-id="input-paths">1.4 Input paths</h2>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">outputs_root <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs"</span></span>
<span id="cb6-2"></span>
<span id="cb6-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Each retained per-plate analysis and the family/temperature it contributes.</span></span>
<span id="cb6-4">plate_inputs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tribble</span>(</span>
<span id="cb6-5">  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>plate_dir,                                                       <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>contributes,</span>
<span id="cb6-6">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient"</span>,          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05 ambient"</span>,</span>
<span id="cb6-7">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260814-mgig-citrate_synthase-F05-36C"</span>,                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05 36C"</span>,</span>
<span id="cb6-8">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C"</span>,  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07 ambient + 36C"</span></span>
<span id="cb6-9">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results_csv =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(outputs_root, plate_dir,</span>
<span id="cb6-11">                                 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_results.csv"</span>))</span>
<span id="cb6-12"></span>
<span id="cb6-13">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(</span>
<span id="cb6-14">  outputs_root,</span>
<span id="cb6-15">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison"</span>)</span>
<span id="cb6-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb6-17"></span>
<span id="cb6-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- plate_inputs: per-plate results files feeding this analysis ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(plate_inputs[, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_dir"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"contributes"</span>)]))</span>
<span id="cb6-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- all input files exist? ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.exists</span>(plate_inputs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>results_csv), plate_inputs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_dir))</span>
<span id="cb6-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- output_dir ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(output_dir)</span></code></pre></div>
<pre><code>--- plate_inputs: per-plate results files feeding this analysis ---
                                                      plate_dir
1         Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient
2                   Gen5-20260814-mgig-citrate_synthase-F05-36C
3 Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C
        contributes
1       F05 ambient
2           F05 36C
3 F07 ambient + 36C

--- all input files exist? ---
        Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient 
                                                         TRUE 
                  Gen5-20260814-mgig-citrate_synthase-F05-36C 
                                                         TRUE 
Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C 
                                                         TRUE 

--- output_dir ---
 chr "../outputs/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison"</code></pre>
</section>
<section id="plate-provenance" class="level2">
<h2 class="anchored" data-anchor-id="plate-provenance">1.5 Plate provenance</h2>
<p>Per-plate calibration and instrument-state values, transcribed from the three source analyses. These are the anchors that make cross-plate comparison defensible: if the GSH standard curve and the CS positive control agree across plates, then a rate measured on one plate means the same thing as a rate measured on another.</p>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">plate_provenance <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tribble</span>(</span>
<span id="cb8-2">  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>plate_dir,                                                      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>plate_date,  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>std_slope_A412_per_nmol, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>std_r2, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>pos_control_mA412_min, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>pos_control_cv_pct, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span>background_usable,</span>
<span id="cb8-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient"</span>,         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-24"</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.03234</span>,                  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9983</span>,  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.700</span>,                  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">22.8</span>,                <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb8-4">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260814-mgig-citrate_synthase-F05-36C"</span>,                   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-14"</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.03075</span>,                  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9985</span>,  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.933</span>,                  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.9</span>,                 <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb8-5">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-24"</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.03140</span>,                  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9992</span>,  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.933</span>,                  <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>,                 <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-6">)</span>
<span id="cb8-7"></span>
<span id="cb8-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- plate_provenance: calibration + instrument state per plate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(plate_provenance))</span></code></pre></div>
<pre><code>--- plate_provenance: calibration + instrument state per plate ---
'data.frame':   3 obs. of  7 variables:
 $ plate_dir              : chr  "Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient" "Gen5-20260814-mgig-citrate_synthase-F05-36C" "Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C"
 $ plate_date             : chr  "2026-08-24" "2026-08-14" "2026-08-24"
 $ std_slope_A412_per_nmol: num  0.0323 0.0307 0.0314
 $ std_r2                 : num  0.998 0.999 0.999
 $ pos_control_mA412_min  : num  2.7 2.93 2.93
 $ pos_control_cv_pct     : num  22.8 3.9 2.6
 $ background_usable      : logi  TRUE TRUE FALSE</code></pre>
<div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">plate_provenance <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb10-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Plate            =</span> plate_dir,</span>
<span id="cb10-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Date             =</span> plate_date,</span>
<span id="cb10-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Std slope (A412/nmol)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> std_slope_A412_per_nmol,</span>
<span id="cb10-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Std curve R^2</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> std_r2,</span>
<span id="cb10-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pos ctrl (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> pos_control_mA412_min,</span>
<span id="cb10-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pos ctrl CV (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> pos_control_cv_pct,</span>
<span id="cb10-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Background estimable</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(background_usable, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no (note 2)"</span>)</span>
<span id="cb10-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Calibration and instrument state for each retained plate."</span>)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Plate</th>
<th style="text-align: left;">Date</th>
<th style="text-align: right;">Std slope (A412/nmol)</th>
<th style="text-align: right;">Std curve R^2</th>
<th style="text-align: right;">Pos ctrl (mA412/min)</th>
<th style="text-align: right;">Pos ctrl CV (%)</th>
<th style="text-align: left;">Background estimable</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient</td>
<td style="text-align: left;">2026-08-24</td>
<td style="text-align: right;">0.03234</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: right;">2.700</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">Gen5-20260814-mgig-citrate_synthase-F05-36C</td>
<td style="text-align: left;">2026-08-14</td>
<td style="text-align: right;">0.03075</td>
<td style="text-align: right;">0.9985</td>
<td style="text-align: right;">2.933</td>
<td style="text-align: right;">3.9</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C</td>
<td style="text-align: left;">2026-08-24</td>
<td style="text-align: right;">0.03140</td>
<td style="text-align: right;">0.9992</td>
<td style="text-align: right;">2.933</td>
<td style="text-align: right;">2.6</td>
<td style="text-align: left;">no (note 2)</td>
</tr>
</tbody>
</table>
<p>Calibration and instrument state for each retained plate.</p>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">prov_spread <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_provenance <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb11-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_min   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(std_slope_A412_per_nmol),</span>
<span id="cb11-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_max   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(std_slope_A412_per_nmol),</span>
<span id="cb11-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_cv    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(std_slope_A412_per_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(std_slope_A412_per_nmol),</span>
<span id="cb11-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pos_min     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(pos_control_mA412_min),</span>
<span id="cb11-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pos_max     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(pos_control_mA412_min),</span>
<span id="cb11-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pos_cv      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(pos_control_mA412_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control_mA412_min),</span>
<span id="cb11-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min_std_r2  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(std_r2)</span>
<span id="cb11-10">  )</span>
<span id="cb11-11"></span>
<span id="cb11-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb11-13">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard-curve slope across plates: %.5f-%.5f A412/nmol (CV %.1f%%)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb11-14">  prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_min, prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_max, prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_cv))</span>
<span id="cb11-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb11-16">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control across plates:     %.3f-%.3f mA412/min (CV %.1f%%)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb11-17">  prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pos_min, prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pos_max, prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pos_cv))</span>
<span id="cb11-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Worst standard-curve R^2:           %.4f</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>min_std_r2))</span></code></pre></div>
<pre><code>Standard-curve slope across plates: 0.03075-0.03234 A412/nmol (CV 2.5%)
Positive control across plates:     2.700-2.933 mA412/min (CV 4.7%)
Worst standard-curve R^2:           0.9983</code></pre>
</section>
</section>
<section id="load-per-plate-results" class="level1">
<h1>2 LOAD PER-PLATE RESULTS</h1>
<section id="read-the-results-csvs" class="level2">
<h2 class="anchored" data-anchor-id="read-the-results-csvs">2.1 Read the results CSVs</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">read_plate_results <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(results_csv, plate_dir) {</span>
<span id="cb13-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(results_csv, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_dir =</span> plate_dir)</span>
<span id="cb13-4">}</span>
<span id="cb13-5"></span>
<span id="cb13-6">plate_results_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Map</span>(read_plate_results,</span>
<span id="cb13-7">                         plate_inputs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>results_csv,</span>
<span id="cb13-8">                         plate_inputs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_dir) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>()</span>
<span id="cb13-10"></span>
<span id="cb13-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- plate_results_raw: all per-plate result rows, stacked ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(plate_results_raw))</span></code></pre></div>
<pre><code>--- plate_results_raw: all per-plate result rows, stacked ---
'data.frame':   32 obs. of  18 variables:
 $ Sample                    : chr  "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ Family                    : chr  "F05" "F05" "F05" "F05" ...
 $ Individual                : int  1 2 3 4 5 6 7 8 1 2 ...
 $ Temperature               : chr  "ambient" "ambient" "ambient" "ambient" ...
 $ Protein conc (ug/mL)      : num  876 1039 1900 1129 712 ...
 $ Total protein (mg)        : num  0.307 0.364 0.665 0.395 0.249 0.781 0.591 0.946 0.334 0.191 ...
 $ Reps used                 : chr  "3/3" "3/3" "3/3" "3/3" ...
 $ CV all reps (%)           : num  4.6 4.1 2.2 2.5 1.9 1.9 1.3 0.8 3.3 2.4 ...
 $ CV used reps (%)          : num  4.6 4.1 2.2 2.5 1.9 1.9 1.3 0.8 3.3 2.4 ...
 $ Rate (mA412/min)          : num  7.6 8.5 13.48 10.18 5.62 ...
 $ BG rate (mA412/min)       : num  0.233 0.233 0.233 0.233 0.233 0.233 0.233 0.233 0.167 0.15 ...
 $ Corrected rate (mA412/min): num  7.37 8.27 13.25 9.95 5.38 ...
 $ Activity (mU/uL)          : num  0.1139 0.1278 0.2048 0.1538 0.0832 ...
 $ Activity (mU/mg protein)  : num  130 123 108 136 117 ...
 $ CV flag                   : chr  "pass" "pass" "pass" "pass" ...
 $ Elevated baseline reps    : chr  "0/3" "0/3" "0/3" "0/3" ...
 $ Interpretation            : chr  "usable" "usable" "usable" "usable" ...
 $ plate_dir                 : chr  "Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient" "Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient" "Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient" "Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient" ...</code></pre>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rows read per plate:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(plate_results_raw<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_dir))</span>
<span id="cb15-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Columns present in every input file:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(plate_results_raw))</span></code></pre></div>
<pre><code>Rows read per plate:

                  Gen5-20260814-mgig-citrate_synthase-F05-36C 
                                                            8 
        Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient 
                                                            8 
Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C 
                                                           16 

Columns present in every input file:
 [1] "Sample"                     "Family"                    
 [3] "Individual"                 "Temperature"               
 [5] "Protein conc (ug/mL)"       "Total protein (mg)"        
 [7] "Reps used"                  "CV all reps (%)"           
 [9] "CV used reps (%)"           "Rate (mA412/min)"          
[11] "BG rate (mA412/min)"        "Corrected rate (mA412/min)"
[13] "Activity (mU/uL)"           "Activity (mU/mg protein)"  
[15] "CV flag"                    "Elevated baseline reps"    
[17] "Interpretation"             "plate_dir"                 </code></pre>
</section>
<section id="keep-only-the-columns-this-analysis-needs" class="level2">
<h2 class="anchored" data-anchor-id="keep-only-the-columns-this-analysis-needs">2.2 Keep only the columns this analysis needs</h2>
<p>The per-plate results tables carry QC columns alongside the activity values. This analysis needs the identity of each individual, its protein normalization, both the raw and background-corrected rate (to undo the background subtraction – note 2), the published activity, and the QC verdict.</p>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">cs_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_results_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb17-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id        =</span> Sample,</span>
<span id="cb17-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family           =</span> Family,</span>
<span id="cb17-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature      =</span> Temperature,</span>
<span id="cb17-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%02d"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(Individual)),</span>
<span id="cb17-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_dir        =</span> plate_dir,</span>
<span id="cb17-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">protein_mg       =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Total protein (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">reps_used        =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Reps used</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_used_pct      =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV used reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_raw         =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_bg          =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">BG rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_corrected   =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Corrected rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_published =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/mg protein)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_flag          =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV flag</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb17-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">interpretation   =</span> Interpretation</span>
<span id="cb17-17">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_provenance <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(plate_dir, plate_date, std_slope_A412_per_nmol),</span>
<span id="cb17-19">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_dir"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(family, temperature, individual)</span>
<span id="cb17-21"></span>
<span id="cb17-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cs_all: one row per individual, columns needed downstream ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(cs_all))</span></code></pre></div>
<pre><code>--- cs_all: one row per individual, columns needed downstream ---
'data.frame':   32 obs. of  16 variables:
 $ sample_id              : chr  "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ family                 : chr  "F05" "F05" "F05" "F05" ...
 $ temperature            : chr  "36C" "36C" "36C" "36C" ...
 $ individual             : chr  "01" "02" "03" "04" ...
 $ plate_dir              : chr  "Gen5-20260814-mgig-citrate_synthase-F05-36C" "Gen5-20260814-mgig-citrate_synthase-F05-36C" "Gen5-20260814-mgig-citrate_synthase-F05-36C" "Gen5-20260814-mgig-citrate_synthase-F05-36C" ...
 $ protein_mg             : num  0.334 0.191 0.234 0.372 0.583 0.443 0.389 0.475 0.307 0.364 ...
 $ reps_used              : chr  "3/3" "3/3" "3/3" "3/3" ...
 $ cv_used_pct            : num  3.3 2.4 3.5 2.3 1.2 2.4 1.2 7.8 4.6 4.1 ...
 $ rate_raw               : num  2.33 2.37 2.45 2.47 2.33 2.37 2.37 2.43 7.6 8.5 ...
 $ rate_bg                : num  0.167 0.15 0.15 0.183 0.183 0.233 0.167 0.183 0.233 0.233 ...
 $ rate_corrected         : num  2.17 2.22 2.3 2.28 2.15 2.13 2.2 2.25 7.37 8.27 ...
 $ activity_published     : num  37 66 56 35 21 ...
 $ cv_flag                : chr  "pass" "pass" "pass" "pass" ...
 $ interpretation         : chr  "usable" "usable" "usable" "usable" ...
 $ plate_date             : chr  "2026-08-14" "2026-08-14" "2026-08-14" "2026-08-14" ...
 $ std_slope_A412_per_nmol: num  0.0307 0.0307 0.0307 0.0307 0.0307 ...</code></pre>
</section>
<section id="verify-the-design-is-complete-and-balanced" class="level2">
<h2 class="anchored" data-anchor-id="verify-the-design-is-complete-and-balanced">2.3 Verify the design is complete and balanced</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">design_counts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(family, temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_individuals"</span>)</span>
<span id="cb19-3"></span>
<span id="cb19-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- design_counts: individuals per family x temperature cell ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(design_counts))</span>
<span id="cb19-6"></span>
<span id="cb19-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Total individuals: %d</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cs_all)))</span>
<span id="cb19-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Duplicated sample_ids: %d</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">duplicated</span>(cs_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id))))</span>
<span id="cb19-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rows with missing protein_mg: %d</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cs_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>protein_mg))))</span>
<span id="cb19-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rows with missing raw rate: %d</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cs_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_raw))))</span>
<span id="cb19-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Design balanced (all cells equal n): %s</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb19-12">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(design_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_individuals)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span></code></pre></div>
<pre><code>--- design_counts: individuals per family x temperature cell ---
  family temperature n_individuals
1    F05         36C             8
2    F05     ambient             8
3    F07         36C             8
4    F07     ambient             8

Total individuals: 32
Duplicated sample_ids: 0
Rows with missing protein_mg: 0
Rows with missing raw rate: 0
Design balanced (all cells equal n): TRUE</code></pre>
</section>
</section>
<section id="background-removal" class="level1">
<h1>3 BACKGROUND REMOVAL</h1>
<section id="why-the-correction-is-removed" class="level2">
<h2 class="anchored" data-anchor-id="why-the-correction-is-removed">3.1 Why the correction is removed</h2>
<p>Per note 2, the <code>F07</code> plate has no estimable background, so its published “corrected” rate already equals its raw rate. The two <code>F05</code> plates <em>do</em> carry a background subtraction. Comparing corrected <code>F05</code> values against uncorrected <code>F07</code> values would put a systematic, plate-dependent offset directly into the family contrast – so instead the correction is stripped from every plate.</p>
</section>
<section id="how-much-does-the-correction-actually-matter" class="level2">
<h2 class="anchored" data-anchor-id="how-much-does-the-correction-actually-matter">3.2 How much does the correction actually matter?</h2>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">bg_impact <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_pct_of_raw =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> rate_bg <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> rate_raw) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(plate_dir) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb21-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n              =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb21-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_min    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(rate_bg),</span>
<span id="cb21-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_max    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(rate_bg),</span>
<span id="cb21-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_pct_min     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(bg_pct_of_raw),</span>
<span id="cb21-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_pct_max     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(bg_pct_of_raw),</span>
<span id="cb21-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb21-11">  )</span>
<span id="cb21-12"></span>
<span id="cb21-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- bg_impact: size of the background correction, per plate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(bg_impact))</span></code></pre></div>
<pre><code>--- bg_impact: size of the background correction, per plate ---
                                                      plate_dir  n bg_rate_min
1                   Gen5-20260814-mgig-citrate_synthase-F05-36C  8       0.150
2         Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient  8       0.233
3 Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C 16       0.000
  bg_rate_max bg_pct_min bg_pct_max
1       0.233   6.122449   9.831224
2       0.233   1.581806   4.145907
3       0.000   0.000000   0.000000</code></pre>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">bg_impact <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb23-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Plate =</span> plate_dir,</span>
<span id="cb23-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n     =</span> n,</span>
<span id="cb23-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">BG rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f - %.3f"</span>, bg_rate_min, bg_rate_max),</span>
<span id="cb23-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">BG as % of raw rate</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f - %.1f"</span>, bg_pct_min, bg_pct_max)</span>
<span id="cb23-7">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Magnitude of the background correction being removed."</span>,</span>
<span id="cb23-9">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"The F07 plate has no estimable background (note 2),"</span>,</span>
<span id="cb23-10">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"so its correction is already zero."</span>))</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Plate</th>
<th style="text-align: right;">n</th>
<th style="text-align: left;">BG rate (mA412/min)</th>
<th style="text-align: left;">BG as % of raw rate</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Gen5-20260814-mgig-citrate_synthase-F05-36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: left;">0.150 - 0.233</td>
<td style="text-align: left;">6.1 - 9.8</td>
</tr>
<tr class="even">
<td style="text-align: left;">Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: left;">0.233 - 0.233</td>
<td style="text-align: left;">1.6 - 4.1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C</td>
<td style="text-align: right;">16</td>
<td style="text-align: left;">0.000 - 0.000</td>
<td style="text-align: left;">0.0 - 0.0</td>
</tr>
</tbody>
</table>
<p>Magnitude of the background correction being removed. The F07 plate has no estimable background (note 2), so its correction is already zero.</p>
</section>
<section id="recompute-activity-without-background-subtraction" class="level2">
<h2 class="anchored" data-anchor-id="recompute-activity-without-background-subtraction">3.3 Recompute activity without background subtraction</h2>
<p>Activity is <strong>linear</strong> in the background-corrected rate: every other term in the Abcam calculation (standard-curve slope, sample volume, dilution factor, homogenate volume, total protein) is a per-sample constant. So the uncorrected activity is recovered exactly by rescaling the published activity by <code>rate_raw / rate_corrected</code>, with no need to re-derive anything from the raw kinetic traces.</p>
<div class="sourceCode" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>subtract_background)</span>
<span id="cb24-2"></span>
<span id="cb24-3">cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb24-5">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Scale factor undoing the background subtraction; exactly 1 where the</span></span>
<span id="cb24-6">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># per-plate analysis already applied no correction (F07 plate).</span></span>
<span id="cb24-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_undo_factor  =</span> rate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> rate_corrected,</span>
<span id="cb24-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_nobg   =</span> activity_published <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> bg_undo_factor,</span>
<span id="cb24-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">log10_activity  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log10</span>(activity_nobg)</span>
<span id="cb24-10">  )</span>
<span id="cb24-11"></span>
<span id="cb24-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cs_activity: activity with background subtraction removed ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb24-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(cs_activity))</span></code></pre></div>
<pre><code>--- cs_activity: activity with background subtraction removed ---
'data.frame':   32 obs. of  19 variables:
 $ sample_id              : chr  "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ family                 : chr  "F05" "F05" "F05" "F05" ...
 $ temperature            : chr  "36C" "36C" "36C" "36C" ...
 $ individual             : chr  "01" "02" "03" "04" ...
 $ plate_dir              : chr  "Gen5-20260814-mgig-citrate_synthase-F05-36C" "Gen5-20260814-mgig-citrate_synthase-F05-36C" "Gen5-20260814-mgig-citrate_synthase-F05-36C" "Gen5-20260814-mgig-citrate_synthase-F05-36C" ...
 $ protein_mg             : num  0.334 0.191 0.234 0.372 0.583 0.443 0.389 0.475 0.307 0.364 ...
 $ reps_used              : chr  "3/3" "3/3" "3/3" "3/3" ...
 $ cv_used_pct            : num  3.3 2.4 3.5 2.3 1.2 2.4 1.2 7.8 4.6 4.1 ...
 $ rate_raw               : num  2.33 2.37 2.45 2.47 2.33 2.37 2.37 2.43 7.6 8.5 ...
 $ rate_bg                : num  0.167 0.15 0.15 0.183 0.183 0.233 0.167 0.183 0.233 0.233 ...
 $ rate_corrected         : num  2.17 2.22 2.3 2.28 2.15 2.13 2.2 2.25 7.37 8.27 ...
 $ activity_published     : num  37 66 56 35 21 ...
 $ cv_flag                : chr  "pass" "pass" "pass" "pass" ...
 $ interpretation         : chr  "usable" "usable" "usable" "usable" ...
 $ plate_date             : chr  "2026-08-14" "2026-08-14" "2026-08-14" "2026-08-14" ...
 $ std_slope_A412_per_nmol: num  0.0307 0.0307 0.0307 0.0307 0.0307 ...
 $ bg_undo_factor         : num  1.07 1.07 1.07 1.08 1.08 ...
 $ activity_nobg          : num  39.7 70.5 59.7 37.9 22.7 ...
 $ log10_activity         : num  1.6 1.85 1.78 1.58 1.36 ...</code></pre>
</section>
<section id="independently-verify-the-rescaling" class="level2">
<h2 class="anchored" data-anchor-id="independently-verify-the-rescaling">3.4 Independently verify the rescaling</h2>
<p>The rescaling above is checked against a from-scratch recomputation of activity out of the raw rate and each plate’s own standard-curve slope, using the Abcam formula (<code>nmol/min = (rate/1000) / std_slope</code>; <code>mU/uL = nmol/min / sample_volume * D</code>; <code>mU/mg = mU/uL * homogenate_volume / total_protein_mg</code>). The two paths must agree to within the rounding of the input CSVs.</p>
<div class="sourceCode" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Assay constants shared by all three plates (identical in all source analyses).</span></span>
<span id="cb26-2">sample_volume_uL     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb26-3">dilution_factor      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb26-4">homogenate_volume_uL <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span></span>
<span id="cb26-5"></span>
<span id="cb26-6">verify <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb26-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb26-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_recomputed =</span></span>
<span id="cb26-9">      ((rate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope_A412_per_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span></span>
<span id="cb26-10">         dilution_factor) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> homogenate_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> protein_mg,</span>
<span id="cb26-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pct_diff =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(activity_recomputed <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> activity_nobg <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb26-12">  )</span>
<span id="cb26-13"></span>
<span id="cb26-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max %% difference, rescaled vs recomputed-from-raw: %.3f%%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb26-15">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(verify<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_diff)))</span>
<span id="cb26-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All within 1%% (input CSV rounding): %s</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(verify<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_diff) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span></code></pre></div>
<pre><code>Max % difference, rescaled vs recomputed-from-raw: 0.415%
All within 1% (input CSV rounding): TRUE</code></pre>
<div class="sourceCode" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb28-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Removing the background correction changes activity by %.1f%%-%.1f%% (median %.1f%%).</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb28-3">  <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_undo_factor) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb28-4">  <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_undo_factor) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb28-5">  <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_undo_factor) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span></code></pre></div>
<pre><code>Removing the background correction changes activity by 0.0%-11.3% (median 0.8%).</code></pre>
</section>
</section>
<section id="analysis-data-set" class="level1">
<h1>4 ANALYSIS DATA SET</h1>
<section id="set-factor-levels" class="level2">
<h2 class="anchored" data-anchor-id="set-factor-levels">4.1 Set factor levels</h2>
<div class="sourceCode" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Group levels are ordered family-major so that, on a single x axis, each</span></span>
<span id="cb30-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># family's ambient and 36C boxes sit side by side.</span></span>
<span id="cb30-3">group_levels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05 ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05 36C"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07 ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07 36C"</span>)</span>
<span id="cb30-4"></span>
<span id="cb30-5">cs_analysis <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb30-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb30-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07"</span>)),</span>
<span id="cb30-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span>)),</span>
<span id="cb30-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family, temperature), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> group_levels),</span>
<span id="cb30-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_dir   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(plate_dir)</span>
<span id="cb30-11">  )</span>
<span id="cb30-12"></span>
<span id="cb30-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cs_analysis: analysis-ready data with ordered factors ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family levels:     "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"temperature levels:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>temperature), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"group levels:      "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" | "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n rows:            "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cs_analysis), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- cs_analysis: analysis-ready data with ordered factors ---
family levels:      F05, F07 
temperature levels: ambient, 36C 
group levels:       F05 ambient | F05 36C | F07 ambient | F07 36C 
n rows:             32 </code></pre>
</section>
<section id="colour-palette" class="level2">
<h2 class="anchored" data-anchor-id="colour-palette">4.2 Colour palette</h2>
<p>Colours are drawn from the <strong>Okabe-Ito</strong> qualitative palette, which is designed to remain distinguishable under deuteranopia, protanopia and tritanopia (Okabe &amp; Ito 2008, <em>Color Universal Design</em>). One hue is bound to each family and reused in every figure in this document, so colour alone identifies the family throughout. Temperature is additionally encoded by point shape and by a light/dark tint of the family hue, so <strong>no figure relies on colour as its only channel</strong> – each remains readable in greyscale and to a colourblind reader.</p>
<div class="sourceCode" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Okabe-Ito colourblind-safe qualitative palette.</span></span>
<span id="cb32-2">okabe_ito <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb32-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blue          =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0072B2"</span>,</span>
<span id="cb32-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vermillion    =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D55E00"</span>,</span>
<span id="cb32-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bluishgreen   =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#009E73"</span>,</span>
<span id="cb32-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">orange        =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#E69F00"</span>,</span>
<span id="cb32-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">skyblue       =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#56B4E9"</span>,</span>
<span id="cb32-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">reddishpurple =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#CC79A7"</span>,</span>
<span id="cb32-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yellow        =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#F0E442"</span>,</span>
<span id="cb32-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">black         =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#000000"</span></span>
<span id="cb32-11">)</span>
<span id="cb32-12"></span>
<span id="cb32-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Family identity: one hue per family.</span></span>
<span id="cb32-14">family_colours <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">F05 =</span> okabe_ito[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">F07 =</span> okabe_ito[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"vermillion"</span>]])</span>
<span id="cb32-15"></span>
<span id="cb32-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Group identity: each family keeps its hue, with the 36C member of the pair</span></span>
<span id="cb32-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># as the lighter tint, so family and temperature are both readable from fill.</span></span>
<span id="cb32-18">group_colours <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb32-19">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05 ambient"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> okabe_ito[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blue"</span>]],</span>
<span id="cb32-20">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05 36C"</span>     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> okabe_ito[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"skyblue"</span>]],</span>
<span id="cb32-21">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07 ambient"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> okabe_ito[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"vermillion"</span>]],</span>
<span id="cb32-22">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07 36C"</span>     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> okabe_ito[[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"orange"</span>]]</span>
<span id="cb32-23">)</span>
<span id="cb32-24"></span>
<span id="cb32-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(group_colours)))</span>
<span id="cb32-26"></span>
<span id="cb32-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- family_colours: hue bound to each family in every figure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(family_colours)</span>
<span id="cb32-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- group_colours: fill bound to each family x temperature group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(group_colours)</span></code></pre></div>
<pre><code>--- family_colours: hue bound to each family in every figure ---
      F05       F07 
"#0072B2" "#D55E00" 

--- group_colours: fill bound to each family x temperature group ---
F05 ambient     F05 36C F07 ambient     F07 36C 
  "#0072B2"   "#56B4E9"   "#D55E00"   "#E69F00" </code></pre>
</section>
<section id="qc-status-of-the-analysis-set" class="level2">
<h2 class="anchored" data-anchor-id="qc-status-of-the-analysis-set">4.3 QC status of the analysis set</h2>
<p>Every individual is retained. The per-plate analyses already excluded unusable technical replicates before averaging; the flags below describe which individuals had a replicate dropped or a wide replicate CV, so any group difference can be checked against QC status rather than silently inheriting it.</p>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">qc_status <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_analysis <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family, temperature) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb34-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n                   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb34-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_full_triplicate   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(reps_used <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"3/3"</span>),</span>
<span id="cb34-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_cv_flagged        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_flag <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pass"</span>),</span>
<span id="cb34-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_not_usable        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(interpretation <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>),</span>
<span id="cb34-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_cv_used_pct     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(cv_used_pct),</span>
<span id="cb34-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb34-10">  )</span>
<span id="cb34-11"></span>
<span id="cb34-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- qc_status: QC composition of each group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(qc_status))</span></code></pre></div>
<pre><code>--- qc_status: QC composition of each group ---
  family temperature n n_full_triplicate n_cv_flagged n_not_usable
1    F05     ambient 8                 8            0            0
2    F05         36C 8                 8            0            0
3    F07     ambient 8                 7            1            0
4    F07         36C 8                 8            0            0
  max_cv_used_pct
1             4.6
2             7.8
3             6.4
4             3.1</code></pre>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">qc_status <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb36-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb36-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> n,</span>
<span id="cb36-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Full 3/3 reps</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> n_full_triplicate,</span>
<span id="cb36-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV-flagged</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> n_cv_flagged,</span>
<span id="cb36-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Not usable</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> n_not_usable,</span>
<span id="cb36-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Worst CV of used reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> max_cv_used_pct</span>
<span id="cb36-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb36-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"QC composition per group. CV-flagged counts"</span>,</span>
<span id="cb36-10">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" individuals whose CV across ALL replicates exceeded "</span>,</span>
<span id="cb36-11">                         analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb36-12">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%; such individuals still contribute a mean over"</span>,</span>
<span id="cb36-13">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" their retained replicates."</span>))</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">Full 3/3 reps</th>
<th style="text-align: right;">CV-flagged</th>
<th style="text-align: right;">Not usable</th>
<th>Worst CV of used reps (%)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td>4.6</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td>7.8</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td>6.4</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td>3.1</td>
</tr>
</tbody>
</table>
<p>QC composition per group. CV-flagged counts individuals whose CV across ALL replicates exceeded 15%; such individuals still contribute a mean over their retained replicates.</p>
</section>
</section>
<section id="descriptive-statistics" class="level1">
<h1>5 DESCRIPTIVE STATISTICS</h1>
<section id="per-group-summary" class="level2">
<h2 class="anchored" data-anchor-id="per-group-summary">5.1 Per-group summary</h2>
<div class="sourceCode" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1">group_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_analysis <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb37-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family, temperature) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb37-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb37-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb37-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_act =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(activity_nobg),</span>
<span id="cb37-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_act   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(activity_nobg),</span>
<span id="cb37-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_act   =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(activity_nobg) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(activity_nobg),</span>
<span id="cb37-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_act =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(activity_nobg),</span>
<span id="cb37-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min_act  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(activity_nobg),</span>
<span id="cb37-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_act  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(activity_nobg),</span>
<span id="cb37-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_rate_raw =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(rate_raw),</span>
<span id="cb37-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_rate_raw   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(rate_raw),</span>
<span id="cb37-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb37-14">  )</span>
<span id="cb37-15"></span>
<span id="cb37-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- group_summary: activity (mU/mg protein), background NOT subtracted ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(group_summary))</span></code></pre></div>
<pre><code>--- group_summary: activity (mU/mg protein), background NOT subtracted ---
  family temperature n  mean_act   sd_act   cv_act median_act  min_act
1    F05     ambient 8 114.20466 19.52111 17.09310  115.90009 84.22106
2    F05         36C 8  40.59051 16.27503 40.09566   36.28073 22.72780
3    F07     ambient 8 129.52200 40.91814 31.59165  124.21200 79.56600
4    F07         36C 8 129.02000 36.02833 27.92461  118.56250 86.54400
    max_act mean_rate_raw sd_rate_raw
1 139.34016      10.62875  3.23688315
2  70.49255       2.39000  0.05345225
3 207.81900       6.23000  1.62935570
4 200.57800       5.99750  2.05133928</code></pre>
<div class="sourceCode" id="cb39" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1">group_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb39-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb39-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> n,</span>
<span id="cb39-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean (mU/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_act, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb39-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">SD</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(sd_act, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb39-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_act, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb39-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Median</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(median_act, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb39-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f - %.1f"</span>, min_act, max_act),</span>
<span id="cb39-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Raw rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f +/- %.2f"</span>, mean_rate_raw, sd_rate_raw)</span>
<span id="cb39-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb39-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity per family x temperature"</span>,</span>
<span id="cb39-12">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"group, with background subtraction removed (note 2)."</span>))</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">Mean (mU/mg)</th>
<th style="text-align: right;">SD</th>
<th>CV (%)</th>
<th style="text-align: right;">Median</th>
<th style="text-align: left;">Range</th>
<th style="text-align: left;">Raw rate (mA412/min)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">114.2</td>
<td style="text-align: right;">19.5</td>
<td>17.1</td>
<td style="text-align: right;">115.9</td>
<td style="text-align: left;">84.2 - 139.3</td>
<td style="text-align: left;">10.63 +/- 3.24</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">40.6</td>
<td style="text-align: right;">16.3</td>
<td>40.1</td>
<td style="text-align: right;">36.3</td>
<td style="text-align: left;">22.7 - 70.5</td>
<td style="text-align: left;">2.39 +/- 0.05</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">129.5</td>
<td style="text-align: right;">40.9</td>
<td>31.6</td>
<td style="text-align: right;">124.2</td>
<td style="text-align: left;">79.6 - 207.8</td>
<td style="text-align: left;">6.23 +/- 1.63</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">129.0</td>
<td style="text-align: right;">36.0</td>
<td>27.9</td>
<td style="text-align: right;">118.6</td>
<td style="text-align: left;">86.5 - 200.6</td>
<td style="text-align: left;">6.00 +/- 2.05</td>
</tr>
</tbody>
</table>
<p>Citrate synthase activity per family x temperature group, with background subtraction removed (note 2).</p>
</section>
<section id="temperature-effect-within-each-family" class="level2">
<h2 class="anchored" data-anchor-id="temperature-effect-within-each-family">5.2 Temperature effect within each family</h2>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">temp_effect <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb40-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(family, temperature, mean_act) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb40-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_wider</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_from =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_from =</span> mean_act) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb40-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb40-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_change    =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> ambient,</span>
<span id="cb40-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fold_change   =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> ambient,</span>
<span id="cb40-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pct_change    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (fold_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb40-8">  )</span>
<span id="cb40-9"></span>
<span id="cb40-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- temp_effect: ambient -&gt; 36C change in mean activity, per family ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(temp_effect))</span></code></pre></div>
<pre><code>--- temp_effect: ambient -&gt; 36C change in mean activity, per family ---
  family  ambient       36C abs_change fold_change  pct_change
1    F05 114.2047  40.59051  -73.61414   0.3554191 -64.4580931
2    F07 129.5220 129.02000   -0.50200   0.9961242  -0.3875789</code></pre>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1">temp_effect <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb42-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family,</span>
<span id="cb42-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Ambient mean (mU/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(ambient, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb42-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C mean (mU/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb42-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Change (mU/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(abs_change, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb42-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Fold change</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(fold_change, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb42-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">% change</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(pct_change, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb42-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Direction and size of the 36C response within each family."</span>)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Family</th>
<th style="text-align: right;">Ambient mean (mU/mg)</th>
<th style="text-align: right;">36C mean (mU/mg)</th>
<th style="text-align: right;">Change (mU/mg)</th>
<th style="text-align: right;">Fold change</th>
<th style="text-align: right;">% change</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05</td>
<td style="text-align: right;">114.2</td>
<td style="text-align: right;">40.6</td>
<td style="text-align: right;">-73.6</td>
<td style="text-align: right;">0.36</td>
<td style="text-align: right;">-64.5</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07</td>
<td style="text-align: right;">129.5</td>
<td style="text-align: right;">129.0</td>
<td style="text-align: right;">-0.5</td>
<td style="text-align: right;">1.00</td>
<td style="text-align: right;">-0.4</td>
</tr>
</tbody>
</table>
<p>Direction and size of the 36C response within each family.</p>
</section>
<section id="individual-level-table" class="level2">
<h2 class="anchored" data-anchor-id="individual-level-table">5.3 Individual-level table</h2>
<div class="sourceCode" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1">individual_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_analysis <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb43-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(family, temperature, individual) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb43-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb43-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual =</span> individual,</span>
<span id="cb43-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature =</span> temperature,</span>
<span id="cb43-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Protein (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> protein_mg,</span>
<span id="cb43-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Raw rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> rate_raw,</span>
<span id="cb43-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity, no BG (mU/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_nobg, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb43-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity, published (mU/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> activity_published,</span>
<span id="cb43-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Reps used</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> reps_used,</span>
<span id="cb43-11">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV used (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> cv_used_pct,</span>
<span id="cb43-12">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">QC</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> interpretation</span>
<span id="cb43-13">  )</span>
<span id="cb43-14"></span>
<span id="cb43-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(individual_table,</span>
<span id="cb43-16">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cs_activity_all_families_no_background.csv"</span>),</span>
<span id="cb43-17">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb43-18"></span>
<span id="cb43-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(individual_table,</span>
<span id="cb43-20">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All 32 individuals with background subtraction"</span>,</span>
<span id="cb43-21">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"removed, alongside the originally published"</span>,</span>
<span id="cb43-22">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background-corrected value for reference."</span>))</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">Protein (mg)</th>
<th style="text-align: right;">Raw rate (mA412/min)</th>
<th style="text-align: right;">Activity, no BG (mU/mg)</th>
<th style="text-align: right;">Activity, published (mU/mg)</th>
<th style="text-align: left;">Reps used</th>
<th style="text-align: right;">CV used (%)</th>
<th style="text-align: left;">QC</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.307</td>
<td style="text-align: right;">7.60</td>
<td style="text-align: right;">134.0</td>
<td style="text-align: right;">129.985</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">4.6</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.364</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">126.4</td>
<td style="text-align: right;">123.008</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">4.1</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.665</td>
<td style="text-align: right;">13.48</td>
<td style="text-align: right;">109.7</td>
<td style="text-align: right;">107.782</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.2</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.395</td>
<td style="text-align: right;">10.18</td>
<td style="text-align: right;">139.3</td>
<td style="text-align: right;">136.192</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.5</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.249</td>
<td style="text-align: right;">5.62</td>
<td style="text-align: right;">122.1</td>
<td style="text-align: right;">116.931</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.781</td>
<td style="text-align: right;">13.62</td>
<td style="text-align: right;">94.3</td>
<td style="text-align: right;">92.676</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.591</td>
<td style="text-align: right;">11.30</td>
<td style="text-align: right;">103.5</td>
<td style="text-align: right;">101.361</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.946</td>
<td style="text-align: right;">14.73</td>
<td style="text-align: right;">84.2</td>
<td style="text-align: right;">82.906</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.8</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.334</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">39.7</td>
<td style="text-align: right;">36.960</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">3.3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.191</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">70.5</td>
<td style="text-align: right;">66.031</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.234</td>
<td style="text-align: right;">2.45</td>
<td style="text-align: right;">59.7</td>
<td style="text-align: right;">56.014</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">3.5</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.372</td>
<td style="text-align: right;">2.47</td>
<td style="text-align: right;">37.9</td>
<td style="text-align: right;">34.950</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.583</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">22.7</td>
<td style="text-align: right;">20.972</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.443</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">30.5</td>
<td style="text-align: right;">27.399</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.389</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">34.7</td>
<td style="text-align: right;">32.210</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.475</td>
<td style="text-align: right;">2.43</td>
<td style="text-align: right;">29.1</td>
<td style="text-align: right;">26.948</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">7.8</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.092</td>
<td style="text-align: right;">3.43</td>
<td style="text-align: right;">207.8</td>
<td style="text-align: right;">207.819</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.378</td>
<td style="text-align: right;">7.43</td>
<td style="text-align: right;">109.6</td>
<td style="text-align: right;">109.600</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.404</td>
<td style="text-align: right;">7.18</td>
<td style="text-align: right;">98.9</td>
<td style="text-align: right;">98.879</td>
<td style="text-align: left;">2/3</td>
<td style="text-align: right;">6.4</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.196</td>
<td style="text-align: right;">4.97</td>
<td style="text-align: right;">141.2</td>
<td style="text-align: right;">141.243</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.231</td>
<td style="text-align: right;">6.53</td>
<td style="text-align: right;">157.8</td>
<td style="text-align: right;">157.813</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.6</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.392</td>
<td style="text-align: right;">7.20</td>
<td style="text-align: right;">102.4</td>
<td style="text-align: right;">102.432</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.576</td>
<td style="text-align: right;">8.22</td>
<td style="text-align: right;">79.6</td>
<td style="text-align: right;">79.566</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">0.196</td>
<td style="text-align: right;">4.88</td>
<td style="text-align: right;">138.8</td>
<td style="text-align: right;">138.824</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.6</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.232</td>
<td style="text-align: right;">4.93</td>
<td style="text-align: right;">118.4</td>
<td style="text-align: right;">118.446</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.326</td>
<td style="text-align: right;">7.48</td>
<td style="text-align: right;">127.8</td>
<td style="text-align: right;">127.815</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.422</td>
<td style="text-align: right;">8.28</td>
<td style="text-align: right;">109.4</td>
<td style="text-align: right;">109.428</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">3.1</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.549</td>
<td style="text-align: right;">8.52</td>
<td style="text-align: right;">86.5</td>
<td style="text-align: right;">86.544</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.5</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.150</td>
<td style="text-align: right;">4.37</td>
<td style="text-align: right;">162.5</td>
<td style="text-align: right;">162.517</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.174</td>
<td style="text-align: right;">3.70</td>
<td style="text-align: right;">118.7</td>
<td style="text-align: right;">118.679</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.363</td>
<td style="text-align: right;">7.05</td>
<td style="text-align: right;">108.2</td>
<td style="text-align: right;">108.153</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">0.101</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">200.6</td>
<td style="text-align: right;">200.578</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>All 32 individuals with background subtraction removed, alongside the originally published background-corrected value for reference.</p>
</section>
</section>
<section id="statistics" class="level1">
<h1>6 STATISTICS</h1>
<section id="two-way-anova-on-log10-activity" class="level2">
<h2 class="anchored" data-anchor-id="two-way-anova-on-log10-activity">6.1 Two-way ANOVA on log10 activity</h2>
<p>The model is <code>log10(activity) ~ family * temperature</code>. The <strong>interaction term is the formal test of the question</strong> in this document: does the temperature response differ between families? Because the design is balanced (8 per cell), sequential sums of squares are unambiguous.</p>
<div class="sourceCode" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1">cs_aov <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aov</span>(log10_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> cs_analysis)</span>
<span id="cb44-2"></span>
<span id="cb44-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cs_aov: two-way factorial ANOVA on log10 activity ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(cs_aov))</span></code></pre></div>
<pre><code>--- cs_aov: two-way factorial ANOVA on log10 activity ---
                   Df Sum Sq Mean Sq F value   Pr(&gt;F)    
family              1 0.6249  0.6249   39.89 7.85e-07 ***
temperature         1 0.4384  0.4384   27.99 1.25e-05 ***
family:temperature  1 0.4496  0.4496   28.70 1.04e-05 ***
Residuals          28 0.4386  0.0157                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<div class="sourceCode" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1">aov_tidy <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(cs_aov)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]])</span>
<span id="cb46-2">aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Term <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rownames</span>(aov_tidy))</span>
<span id="cb46-3"></span>
<span id="cb46-4">anova_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> aov_tidy <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb46-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb46-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Term    =</span> Term,</span>
<span id="cb46-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Df      =</span> Df,</span>
<span id="cb46-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sum Sq</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sum Sq</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb46-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean Sq</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean Sq</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb46-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">F value</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">F value</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">F value</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)),</span>
<span id="cb46-11">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p value</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pr(&gt;F)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signif</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pr(&gt;F)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)),</span>
<span id="cb46-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Significant =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pr(&gt;F)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb46-13">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pr(&gt;F)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no"</span>))</span>
<span id="cb46-14">  )</span>
<span id="cb46-15"></span>
<span id="cb46-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(anova_table, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb46-17">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Two-way ANOVA of log10 CS activity."</span>,</span>
<span id="cb46-18">                              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"The family:temperature row is the test of"</span>,</span>
<span id="cb46-19">                              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"whether families differ in temperature"</span>,</span>
<span id="cb46-20">                              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"response (alpha = %.2f)."</span>),</span>
<span id="cb46-21">                        analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha))</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 27%">
<col style="width: 6%">
<col style="width: 10%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 13%">
<col style="width: 17%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Term</th>
<th style="text-align: right;">Df</th>
<th style="text-align: right;">Sum Sq</th>
<th style="text-align: right;">Mean Sq</th>
<th style="text-align: right;">F value</th>
<th style="text-align: right;">p value</th>
<th style="text-align: left;">Significant</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">family</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.6249</td>
<td style="text-align: right;">0.6249</td>
<td style="text-align: right;">39.892</td>
<td style="text-align: right;">8.00e-07</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">temperature</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.4384</td>
<td style="text-align: right;">0.4384</td>
<td style="text-align: right;">27.988</td>
<td style="text-align: right;">1.25e-05</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family:temperature</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.4496</td>
<td style="text-align: right;">0.4496</td>
<td style="text-align: right;">28.702</td>
<td style="text-align: right;">1.04e-05</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">Residuals</td>
<td style="text-align: right;">28</td>
<td style="text-align: right;">0.4386</td>
<td style="text-align: right;">0.0157</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;"></td>
</tr>
</tbody>
</table>
<p>Two-way ANOVA of log10 CS activity. The family:temperature row is the test of whether families differ in temperature response (alpha = 0.05).</p>
<div class="sourceCode" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">p_family      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pr(&gt;F)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family"</span>]</span>
<span id="cb47-2">p_temperature <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pr(&gt;F)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"temperature"</span>]</span>
<span id="cb47-3">p_interaction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Pr(&gt;F)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family:temperature"</span>]</span>
<span id="cb47-4"></span>
<span id="cb47-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family effect:              p = %.5g</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, p_family))</span>
<span id="cb47-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"temperature effect:         p = %.5g</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, p_temperature))</span>
<span id="cb47-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family x temperature:       p = %.5g</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, p_interaction))</span>
<span id="cb47-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interaction significant at alpha = %.2f: %s</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb47-9">            analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha, p_interaction <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha))</span></code></pre></div>
<pre><code>family effect:              p = 7.8529e-07
temperature effect:         p = 1.2544e-05
family x temperature:       p = 1.0448e-05

Interaction significant at alpha = 0.05: TRUE</code></pre>
</section>
<section id="variance-explained" class="level2">
<h2 class="anchored" data-anchor-id="variance-explained">6.2 Variance explained</h2>
<div class="sourceCode" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1">ss <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sum Sq</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span></span>
<span id="cb49-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(ss) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> aov_tidy<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Term</span>
<span id="cb49-3">ss_total <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(ss)</span>
<span id="cb49-4"></span>
<span id="cb49-5">eta_sq <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb49-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Term          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(ss),</span>
<span id="cb49-7">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sum Sq</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(ss, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb49-8">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">% of total variance</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> ss <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> ss_total, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb49-9">)</span>
<span id="cb49-10"></span>
<span id="cb49-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- eta_sq: partition of variance in log10 activity ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(eta_sq))</span></code></pre></div>
<pre><code>--- eta_sq: partition of variance in log10 activity ---
                Term Sum Sq % of total variance
1             family 0.6249                32.0
2        temperature 0.4384                22.5
3 family:temperature 0.4496                23.0
4          Residuals 0.4386                22.5</code></pre>
<div class="sourceCode" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(eta_sq, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Partition of total variance in log10 activity"</span>,</span>
<span id="cb51-2">                              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(eta-squared). Residuals represent"</span>,</span>
<span id="cb51-3">                              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"between-individual variation within groups."</span>))</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Term</th>
<th style="text-align: right;">Sum Sq</th>
<th style="text-align: right;">% of total variance</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">family</td>
<td style="text-align: right;">0.6249</td>
<td style="text-align: right;">32.0</td>
</tr>
<tr class="even">
<td style="text-align: left;">temperature</td>
<td style="text-align: right;">0.4384</td>
<td style="text-align: right;">22.5</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family:temperature</td>
<td style="text-align: right;">0.4496</td>
<td style="text-align: right;">23.0</td>
</tr>
<tr class="even">
<td style="text-align: left;">Residuals</td>
<td style="text-align: right;">0.4386</td>
<td style="text-align: right;">22.5</td>
</tr>
</tbody>
</table>
<p>Partition of total variance in log10 activity (eta-squared). Residuals represent between-individual variation within groups.</p>
</section>
<section id="residual-diagnostics" class="level2">
<h2 class="anchored" data-anchor-id="residual-diagnostics">6.3 Residual diagnostics</h2>
<div class="sourceCode" id="cb52" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb52-1">resid_shapiro <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">shapiro.test</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">residuals</span>(cs_aov))</span>
<span id="cb52-2">resid_bartlett <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bartlett.test</span>(log10_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> cs_analysis)</span>
<span id="cb52-3"></span>
<span id="cb52-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shapiro-Wilk on residuals:  W = %.4f, p = %.4g</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb52-5">            resid_shapiro<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>statistic, resid_shapiro<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value))</span>
<span id="cb52-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Bartlett homogeneity:       K^2 = %.4f, p = %.4g</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb52-7">            resid_bartlett<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>statistic, resid_bartlett<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value))</span>
<span id="cb52-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Residuals consistent with normality (p &gt; %.2f): %s</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb52-9">            analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha, resid_shapiro<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha))</span>
<span id="cb52-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group variances homogeneous (p &gt; %.2f): %s</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb52-11">            analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha, resid_bartlett<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha))</span></code></pre></div>
<pre><code>Shapiro-Wilk on residuals:  W = 0.9765, p = 0.6941
Bartlett homogeneity:       K^2 = 3.5845, p = 0.31

Residuals consistent with normality (p &gt; 0.05): TRUE
Group variances homogeneous (p &gt; 0.05): TRUE</code></pre>
<div class="sourceCode" id="cb54" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb54-1">diag_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb54-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fitted   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fitted</span>(cs_aov),</span>
<span id="cb54-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">residual =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">residuals</span>(cs_aov),</span>
<span id="cb54-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group    =</span> cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>group</span>
<span id="cb54-5">)</span>
<span id="cb54-6"></span>
<span id="cb54-7">resid_fitted_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(diag_df,</span>
<span id="cb54-8">                            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> fitted, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> residual,</span>
<span id="cb54-9">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> group_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Residuals vs fitted values"</span>,</span>
<span id="cb54-15">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Two-way ANOVA on log10 CS activity"</span>,</span>
<span id="cb54-16">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fitted log10 activity"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Residual"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb54-19"></span>
<span id="cb54-20">qq_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> diag_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb54-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(residual) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb54-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">theoretical =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qnorm</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ppoints</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>())))</span>
<span id="cb54-23"></span>
<span id="cb54-24">qq_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(qq_df, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> theoretical, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> residual)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_abline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(qq_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>residual), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(qq_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>residual),</span>
<span id="cb54-26">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> group_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">18</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normal Q-Q plot of residuals"</span>,</span>
<span id="cb54-31">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shapiro-Wilk p = %.3g"</span>, resid_shapiro<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value),</span>
<span id="cb54-32">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Theoretical quantile"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Residual"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb54-35"></span>
<span id="cb54-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"anova_residuals_vs_fitted.png"</span>), resid_fitted_plot,</span>
<span id="cb54-37">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb54-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"anova_qq_residuals.png"</span>), qq_plot,</span>
<span id="cb54-39">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb54-40"></span>
<span id="cb54-41"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(resid_fitted_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison_files/figure-gfm/plot-diagnostics-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb55" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb55-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(qq_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison_files/figure-gfm/plot-diagnostics-2.png" class="img-fluid"><!-- --></p>
</section>
<section id="tukey-hsd-pairwise-contrasts" class="level2">
<h2 class="anchored" data-anchor-id="tukey-hsd-pairwise-contrasts">6.4 Tukey HSD pairwise contrasts</h2>
<div class="sourceCode" id="cb56" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb56-1">tukey_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">TukeyHSD</span>(cs_aov, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">which =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family:temperature"</span>)</span>
<span id="cb56-2"></span>
<span id="cb56-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- tukey_res: all pairwise group contrasts on log10 activity ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(tukey_res)</span></code></pre></div>
<pre><code>--- tukey_res: all pairwise group contrasts on log10 activity ---
  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = log10_activity ~ family * temperature, data = cs_analysis)

$`family:temperature`
                               diff        lwr        upr     p adj
F07:ambient-F05:ambient  0.04242003 -0.1284413  0.2132814 0.9046094
F05:36C-F05:ambient     -0.47116676 -0.6420281 -0.3003054 0.0000002
F07:36C-F05:ambient      0.04538564 -0.1254757  0.2162470 0.8861705
F05:36C-F07:ambient     -0.51358679 -0.6844482 -0.3427254 0.0000000
F07:36C-F07:ambient      0.00296561 -0.1678958  0.1738270 0.9999608
F07:36C-F05:36C          0.51655240  0.3456910  0.6874138 0.0000000</code></pre>
<div class="sourceCode" id="cb58" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb58-1">tukey_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(tukey_res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family:temperature</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb58-2">tukey_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Contrast <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rownames</span>(tukey_df)</span>
<span id="cb58-3"></span>
<span id="cb58-4">tukey_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tukey_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb58-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Contrast =</span> Contrast,</span>
<span id="cb58-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Diff (log10)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(diff, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb58-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Fold change</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>diff, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb58-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">95% CI (fold)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f - %.2f"</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>lwr, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span>upr),</span>
<span id="cb58-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signif</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb58-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Significant     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> analysis_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>alpha, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no"</span>)</span>
<span id="cb58-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)</span>
<span id="cb58-14"></span>
<span id="cb58-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(tukey_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey_pairwise_contrasts.csv"</span>),</span>
<span id="cb58-16">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb58-17"></span>
<span id="cb58-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(tukey_table, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb58-19">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tukey HSD contrasts between all four groups."</span>,</span>
<span id="cb58-20">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Differences on the log10 scale are back-transformed to"</span>,</span>
<span id="cb58-21">                      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fold changes; a fold change of 1 means no difference."</span>))</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Contrast</th>
<th style="text-align: right;">Diff (log10)</th>
<th style="text-align: right;">Fold change</th>
<th style="text-align: left;">95% CI (fold)</th>
<th style="text-align: right;">p adj</th>
<th style="text-align: left;">Significant</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07:36C-F05:36C</td>
<td style="text-align: right;">0.5166</td>
<td style="text-align: right;">3.29</td>
<td style="text-align: left;">2.22 - 4.87</td>
<td style="text-align: right;">0.0000000</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05:36C-F07:ambient</td>
<td style="text-align: right;">-0.5136</td>
<td style="text-align: right;">0.31</td>
<td style="text-align: left;">0.21 - 0.45</td>
<td style="text-align: right;">0.0000000</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05:36C-F05:ambient</td>
<td style="text-align: right;">-0.4712</td>
<td style="text-align: right;">0.34</td>
<td style="text-align: left;">0.23 - 0.50</td>
<td style="text-align: right;">0.0000002</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07:36C-F05:ambient</td>
<td style="text-align: right;">0.0454</td>
<td style="text-align: right;">1.11</td>
<td style="text-align: left;">0.75 - 1.65</td>
<td style="text-align: right;">0.8862000</td>
<td style="text-align: left;">no</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07:ambient-F05:ambient</td>
<td style="text-align: right;">0.0424</td>
<td style="text-align: right;">1.10</td>
<td style="text-align: left;">0.74 - 1.63</td>
<td style="text-align: right;">0.9046000</td>
<td style="text-align: left;">no</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07:36C-F07:ambient</td>
<td style="text-align: right;">0.0030</td>
<td style="text-align: right;">1.01</td>
<td style="text-align: left;">0.68 - 1.49</td>
<td style="text-align: right;">1.0000000</td>
<td style="text-align: left;">no</td>
</tr>
</tbody>
</table>
<p>Tukey HSD contrasts between all four groups. Differences on the log10 scale are back-transformed to fold changes; a fold change of 1 means no difference.</p>
</section>
<section id="the-two-within-family-temperature-contrasts" class="level2">
<h2 class="anchored" data-anchor-id="the-two-within-family-temperature-contrasts">6.5 The two within-family temperature contrasts</h2>
<p>Pulled out of the Tukey table because these two rows, read together, are the interaction: how each family responds to 36 °C.</p>
<div class="sourceCode" id="cb59" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb59-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># TukeyHSD labels interaction levels with a ":" separator, e.g. "F05:36C".</span></span>
<span id="cb59-2">within_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tukey_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb59-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Contrast <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05:36C-F05:ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07:36C-F07:ambient"</span>))</span>
<span id="cb59-4"></span>
<span id="cb59-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(within_family) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb59-6"></span>
<span id="cb59-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- within_family: the ambient vs 36C contrast inside each family ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb59-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(within_family))</span></code></pre></div>
<pre><code>--- within_family: the ambient vs 36C contrast inside each family ---
                               Contrast Diff (log10) Fold change 95% CI (fold)
F05:36C-F05:ambient F05:36C-F05:ambient      -0.4712        0.34   0.23 - 0.50
F07:36C-F07:ambient F07:36C-F07:ambient       0.0030        1.01   0.68 - 1.49
                        p adj Significant
F05:36C-F05:ambient 1.954e-07         yes
F07:36C-F07:ambient 1.000e+00          no</code></pre>
<div class="sourceCode" id="cb61" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb61-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(within_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb61-2">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Within-family ambient vs 36C contrasts (Tukey-adjusted)."</span>)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 16%">
<col style="width: 15%">
<col style="width: 18%">
<col style="width: 8%">
<col style="width: 15%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Contrast</th>
<th style="text-align: right;">Diff (log10)</th>
<th>Fold change</th>
<th style="text-align: left;">95% CI (fold)</th>
<th style="text-align: right;">p adj</th>
<th style="text-align: left;">Significant</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05:36C-F05:ambient</td>
<td style="text-align: right;">-0.4712</td>
<td>0.34</td>
<td style="text-align: left;">0.23 - 0.50</td>
<td style="text-align: right;">2e-07</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07:36C-F07:ambient</td>
<td style="text-align: right;">0.0030</td>
<td>1.01</td>
<td style="text-align: left;">0.68 - 1.49</td>
<td style="text-align: right;">1e+00</td>
<td style="text-align: left;">no</td>
</tr>
</tbody>
</table>
<p>Within-family ambient vs 36C contrasts (Tukey-adjusted).</p>
</section>
</section>
<section id="figures" class="level1">
<h1>7 FIGURES</h1>
<section id="activity-by-family-and-temperature" class="level2">
<h2 class="anchored" data-anchor-id="activity-by-family-and-temperature">7.1 Activity by family and temperature</h2>
<p>Box plots of all four groups on a single axis, with every individual overlaid (n = 8 per group, so the underlying points are worth showing rather than summarising away). Boxes are the standard Tukey construction: the middle line is the median, the box spans the interquartile range, and the whiskers reach the most extreme point within 1.5 × IQR of the box.</p>
<section id="significance-notation" class="level3">
<h3 class="anchored" data-anchor-id="significance-notation">7.1.1 Significance notation</h3>
<p>The brackets are built <strong>from the Tukey HSD table computed above</strong>, not entered by hand, so the annotation cannot drift from the statistics.</p>
<p>Four of the six pairwise contrasts are annotated: the two <strong>within-family</strong> temperature contrasts and the two <strong>within-temperature</strong> family contrasts – i.e.&nbsp;every pair differing in exactly one factor. The two remaining “diagonal” contrasts (<code>F05 ambient</code> vs <code>F07 36C</code>, and <code>F05 36C</code> vs <code>F07 ambient</code>) change family <em>and</em> temperature at once and so cannot be attributed to either factor; they are not annotated. This is not selection by outcome – one omitted diagonal is significant and the other is not – and <strong>all six contrasts remain in the Tukey table and in <code>tukey_pairwise_contrasts.csv</code></strong>. Non-significant retained contrasts are labelled <code>ns</code> rather than left blank.</p>
<div class="sourceCode" id="cb62" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb62-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Star notation used on the plot.</span></span>
<span id="cb62-2">sig_stars <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb62-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"***"</span>,</span>
<span id="cb62-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>,  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**"</span>,</span>
<span id="cb62-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>,  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ns"</span>)))</span>
<span id="cb62-6">}</span>
<span id="cb62-7"></span>
<span id="cb62-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># x positions of each group on the plot's discrete axis.</span></span>
<span id="cb62-9">group_x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(group_levels), group_levels)</span>
<span id="cb62-10"></span>
<span id="cb62-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># TukeyHSD row names are "&lt;groupB&gt;-&lt;groupA&gt;" with ":" between factor levels.</span></span>
<span id="cb62-12">sig_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tukey_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb62-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">contrast =</span> Contrast,</span>
<span id="cb62-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p_adj    =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb62-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">g2       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, Contrast)),</span>
<span id="cb62-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">g1       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, Contrast))</span>
<span id="cb62-18">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-19">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Keep only pairs differing in exactly one factor (see prose above).</span></span>
<span id="cb62-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb62-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fam1 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" .*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, g1), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fam2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" .*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, g2),</span>
<span id="cb62-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tmp1 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">S+ "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, g1), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tmp2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">S+ "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, g2)</span>
<span id="cb62-23">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>((fam1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> fam2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> (tmp1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> tmp2)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb62-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xlo   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmin</span>(group_x[g1], group_x[g2]),</span>
<span id="cb62-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xhi   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmax</span>(group_x[g1], group_x[g2]),</span>
<span id="cb62-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">span  =</span> xhi <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> xlo,</span>
<span id="cb62-29">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sig_stars</span>(p_adj)</span>
<span id="cb62-30">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(span, xlo)</span>
<span id="cb62-32"></span>
<span id="cb62-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_brackets) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb62-34"></span>
<span id="cb62-35"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pack brackets onto as few tiers as possible: shortest spans lowest, and two</span></span>
<span id="cb62-36"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># brackets share a tier when their x ranges do not overlap. This keeps the</span></span>
<span id="cb62-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># annotation band shallow so it does not crowd the data.</span></span>
<span id="cb62-38">tier_of <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">integer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_brackets))</span>
<span id="cb62-39">tier_end <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># right-most x reached on each tier so far</span></span>
<span id="cb62-40"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_brackets))) {</span>
<span id="cb62-41">  placed <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb62-42">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (t <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(tier_end)) {</span>
<span id="cb62-43">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (sig_brackets<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>xlo[i] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> tier_end[t] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.25</span>) {   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 0.25 = visual gap</span></span>
<span id="cb62-44">      tier_of[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t; tier_end[t] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sig_brackets<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>xhi[i]; placed <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>; <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span></span>
<span id="cb62-45">    }</span>
<span id="cb62-46">  }</span>
<span id="cb62-47">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>placed) {</span>
<span id="cb62-48">    tier_end <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(tier_end, sig_brackets<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>xhi[i])</span>
<span id="cb62-49">    tier_of[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(tier_end)</span>
<span id="cb62-50">  }</span>
<span id="cb62-51">}</span>
<span id="cb62-52"></span>
<span id="cb62-53">y_data_max <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_nobg)</span>
<span id="cb62-54"></span>
<span id="cb62-55">sig_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sig_brackets <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb62-57">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tier   =</span> tier_of,</span>
<span id="cb62-58">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y_top  =</span> y_data_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.05</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.075</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (tier <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb62-59">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y_tick =</span> y_data_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.018</span></span>
<span id="cb62-60">  )</span>
<span id="cb62-61"></span>
<span id="cb62-62"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- sig_brackets: significance annotations derived from tukey_df ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb62-63"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(sig_brackets[, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"contrast"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p_adj"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"label"</span>,</span>
<span id="cb62-64">                                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"xlo"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"xhi"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tier"</span>)]))</span>
<span id="cb62-65"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Brackets packed onto %d tiers (from %d contrasts).</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-66">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(sig_brackets<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>tier), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_brackets)))</span></code></pre></div>
<pre><code>--- sig_brackets: significance annotations derived from tukey_df ---
                                       contrast        p_adj label xlo xhi tier
F05:36C-F05:ambient         F05:36C-F05:ambient 1.953657e-07   ***   1   2    1
F07:36C-F07:ambient         F07:36C-F07:ambient 9.999608e-01    ns   3   4    1
F07:ambient-F05:ambient F07:ambient-F05:ambient 9.046094e-01    ns   1   3    2
F07:36C-F05:36C                 F07:36C-F05:36C 3.240667e-08   ***   2   4    3

Brackets packed onto 3 tiers (from 4 contrasts).</code></pre>
<div class="sourceCode" id="cb64" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb64-1">sig_caption <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(</span>
<span id="cb64-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Significance: Tukey HSD on log10 activity. "</span>,</span>
<span id="cb64-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*** p &lt; 0.001,  ** p &lt; 0.01,  * p &lt; 0.05,  ns = not significant.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb64-4">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Brackets show the four contrasts differing in exactly one factor; "</span>,</span>
<span id="cb64-5">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all six pairwise contrasts are in tukey_pairwise_contrasts.csv."</span>)</span>
<span id="cb64-6"></span>
<span id="cb64-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(sig_caption, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>Significance: Tukey HSD on log10 activity. *** p &lt; 0.001,  ** p &lt; 0.01,  * p &lt; 0.05,  ns = not significant.
Brackets show the four contrasts differing in exactly one factor; all six pairwise contrasts are in tukey_pairwise_contrasts.csv. </code></pre>
<div class="sourceCode" id="cb66" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb66-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>)  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># reproducible jitter</span></span>
<span id="cb66-2"></span>
<span id="cb66-3">activity_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(cs_analysis, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_nobg)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb66-5">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.55</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> temperature), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb66-7">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey15"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-8">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Significance brackets: horizontal span + downward ticks + star label.</span></span>
<span id="cb66-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sig_brackets,</span>
<span id="cb66-10">               <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> xlo, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> xhi, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_top, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> y_top),</span>
<span id="cb66-11">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sig_brackets,</span>
<span id="cb66-13">               <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> xlo, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> xlo, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_top, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> y_top <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y_tick),</span>
<span id="cb66-14">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sig_brackets,</span>
<span id="cb66-16">               <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> xhi, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> xhi, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_top, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> y_top <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> y_tick),</span>
<span id="cb66-17">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sig_brackets,</span>
<span id="cb66-19">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> (xlo <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> xhi) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_top, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> label),</span>
<span id="cb66-20">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.8</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> group_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ambient =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>),</span>
<span id="cb66-23">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.04</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.06</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb66-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family F05 loses citrate synthase activity at 36 C; family F07 does not"</span>,</span>
<span id="cb66-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb66-28">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Box = median and IQR, whiskers to 1.5 x IQR; each point is one"</span>,</span>
<span id="cb66-29">            <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"individual (n = 8 per group). Background not subtracted."</span>,</span>
<span id="cb66-30">            <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">family x temperature p = %.2g"</span>),</span>
<span id="cb66-31">      p_interaction),</span>
<span id="cb66-32">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb66-33">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU / mg protein)"</span>,</span>
<span id="cb66-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> sig_caption</span>
<span id="cb66-35">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-36">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb66-37">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb66-38">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">9.5</span>),</span>
<span id="cb66-39">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.caption  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">8.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>),</span>
<span id="cb66-40">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>),</span>
<span id="cb66-41">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"right"</span>)</span>
<span id="cb66-42"></span>
<span id="cb66-43"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cs_activity_by_family_temperature.png"</span>), activity_plot,</span>
<span id="cb66-44">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb66-45"></span>
<span id="cb66-46"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(activity_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison_files/figure-gfm/plot-activity-by-group-1.png" class="img-fluid"><!-- --></p>
</section>
</section>
<section id="interaction-plot" class="level2">
<h2 class="anchored" data-anchor-id="interaction-plot">7.2 Interaction plot</h2>
<p>The two lines are the interaction: parallel lines would mean both families respond to temperature the same way. Family labels sit at the right end of each line, so no legend is needed.</p>
<div class="sourceCode" id="cb67" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb67-1">interaction_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb67-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb67-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07"</span>)),</span>
<span id="cb67-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span>)),</span>
<span id="cb67-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_act      =</span> sd_act <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(n),</span>
<span id="cb67-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ci_half     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qt</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.975</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">df =</span> n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> se_act</span>
<span id="cb67-7">  )</span>
<span id="cb67-8"></span>
<span id="cb67-9">label_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> interaction_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(temperature <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span>)</span>
<span id="cb67-10"></span>
<span id="cb67-11">interaction_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(interaction_df,</span>
<span id="cb67-12">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_act,</span>
<span id="cb67-13">                               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> family)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_act <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> ci_half, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_act <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> ci_half),</span>
<span id="cb67-16">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.07</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> label_df, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> family),</span>
<span id="cb67-19">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">show.legend =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> family_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_discrete</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.28</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb67-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"The two families respond to 36 C differently (non-parallel lines)"</span>,</span>
<span id="cb67-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb67-25">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group mean +/- 95%% CI, n = 8 per group. Background not subtracted. family x temperature p = %.2g"</span>,</span>
<span id="cb67-26">      p_interaction),</span>
<span id="cb67-27">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature exposure"</span>,</span>
<span id="cb67-28">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean CS activity (mU / mg protein)"</span></span>
<span id="cb67-29">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb67-32"></span>
<span id="cb67-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cs_activity_interaction_plot.png"</span>), interaction_plot,</span>
<span id="cb67-34">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb67-35"></span>
<span id="cb67-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(interaction_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison_files/figure-gfm/plot-interaction-1.png" class="img-fluid"><!-- --></p>
</section>
<section id="per-individual-activity" class="level2">
<h2 class="anchored" data-anchor-id="per-individual-activity">7.3 Per-individual activity</h2>
<div class="sourceCode" id="cb68" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb68-1">individual_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(</span>
<span id="cb68-2">  cs_analysis <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(family, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>, individual)),</span>
<span id="cb68-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(label, activity_nobg), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_nobg,</span>
<span id="cb68-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> temperature)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(label, activity_nobg), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> activity_nobg),</span>
<span id="cb68-6">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey75"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> family_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ambient =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb68-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per-individual CS activity across both families and exposures"</span>,</span>
<span id="cb68-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background not subtracted. Each row is one individual."</span>,</span>
<span id="cb68-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb68-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU / mg protein)"</span></span>
<span id="cb68-16">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb68-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb68-19">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>),</span>
<span id="cb68-20">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"right"</span>)</span>
<span id="cb68-21"></span>
<span id="cb68-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cs_activity_per_individual.png"</span>), individual_plot,</span>
<span id="cb68-23">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb68-24"></span>
<span id="cb68-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(individual_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison_files/figure-gfm/plot-individuals-1.png" class="img-fluid"><!-- --></p>
</section>
<section id="effect-of-removing-the-background-correction" class="level2">
<h2 class="anchored" data-anchor-id="effect-of-removing-the-background-correction">7.4 Effect of removing the background correction</h2>
<p>A check that the decision in note 2 does not drive any group difference: if removing the correction mattered, points would sit far off the 1:1 line.</p>
<div class="sourceCode" id="cb69" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb69-1">bg_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(cs_analysis,</span>
<span id="cb69-2">                  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> activity_published, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_nobg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb69-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_abline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb69-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> temperature), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb69-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> family_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb69-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ambient =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb69-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb69-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Removing the background correction shifts activity by at most ~11%"</span>,</span>
<span id="cb69-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dashed line is 1:1 (no change). Points above the line are"</span>,</span>
<span id="cb69-10">                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"the two F05 plates, where a background rate was estimable;"</span>,</span>
<span id="cb69-11">                     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07 points sit on the line."</span>),</span>
<span id="cb69-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity as published, background subtracted (mU / mg protein)"</span>,</span>
<span id="cb69-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity with background NOT subtracted (mU / mg protein)"</span></span>
<span id="cb69-14">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb69-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb69-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb69-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>))</span>
<span id="cb69-18"></span>
<span id="cb69-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background_correction_effect.png"</span>), bg_plot,</span>
<span id="cb69-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb69-21"></span>
<span id="cb69-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison_files/figure-gfm/plot-background-effect-1.png" class="img-fluid"><!-- --></p>
</section>
</section>
<section id="summary" class="level1">
<h1>8 SUMMARY</h1>
<div class="sourceCode" id="cb70" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb70-1">f05_fold <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fold_change[temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05"</span>]</span>
<span id="cb70-2">f07_fold <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fold_change[temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07"</span>]</span>
<span id="cb70-3"></span>
<span id="cb70-4">f05_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> within_family<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[within_family<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Contrast <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05:36C-F05:ambient"</span>]</span>
<span id="cb70-5">f07_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> within_family<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[within_family<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Contrast <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07:36C-F07:ambient"</span>]</span>
<span id="cb70-6"></span>
<span id="cb70-7">amb_contrast <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tukey_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Contrast <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07:ambient-F05:ambient"</span>)</span>
<span id="cb70-8"></span>
<span id="cb70-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05: 36C / ambient = %.2f-fold (Tukey p = %.3g)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, f05_fold, f05_p))</span>
<span id="cb70-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07: 36C / ambient = %.2f-fold (Tukey p = %.3g)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, f07_fold, f07_p))</span>
<span id="cb70-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ambient F07 vs F05: %.2f-fold (Tukey p = %.3g)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb70-12">            amb_contrast<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Fold change</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, amb_contrast<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>))</span>
<span id="cb70-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Interaction p = %.3g | %% variance explained by interaction = %.1f%%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb70-14">            p_interaction,</span>
<span id="cb70-15">            eta_sq<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">% of total variance</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[eta_sq<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family:temperature"</span>]))</span></code></pre></div>
<pre><code>F05: 36C / ambient = 0.36-fold (Tukey p = 1.95e-07)
F07: 36C / ambient = 1.00-fold (Tukey p = 1)
Ambient F07 vs F05: 1.10-fold (Tukey p = 0.905)
Interaction p = 1.04e-05 | % variance explained by interaction = 23.0%</code></pre>
<section id="findings" class="level2">
<h2 class="anchored" data-anchor-id="findings">8.1 Findings</h2>
<div class="sourceCode" id="cb72" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb72-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb72-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1. **The temperature response differs between the two families.** The</span></span>
<span id="cb72-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   family &amp;times; temperature interaction is significant (p = %.2g), accounting</span></span>
<span id="cb72-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   for %.1f%% of the total variance in log10 activity. This is the central</span></span>
<span id="cb72-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   result: a single </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">heat effect</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\"</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;"> on CS activity does not describe both</span></span>
<span id="cb72-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   families.</span></span>
<span id="cb72-7"></span>
<span id="cb72-8"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2. **Family `F05` loses CS activity at 36 &amp;deg;C.** Mean activity falls from</span></span>
<span id="cb72-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   %.1f to %.1f mU/mg protein, a **%.2f-fold change (%.0f%%)**, and the</span></span>
<span id="cb72-10"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   contrast survives Tukey adjustment (p = %.2g).</span></span>
<span id="cb72-11"></span>
<span id="cb72-12"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">3. **Family `F07` shows essentially no temperature response.** Mean activity</span></span>
<span id="cb72-13"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   moves from %.1f to %.1f mU/mg protein -- a %.2f-fold change, entirely</span></span>
<span id="cb72-14"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   non-significant (p = %.2g). The `F07` 95%% CI at 36 &amp;deg;C overlaps its</span></span>
<span id="cb72-15"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   ambient CI substantially.</span></span>
<span id="cb72-16"></span>
<span id="cb72-17"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">4. **The two families are indistinguishable at ambient temperature**</span></span>
<span id="cb72-18"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   (%.2f-fold, p = %.2g). The families differ only *after* heat exposure,</span></span>
<span id="cb72-19"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   which is what makes this an interaction rather than a baseline family</span></span>
<span id="cb72-20"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   difference.</span></span>
<span id="cb72-21"></span>
<span id="cb72-22"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">5. **Removing the background correction does not drive any of this.** Across</span></span>
<span id="cb72-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   all 32 individuals the correction was worth %.1f%%-%.1f%% of activity</span></span>
<span id="cb72-24"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   (median %.1f%%), and both families' ambient groups shift in the same</span></span>
<span id="cb72-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">   direction, so no group contrast depends on the choice.</span></span>
<span id="cb72-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb72-27">p_interaction,</span>
<span id="cb72-28">eta_sq<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">% of total variance</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[eta_sq<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Term <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family:temperature"</span>],</span>
<span id="cb72-29">temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>ambient[temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05"</span>],</span>
<span id="cb72-30">temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05"</span>],</span>
<span id="cb72-31">f05_fold, temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pct_change[temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05"</span>], f05_p,</span>
<span id="cb72-32">temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>ambient[temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07"</span>],</span>
<span id="cb72-33">temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">36C</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>[temp_effect<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F07"</span>],</span>
<span id="cb72-34">f07_fold, f07_p,</span>
<span id="cb72-35">amb_contrast<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Fold change</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>, amb_contrast<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p adj</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>,</span>
<span id="cb72-36"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_undo_factor) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb72-37"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_undo_factor) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb72-38"><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(cs_analysis<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_undo_factor) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)))</span></code></pre></div>
<ol type="1">
<li><p><strong>The temperature response differs between the two families.</strong> The family × temperature interaction is significant (p = 1e-05), accounting for 23.0% of the total variance in log10 activity. This is the central result: a single “heat effect” on CS activity does not describe both families.</p></li>
<li><p><strong>Family <code>F05</code> loses CS activity at 36 °C.</strong> Mean activity falls from 114.2 to 40.6 mU/mg protein, a <strong>0.36-fold change (-64%)</strong>, and the contrast survives Tukey adjustment (p = 2e-07).</p></li>
<li><p><strong>Family <code>F07</code> shows essentially no temperature response.</strong> Mean activity moves from 129.5 to 129.0 mU/mg protein – a 1.00-fold change, entirely non-significant (p = 1). The <code>F07</code> 95% CI at 36 °C overlaps its ambient CI substantially.</p></li>
<li><p><strong>The two families are indistinguishable at ambient temperature</strong> (1.10-fold, p = 0.9). The families differ only <em>after</em> heat exposure, which is what makes this an interaction rather than a baseline family difference.</p></li>
<li><p><strong>Removing the background correction does not drive any of this.</strong> Across all 32 individuals the correction was worth 0.0%-11.3% of activity (median 0.8%), and both families’ ambient groups shift in the same direction, so no group contrast depends on the choice.</p></li>
</ol>
</section>
<section id="interpretation-and-caveats" class="level2">
<h2 class="anchored" data-anchor-id="interpretation-and-caveats">8.2 Interpretation and caveats</h2>
<div class="sourceCode" id="cb73" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb73-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb73-2"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">- **Statistical model.** Two-way ANOVA on log10 activity, balanced at n = 8</span></span>
<span id="cb73-3"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  per cell. Residuals are consistent with normality (Shapiro-Wilk</span></span>
<span id="cb73-4"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  p = %.3g) and group variances are homogeneous (Bartlett p = %.3g), so the</span></span>
<span id="cb73-5"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  parametric model is appropriate here. Working on the log scale makes the</span></span>
<span id="cb73-6"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  interaction a test of *fold-change* response, which is the meaningful</span></span>
<span id="cb73-7"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  comparison for an enzyme rate.</span></span>
<span id="cb73-8"></span>
<span id="cb73-9"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">- **Assay design.** The `F05` ambient-vs-36 &amp;deg;C comparison is made across</span></span>
<span id="cb73-10"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  two plates run ten days apart (2026-08-14 and 2026-08-24), whereas the</span></span>
<span id="cb73-11"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  `F07` comparison is made within a single plate (note 4). Cross-plate</span></span>
<span id="cb73-12"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  comparability is supported by the calibration and instrument-state values</span></span>
<span id="cb73-13"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  in [PLATE PROVENANCE](#plate-provenance): standard-curve slope varies by</span></span>
<span id="cb73-14"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  only %.1f%% CV across plates (all R&lt;sup&gt;2&lt;/sup&gt; &gt;= %.4f) and the CS</span></span>
<span id="cb73-15"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  positive control by %.1f%% CV.</span></span>
<span id="cb73-16"></span>
<span id="cb73-17"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">- **Background correction.** No activity value in this document has</span></span>
<span id="cb73-18"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  background subtracted (note 2), so all four groups are treated</span></span>
<span id="cb73-19"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  identically. The `F07` plate's background wells received the wrong reagent</span></span>
<span id="cb73-20"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  and cannot be recovered; a future plate with correct Background Control Mix</span></span>
<span id="cb73-21"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  would let this choice be checked rather than assumed.</span></span>
<span id="cb73-22"></span>
<span id="cb73-23"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">- **Scope.** Two families, eight individuals per family per exposure. These</span></span>
<span id="cb73-24"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  results describe these two families and do not establish how broadly</span></span>
<span id="cb73-25"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">  family-dependent heat sensitivity extends across *M. gigas*.</span></span>
<span id="cb73-26"><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb73-27">resid_shapiro<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, resid_bartlett<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value,</span>
<span id="cb73-28">prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_cv, prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>min_std_r2, prov_spread<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pos_cv))</span></code></pre></div>
<ul>
<li><p><strong>Statistical model.</strong> Two-way ANOVA on log10 activity, balanced at n = 8 per cell. Residuals are consistent with normality (Shapiro-Wilk p = 0.694) and group variances are homogeneous (Bartlett p = 0.31), so the parametric model is appropriate here. Working on the log scale makes the interaction a test of <em>fold-change</em> response, which is the meaningful comparison for an enzyme rate.</p></li>
<li><p><strong>Assay design.</strong> The <code>F05</code> ambient-vs-36 °C comparison is made across two plates run ten days apart (2026-08-14 and 2026-08-24), whereas the <code>F07</code> comparison is made within a single plate (note 4). Cross-plate comparability is supported by the calibration and instrument-state values in PLATE PROVENANCE: standard-curve slope varies by only 2.5% CV across plates (all R<sup>2</sup> &gt;= 0.9983) and the CS positive control by 4.7% CV.</p></li>
<li><p><strong>Background correction.</strong> No activity value in this document has background subtracted (note 2), so all four groups are treated identically. The <code>F07</code> plate’s background wells received the wrong reagent and cannot be recovered; a future plate with correct Background Control Mix would let this choice be checked rather than assumed.</p></li>
<li><p><strong>Scope.</strong> Two families, eight individuals per family per exposure. These results describe these two families and do not establish how broadly family-dependent heat sensitivity extends across <em>M. gigas</em>.</p></li>
</ul>
</section>
<section id="output-files" class="level2">
<h2 class="anchored" data-anchor-id="output-files">8.3 Output files</h2>
<div class="sourceCode" id="cb74" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb74-1">manifest <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb74-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list.files</span>(output_dir),</span>
<span id="cb74-3">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb74-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb74-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size_kb =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.size</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, file)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1024</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb74-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb74-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.csv$"</span>, file) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"table"</span>,</span>
<span id="cb74-8">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.png$"</span>, file) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"figure"</span>,</span>
<span id="cb74-9">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                   <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"documentation"</span></span>
<span id="cb74-10">    )</span>
<span id="cb74-11">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb74-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(type, file)</span>
<span id="cb74-13"></span>
<span id="cb74-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(manifest, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Files written to `%s`."</span>, output_dir))</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">file</th>
<th style="text-align: right;">size_kb</th>
<th style="text-align: left;">type</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">README.md</td>
<td style="text-align: right;">4.5</td>
<td style="text-align: left;">documentation</td>
</tr>
<tr class="even">
<td style="text-align: left;">anova_qq_residuals.png</td>
<td style="text-align: right;">107.9</td>
<td style="text-align: left;">figure</td>
</tr>
<tr class="odd">
<td style="text-align: left;">anova_residuals_vs_fitted.png</td>
<td style="text-align: right;">95.8</td>
<td style="text-align: left;">figure</td>
</tr>
<tr class="even">
<td style="text-align: left;">background_correction_effect.png</td>
<td style="text-align: right;">166.0</td>
<td style="text-align: left;">figure</td>
</tr>
<tr class="odd">
<td style="text-align: left;">cs_activity_by_family_temperature.png</td>
<td style="text-align: right;">157.4</td>
<td style="text-align: left;">figure</td>
</tr>
<tr class="even">
<td style="text-align: left;">cs_activity_interaction_plot.png</td>
<td style="text-align: right;">132.1</td>
<td style="text-align: left;">figure</td>
</tr>
<tr class="odd">
<td style="text-align: left;">cs_activity_per_individual.png</td>
<td style="text-align: right;">134.6</td>
<td style="text-align: left;">figure</td>
</tr>
<tr class="even">
<td style="text-align: left;">cs_activity_all_families_no_background.csv</td>
<td style="text-align: right;">2.6</td>
<td style="text-align: left;">table</td>
</tr>
<tr class="odd">
<td style="text-align: left;">tukey_pairwise_contrasts.csv</td>
<td style="text-align: right;">0.4</td>
<td style="text-align: left;">table</td>
</tr>
</tbody>
</table>
<p>Files written to <code>../outputs/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison</code>.</p>
</section>
</section>
<section id="session-info" class="level1">
<h1>9 SESSION INFO</h1>
<div class="sourceCode" id="cb75" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb75-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sessionInfo</span>()</span></code></pre></div>
<pre><code>R version 4.6.1 (2026-06-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Los_Angeles
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] tibble_3.3.1  ggplot2_4.0.3 tidyr_1.3.2   dplyr_1.2.1   knitr_1.51   

loaded via a namespace (and not attached):
 [1] vctrs_0.7.3        cli_3.6.6          rlang_1.2.0        xfun_0.57         
 [5] purrr_1.2.2        generics_0.1.4     textshaping_1.0.5  S7_0.2.2          
 [9] labeling_0.4.3     glue_1.8.1         htmltools_0.5.9    ragg_1.5.2        
[13] scales_1.4.0       rmarkdown_2.31     grid_4.6.1         evaluate_1.0.5    
[17] fastmap_1.2.0      yaml_2.3.12        lifecycle_1.0.5    compiler_4.6.1    
[21] RColorBrewer_1.1-3 pkgconfig_2.0.3    rstudioapi_0.18.0  systemfonts_1.3.2 
[25] farver_2.1.2       digest_0.6.39      R6_2.6.1           tidyselect_1.2.1  
[29] pillar_1.11.1      magrittr_2.0.5     withr_3.0.2        tools_4.6.1       
[33] gtable_0.3.6      </code></pre>


</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>citrate synthase</category>
  <category>ABCAM</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/</guid>
  <pubDate>Tue, 25 Aug 2026 07:00:00 GMT</pubDate>
  <media:content url="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-25-Citrate-Synthase-Analysis---SORMI-June-2026-M.gigas-Family-5-vs-Family-7-Temperature-Response/Gen5-20260825-mgig-sormi-citrate_synthase-F05-F07-temperature-comparison_files/figure-gfm/plot-activity-by-group-1.png" medium="image" type="image/png" height="101" width="144"/>
</item>
<item>
  <title>Citrate Synthase Assay - SORMI June 2026 M.gigas Family 5 Ambient Ctenidia Re-assay</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>This is a re-assay of the eight <em>Magallana gigas</em> (Pacific oyster) Family 5 ctenidia homogenates held at <strong>ambient</strong> temperature, using the Citrate Synthase Assay Kit (ABCAM; cat: ab239712). The <a href="../../../posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/index.html">original assay of these same homogenates on 20260811</a> (Notebook entry) had QC failures serious enough that its activity values could not be used — a failed GSH standard curve, standards above the photometric linear range, background control wells behaving as active reactions, and one sample (<code>F05_05_ambient</code>) with no clean replicate. This plate is the re-run called for by that entry.</p>
<p>Two things changed relative to the 20260811 run: a <strong>shorter read window</strong> (20 min / 11 reads, vs.&nbsp;40 min / 21 reads) and a <strong>pooled background control design</strong> in place of paired per-sample backgrounds. Samples had been <a href="../../../posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/index.html">previously homogenized on 20260811</a> (Notebook entry), and protein concentrations for normalization were <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">determined on 20260813</a> (Notebook entry) — the same homogenates and the same protein measurements used for the original assay.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p><strong>This re-assay succeeded and supersedes the 20260811 ambient results.</strong> No sample well, positive-control well, or background well is flagged for anything on this plate: no decreasing kinetics, no read glitches, no elevated starting absorbance, and all three pooled-background replicates are flat. All eight samples pass the 15% technical CV threshold (0.8-4.6%), the GSH standard curve has zero flagged outlier wells (R<sup>2</sup> = 0.9983), and no replicate is excluded from any sample. <strong>This plate does not need re-assay.</strong></p>
<p>One caution worth carrying forward: the positive control’s three replicates rise linearly (R<sup>2</sup> 0.997-1.000) but disagree in rate by <strong>22.8% CV</strong> (<code>D7</code> at 2.00 mA412/min vs.&nbsp;<code>D8</code>/<code>D9</code> at 2.95-3.15 mA412/min) — worse precision than any individual sample’s technical triplicate on this plate. This does not enter any activity calculation, so it is a plate-level caution rather than a disqualifier, but it is worth watching on future plates.</p>
</div>
</div>
<p>All data/code/analysis is available here:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase">https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase</a></li>
</ul>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<section id="citrate-synthase-assay" class="level2">
<h2 class="anchored" data-anchor-id="citrate-synthase-assay">Citrate Synthase Assay</h2>
<p>The Citrate Synthase Assay Kit (ABCAM; cat: ab239712) was used according to the manufacturer’s instructions (<a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf</a> (GitHub; PDF)). The kit is a coupled kinetic assay: citrate synthase condenses acetyl-CoA and oxaloacetate to release free CoA-SH, the liberated thiol reduces DTNB to TNB<sup>2-</sup>, and the rate of absorbance increase at 412 nm is proportional to citrate synthase activity. Absolute nmol of thiol are assigned from a reduced glutathione (GSH) standard curve read on the same plate.</p>
<p>Per reaction well, 2 µL of undiluted homogenate was combined with 48 µL of Assay Buffer 7, followed by 50 µL of Reaction Mix. Each of the eight samples was assayed in technical triplicate in a clear, flat-bottomed 96-well plate. A six-point GSH standard curve (0, 8, 16, 24, 32, 40 nmol/well) and a CS positive control were included in triplicate on the same plate.</p>
<p>REACTION MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>43</td>
<td>55</td>
<td>2365</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>55</td>
<td>275</td>
</tr>
<tr class="odd">
<td>CS Substrate</td>
<td>2</td>
<td>55</td>
<td>110</td>
</tr>
</tbody>
</table>
<p>BACKGROUND MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>45</td>
<td>4</td>
<td>180</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>4</td>
<td>20</td>
</tr>
</tbody>
</table>
<p>Absorbance was read at 412 nm in kinetic mode at 25°C on a Synergy HTX plate reader (Agilent), every 2 minutes for 20 minutes (11 reads).</p>
</section>
<section id="normalization" class="level2">
<h2 class="anchored" data-anchor-id="normalization">Normalization</h2>
<p>Activity was normalized to total extracted protein rather than tissue weight. Tissue was homogenized in 350 µL of Assay Buffer 7, and protein concentration in each homogenate was <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">quantified on 20260813</a> (Notebook entry) using the Bradford assay. Total protein mass per sample is that concentration multiplied by the 350 µL homogenization volume. Tissue weights are recorded in the plate layout labels for provenance only and play no role in the activity calculation. Protein values come from two assays run on 20260813: the F05 plate (<code>F05_04</code>, <code>F05_05</code>, <code>F05_07</code>) and the F05/F07 re-assay plate (<code>F05_01</code>, <code>F05_02</code>, <code>F05_03</code>, <code>F05_06</code>, <code>F05_08</code>, re-assayed at dilution).</p>
</section>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<p>Data were analyzed in R. The Rmd file is here (GitHub):</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient.Rmd">Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient.Rmd</a></li>
</ul>
<p>Background correction used a <strong>single pooled background control</strong> rather than a paired per-sample background as on the 20260811 and 20260814 plates. A pool was made from 5 µL of each of the eight sample homogenates, and 2 µL of that pool (matching the 2 µL sample volume used for every reaction well) was run in triplicate with Background Control Mix (no CS Substrate Mix), producing wells <code>BG-citrate_synthase</code> (D10-D12). Because there is only one background estimate for the whole plate, the same background-corrected rate is subtracted from every sample.</p>
<p>Knitted markdown is below.</p>
</section>
<section id="data-files" class="level2">
<h2 class="anchored" data-anchor-id="data-files">Data files</h2>
<section id="plate-reader-files" class="level3">
<h3 class="anchored" data-anchor-id="plate-reader-files">Plate reader files</h3>
<p>Plate reader files (<code>*.xpt</code>) are available here (require Gen5 software to open):</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/plate_reader_files</li>
</ul>
</section>
<section id="raw-absorbance-data" class="level3">
<h3 class="anchored" data-anchor-id="raw-absorbance-data">Raw absorbance data</h3>
<p>Raw absorbance data (<code>*.csv</code>), plate layouts, and Gen5 full reports are available here:</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/raw_absorbance</li>
</ul>
</section>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Unlike the <a href="../../../posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/index.html">Family 5 36°C plate</a> (Notebook entry), where activity was essentially uniform across individuals, this ambient plate shows real, well-resolved inter-individual variation. Background-corrected rates range <strong>5.38 to 14.50 mA412/min</strong> across the eight individuals — a 169% spread against 0.8-4.6% technical CV per sample, far larger than the technical noise floor.</p>
<p>Protein normalization looks appropriate here rather than artifactual: raw rate (mU/µL) is strongly and significantly correlated with total extracted protein (r = +0.96, p = 0.0002), the opposite of the pattern on the 20260814 36°C plate. That makes mU/mg protein the recommended basis for downstream comparison on this plate — normalizing is removing a real extraction-efficiency covariate, not introducing an artifact.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Reps used</th>
<th style="text-align: right;">CV all reps (%)</th>
<th style="text-align: right;">Corrected rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/uL)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">4.6</td>
<td style="text-align: right;">7.37</td>
<td style="text-align: right;">0.1139</td>
<td style="text-align: right;">129.985</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">4.1</td>
<td style="text-align: right;">8.27</td>
<td style="text-align: right;">0.1278</td>
<td style="text-align: right;">123.008</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.2</td>
<td style="text-align: right;">13.25</td>
<td style="text-align: right;">0.2048</td>
<td style="text-align: right;">107.782</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.5</td>
<td style="text-align: right;">9.95</td>
<td style="text-align: right;">0.1538</td>
<td style="text-align: right;">136.192</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: right;">5.38</td>
<td style="text-align: right;">0.0832</td>
<td style="text-align: right;">116.931</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: right;">13.38</td>
<td style="text-align: right;">0.2069</td>
<td style="text-align: right;">92.676</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.3</td>
<td style="text-align: right;">11.07</td>
<td style="text-align: right;">0.1711</td>
<td style="text-align: right;">101.361</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.8</td>
<td style="text-align: right;">14.50</td>
<td style="text-align: right;">0.2242</td>
<td style="text-align: right;">82.906</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>Note that <code>F05_05_ambient</code> — the sample disqualified entirely on 20260811, where all three replicates started at an elevated A412 (0.65-0.93) indicating contamination or mis-dispensing rather than enzymology — now has three clean replicates at 1.9% CV and no elevated baseline. It is the lowest of the eight at 5.38 mA412/min.</p>
<p>The pooled background design cut the wells needed for background control roughly 8-fold (3 wells vs.&nbsp;24 on the paired per-sample design). On this plate the background rate is a small fraction of the sample signal (~2.2%) either way, so the simplification looks low-risk here, though a pooled design should be re-validated if background ever becomes a larger fraction of the raw signal.</p>
<p>There is also widespread but harmless GSH standard signal decay: 13 of 15 (strict) to 15 of 18 (including exact-zero ties) non-zero-concentration standard wells lose signal between t = 0 and t = 20 min, consistent with TNB<sup>2-</sup> instability. Because the standard curve is calibrated at t = 0, this has no effect on the fit.</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Citrate synthase (CS) activity in ctenidia of eight <em>Magallana gigas</em> (Pacific oyster) individuals from <strong>family F05</strong> held at <strong>ambient</strong> temperature, re-assayed 2026-08-24 with the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">Abcam Citrate Synthase Assay Kit (ab239712), v4a</a>. This is the same eight <code>F05</code> ambient homogenates originally assayed 2026-08-11 (<code>Gen5-20260811-mgig-citrate_synthase-F05-ambient.Rmd</code>), re-run with a shorter read window and a different background-control design (see note 3).</p>
<p>The kit is a <strong>coupled kinetic</strong> assay. CS condenses acetyl-CoA and oxaloacetate, releasing free CoA-SH; the liberated thiol reduces DTNB to TNB<sup>2-</sup>, which absorbs at 412 nm. The <strong>rate</strong> of A412 increase is proportional to CS activity, and absolute nmol of thiol are assigned from a <strong>GSH (reduced glutathione) standard curve</strong> read on the same plate.</p>
<p>Absorbance was read at 412 nm in kinetic mode, 25 °C, every 2 min for 20 min (11 reads) on a Synergy HTX. See note 1.</p>
<p>Total extracted protein per homogenate (used for normalization, note 2) was not measured on this plate; it comes from two BCA/Bradford-style protein-quantification assays run 2026-08-13: <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260813-mgig-sormi-BSA-F05-protein.Rmd"><code>Gen5-20260813-mgig-sormi-BSA-F05-protein.Rmd</code></a> (<code>F05_04_ambient</code>, <code>F05_05_ambient</code>, <code>F05_07_ambient</code>) and <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260813-mgig-sormi-BSA-F05-F07-reassay-protein.Rmd"><code>Gen5-20260813-mgig-sormi-BSA-F05-F07-reassay-protein.Rmd</code></a> (<code>F05_01_ambient</code>, <code>F05_02_ambient</code>, <code>F05_03_ambient</code>, <code>F05_06_ambient</code>, <code>F05_08_ambient</code>, re-assayed at dilution). These are the same homogenates and the same protein measurements used for the original 2026-08-11 assay of this plate.</p>
<p>This document is fully self-contained: layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are all defined directly below (see <code>## Pipeline functions</code> under SETUP) rather than sourced from a separate script, so the whole analysis can be reproduced from this one file.</p>
<section id="sample-naming-convention" class="level2">
<h2 class="anchored" data-anchor-id="sample-naming-convention">1.1 Sample naming convention</h2>
<p>Well labels follow <code>&lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;-&lt;assay_type&gt;-&lt;weight&gt;-df.&lt;n&gt;</code> for sample wells (e.g.&nbsp;<code>F05_01_ambient-citrate_synthase-10.1-df.0</code>), <code>STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</code> for GSH standards, <code>POS-&lt;assay_type&gt;</code> for the positive control, and <code>BG-&lt;assay_type&gt;</code> for the pooled background control (see note 3) – the background label carries no weight or dilution suffix, since it is not tied to any single individual’s tissue. The trailing number in the sample label (e.g.&nbsp;<code>10.1</code>) is tissue weight in mg, which is <strong>not</strong> used for normalization here (note 2); it is parsed and validated but plays no role in the activity calculation.</p>
</section>
<section id="notes" class="level2">
<h2 class="anchored" data-anchor-id="notes">1.2 Notes</h2>
<ol type="1">
<li><strong>Read duration for this plate is 20 minutes</strong> (11 reads at 2-min intervals) – shorter than the original 2026-08-11 run of these same homogenates (40 min, 21 reads). The assay parameters below set <code>read_duration_min = 20</code> to match. Rate extraction uses a fixed-width sliding window (<code>rate_window_n = 5</code> points = 8 min) rather than the full trace, so this only changes how many windows are available to slide across; see the KINETIC TRACES section for whether the assay is still in its linear phase over this window.</li>
<li><strong>Activity is normalized to total extracted protein, not tissue weight</strong>, because protein concentration was measured directly (BCA-style assay, <code>sample_protein_concentrations_*.csv</code>), and controls for extraction efficiency in a way tissue weight cannot. These are the same protein measurements used for the original 2026-08-11 ambient plate (same homogenates), and no <code>Sample</code> string in either protein-concentration CSV needed correction for this plate.</li>
<li><strong>Background correction uses a single pooled background control, not a paired per-sample background as on the 2026-08-11 and 2026-08-14 plates.</strong> A pool was made from 5 µL of each of the 8 sample homogenates, and 2 µL of that pool (matching <code>sample_volume_uL</code> used for every reaction well) was run in triplicate with Background Control Mix (no CS Substrate Mix) to produce wells <code>BG-citrate_synthase</code> (D10-D12). Because there is only one background estimate for the whole plate, the same background-corrected rate is subtracted from every sample, rather than each sample carrying its own paired background replicate set.</li>
</ol>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="pipeline-functions" class="level2">
<h2 class="anchored" data-anchor-id="pipeline-functions">1.3 Pipeline functions</h2>
<p>All layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are defined directly in this document (rather than sourced from a separate script) so that it is fully self-contained and reproducible from this single file. The functions are grouped below by pipeline stage; each is called in the DATA / KINETIC TRACES / ANOMALY DETECTION / GSH STANDARD CURVE / RATE EXTRACTION / BACKGROUND CORRECTION / TECHNICAL REPLICATE PRECISION / CITRATE SYNTHASE ACTIVITY / QC SUMMARY sections that follow. Nothing plate-specific (typo fixes, disqualified samples, thresholds) is hardcoded in any function – it is always passed in as an argument, from the <code>assay_params</code> list defined further below or from a plate-specific fix list.</p>
<section id="data-import-and-layout-parsing" class="level3">
<h3 class="anchored" data-anchor-id="data-import-and-layout-parsing">1.3.1 Data import and layout parsing</h3>
<p>Reads the raw Gen5 exports (kinetic absorbance CSV, full-report text backup, plate-layout CSV), reconciles them against each other, and attaches well-type/sample-id/replicate metadata plus measured protein concentrations to every well.</p>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## elapsed_to_min()</span></span>
<span id="cb4-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert Gen5 "H:MM:SS" elapsed-time strings to decimal minutes.</span></span>
<span id="cb4-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : x - character vector of "H:MM:SS" strings</span></span>
<span id="cb4-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of elapsed minutes, same length as x</span></span>
<span id="cb4-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-7">elapsed_to_min <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb4-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-9">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p)</span>
<span id="cb4-10">    p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span></span>
<span id="cb4-11">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb4-12">}</span>
<span id="cb4-13"></span>
<span id="cb4-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-15"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_absorbance_csv()</span></span>
<span id="cb4-16"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "absorbance-*.csv" kinetic export: wavelength</span></span>
<span id="cb4-17"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           header, a "Time," row, a temperature row, then one row per well</span></span>
<span id="cb4-18"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well ID in column 1, one OD reading per timepoint thereafter).</span></span>
<span id="cb4-19"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the absorbance-*.csv file</span></span>
<span id="cb4-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-23">read_absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-24">  ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-25">  time_i   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time,"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-26">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[time_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb4-27">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> time_str[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>time_str <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time"</span>)]</span>
<span id="cb4-28">  tmin     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(time_str)</span>
<span id="cb4-29"></span>
<span id="cb4-30">  well_ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2},"</span>, ln)]</span>
<span id="cb4-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(well_ln, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-33">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(tmin) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb4-34">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-35">  }))</span>
<span id="cb4-36">}</span>
<span id="cb4-37"></span>
<span id="cb4-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_full_report()</span></span>
<span id="cb4-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "full_report-*.txt" export: tab-delimited, wells</span></span>
<span id="cb4-41"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across columns, timepoints down rows. Used only as an</span></span>
<span id="cb4-42"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           independent cross-check against the absorbance CSV, never as a</span></span>
<span id="cb4-43"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           primary data source.</span></span>
<span id="cb4-44"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the full_report-*.txt file</span></span>
<span id="cb4-45"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-46"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-47"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-48">read_full_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-49">  ln  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-50">  hdr_i <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.*</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">A1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-51">  hdr   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[hdr_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]])</span>
<span id="cb4-52">  rows  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[0-9]:[0-9]{2}:[0-9]{2}</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)]</span>
<span id="cb4-53">  m     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">do.call</span>(rbind, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(rows, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>))</span>
<span id="cb4-54">  tmin  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb4-55"></span>
<span id="cb4-56">  well_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2}$"</span>, hdr))</span>
<span id="cb4-57">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(well_cols, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(j) {</span>
<span id="cb4-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> hdr[j], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-59">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(m[, j]), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-60">  }))</span>
<span id="cb4-61">}</span>
<span id="cb4-62"></span>
<span id="cb4-63"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-64"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## parse_plate_layout()</span></span>
<span id="cb4-65"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert a raw Gen5 plate-layout CSV export into one row per</span></span>
<span id="cb4-66"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           occupied well with its descriptive label. Auto-detects two</span></span>
<span id="cb4-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           export formats seen in practice:</span></span>
<span id="cb4-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "single"  - one row per plate row (row 1 = column numbers,</span></span>
<span id="cb4-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         column 1 = row letter, last column = "Name" tag);</span></span>
<span id="cb4-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         each cell already holds the full descriptive label.</span></span>
<span id="cb4-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "double"  - each plate row is exported as TWO rows: a</span></span>
<span id="cb4-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         "Well ID" row (SPL codes) immediately followed by</span></span>
<span id="cb4-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         a "Name" row (the descriptive label actually used</span></span>
<span id="cb4-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         downstream).</span></span>
<span id="cb4-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           The format is detected from column 1: if a value repeats twice</span></span>
<span id="cb4-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           in a row (once for the well-ID row, once for the label row)</span></span>
<span id="cb4-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           immediately below a numeric header, it is treated as "double".</span></span>
<span id="cb4-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the layout-*.csv file</span></span>
<span id="cb4-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per occupied well:</span></span>
<span id="cb4-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr, e.g. "A1"), plate_row (chr), plate_col (int),</span></span>
<span id="cb4-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label (chr, trimmed descriptive label)</span></span>
<span id="cb4-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-83">parse_plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-84">  plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-85"></span>
<span id="cb4-86">  col1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1)</span>
<span id="cb4-87">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "double" format: row letters appear twice in a row in column 1</span></span>
<span id="cb4-88">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (once tagging the Well-ID row, once tagging the Name row), e.g.</span></span>
<span id="cb4-89">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "A", "A", "B", "B", ... Detect by checking whether non-empty,</span></span>
<span id="cb4-90">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># non-header values in col1 are each immediately followed by a repeat.</span></span>
<span id="cb4-91">  data_rows   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(col1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(col1))[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># drop header row (row 1)</span></span>
<span id="cb4-92">  is_double <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb4-93">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]][<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))])</span>
<span id="cb4-94"></span>
<span id="cb4-95">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (is_double) {</span>
<span id="cb4-96">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pair each row-letter row with the following label row.</span></span>
<span id="cb4-97">    row_letter_rows <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]</span>
<span id="cb4-98">    label_rows      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]</span>
<span id="cb4-99">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(row_letter_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(label_rows))</span>
<span id="cb4-100"></span>
<span id="cb4-101">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pair_idx =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(row_letter_rows),</span>
<span id="cb4-102">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-103">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-104">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> col1[row_letter_rows[pair_idx]],</span>
<span id="cb4-105">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-106">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-107">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j],</span>
<span id="cb4-108">                                   label_rows[pair_idx], col_idx))</span>
<span id="cb4-109">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-110">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-111">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-112">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-113">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb4-114">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "single" format: row 1 = column numbers, column 1 = row letters,</span></span>
<span id="cb4-115">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># last column = "Name" tag; each cell already holds the full label.</span></span>
<span id="cb4-116">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(plate_layout),</span>
<span id="cb4-117">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-118">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-119">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1[row_idx],</span>
<span id="cb4-120">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-121">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-122">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j], row_idx, col_idx))</span>
<span id="cb4-123">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-124">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-126">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-127">  }</span>
<span id="cb4-128"></span>
<span id="cb4-129">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(out, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(is_double, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"double"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"single"</span>)</span>
<span id="cb4-130">  out</span>
<span id="cb4-131">}</span>
<span id="cb4-132"></span>
<span id="cb4-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-134"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## reconcile_kinetic_sources()</span></span>
<span id="cb4-135"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Cross-check the absorbance CSV (primary data source) against</span></span>
<span id="cb4-136"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the full_report text export (independent instrument export)</span></span>
<span id="cb4-137"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and the plate layout (expected well set). Fails loudly</span></span>
<span id="cb4-138"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (stopifnot) if any layout well is missing from the CSV, or if</span></span>
<span id="cb4-139"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the two kinetic sources disagree on any shared reading.</span></span>
<span id="cb4-140"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : absorbance_csv - long-format data.frame from read_absorbance_csv()</span></span>
<span id="cb4-141"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           full_report    - long-format data.frame from read_full_report()</span></span>
<span id="cb4-142"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-143"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerance      - max allowed |CSV - report| absolute difference</span></span>
<span id="cb4-144"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            (default 1e-9, i.e. exact agreement)</span></span>
<span id="cb4-145"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(plate_readings, overlap_check, summary), where</span></span>
<span id="cb4-146"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_readings = absorbance_csv with a `source` column added,</span></span>
<span id="cb4-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           summary        = named list of counts for reporting</span></span>
<span id="cb4-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-149">reconcile_kinetic_sources <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(absorbance_csv, full_report, layout_wells,</span>
<span id="cb4-150">                                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tolerance =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>) {</span>
<span id="cb4-151">  wells_csv    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-152">  wells_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-153"></span>
<span id="cb4-154">  wells_report_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_report, wells_csv)</span>
<span id="cb4-155">  wells_layout_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, wells_csv)</span>
<span id="cb4-156">  wells_csv_not_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_csv, layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-157"></span>
<span id="cb4-158">  overlap_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">inner_join</span>(absorbance_csv, full_report,</span>
<span id="cb4-159">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"time_min"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_csv"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_report"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-160">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_diff =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(od_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_report))</span>
<span id="cb4-161"></span>
<span id="cb4-162">  max_disagreement <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(overlap_check<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>abs_diff) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb4-163"></span>
<span id="cb4-164">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-165">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb4-166">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> tolerance</span>
<span id="cb4-167">  )</span>
<span id="cb4-168"></span>
<span id="cb4-169">  plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> absorbance_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance_csv"</span>)</span>
<span id="cb4-170"></span>
<span id="cb4-171">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-172">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_readings =</span> plate_readings,</span>
<span id="cb4-173">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overlap_check  =</span> overlap_check,</span>
<span id="cb4-174">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">summary =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-175">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv),</span>
<span id="cb4-176">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report            =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report),</span>
<span id="cb4-177">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report_not_csv),</span>
<span id="cb4-178">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_layout_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv),</span>
<span id="cb4-179">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv_not_layout    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv_not_layout),</span>
<span id="cb4-180">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_shared_readings         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check),</span>
<span id="cb4-181">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_disagreement          =</span> max_disagreement</span>
<span id="cb4-182">    )</span>
<span id="cb4-183">  )</span>
<span id="cb4-184">}</span>
<span id="cb4-185"></span>
<span id="cb4-186"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-187"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## annotate_wells()</span></span>
<span id="cb4-188"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Join layout labels onto the kinetic readings and parse each</span></span>
<span id="cb4-189"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label into well_type, sample_id, family, individual,</span></span>
<span id="cb4-190"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           temperature, tissue weight, and standard concentration.</span></span>
<span id="cb4-191"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Expected label grammar:</span></span>
<span id="cb4-192"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             sample              : &lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;-&lt;assay_type&gt;-&lt;weight&gt;-df.&lt;n&gt;</span></span>
<span id="cb4-193"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             standard            : STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</span></span>
<span id="cb4-194"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             positive control    : POS-&lt;assay_type&gt;</span></span>
<span id="cb4-195"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             background (pooled) : BG-&lt;assay_type&gt;</span></span>
<span id="cb4-196"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Unlike the paired per-sample background design used on earlier</span></span>
<span id="cb4-197"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plates (`_BG` appended to a sample's own label), this plate's</span></span>
<span id="cb4-198"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background wells are a single pooled control with no sample_id,</span></span>
<span id="cb4-199"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           family, individual, or weight of their own (note 3) -- so</span></span>
<span id="cb4-200"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id/family/individual/temperature/weight_mg parsing is</span></span>
<span id="cb4-201"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           restricted to well_type == "sample" only.</span></span>
<span id="cb4-202"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Label typos (e.g. a misspelled assay_type) are corrected before</span></span>
<span id="cb4-203"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           parsing via `label_fixes`, a named character vector of</span></span>
<span id="cb4-204"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           c(pattern = replacement) pairs applied in order with gsub().</span></span>
<span id="cb4-205"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_readings - data.frame from reconcile_kinetic_sources()$plate_readings</span></span>
<span id="cb4-206"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-207"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label_fixes    - optional named character vector, e.g.</span></span>
<span id="cb4-208"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            c("citrate_synthasse" = "citrate_synthase")</span></span>
<span id="cb4-209"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : plate_long - fully annotated long-format data.frame, one row</span></span>
<span id="cb4-210"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           per well x timepoint, with well_type, sample_id, family,</span></span>
<span id="cb4-211"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           individual, temperature, weight_mg, std_nmol columns added</span></span>
<span id="cb4-212"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-213">annotate_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_readings, layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-214">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_readings <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-215">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-216">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-217">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb4-218">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-219">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^POS-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>,</span>
<span id="cb4-220">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^BG-"</span>,  label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>,</span>
<span id="cb4-221">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span></span>
<span id="cb4-222">      ),</span>
<span id="cb4-223">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_clean =</span> label</span>
<span id="cb4-224">    )</span>
<span id="cb4-225"></span>
<span id="cb4-226">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(label_fixes)) {</span>
<span id="cb4-227">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(label_fixes)) {</span>
<span id="cb4-228">      plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, label_fixes[[pat]], plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean)</span>
<span id="cb4-229">    }</span>
<span id="cb4-230">  }</span>
<span id="cb4-231"></span>
<span id="cb4-232">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-233">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-234">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb4-235">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-[a-zA-Z_]+-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-236">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^(F[0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-237">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_([0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-238">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_[0-9]+_(.*)$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-239">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight_mg   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb4-240">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-[a-zA-Z_]+-([0-9.]+)-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">..*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean)),</span>
<span id="cb4-241">                           <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb4-242">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-243">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-[a-zA-Z_]+-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean)), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb4-244">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-245">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well_type, sample_id, well, time_min)</span>
<span id="cb4-246"></span>
<span id="cb4-247">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fail loudly rather than silently dropping malformed labels</span></span>
<span id="cb4-248">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-249">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type)),</span>
<span id="cb4-250">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>])),</span>
<span id="cb4-251">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>]))</span>
<span id="cb4-252">  )</span>
<span id="cb4-253"></span>
<span id="cb4-254">  plate_long</span>
<span id="cb4-255">}</span>
<span id="cb4-256"></span>
<span id="cb4-257"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-258"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## load_protein_concentrations()</span></span>
<span id="cb4-259"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Load one or more BCA/Bradford-style protein-concentration CSV</span></span>
<span id="cb4-260"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exports, concatenate them, and match each plate sample to</span></span>
<span id="cb4-261"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exactly one protein-concentration record. Fails loudly if any</span></span>
<span id="cb4-262"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate sample has zero or more than one match. Converts</span></span>
<span id="cb4-263"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration (ug/mL) to total protein mass (mg) in the full</span></span>
<span id="cb4-264"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate using the measured homogenization volume.</span></span>
<span id="cb4-265"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : protein_files        - character vector of CSV paths, each with</span></span>
<span id="cb4-266"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   columns `Sample` and</span></span>
<span id="cb4-267"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   `Calculated concentration (ug/mL)`</span></span>
<span id="cb4-268"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_sample_ids     - character vector of this plate's sample IDs</span></span>
<span id="cb4-269"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate_volume_uL - measured homogenization volume (uL),</span></span>
<span id="cb4-270"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   applied identically to every sample</span></span>
<span id="cb4-271"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_fixes      - optional named character vector of</span></span>
<span id="cb4-272"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   c(pattern = replacement) label-typo</span></span>
<span id="cb4-273"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   corrections applied to the protein</span></span>
<span id="cb4-274"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   file's Sample column before matching</span></span>
<span id="cb4-275"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per plate sample:</span></span>
<span id="cb4-276"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id, source_file, conc_ug_mL, total_protein_mg</span></span>
<span id="cb4-277"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-278">load_protein_concentrations <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(protein_files, plate_sample_ids,</span>
<span id="cb4-279">                                         homogenate_volume_uL,</span>
<span id="cb4-280">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-281">  protein_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_files <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-282">    purrr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(.x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-283">                      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source_file =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(.x))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-284">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_protein =</span> Sample, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc_ug_mL =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Calculated concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-285">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id_protein, source_file, conc_ug_mL)</span>
<span id="cb4-286"></span>
<span id="cb4-287">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(sample_id_fixes)) {</span>
<span id="cb4-288">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(sample_id_fixes)) {</span>
<span id="cb4-289">      protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, sample_id_fixes[[pat]],</span>
<span id="cb4-290">                                             protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein)</span>
<span id="cb4-291">    }</span>
<span id="cb4-292">  }</span>
<span id="cb4-293"></span>
<span id="cb4-294">  protein_matches <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_id_protein <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> plate_sample_ids)</span>
<span id="cb4-295">  match_counts    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(sample_id_protein, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_matches"</span>)</span>
<span id="cb4-296"></span>
<span id="cb4-297">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-298">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(plate_sample_ids <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> protein_matches<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein),</span>
<span id="cb4-299">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(match_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-300">  )</span>
<span id="cb4-301"></span>
<span id="cb4-302">  protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-303">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-304">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_protein_mg =</span> conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> homogenate_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-305">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb4-306">}</span></code></pre></div>
</section>
<section id="well-level-kinetic-qc" class="level3">
<h3 class="anchored" data-anchor-id="well-level-kinetic-qc">1.3.2 Well-level kinetic QC</h3>
<p>Flags read glitches, non-rising (‘decreasing’) traces, elevated t0 baselines, and other well-level anomalies before any rate is trusted.</p>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## local_step_excess()</span></span>
<span id="cb5-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For a kinetic trace, measure how much each read-to-read step</span></span>
<span id="cb5-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           departs from the AVERAGE of its two immediate neighbouring</span></span>
<span id="cb5-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           steps. A large local excess flags a read glitch; comparing to</span></span>
<span id="cb5-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           local neighbours (rather than the trace's overall median step)</span></span>
<span id="cb5-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerates traces that smoothly decelerate throughout.</span></span>
<span id="cb5-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : od - numeric vector of OD readings in time order</span></span>
<span id="cb5-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of length length(od) - 1 (one per step)</span></span>
<span id="cb5-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-11">local_step_excess <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(od) {</span>
<span id="cb5-12">  d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)</span>
<span id="cb5-13">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(d)</span>
<span id="cb5-14">  local_expect <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb5-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(d[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n))])</span>
<span id="cb5-16">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb5-17">  d <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> local_expect</span>
<span id="cb5-18">}</span>
<span id="cb5-19"></span>
<span id="cb5-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_diagnostics()</span></span>
<span id="cb5-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute four independent per-well trace-shape diagnostics from</span></span>
<span id="cb5-23"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the raw kinetic trace, before any rate fitting: direction</span></span>
<span id="cb5-24"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (net change), monotonicity (fraction of rising steps),</span></span>
<span id="cb5-25"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           over-range (any read above the photometric linearity ceiling),</span></span>
<span id="cb5-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and discontinuity (a read-to-read glitch via local_step_excess).</span></span>
<span id="cb5-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Also flags an elevated starting absorbance for sample wells,</span></span>
<span id="cb5-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and background wells that behave like active reactions.</span></span>
<span id="cb5-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb5-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with od_linear_max, glitch_excess_od,</span></span>
<span id="cb5-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          sample_baseline_od, bg_flat_od_max,</span></span>
<span id="cb5-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          bg_flat_drift_max</span></span>
<span id="cb5-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_diagnostics - one row per well, with od_first, od_last,</span></span>
<span id="cb5-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           od_max, net_change, frac_rising, max_step, typical_step,</span></span>
<span id="cb5-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           step_excess, glitch_at_min, and flag_* / n_flags columns</span></span>
<span id="cb5-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-37">compute_well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb5-38">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-39">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-40">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, plate_row, plate_col, well_type, sample_id, label, std_nmol, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb5-42">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_first        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-43">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_last         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od),</span>
<span id="cb5-44">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_max          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(od),</span>
<span id="cb5-45">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_change      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-46">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">frac_rising     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb5-47">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_step        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)))],</span>
<span id="cb5-48">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typical_step    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od))),</span>
<span id="cb5-49">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_excess     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)))],</span>
<span id="cb5-50">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_at_min   =</span> time_min[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L],</span>
<span id="cb5-51">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb5-52">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb5-54">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_ratio      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(max_step) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmax</span>(typical_step, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>),</span>
<span id="cb5-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_decreasing =</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb5-56">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_over_range =</span> od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb5-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_glitch     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(step_excess) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glitch_excess_od,</span>
<span id="cb5-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_high_baseline =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_bg_active  =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb5-60">                        (od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb5-61">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(net_change) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_drift_max),</span>
<span id="cb5-62">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_flags         =</span> flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_over_range <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-63">                        flag_bg_active <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_high_baseline</span>
<span id="cb5-64">    )</span>
<span id="cb5-65">}</span>
<span id="cb5-66"></span>
<span id="cb5-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_baseline_diagnostics()</span></span>
<span id="cb5-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Classify sample/background wells by starting absorbance</span></span>
<span id="cb5-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (elevated vs. normal) and summarize, per sample, how many of</span></span>
<span id="cb5-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           its replicates are baseline-compromised. A sample with all</span></span>
<span id="cb5-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           replicates elevated has no clean replicate at all.</span></span>
<span id="cb5-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb5-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with sample_baseline_od</span></span>
<span id="cb5-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(baseline_check, baseline_per_sample)</span></span>
<span id="cb5-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-77">compute_baseline_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, assay_params) {</span>
<span id="cb5-78">  baseline_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-79">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-80">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-81">                             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-82">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(od_first))</span>
<span id="cb5-83"></span>
<span id="cb5-84">  baseline_per_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_check <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-85">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-87">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_elevated =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb5-88">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-89">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(n_elevated))</span>
<span id="cb5-90"></span>
<span id="cb5-91">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_check =</span> baseline_check, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_per_sample =</span> baseline_per_sample)</span>
<span id="cb5-92">}</span></code></pre></div>
</section>
<section id="standard-curve-and-rate-extraction" class="level3">
<h3 class="anchored" data-anchor-id="standard-curve-and-rate-extraction">1.3.3 Standard curve and rate extraction</h3>
<p>Fits the GSH standard curve, extracts each well’s rate via a sliding-window linear regression gated on R-squared, and summarizes the positive control.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## fit_standard_curve()</span></span>
<span id="cb6-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Extract t=0 GSH standard readings, quantify signal drift over</span></span>
<span id="cb6-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the run, compute per-concentration replicate statistics, flag</span></span>
<span id="cb6-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           outlier wells by deviation from their triplicate median, and</span></span>
<span id="cb6-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit three candidate calibration lines (all wells, per-</span></span>
<span id="cb6-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration means, outlier-excluded). The outlier-excluded</span></span>
<span id="cb6-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit is the calibration used downstream.</span></span>
<span id="cb6-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb6-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with std_outlier_od</span></span>
<span id="cb6-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list with standards_t0, standard_drift, standard_summary,</span></span>
<span id="cb6-12"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           standards_flagged, fit_all_wells, fit_means, fit_no_outliers,</span></span>
<span id="cb6-13"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit_comparison, std_slope, std_intercept, std_r2, std_nmol_max</span></span>
<span id="cb6-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-15">fit_standard_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb6-16">  standards_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, time_min, od, source)</span>
<span id="cb6-19"></span>
<span id="cb6-20">  standards_t0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-24"></span>
<span id="cb6-25">  standard_drift <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t0 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t40 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(time_min)],</span>
<span id="cb6-28">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drift =</span> od_t40 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_t0, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-30"></span>
<span id="cb6-31">  standard_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od),</span>
<span id="cb6-34">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_pct =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od),</span>
<span id="cb6-35">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-36">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-37">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_od =</span> mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean_od[std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>],</span>
<span id="cb6-38">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_per_nmol =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, net_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_nmol, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>))</span>
<span id="cb6-39"></span>
<span id="cb6-40">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-42">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">triplicate_median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od),</span>
<span id="cb6-43">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">deviation =</span> od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> triplicate_median,</span>
<span id="cb6-44">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_outlier =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation)))</span>
<span id="cb6-47"></span>
<span id="cb6-48">  fit_all_wells   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged)</span>
<span id="cb6-49">  fit_means       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standard_summary)</span>
<span id="cb6-50">  fit_no_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier))</span>
<span id="cb6-51"></span>
<span id="cb6-52">  fit_comparison <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb6-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all wells"</span>,          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_all_wells),</span>
<span id="cb6-54">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-55">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration means"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_means),</span>
<span id="cb6-57">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-58">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_means)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier-excluded"</span>,   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_no_outliers),</span>
<span id="cb6-60">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-61">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared)</span>
<span id="cb6-62">  )</span>
<span id="cb6-63"></span>
<span id="cb6-64">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb6-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_all      =</span> standards_all,</span>
<span id="cb6-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_t0       =</span> standards_t0,</span>
<span id="cb6-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_drift     =</span> standard_drift,</span>
<span id="cb6-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_summary   =</span> standard_summary,</span>
<span id="cb6-69">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_flagged  =</span> standards_flagged,</span>
<span id="cb6-70">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_all_wells      =</span> fit_all_wells,</span>
<span id="cb6-71">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_means          =</span> fit_means,</span>
<span id="cb6-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_no_outliers    =</span> fit_no_outliers,</span>
<span id="cb6-73">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_comparison     =</span> fit_comparison,</span>
<span id="cb6-74">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_slope          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]),</span>
<span id="cb6-75">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_intercept      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb6-76">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_r2             =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared,</span>
<span id="cb6-77">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol_max       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol)</span>
<span id="cb6-78">  )</span>
<span id="cb6-79">}</span>
<span id="cb6-80"></span>
<span id="cb6-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## window_slopes()</span></span>
<span id="cb6-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Fit every sliding window of `w` consecutive timepoints on one</span></span>
<span id="cb6-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           kinetic trace and return the slope (mOD/min) and R^2 of each.</span></span>
<span id="cb6-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : t - numeric vector of timepoints (min)</span></span>
<span id="cb6-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           y - numeric vector of OD readings, same length as t</span></span>
<span id="cb6-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           w - window width in number of points</span></span>
<span id="cb6-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per window: t_start, t_end,</span></span>
<span id="cb6-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2</span></span>
<span id="cb6-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-91">window_slopes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(t, y, w) {</span>
<span id="cb6-92">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(y)</span>
<span id="cb6-93">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb6-94">    i  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> s<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-95">    f  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(y[i] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> t[i])</span>
<span id="cb6-96">    r2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(f)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb6-97">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> t[i[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> t[i[w]],</span>
<span id="cb6-98">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(f)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb6-99">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(r2), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, r2))</span>
<span id="cb6-100">  }))</span>
<span id="cb6-101">}</span>
<span id="cb6-102"></span>
<span id="cb6-103"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-104"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_rates()</span></span>
<span id="cb6-105"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For every well, scan all sliding windows of assay_params$</span></span>
<span id="cb6-106"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           rate_window_n consecutive reads and record the max-increasing</span></span>
<span id="cb6-107"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           window (used for activity) and the max-absolute window</span></span>
<span id="cb6-108"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (diagnostic only -- matches Gen5's own `Max V` convention,</span></span>
<span id="cb6-109"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           which can report large negative "rates" for degrading wells).</span></span>
<span id="cb6-110"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           A rate is `rate_usable` only if its R^2 clears the floor, the</span></span>
<span id="cb6-111"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well's net change is positive, and no read glitch falls inside</span></span>
<span id="cb6-112"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the fitted window.</span></span>
<span id="cb6-113"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long       - data.frame from annotate_wells()</span></span>
<span id="cb6-114"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb6-115"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with rate_window_n, rate_min_r2</span></span>
<span id="cb6-116"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_rates - one row per well: t_start, t_end, slope_mOD_min,</span></span>
<span id="cb6-117"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           r2, max_abs_slope_mOD_min, abs_window_is_negative,</span></span>
<span id="cb6-118"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           glitch_in_window, rate_usable (plus diagnostic columns joined in)</span></span>
<span id="cb6-119"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-120">compute_well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, well_diagnostics, assay_params) {</span>
<span id="cb6-121">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-122">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-123">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, well_type, sample_id, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-124">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_modify</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> {</span>
<span id="cb6-125">      w   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">window_slopes</span>(.x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min, .x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_window_n)</span>
<span id="cb6-126">      inc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min), ]</span>
<span id="cb6-127">      abs_ <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), ]</span>
<span id="cb6-128">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb6-129">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_start, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_end,</span>
<span id="cb6-130">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2,</span>
<span id="cb6-131">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_abs_slope_mOD_min =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min,</span>
<span id="cb6-132">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_window_is_negative =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb6-133">      )</span>
<span id="cb6-134">    }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-135">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-136">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, net_change, frac_rising, od_max,</span>
<span id="cb6-137">                                          flag_decreasing, flag_over_range,</span>
<span id="cb6-138">                                          flag_glitch, glitch_at_min,</span>
<span id="cb6-139">                                          flag_bg_active, n_flags),</span>
<span id="cb6-140">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-141">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb6-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_in_window =</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> t_start <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> t_end,</span>
<span id="cb6-143">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_usable      =</span> r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_min_r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>glitch_in_window</span>
<span id="cb6-144">    )</span>
<span id="cb6-145">}</span>
<span id="cb6-146"></span>
<span id="cb6-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_positive_control()</span></span>
<span id="cb6-149"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute the CS Positive Control's rate and activity, and check</span></span>
<span id="cb6-150"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           that its replicates rose linearly -- the plate's proof that the</span></span>
<span id="cb6-151"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reaction chemistry (DTNB, coupling, reader) worked, independent</span></span>
<span id="cb6-152"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           of any sample-specific problem.</span></span>
<span id="cb6-153"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates   - data.frame from compute_well_rates()</span></span>
<span id="cb6-154"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope    - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb6-155"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with sample_volume_uL, dilution_factor</span></span>
<span id="cb6-156"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : pos_control - one row per positive-control well: t_start, t_end,</span></span>
<span id="cb6-157"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2, net_change, activity_mU_uL</span></span>
<span id="cb6-158"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-159">compute_positive_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, std_slope, assay_params) {</span>
<span id="cb6-160">  well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-161">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-162">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_uL =</span> (slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb6-163">                            assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor)</span>
<span id="cb6-164">}</span></code></pre></div>
</section>
<section id="background-correction-replicate-cv-and-activity-calculation" class="level3">
<h3 class="anchored" data-anchor-id="background-correction-replicate-cv-and-activity-calculation">1.3.4 Background correction, replicate CV, and activity calculation</h3>
<p>Estimates a single pooled background rate from the flat (well-behaved) background replicates, computes technical-replicate coefficients of variation, and converts corrected rates into protein-normalized CS activity.</p>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_background_correction()</span></span>
<span id="cb7-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Estimate a single, plate-wide background rate from the flat</span></span>
<span id="cb7-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well-behaved) replicates of the pooled background control</span></span>
<span id="cb7-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (note 3), since anomalous background wells do not measure</span></span>
<span id="cb7-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background. Unlike earlier plates' per-sample background</span></span>
<span id="cb7-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           design, this plate has one background triplicate for the whole</span></span>
<span id="cb7-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate, so the estimate is a single row rather than one row per</span></span>
<span id="cb7-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id.</span></span>
<span id="cb7-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates - data.frame from compute_well_rates()</span></span>
<span id="cb7-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : background_correction - one-row data.frame: n_bg_total,</span></span>
<span id="cb7-12"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           n_bg_flat, bg_rate_flat (NA if no flat replicate exists),</span></span>
<span id="cb7-13"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           bg_rate_all</span></span>
<span id="cb7-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-15">compute_background_correction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates) {</span>
<span id="cb7-16">  bg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)</span>
<span id="cb7-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb7-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_total   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg),</span>
<span id="cb7-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_flat    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active),</span>
<span id="cb7-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_flat =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb7-21">                          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active]), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb7-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_all  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)</span>
<span id="cb7-23">  )</span>
<span id="cb7-24">}</span>
<span id="cb7-25"></span>
<span id="cb7-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_replicate_cv()</span></span>
<span id="cb7-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute technical-replicate coefficient of variation (CV%) on</span></span>
<span id="cb7-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the extracted rate, both across ALL three replicates and</span></span>
<span id="cb7-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across USABLE replicates only (rate_usable == TRUE). Flags any</span></span>
<span id="cb7-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample whose CV exceeds assay_params$cv_threshold_pct.</span></span>
<span id="cb7-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates       - data.frame from compute_well_rates()</span></span>
<span id="cb7-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_order  - character vector giving the row order /</span></span>
<span id="cb7-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              complete sample-ID set to report (typically</span></span>
<span id="cb7-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              the plate's sample IDs, e.g. from</span></span>
<span id="cb7-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              protein_by_sample$sample_id)</span></span>
<span id="cb7-37"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with cv_threshold_pct</span></span>
<span id="cb7-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cv_summary - one row per sample: n_all, mean_all, sd_all,</span></span>
<span id="cb7-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_all, n_usable, mean_usable, sd_usable, cv_usable,</span></span>
<span id="cb7-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           excluded_wells, fails_cv_all, fails_cv_usable</span></span>
<span id="cb7-41"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-42">compute_replicate_cv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, sample_id_order, assay_params) {</span>
<span id="cb7-43">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-44"></span>
<span id="cb7-45">  cv_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-47">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-48">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_all =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-49"></span>
<span id="cb7-50">  cv_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-51">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-54">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-55">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_usable =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-56"></span>
<span id="cb7-57">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_order, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_all, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-60">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-61">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">excluded_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(sample_id, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb7-62">        w <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable]</span>
<span id="cb7-63">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(w) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(w, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)</span>
<span id="cb7-64">      }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb7-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_all    =</span> cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-66">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_usable =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> cv_usable <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct</span>
<span id="cb7-67">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-68">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-69">}</span>
<span id="cb7-70"></span>
<span id="cb7-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## calculate_cs_activity()</span></span>
<span id="cb7-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute per-sample CS activity following Abcam sec 10.3, using</span></span>
<span id="cb7-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           only usable replicates, corrected for the single pooled</span></span>
<span id="cb7-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background rate (note 3), scaled through the standard curve,</span></span>
<span id="cb7-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and normalized to total extracted protein (rather than tissue</span></span>
<span id="cb7-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           weight).</span></span>
<span id="cb7-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates            - data.frame from compute_well_rates()</span></span>
<span id="cb7-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           protein_by_sample     - data.frame from load_protein_concentrations()</span></span>
<span id="cb7-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background_correction - one-row data.frame from</span></span>
<span id="cb7-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    compute_background_correction()</span></span>
<span id="cb7-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope             - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb7-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_nmol_max          - max calibrated GSH concentration, from fit_standard_curve()</span></span>
<span id="cb7-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params          - list with sample_volume_uL, dilution_factor,</span></span>
<span id="cb7-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    homogenate_volume_uL, read_duration_min</span></span>
<span id="cb7-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_long            - data.frame from annotate_wells(), used to</span></span>
<span id="cb7-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    attach family/individual/temperature</span></span>
<span id="cb7-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cs_activity - one row per sample: n_reps_used, mean_rate_mOD_min,</span></span>
<span id="cb7-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sd_rate, cv_rate, family, individual, temperature, conc_ug_mL,</span></span>
<span id="cb7-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           total_protein_mg, bg_rate_mOD_min, corrected_mOD_min,</span></span>
<span id="cb7-91"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_uL, total_mU_in_homogenate,</span></span>
<span id="cb7-92"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_mg_protein, within_std_range</span></span>
<span id="cb7-93"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-94">calculate_cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, protein_by_sample, background_correction,</span>
<span id="cb7-95">                                   std_slope, std_nmol_max, assay_params, plate_long) {</span>
<span id="cb7-96">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-97"></span>
<span id="cb7-98">  bg_rate <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat)</span>
<span id="cb7-99"></span>
<span id="cb7-100">  sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-101">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-102">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-103">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_reps_used =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_rate_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-104">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_rate =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-105">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_rate =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-106">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-107">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb7-108">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-109">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, conc_ug_mL, total_protein_mg),</span>
<span id="cb7-110">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-111">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-112">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_mOD_min       =</span> bg_rate,</span>
<span id="cb7-113">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">corrected_mOD_min     =</span> mean_rate_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> bg_rate_mOD_min,</span>
<span id="cb7-114">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_OD_min           =</span> corrected_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb7-115">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_per_min          =</span> rate_OD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope,</span>
<span id="cb7-116">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_uL    =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span></span>
<span id="cb7-117">                              assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor,</span>
<span id="cb7-118">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_mU_in_homogenate =</span> activity_mU_per_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb7-119">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_mg_protein =</span> total_mU_in_homogenate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> total_protein_mg,</span>
<span id="cb7-120">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_in_window        =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>read_duration_min),</span>
<span id="cb7-121">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">within_std_range      =</span> nmol_in_window <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> std_nmol_max</span>
<span id="cb7-122">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-123">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-124">}</span>
<span id="cb7-125"></span>
<span id="cb7-126"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-127"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_results_table()</span></span>
<span id="cb7-128"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Assemble the final, presentation-ready per-sample results</span></span>
<span id="cb7-129"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           table from cs_activity, cv_summary and baseline diagnostics,</span></span>
<span id="cb7-130"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           with a plain-language Interpretation column.</span></span>
<span id="cb7-131"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : cs_activity          - data.frame from calculate_cs_activity()</span></span>
<span id="cb7-132"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary           - data.frame from compute_replicate_cv()</span></span>
<span id="cb7-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample  - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb7-134"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params         - list with cv_threshold_pct, homogenate_volume_uL</span></span>
<span id="cb7-135"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : results_table - formatted data.frame, ready for kable()/write.csv()</span></span>
<span id="cb7-136"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-137">build_results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(cs_activity, cv_summary, baseline_per_sample, assay_params) {</span>
<span id="cb7-138">  cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-139">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-140">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-141">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb7-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample                       =</span> sample_id,</span>
<span id="cb7-143">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family                       =</span> family,</span>
<span id="cb7-144">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual                   =</span> individual,</span>
<span id="cb7-145">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature                  =</span> temperature,</span>
<span id="cb7-146">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Protein conc (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-147">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Total protein (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(total_protein_mg, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Reps used</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, n_all),</span>
<span id="cb7-149">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV all reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>            <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_all, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-150">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV used reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_rate, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-151">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-152">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">BG rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(bg_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-153">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Corrected rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(corrected_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-154">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/uL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_uL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb7-155">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/mg protein)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_mg_protein, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-156">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV flag</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-157">                                            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FAIL &gt;"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pass"</span>),</span>
<span id="cb7-158">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Elevated baseline reps</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_elevated, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3"</span>),</span>
<span id="cb7-159">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Interpretation               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb7-160">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DO NOT USE - no clean replicate"</span>,</span>
<span id="cb7-161">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - some reps compromised"</span>,</span>
<span id="cb7-162">        cv_rate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_rate) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - imprecise"</span>,</span>
<span id="cb7-163">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span></span>
<span id="cb7-164">      )</span>
<span id="cb7-165">    )</span>
<span id="cb7-166">}</span></code></pre></div>
</section>
<section id="qc-summary-and-narrative-generation" class="level3">
<h3 class="anchored" data-anchor-id="qc-summary-and-narrative-generation">1.3.5 QC summary and narrative generation</h3>
<p>Assembles the per-well QC summary table and auto-generates the plain-language QC findings bullets used in the QC SUMMARY section below.</p>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_qc_summary_table()</span></span>
<span id="cb8-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Consolidate every QC check performed across the pipeline into a</span></span>
<span id="cb8-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           single two-column (check, value) table, suitable for kable() and</span></span>
<span id="cb8-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           for writing to qc_summary.csv. Mirrors the individual find</span></span>
<span id="cb8-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           functions but as compact, at-a-glance figures rather than prose.</span></span>
<span id="cb8-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : layout_wells, reconcile_summary, std_curve, well_diagnostics,</span></span>
<span id="cb8-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates, cv_summary, baseline_per_sample, pos_control,</span></span>
<span id="cb8-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params</span></span>
<span id="cb8-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : qc_summary - data.frame with columns check, value (both chr)</span></span>
<span id="cb8-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-12">build_qc_summary_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(layout_wells, reconcile_summary, std_curve,</span>
<span id="cb8-13">                                    well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-14">                                    baseline_per_sample, pos_control, assay_params) {</span>
<span id="cb8-15">  standard_summary  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-16">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb8-17">  standard_drift    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb8-18">  sample_rates      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb8-19"></span>
<span id="cb8-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb8-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-22">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout"</span>,</span>
<span id="cb8-23">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from absorbance CSV"</span>,</span>
<span id="cb8-24">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max disagreement between absorbance CSV and full report"</span>,</span>
<span id="cb8-25">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard concentrations with replicate CV &gt; threshold"</span>,</span>
<span id="cb8-26">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers"</span>,</span>
<span id="cb8-27">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (outlier-excluded, replicate level)"</span>,</span>
<span id="cb8-28">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (all wells, replicate level)"</span>,</span>
<span id="cb8-29">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells that LOST signal over the run"</span>,</span>
<span id="cb8-30">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards above photometric linearity ceiling"</span>,</span>
<span id="cb8-31">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background control wells behaving as active reactions"</span>,</span>
<span id="cb8-32">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a decreasing trace"</span>,</span>
<span id="cb8-33">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with an elevated starting A412"</span>,</span>
<span id="cb8-34">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with ALL THREE replicates baseline-compromised"</span>,</span>
<span id="cb8-35">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a read glitch"</span>,</span>
<span id="cb8-36">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells usable for rate extraction"</span>,</span>
<span id="cb8-37">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (all reps)"</span>,</span>
<span id="cb8-38">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (usable reps)"</span>,</span>
<span id="cb8-39">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control replicates rising and linear"</span></span>
<span id="cb8-40">    ),</span>
<span id="cb8-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-42">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells),</span>
<span id="cb8-43">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv,</span>
<span id="cb8-44">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.g"</span>, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement),</span>
<span id="cb8-45">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb8-46">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-47">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-48">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-49">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2),</span>
<span id="cb8-50">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb8-51">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift)),</span>
<span id="cb8-52">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max],</span>
<span id="cb8-53">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-54">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-55">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)),</span>
<span id="cb8-56">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-57">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-58">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-59">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-60">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-61">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-62">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(baseline_per_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-63">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id[baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n],</span>
<span id="cb8-64">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-65">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-66">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-67">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_rates)),</span>
<span id="cb8-68">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-69">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-70">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pos_control))</span>
<span id="cb8-71">    ),</span>
<span id="cb8-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-73">  )</span>
<span id="cb8-74">}</span>
<span id="cb8-75"></span>
<span id="cb8-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## generate_qc_findings()</span></span>
<span id="cb8-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Walk the QC/CV/anomaly objects for a plate and emit a</span></span>
<span id="cb8-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           consistent, generic-language markdown bullet list of findings</span></span>
<span id="cb8-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (decreasing/glitched/high-baseline wells, background-control</span></span>
<span id="cb8-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           mix-ups, standard-curve QC failures, CV failures, disqualified</span></span>
<span id="cb8-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           samples). Intended to seed the SUMMARY section of a plate's</span></span>
<span id="cb8-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           .Rmd; a short hand-written subsection for plate-specific</span></span>
<span id="cb8-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           interpretation should follow it.</span></span>
<span id="cb8-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics    - data.frame from compute_well_diagnostics()</span></span>
<span id="cb8-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates          - data.frame from compute_well_rates()</span></span>
<span id="cb8-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary          - data.frame from compute_replicate_cv()</span></span>
<span id="cb8-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb8-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_curve           - list from fit_standard_curve()</span></span>
<span id="cb8-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reconcile_summary   - list from reconcile_kinetic_sources()$summary</span></span>
<span id="cb8-91"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params        - list with cv_threshold_pct, od_linear_max</span></span>
<span id="cb8-92"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : character vector, one markdown bullet per finding (empty</span></span>
<span id="cb8-93"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           findings are omitted, so a clean plate returns a short list)</span></span>
<span id="cb8-94"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-95">generate_qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-96">                                  baseline_per_sample, std_curve,</span>
<span id="cb8-97">                                  reconcile_summary, assay_params) {</span>
<span id="cb8-98">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-99"></span>
<span id="cb8-100">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Source reconciliation</span></span>
<span id="cb8-101">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span></span>
<span id="cb8-102">      (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>)) {</span>
<span id="cb8-103">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-104">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic source disagreement.** %d layout well(s) missing from the absorbance CSV; max disagreement between absorbance CSV and full report was %.4g A412."</span>,</span>
<span id="cb8-105">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement))</span>
<span id="cb8-106">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-107">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-108">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic sources agree.** absorbance CSV and full report agree exactly on all %d shared well x timepoint readings; all layout wells are present."</span>,</span>
<span id="cb8-109">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings))</span>
<span id="cb8-110">  }</span>
<span id="cb8-111"></span>
<span id="cb8-112">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sample wells with decreasing kinetics</span></span>
<span id="cb8-113">  dec_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_decreasing)</span>
<span id="cb8-114">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-115">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-116">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Decreasing kinetics.** %d sample well(s) end lower than (or equal to) their starting A412 and are excluded from rate extraction: %s."</span>,</span>
<span id="cb8-117">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(dec_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-118">  }</span>
<span id="cb8-119"></span>
<span id="cb8-120">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Read glitches</span></span>
<span id="cb8-121">  glitch_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_glitch)</span>
<span id="cb8-122">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-123">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-124">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Read glitches.** %d sample well(s) contain a single read-to-read step inconsistent with its neighbours: %s (only disqualifying if it falls inside the fitted rate window)."</span>,</span>
<span id="cb8-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(glitch_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-126">  }</span>
<span id="cb8-127"></span>
<span id="cb8-128">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Elevated baseline</span></span>
<span id="cb8-129">  high_baseline <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_high_baseline)</span>
<span id="cb8-130">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-131">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-132">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Elevated starting absorbance.** %d sample well(s) start above the baseline threshold (A412 &gt; %s), indicating pre-existing thiol/contamination before the reaction began: %s."</span>,</span>
<span id="cb8-133">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(high_baseline<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-134">  }</span>
<span id="cb8-135"></span>
<span id="cb8-136">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Samples fully disqualified by baseline</span></span>
<span id="cb8-137">  disqualified <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n)</span>
<span id="cb8-138">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(disqualified) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-139">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-140">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Sample(s) with no clean replicate.** Every replicate of %s has an elevated starting A412; these samples have no usable measurement on this plate regardless of CV."</span>,</span>
<span id="cb8-141">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(disqualified<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-142">  }</span>
<span id="cb8-143"></span>
<span id="cb8-144">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Over-range wells</span></span>
<span id="cb8-145">  over_range <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(flag_over_range)</span>
<span id="cb8-146">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-147">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Over-range wells.** %d well(s) exceed the photometric linearity ceiling (A412 &gt; %s): %s."</span>,</span>
<span id="cb8-149">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-150">  }</span>
<span id="cb8-151"></span>
<span id="cb8-152">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Background wells behaving as active reactions</span></span>
<span id="cb8-153">  bg_active <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>, flag_bg_active)</span>
<span id="cb8-154">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-155">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-156">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Background control wells behaving as active reactions.** %d of %d background wells show a starting A412 or drift inconsistent with a flat, inactive well: %s."</span>,</span>
<span id="cb8-157">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb8-158">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(bg_active<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-159">  }</span>
<span id="cb8-160"></span>
<span id="cb8-161">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standard curve QC</span></span>
<span id="cb8-162">  std_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-163">  cv_fail_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct)</span>
<span id="cb8-164">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-165">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-166">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**GSH standard curve replicate imprecision.** %d of %d concentrations exceed %s%% CV: %s nmol/well."</span>,</span>
<span id="cb8-167">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-168">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(cv_fail_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-169">  }</span>
<span id="cb8-170">  n_std_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier)</span>
<span id="cb8-171">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_std_outliers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-172">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-173">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard outlier wells.** %d of %d standard wells deviate from their triplicate median by more than %s A412: %s."</span>,</span>
<span id="cb8-174">      n_std_outliers, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od,</span>
<span id="cb8-175">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-176">  }</span>
<span id="cb8-177">  over_range_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max)</span>
<span id="cb8-178">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-179">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-180">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standards above the photometric linear range.** %s nmol/well read above A412 %s; the calibration is trustworthy only below these concentrations."</span>,</span>
<span id="cb8-181">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max))</span>
<span id="cb8-182">  }</span>
<span id="cb8-183">  n_drift_neg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-184">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_drift_neg <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-185">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-186">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard signal decay.** %d of %d standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0."</span>,</span>
<span id="cb8-187">      n_drift_neg, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift)))</span>
<span id="cb8-188">  }</span>
<span id="cb8-189">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-190">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard curve fit (outlier-excluded):** slope = %.5f A412/nmol, R^2 = %.4f (all-wells R^2 = %.4f)."</span>,</span>
<span id="cb8-191">    std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared))</span>
<span id="cb8-192"></span>
<span id="cb8-193">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Technical replicate CV failures</span></span>
<span id="cb8-194">  fail_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all)</span>
<span id="cb8-195">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-196">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-197">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% (all replicates).** %d of %d samples: %s."</span>,</span>
<span id="cb8-198">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary),</span>
<span id="cb8-199">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%)"</span>, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-200">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-201">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-202">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV.** All %d samples are within %s%% CV across all three replicates."</span>,</span>
<span id="cb8-203">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct))</span>
<span id="cb8-204">  }</span>
<span id="cb8-205">  fail_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable)</span>
<span id="cb8-206">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-207">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-208">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% persists after excluding flagged replicates.** %s."</span>,</span>
<span id="cb8-209">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-210">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%, n=%d)"</span>, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_usable,</span>
<span id="cb8-211">                    fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_usable), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-212">  }</span>
<span id="cb8-213"></span>
<span id="cb8-214">  bullets</span>
<span id="cb8-215">}</span></code></pre></div>
</section>
</section>
<section id="assay-parameters" class="level2">
<h2 class="anchored" data-anchor-id="assay-parameters">1.4 Assay parameters</h2>
<p>All assay constants and QC thresholds are collected here so nothing downstream hard-codes a number.</p>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">assay_params <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb9-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># homogenate volume per reaction well (V in Abcam formula); also the pooled-background volume (note 3)</span></span>
<span id="cb9-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">buffer_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">48</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Assay Buffer 7 added to reach 50 uL pre-Reaction Mix</span></span>
<span id="cb9-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_factor       =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># D; layout `df.0` = undiluted homogenate</span></span>
<span id="cb9-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_volume_uL  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MEASURED buffer volume tissue was homogenized in (see note 2)</span></span>
<span id="cb9-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_wavelength_nm    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">412</span>,</span>
<span id="cb9-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_interval_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb9-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_duration_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># see note 1</span></span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_window_n         =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># points per sliding regression window (5 pts = 8 min)</span></span>
<span id="cb9-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_min_r2           =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.80</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># min R^2 for a rate window to be trusted</span></span>
<span id="cb9-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_excess_od      =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |step - mean of neighbouring steps| flagging a read glitch</span></span>
<span id="cb9-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_threshold_pct      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># technical-replicate CV QC threshold</span></span>
<span id="cb9-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_linear_max         =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># upper A412 bound for reliable photometry</span></span>
<span id="cb9-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_outlier_od        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |deviation from triplicate median| flagging a standard well</span></span>
<span id="cb9-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_baseline_od    =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># max acceptable t0 A412 for a sample well</span></span>
<span id="cb9-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_od_max        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a well-behaved background well starts below this A412</span></span>
<span id="cb9-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_drift_max     =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ...and drifts less than this over the whole run</span></span>
<span id="cb9-18">)</span>
<span id="cb9-19"></span>
<span id="cb9-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- assay_params: assay constants and QC thresholds ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb9-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(assay_params)</span></code></pre></div>
<pre><code>--- assay_params: assay constants and QC thresholds ---

List of 16
 $ sample_volume_uL    : num 2
 $ buffer_volume_uL    : num 48
 $ dilution_factor     : num 1
 $ homogenate_volume_uL: num 350
 $ read_wavelength_nm  : num 412
 $ read_interval_min   : num 2
 $ read_duration_min   : num 20
 $ rate_window_n       : num 5
 $ rate_min_r2         : num 0.8
 $ glitch_excess_od    : num 0.02
 $ cv_threshold_pct    : num 15
 $ od_linear_max       : num 1.5
 $ std_outlier_od      : num 0.15
 $ sample_baseline_od  : num 0.35
 $ bg_flat_od_max      : num 0.15
 $ bg_flat_drift_max   : num 0.05</code></pre>
</section>
<section id="output-directory" class="level2">
<h2 class="anchored" data-anchor-id="output-directory">1.5 Output directory</h2>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Output directory for this analysis (matches this file's name, per ../code/README.md)</span></span>
<span id="cb11-2">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient"</span></span>
<span id="cb11-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb11-4"></span>
<span id="cb11-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- output_dir: destination for all figures and tables ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb11-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(output_dir)</span></code></pre></div>
<pre><code>--- output_dir: destination for all figures and tables ---
 chr "../outputs/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient"</code></pre>
</section>
</section>
<section id="data" class="level1">
<h1>2 DATA</h1>
<p>Data are read from the local repo (<code>../data/raw_absorbance/</code>) so this document renders before/after the files are pushed to GitHub.</p>
<section id="plate-layout" class="level2">
<h2 class="anchored" data-anchor-id="plate-layout">2.1 Plate layout</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">data_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/raw_absorbance"</span></span>
<span id="cb13-2">run_stem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient"</span></span>
<span id="cb13-3"></span>
<span id="cb13-4">layout_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_layout</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb13-5"></span>
<span id="cb13-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout format detected:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(layout_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-8"></span>
<span id="cb13-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- layout_wells: one row per occupied well, with its descriptive label ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(layout_wells)</span></code></pre></div>
<pre><code>Layout format detected: single 
Occupied wells in layout: 48 

--- layout_wells: one row per occupied well, with its descriptive label ---

'data.frame':   48 obs. of  4 variables:
 $ well     : chr  "A1" "A2" "A3" "A4" ...
 $ plate_row: chr  "A" "A" "A" "A" ...
 $ plate_col: int  1 2 3 4 5 6 7 8 9 10 ...
 $ label    : chr  "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_02_ambient-citrate_synthase-17.5-df.0" ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "row_idx" "col_idx"
  ..$ dimnames:List of 2
  .. ..$ row_idx: chr [1:8] "row_idx=2" "row_idx=3" "row_idx=4" "row_idx=5" ...
  .. ..$ col_idx: chr [1:12] "col_idx= 2" "col_idx= 3" "col_idx= 4" "col_idx= 5" ...
 - attr(*, "layout_format")= chr "single"</code></pre>
</section>
<section id="kinetic-readers" class="level2">
<h2 class="anchored" data-anchor-id="kinetic-readers">2.2 Kinetic readers</h2>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_absorbance_csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb15-2">full_report    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_full_report</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full_report-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".txt"</span>)))</span>
<span id="cb15-3"></span>
<span id="cb15-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance CSV : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-5">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full report    : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-7">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-8"></span>
<span id="cb15-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- absorbance_csv: long-format readings from absorbance-*.csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(absorbance_csv)</span>
<span id="cb15-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- full_report: long-format readings from full_report-*.txt ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(full_report)</span></code></pre></div>
<pre><code>absorbance CSV : 48 wells x 11 timepoints
full report    : 48 wells x 11 timepoints

--- absorbance_csv: long-format readings from absorbance-*.csv ---

'data.frame':   528 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.135 0.15 0.165 0.181 0.196 0.212 0.227 0.242 0.255 0.269 ...

--- full_report: long-format readings from full_report-*.txt ---

'data.frame':   528 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.135 0.15 0.165 0.181 0.196 0.212 0.227 0.242 0.255 0.269 ...</code></pre>
</section>
<section id="cross-check-against-the-full-report" class="level2">
<h2 class="anchored" data-anchor-id="cross-check-against-the-full-report">2.3 Cross-check against the full report</h2>
<p><code>absorbance-*.csv</code> is used for every well; <code>full_report-*.txt</code> is used only to confirm the CSV is trustworthy: every well it reports should also be in the CSV, every well the layout expects should be in the CSV, and every reading the two files share should agree exactly.</p>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">recon <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reconcile_kinetic_sources</span>(absorbance_csv, full_report, layout_wells)</span>
<span id="cb17-2">plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_readings</span>
<span id="cb17-3"></span>
<span id="cb17-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in absorbance CSV          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report             :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report not in CSV  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from CSV    :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CSV wells not in layout          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv_not_layout, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shared well x timepoints         :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max |CSV - report| disagreement  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-11"></span>
<span id="cb17-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- recon$overlap_check: per-reading comparison of the two raw files ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>overlap_check)</span>
<span id="cb17-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_readings: readings for all occupied wells, from absorbance_csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_readings)</span></code></pre></div>
<pre><code>Wells in absorbance CSV          : 48 
Wells in full report             : 48 
Wells in full report not in CSV  : 0 
Layout wells missing from CSV    : 0 
CSV wells not in layout          : 0 
Shared well x timepoints         : 528 
Max |CSV - report| disagreement  : 0 

--- recon$overlap_check: per-reading comparison of the two raw files ---

'data.frame':   528 obs. of  5 variables:
 $ well     : chr  "A1" "A1" "A1" "A1" ...
 $ time_min : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od_csv   : num  0.135 0.15 0.165 0.181 0.196 0.212 0.227 0.242 0.255 0.269 ...
 $ od_report: num  0.135 0.15 0.165 0.181 0.196 0.212 0.227 0.242 0.255 0.269 ...
 $ abs_diff : num  0 0 0 0 0 0 0 0 0 0 ...

--- plate_readings: readings for all occupied wells, from absorbance_csv ---

'data.frame':   528 obs. of  4 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.135 0.15 0.165 0.181 0.196 0.212 0.227 0.242 0.255 0.269 ...
 $ source  : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...</code></pre>
<p>This plate’s <code>absorbance-*.csv</code> covers the full 48 occupied wells (24 sample + 18 standard + 3 positive-control + 3 pooled-background, note 3) and the layout carries no spelling typo, so no label fix is needed here.</p>
</section>
<section id="annotate-wells-and-parse-metadata" class="level2">
<h2 class="anchored" data-anchor-id="annotate-wells-and-parse-metadata">2.4 Annotate wells and parse metadata</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate_wells</span>(plate_readings, layout_wells))</span>
<span id="cb19-2"></span>
<span id="cb19-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells per type:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(well, well_type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_wells"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-5">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb19-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards (nmol/well):"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-8"></span>
<span id="cb19-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_long: fully annotated long-format plate, one row per well x timepoint ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_long)</span></code></pre></div>
<pre><code>Wells per type:
        well_type n_wells
       background       3
 positive_control       3
           sample      24
         standard      18

Samples: F05_01_ambient, F05_02_ambient, F05_03_ambient, F05_04_ambient, F05_05_ambient, F05_06_ambient, F05_07_ambient, F05_08_ambient 
Standards (nmol/well): 0, 8, 16, 24, 32, 40 

--- plate_long: fully annotated long-format plate, one row per well x timepoint ---

'data.frame':   528 obs. of  15 variables:
 $ well       : chr  "D10" "D10" "D10" "D10" ...
 $ time_min   : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od         : num  0.064 0.064 0.064 0.065 0.065 0.065 0.066 0.066 0.067 0.067 ...
 $ source     : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ plate_row  : chr  "D" "D" "D" "D" ...
 $ plate_col  : int  10 10 10 10 10 10 10 10 10 10 ...
 $ label      : chr  "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" ...
 $ well_type  : chr  "background" "background" "background" "background" ...
 $ label_clean: chr  "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" ...
 $ sample_id  : chr  NA NA NA NA ...
 $ family     : chr  NA NA NA NA ...
 $ individual : chr  NA NA NA NA ...
 $ temperature: chr  NA NA NA NA ...
 $ weight_mg  : num  NA NA NA NA NA NA NA NA NA NA ...
 $ std_nmol   : num  NA NA NA NA NA NA NA NA NA NA ...</code></pre>
<p><code>annotate_wells()</code> emits a harmless <code>NAs introduced by coercion</code> warning (suppressed above), because its <code>weight_mg</code> parser only applies to <code>sample</code> wells and returns <code>NA</code> for standards/positive control/background by construction (background is a pooled control with no individual weight of its own, note 3). No <code>weight_mg</code> value is actually missing for a sample well; <code>annotate_wells()</code>’s internal <code>stopifnot()</code> would halt otherwise.</p>
</section>
<section id="protein-concentration-normalization-factor" class="level2">
<h2 class="anchored" data-anchor-id="protein-concentration-normalization-factor">2.5 Protein concentration (normalization factor)</h2>
<p>Activity is normalized to total extracted protein rather than tissue weight (note 2). Protein concentration for each sample was measured on a separate BCA/Bradford-style plate (595 nm) and supplied as two CSV exports – the same measurements used for the original 2026-08-11 assay of these homogenates. No <code>Sample</code> string typo needed correction for this plate’s samples.</p>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">protein_files <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb21-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/sample_protein_concentrations_1.csv"</span>,</span>
<span id="cb21-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/sample_protein_concentrations_2.csv"</span></span>
<span id="cb21-4">)</span>
<span id="cb21-5"></span>
<span id="cb21-6">plate_sample_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)))</span>
<span id="cb21-7"></span>
<span id="cb21-8">protein_by_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">load_protein_concentrations</span>(protein_files, plate_sample_ids,</span>
<span id="cb21-9">                                                  assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-11">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb21-12">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb21-13"></span>
<span id="cb21-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples matched to a protein concentration record:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample),</span>
<span id="cb21-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(plate_sample_ids), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein concentration range (ug/mL):"</span>,</span>
<span id="cb21-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_ug_mL), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total protein per homogenate range (mg):"</span>,</span>
<span id="cb21-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, source_file, conc_ug_mL, total_protein_mg) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-21">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb21-22"></span>
<span id="cb21-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_by_sample: matched protein concentration and total protein per homogenate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_by_sample)</span></code></pre></div>
<pre><code>Samples matched to a protein concentration record: 8 / 8 
Protein concentration range (ug/mL): 711.7 - 2703.7 
Total protein per homogenate range (mg): 0.249 - 0.946 

      sample_id                         source_file conc_ug_mL total_protein_mg
 F05_01_ambient sample_protein_concentrations_2.csv      876.1         0.306635
 F05_02_ambient sample_protein_concentrations_2.csv     1038.9         0.363615
 F05_03_ambient sample_protein_concentrations_2.csv     1900.4         0.665140
 F05_04_ambient sample_protein_concentrations_1.csv     1129.4         0.395290
 F05_05_ambient sample_protein_concentrations_1.csv      711.7         0.249095
 F05_06_ambient sample_protein_concentrations_2.csv     2232.4         0.781340
 F05_07_ambient sample_protein_concentrations_1.csv     1687.8         0.590730
 F05_08_ambient sample_protein_concentrations_2.csv     2703.7         0.946295

--- protein_by_sample: matched protein concentration and total protein per homogenate ---

'data.frame':   8 obs. of  7 variables:
 $ sample_id       : chr  "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ source_file     : chr  "sample_protein_concentrations_2.csv" "sample_protein_concentrations_2.csv" "sample_protein_concentrations_2.csv" "sample_protein_concentrations_1.csv" ...
 $ conc_ug_mL      : num  876 1039 1900 1129 712 ...
 $ total_protein_mg: num  0.307 0.364 0.665 0.395 0.249 ...
 $ family          : chr  "F05" "F05" "F05" "F05" ...
 $ individual      : chr  "01" "02" "03" "04" ...
 $ temperature     : chr  "ambient" "ambient" "ambient" "ambient" ...</code></pre>
</section>
</section>
<section id="kinetic-traces" class="level1">
<h1>3 KINETIC TRACES</h1>
<p>Every trace is plotted before any rate is extracted. In this assay the <strong>shape</strong> of the trace is the primary diagnostic: CS activity must produce a monotonically <em>rising</em> A412, and only a genuinely linear stretch may be used for a rate.</p>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">trace_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plate_long, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> plate_row <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> plate_col, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>,</span>
<span id="cb23-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labeller =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row, d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>,</span>
<span id="cb23-8">                                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">positive_control =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6a51a3"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 kinetic traces, all occupied wells"</span>,</span>
<span id="cb23-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dotted line = assumed photometric linearity ceiling (A412 = "</span>,</span>
<span id="cb23-11">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-12">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Rising traces only are usable for rate extraction."</span>),</span>
<span id="cb23-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (min)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb23-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>),</span>
<span id="cb23-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb23-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb23-19"></span>
<span id="cb23-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kinetic_traces_all_wells.png"</span>), trace_plot,</span>
<span id="cb23-21">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb23-22"></span>
<span id="cb23-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- trace_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb23-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(trace_plot)</span>
<span id="cb23-25"></span>
<span id="cb23-26">trace_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient_files/figure-gfm/plot-kinetic-traces-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- trace_plot: ggplot object structure ---

data: well, time_min, od, source, plate_row, plate_col, label,
  well_type, label_clean, sample_id, family, individual, temperature,
  weight_mg, std_nmol [528x15]
mapping:  x = ~time_min, y = ~od, group = ~well, colour = ~well_type
scales:   colour 
faceting:  ~plate_row, ~plate_col 
-----------------------------------
geom_line: na.rm = FALSE, orientation = NA, arrow = NULL, arrow.fill = NULL, lineend = butt, linejoin = round, linemitre = 10
stat_identity: na.rm = FALSE
position_identity 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
<p>Every sample and positive-control trace on this plate rises across the full 20-minute window (replicate-level R<sup>2</sup> &gt; 0.99 for the fitted rate window on every sample well, computed below). The three pooled-background traces (D10-D12) are visibly near-flat and far lower in absolute A412 than any sample well, consistent with a well-behaved background control. This plate shows no elevated-starting-absorbance or contamination signature in any sample well.</p>
</section>
<section id="anomaly-detection" class="level1">
<h1>4 ANOMALY DETECTION</h1>
<section id="per-well-trace-diagnostics" class="level2">
<h2 class="anchored" data-anchor-id="per-well-trace-diagnostics">4.1 Per-well trace diagnostics</h2>
<p>Four independent checks, computed from the raw trace before any rate fitting:</p>
<ol type="1">
<li><strong>Direction</strong> — net A412 change from first to last read. A CS-containing well must be positive.</li>
<li><strong>Monotonicity</strong> — fraction of the 10 read-to-read intervals that rise.</li>
<li><strong>Over-range</strong> — any read above the photometric linearity ceiling.</li>
<li><strong>Discontinuity</strong> — a single read-to-read step that departs from its two <em>neighbouring</em> steps, catching read glitches rather than biology.</li>
</ol>
<p>Two further checks specific to well role: an elevated starting A412 (pre-existing thiol/contamination) for sample wells, and a background well whose trace is not flat (indicating it received Reaction Mix rather than Background Control Mix).</p>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_diagnostics</span>(plate_long, assay_params)</span>
<span id="cb25-2"></span>
<span id="cb25-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Flag counts across all"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">starts_with</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flag_"</span>), sum)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-5">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb25-6"></span>
<span id="cb25-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Wells with at least one flag:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-8"></span>
<span id="cb25-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- well_diagnostics: per-well trace diagnostics and anomaly flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_diagnostics)</span></code></pre></div>
<pre><code>Flag counts across all 48 wells:
 flag_decreasing flag_over_range flag_glitch flag_high_baseline flag_bg_active
              15               0           0                  0              0

Wells with at least one flag: 15 / 48 

--- well_diagnostics: per-well trace diagnostics and anomaly flags ---

tibble [48 × 24] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:48] "A1" "A10" "A11" "A12" ...
 $ plate_row         : chr [1:48] "A" "A" "A" "A" ...
 $ plate_col         : int [1:48] 1 10 11 12 2 3 4 5 6 7 ...
 $ well_type         : chr [1:48] "sample" "sample" "sample" "sample" ...
 $ sample_id         : chr [1:48] "F05_01_ambient" "F05_04_ambient" "F05_04_ambient" "F05_04_ambient" ...
 $ label             : chr [1:48] "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_04_ambient-citrate_synthase-14.0-df.0" "F05_04_ambient-citrate_synthase-14.0-df.0" "F05_04_ambient-citrate_synthase-14.0-df.0" ...
 $ std_nmol          : num [1:48] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:48] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:48] 0.135 0.121 0.12 0.122 0.12 0.119 0.119 0.124 0.119 0.128 ...
 $ od_last           : num [1:48] 0.28 0.293 0.297 0.301 0.268 0.257 0.274 0.285 0.271 0.314 ...
 $ od_max            : num [1:48] 0.28 0.293 0.297 0.301 0.268 0.257 0.274 0.285 0.271 0.314 ...
 $ net_change        : num [1:48] 0.145 0.172 0.177 0.179 0.148 0.138 0.155 0.161 0.152 0.186 ...
 $ frac_rising       : num [1:48] 1 1 1 1 1 1 1 1 1 1 ...
 $ max_step          : num [1:48] 0.016 0.02 0.021 0.021 0.016 ...
 $ typical_step      : num [1:48] 0.015 0.0185 0.0195 0.0195 0.015 ...
 $ step_excess       : num [1:48] -0.003 -0.001 -0.002 -0.003 -0.001 ...
 $ glitch_at_min     : num [1:48] 20 20 20 20 2 2 20 20 2 14 ...
 $ step_ratio        : num [1:48] 1.07 1.08 1.08 1.08 1.07 ...
 $ flag_decreasing   : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range   : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags           : int [1:48] 0 0 0 0 0 0 0 0 0 0 ...</code></pre>
</section>
<section id="anomaly-table" class="level2">
<h2 class="anchored" data-anchor-id="anomaly-table">4.2 Anomaly table</h2>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">anomaly_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, well_type, od_first, net_change, n_flags,</span>
<span id="cb27-4">         flag_decreasing, flag_over_range, flag_glitch,</span>
<span id="cb27-5">         flag_high_baseline, flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(n_flags), well)</span>
<span id="cb27-7"></span>
<span id="cb27-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(anomaly_table, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb27-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells with at least one anomaly flag"</span>)</span>
<span id="cb27-10"></span>
<span id="cb27-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Total flagged wells:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(anomaly_table), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-12"></span>
<span id="cb27-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- anomaly_table: all flagged wells with their specific flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(anomaly_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: left;">well_type</th>
<th style="text-align: right;">od_first</th>
<th style="text-align: right;">net_change</th>
<th style="text-align: right;">n_flags</th>
<th style="text-align: left;">flag_decreasing</th>
<th style="text-align: left;">flag_over_range</th>
<th style="text-align: left;">flag_glitch</th>
<th style="text-align: left;">flag_high_baseline</th>
<th style="text-align: left;">flag_bg_active</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">C10</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.869</td>
<td style="text-align: right;">-0.012</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C11</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.862</td>
<td style="text-align: right;">-0.013</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C12</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.865</td>
<td style="text-align: right;">-0.010</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C4</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.367</td>
<td style="text-align: right;">-0.001</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C5</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.381</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C6</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.380</td>
<td style="text-align: right;">-0.001</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C7</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.634</td>
<td style="text-align: right;">-0.004</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C8</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.634</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C9</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.619</td>
<td style="text-align: right;">-0.001</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D1</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.126</td>
<td style="text-align: right;">-0.019</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D2</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.104</td>
<td style="text-align: right;">-0.014</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D3</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.123</td>
<td style="text-align: right;">-0.016</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D4</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.419</td>
<td style="text-align: right;">-0.025</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D5</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.430</td>
<td style="text-align: right;">-0.030</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D6</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.433</td>
<td style="text-align: right;">-0.029</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
</tbody>
</table>
<p>Wells with at least one anomaly flag</p>
<pre><code>Total flagged wells: 15 / 48 

--- anomaly_table: all flagged wells with their specific flags ---

tibble [15 × 11] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:15] "C10" "C11" "C12" "C4" ...
 $ sample_id         : chr [1:15] NA NA NA NA ...
 $ well_type         : chr [1:15] "standard" "standard" "standard" "standard" ...
 $ od_first          : num [1:15] 0.869 0.862 0.865 0.367 0.381 ...
 $ net_change        : num [1:15] -0.012 -0.013 -0.01 -0.001 0 ...
 $ n_flags           : int [1:15] 1 1 1 1 1 1 1 1 1 1 ...
 $ flag_decreasing   : logi [1:15] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ flag_over_range   : logi [1:15] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:15] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:15] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:15] FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<p>Every flagged well on this plate is a <strong>GSH standard</strong>, and every flag is <code>flag_decreasing</code> – 15 of the 18 standard wells (all five non-zero concentrations: 8, 16, 24, 32, 40 nmol) end at or below their own starting A412 over the 20-minute window, consistent with TNB<sup>2-</sup> signal decay (see GSH STANDARD CURVE below). This is a substantially larger fraction than the 20260814 plate (3/18 standards lost signal there), but because the standard curve is calibrated at t = 0 (not from the endpoint), it does not compromise the calibration (R<sup>2</sup> = 0.9983, no outlier wells). <strong>No sample well, positive-control well, or background well is flagged for anything on this plate</strong> – no read glitches, no elevated baseline, and no background well behaving as an active reaction.</p>
</section>
<section id="background-wells-behaving-as-active-reactions" class="level2">
<h2 class="anchored" data-anchor-id="background-wells-behaving-as-active-reactions">4.3 Background wells behaving as active reactions</h2>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">bg_active_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>, flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, od_first, net_change)</span>
<span id="cb29-4"></span>
<span id="cb29-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(bg_active_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb29-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background wells with a non-flat trace"</span>)</span>
<span id="cb29-7"></span>
<span id="cb29-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background wells behaving as active reactions:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active_wells),</span>
<span id="cb29-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-10"></span>
<span id="cb29-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_active_wells: background wells excluded from the background-rate estimate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_active_wells)</span></code></pre></div>
<dl>
<dt>well sample_id od_first net_change —— ———– ———- ————</dt>
<dd>
<p>Background wells with a non-flat trace</p>
<p>Background wells behaving as active reactions: 0 / 3</p>
<p>— bg_active_wells: background wells excluded from the background-rate estimate —</p>
<p>tibble [0 × 4] (S3: tbl_df/tbl/data.frame) $ well : chr(0) $ sample_id : chr(0) $ od_first : num(0) $ net_change: num(0)</p>
</dd>
</dl>
<p>All three pooled-background replicates (<code>D10</code>, <code>D11</code>, <code>D12</code>) are flat and well-behaved: starting A412 0.055-0.064 (well below the 0.15 threshold) and net change 0.002-0.003 over the full 20 minutes (well below the 0.05 drift threshold). All three are used in the background-rate estimate below.</p>
</section>
<section id="baseline-diagnostic-elevated-starting-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="baseline-diagnostic-elevated-starting-absorbance">4.4 Baseline diagnostic (elevated starting absorbance)</h2>
<div class="sourceCode" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1">bd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_baseline_diagnostics</span>(well_diagnostics, assay_params)</span>
<span id="cb30-2">baseline_check       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_check</span>
<span id="cb30-3">baseline_per_sample  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_per_sample</span>
<span id="cb30-4"></span>
<span id="cb30-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample/background wells with elevated starting A412 (&gt; "</span>,</span>
<span id="cb30-6">    assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"):"</span>,</span>
<span id="cb30-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline_check<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(baseline_check), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb30-8"></span>
<span id="cb30-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(baseline_per_sample, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb30-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Elevated-baseline replicate count per sample"</span>)</span>
<span id="cb30-11"></span>
<span id="cb30-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_check: per-well baseline classification ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_check)</span>
<span id="cb30-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_per_sample: elevated-replicate count per sample ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_per_sample)</span></code></pre></div>
<pre><code>Sample/background wells with elevated starting A412 (&gt; 0.35):0/27</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">n_elevated</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">median_baseline</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.120</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.119</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.128</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.121</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.119</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.133</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.124</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.131</td>
</tr>
</tbody>
</table>
<p>Elevated-baseline replicate count per sample</p>
<pre><code>--- baseline_check: per-well baseline classification ---

tibble [27 × 25] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:27] "B4" "A1" "B10" "B5" ...
 $ plate_row         : chr [1:27] "B" "A" "B" "B" ...
 $ plate_col         : int [1:27] 4 1 10 5 11 6 12 7 8 9 ...
 $ well_type         : chr [1:27] "sample" "sample" "sample" "sample" ...
 $ sample_id         : chr [1:27] "F05_06_ambient" "F05_01_ambient" "F05_08_ambient" "F05_06_ambient" ...
 $ label             : chr [1:27] "F05_06_ambient-citrate_synthase-30.2-df.0" "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_08_ambient-citrate_synthase-30.6-df.0" "F05_06_ambient-citrate_synthase-30.2-df.0" ...
 $ std_nmol          : num [1:27] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:27] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:27] 0.136 0.135 0.135 0.133 0.131 0.131 0.129 0.128 0.128 0.126 ...
 $ od_last           : num [1:27] 0.323 0.28 0.32 0.319 0.317 0.318 0.314 0.314 0.317 0.311 ...
 $ od_max            : num [1:27] 0.323 0.28 0.32 0.319 0.317 0.318 0.314 0.314 0.317 0.311 ...
 $ net_change        : num [1:27] 0.187 0.145 0.185 0.186 0.186 0.187 0.185 0.186 0.189 0.185 ...
 $ frac_rising       : num [1:27] 1 1 1 1 1 1 1 1 1 1 ...
 $ max_step          : num [1:27] 0.028 0.016 0.032 0.028 0.031 0.029 0.032 0.027 0.029 0.029 ...
 $ typical_step      : num [1:27] 0.02 0.015 0.018 0.0195 0.0185 0.0195 0.018 0.0205 0.02 0.0195 ...
 $ step_excess       : num [1:27] -0.002 -0.003 -0.0015 0.001 -0.002 ...
 $ glitch_at_min     : num [1:27] 20 20 14 10 12 8 12 14 2 2 ...
 $ step_ratio        : num [1:27] 1.4 1.07 1.78 1.44 1.68 ...
 $ flag_decreasing   : logi [1:27] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range   : logi [1:27] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:27] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:27] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:27] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags           : int [1:27] 0 0 0 0 0 0 0 0 0 0 ...
 $ baseline          : chr [1:27] "normal" "normal" "normal" "normal" ...

--- baseline_per_sample: elevated-replicate count per sample ---

tibble [8 × 4] (S3: tbl_df/tbl/data.frame)
 $ sample_id      : chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ n_elevated     : int [1:8] 0 0 0 0 0 0 0 0
 $ n              : int [1:8] 3 3 3 3 3 3 3 3
 $ median_baseline: num [1:8] 0.12 0.119 0.128 0.121 0.119 0.133 0.124 0.131</code></pre>
<p>No sample or background well anywhere on this plate starts above A412 0.35 — sample wells all start within a tight 0.118-0.136 range and the pooled background wells start even lower (0.055-0.064), both well below the 0.35 threshold. No sample has any elevated-baseline replicate, and none is disqualified on this basis.</p>
</section>
<section id="plot-starting-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="plot-starting-absorbance">4.5 Plot starting absorbance</h2>
<div class="sourceCode" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1">baseline_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(baseline_check, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(well, od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od_first,</span>
<span id="cb33-2">                                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb33-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb33-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb33-5">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb33-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb33-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Starting A412 (t = 0) for every sample/background well"</span>,</span>
<span id="cb33-8">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dashed line = elevated-baseline threshold (A412 = "</span>,</span>
<span id="cb33-9">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). No well on this plate exceeds it."</span>),</span>
<span id="cb33-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 at t = 0"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb33-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb33-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb33-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb33-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb33-15"></span>
<span id="cb33-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"starting_absorbance.png"</span>), baseline_plot,</span>
<span id="cb33-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb33-18"></span>
<span id="cb33-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- baseline_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb33-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(baseline_plot)</span>
<span id="cb33-21"></span>
<span id="cb33-22">baseline_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient_files/figure-gfm/plot-baseline-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- baseline_plot: ggplot object structure ---

data: well, plate_row, plate_col, well_type, sample_id, label,
  std_nmol, source, od_first, od_last, od_max, net_change, frac_rising,
  max_step, typical_step, step_excess, glitch_at_min, step_ratio,
  flag_decreasing, flag_over_range, flag_glitch, flag_high_baseline,
  flag_bg_active, n_flags, baseline [27x25]
mapping:  x = ~reorder(well, od_first), y = ~od_first, fill = ~well_type
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_col: na.rm = FALSE, just = 0.5, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_stack 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
</section>
<section id="gsh-standard-curve" class="level1">
<h1>5 GSH STANDARD CURVE</h1>
<p>The GSH standard is a <strong>stoichiometric endpoint</strong>, not an enzymatic reaction: free thiol reduces DTNB immediately on mixing. The standard curve is therefore read from a single timepoint, and t = 0 is used because TNB<sup>2-</sup> degrades over the run (quantified below).</p>
<section id="fit-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="fit-the-standard-curve">5.1 Fit the standard curve</h2>
<p>Three candidate fits are compared:</p>
<ul>
<li><strong>all wells</strong> — every standard replicate, no exclusions</li>
<li><strong>concentration means</strong> — the conventional fit, on per-concentration means</li>
<li><strong>outlier-excluded</strong> — replicate-level fit after dropping flagged wells</li>
</ul>
<p>The outlier-excluded fit is used for activity calculation.</p>
<div class="sourceCode" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1">std_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit_standard_curve</span>(plate_long, assay_params)</span>
<span id="cb35-2"></span>
<span id="cb35-3">standards_t0       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_t0</span>
<span id="cb35-4">standard_drift     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb35-5">standard_summary   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb35-6">standards_flagged  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb35-7">fit_all_wells      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells</span>
<span id="cb35-8">fit_comparison     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_comparison</span>
<span id="cb35-9">std_slope          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope</span>
<span id="cb35-10">std_intercept      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_intercept</span>
<span id="cb35-11">std_r2             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2</span>
<span id="cb35-12">std_nmol_max       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol_max</span>
<span id="cb35-13"></span>
<span id="cb35-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_t0), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"at"</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(standards_t0<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol),</span>
<span id="cb35-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentrations</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard drift over 20 min (dA412): median"</span>,</span>
<span id="cb35-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)),</span>
<span id="cb35-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| range"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" to "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards that LOST signal (drift &lt; 0):"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-20"></span>
<span id="cb35-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standard_summary: per-concentration mean/SD/CV of t0 absorbance ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standard_summary)</span>
<span id="cb35-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standard_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb35-24">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve, per-concentration summary at t = 0"</span>)</span>
<span id="cb35-25"></span>
<span id="cb35-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Concentrations exceeding"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"% replicate CV:"</span>,</span>
<span id="cb35-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb35-28">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-29"></span>
<span id="cb35-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standards_flagged: every standard well with its deviation from the triplicate median ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_flagged)</span>
<span id="cb35-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_outlier) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, triplicate_median, deviation),</span>
<span id="cb35-33">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers (|deviation| &gt; 0.15 A412)"</span>)</span>
<span id="cb35-34"></span>
<span id="cb35-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- fit_comparison: slope/intercept/R^2 for all three candidate fits ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(fit_comparison)</span>
<span id="cb35-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># row.names = FALSE: coef() attaches the predictor's name ("std_nmol") to the</span></span>
<span id="cb35-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># slope/intercept elements, which data.frame() otherwise promotes to a mangled</span></span>
<span id="cb35-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># row label (e.g. "std_nmol...1") that breaks pandoc's pipe-table parser.</span></span>
<span id="cb35-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(fit_comparison, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb35-41">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve fit comparison (outlier-excluded fit used downstream)"</span>)</span></code></pre></div>
<pre><code>Standard wells: 18 at 6 concentrations
Standard drift over 20 min (dA412): median -0.007 | range -0.030 to 0.003 
Standards that LOST signal (drift &lt; 0): 13 / 18 

--- standard_summary: per-concentration mean/SD/CV of t0 absorbance ---

tibble [6 × 9] (S3: tbl_df/tbl/data.frame)
 $ std_nmol   : num [1:6] 0 8 16 24 32 40
 $ n          : int [1:6] 3 3 3 3 3 3
 $ mean_od    : num [1:6] 0.108 0.376 0.629 0.865 1.118 ...
 $ sd_od      : num [1:6] 0.00153 0.00781 0.00866 0.00351 0.01193 ...
 $ se_od      : num [1:6] 0.000882 0.004509 0.005 0.002028 0.006888 ...
 $ cv_pct     : num [1:6] 1.41 2.077 1.377 0.406 1.067 ...
 $ median_od  : num [1:6] 0.108 0.38 0.634 0.865 1.123 ...
 $ net_od     : num [1:6] 0 0.268 0.521 0.757 1.009 ...
 $ od_per_nmol: num [1:6] NA 0.0335 0.0325 0.0315 0.0315 ...</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 6%">
<col style="width: 11%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">std_nmol</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">mean_od</th>
<th style="text-align: right;">sd_od</th>
<th style="text-align: right;">se_od</th>
<th style="text-align: right;">cv_pct</th>
<th style="text-align: right;">median_od</th>
<th style="text-align: right;">net_od</th>
<th style="text-align: right;">od_per_nmol</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.108</td>
<td style="text-align: right;">0.0015</td>
<td style="text-align: right;">0.0009</td>
<td style="text-align: right;">1.41</td>
<td style="text-align: right;">0.108</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td style="text-align: right;">8</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.376</td>
<td style="text-align: right;">0.0078</td>
<td style="text-align: right;">0.0045</td>
<td style="text-align: right;">2.08</td>
<td style="text-align: right;">0.380</td>
<td style="text-align: right;">0.268</td>
<td style="text-align: right;">0.0335</td>
</tr>
<tr class="odd">
<td style="text-align: right;">16</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.629</td>
<td style="text-align: right;">0.0087</td>
<td style="text-align: right;">0.0050</td>
<td style="text-align: right;">1.38</td>
<td style="text-align: right;">0.634</td>
<td style="text-align: right;">0.521</td>
<td style="text-align: right;">0.0325</td>
</tr>
<tr class="even">
<td style="text-align: right;">24</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.865</td>
<td style="text-align: right;">0.0035</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">0.41</td>
<td style="text-align: right;">0.865</td>
<td style="text-align: right;">0.757</td>
<td style="text-align: right;">0.0315</td>
</tr>
<tr class="odd">
<td style="text-align: right;">32</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.118</td>
<td style="text-align: right;">0.0119</td>
<td style="text-align: right;">0.0069</td>
<td style="text-align: right;">1.07</td>
<td style="text-align: right;">1.123</td>
<td style="text-align: right;">1.009</td>
<td style="text-align: right;">0.0315</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.427</td>
<td style="text-align: right;">0.0074</td>
<td style="text-align: right;">0.0043</td>
<td style="text-align: right;">0.52</td>
<td style="text-align: right;">1.430</td>
<td style="text-align: right;">1.319</td>
<td style="text-align: right;">0.0330</td>
</tr>
</tbody>
</table>
<p>GSH standard curve, per-concentration summary at t = 0</p>
<pre><code>Concentrations exceeding 15 % replicate CV:  

--- standards_flagged: every standard well with its deviation from the triplicate median ---

tibble [18 × 7] (S3: tbl_df/tbl/data.frame)
 $ well             : chr [1:18] "D2" "C9" "C4" "D4" ...
 $ std_nmol         : num [1:18] 32 16 8 40 24 40 24 32 0 0 ...
 $ od               : num [1:18] 1.104 0.619 0.367 1.419 0.869 ...
 $ source           : chr [1:18] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ triplicate_median: num [1:18] 1.123 0.634 0.38 1.43 0.865 ...
 $ deviation        : num [1:18] -0.019 -0.015 -0.013 -0.011 0.004 ...
 $ is_outlier       : logi [1:18] FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<dl>
<dt>well std_nmol od triplicate_median deviation —— ———- —- ——————- ———–</dt>
<dd>
<p>Standard wells flagged as outliers (|deviation| &gt; 0.15 A412)</p>
<p>— fit_comparison: slope/intercept/R^2 for all three candidate fits —</p>
<p>‘data.frame’: 3 obs. of 5 variables: $ fit : chr “all wells” “concentration means” “outlier-excluded” $ n : int 18 6 18 $ slope : num 0.0323 0.0323 0.0323 $ intercept: num 0.107 0.107 0.107 $ r_squared: num 0.998 0.999 0.998</p>
</dd>
</dl>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">fit</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">slope</th>
<th style="text-align: right;">intercept</th>
<th style="text-align: right;">r_squared</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">all wells</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">0.03234</td>
<td style="text-align: right;">0.1071</td>
<td style="text-align: right;">0.99831</td>
</tr>
<tr class="even">
<td style="text-align: left;">concentration means</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0.03234</td>
<td style="text-align: right;">0.1071</td>
<td style="text-align: right;">0.99851</td>
</tr>
<tr class="odd">
<td style="text-align: left;">outlier-excluded</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">0.03234</td>
<td style="text-align: right;">0.1071</td>
<td style="text-align: right;">0.99831</td>
</tr>
</tbody>
</table>
<p>Standard curve fit comparison (outlier-excluded fit used downstream)</p>
<p><strong>No standard well is flagged as an outlier on this plate</strong> – every concentration’s triplicate CV is under 2.1% (highest: 8 nmol at 2.1%), and no well deviates from its triplicate median by more than the 0.15 A412 threshold. Because there are no outliers to exclude, the “outlier-excluded” and “all wells” fits are identical: slope = 0.03234 A412/nmol, R<sup>2</sup> = 0.9983. <strong>Signal decay is more widespread than on prior plates</strong>, however: 13 of 15 non-zero-concentration standards lose signal strictly (drift &lt; 0) between t = 0 and t = 20 min (the remaining 2 are unchanged to three decimals), and 15 of 18 are flagged <code>flag_decreasing</code> above once ties at exactly zero net change are included. Because the curve is read at t = 0, this decay affects none of the values used for calibration.</p>
</section>
<section id="plot-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="plot-the-standard-curve">5.2 Plot the standard curve</h2>
<div class="sourceCode" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1">std_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(standards_flagged, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> is_outlier), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier),</span>
<span id="cb38-4">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a1d99b"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>),</span>
<span id="cb38-6">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"included"</span>),</span>
<span id="cb38-7">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve (t = 0), family F05 ambient"</span>,</span>
<span id="cb38-9">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outlier-excluded fit: slope = %.5f A412/nmol, R² = %.4f (n = %d)"</span>,</span>
<span id="cb38-10">                          std_slope, std_r2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier))),</span>
<span id="cb38-11">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH (nmol/well)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 at t = 0"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb38-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb38-15"></span>
<span id="cb38-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gsh_standard_curve.png"</span>), std_plot,</span>
<span id="cb38-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb38-18"></span>
<span id="cb38-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- std_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb38-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_plot)</span>
<span id="cb38-21"></span>
<span id="cb38-22">std_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient_files/figure-gfm/plot-standard-curve-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- std_plot: ggplot object structure ---

data: well, std_nmol, od, source, triplicate_median, deviation,
  is_outlier [18x7]
mapping:  x = ~std_nmol, y = ~od
scales:   colour 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: colour = ~is_outlier 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

geom_smooth: na.rm = FALSE, orientation = NA, se = TRUE
stat_smooth: na.rm = FALSE, orientation = NA, se = TRUE, method = lm
position_identity </code></pre>
<p>The top standard (40 nmol) stays comfortably within the photometric linear range here – the highest reading is A412 1.43, below the 1.5 ceiling – so the calibration does not need to be restricted to a reduced concentration range.</p>
</section>
</section>
<section id="rate-extraction" class="level1">
<h1>6 RATE EXTRACTION</h1>
<p>Rates are extracted with a sliding-window approach: for each well, the 5-point (8-minute) window of steepest <em>positive</em> slope is taken as the rate, with its R<sup>2</sup> retained for the usability check.</p>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_rates</span>(plate_long, well_diagnostics, assay_params)</span>
<span id="cb40-2"></span>
<span id="cb40-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- well_rates: extracted rate window per well ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_rates)</span></code></pre></div>
<pre><code>--- well_rates: extracted rate window per well ---

tibble [48 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:48] "A1" "A10" "A11" "A12" ...
 $ well_type             : chr [1:48] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:48] "F05_01_ambient" "F05_04_ambient" "F05_04_ambient" "F05_04_ambient" ...
 $ std_nmol              : num [1:48] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:48] 4 2 0 0 2 2 4 2 2 0 ...
 $ t_end                 : num [1:48] 12 10 8 8 10 10 12 10 10 8 ...
 $ slope_mOD_min         : num [1:48] 7.75 9.9 10.25 10.4 7.85 ...
 $ r2                    : num [1:48] 1 1 1 1 1 ...
 $ max_abs_slope_mOD_min : num [1:48] 7.75 9.9 10.25 10.4 7.85 ...
 $ abs_window_is_negative: logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ net_change            : num [1:48] 0.145 0.172 0.177 0.179 0.148 0.138 0.155 0.161 0.152 0.186 ...
 $ frac_rising           : num [1:48] 1 1 1 1 1 1 1 1 1 1 ...
 $ od_max                : num [1:48] 0.28 0.293 0.297 0.301 0.268 0.257 0.274 0.285 0.271 0.314 ...
 $ flag_decreasing       : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range       : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ glitch_at_min         : num [1:48] 20 20 20 20 2 2 20 20 2 14 ...
 $ flag_bg_active        : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:48] 0 0 0 0 0 0 0 0 0 0 ...
 $ glitch_in_window      : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:48] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<section id="rate-tables-by-well-type" class="level2">
<h2 class="anchored" data-anchor-id="rate-tables-by-well-type">6.1 Rate tables by well type</h2>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1">sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb42-2"></span>
<span id="cb42-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, t_start, t_end, slope_mOD_min, r2, rate_usable),</span>
<span id="cb42-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb42-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Extracted rate window, sample wells"</span>)</span>
<span id="cb42-6"></span>
<span id="cb42-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Sample wells with a usable rate:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_rates), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample rate range (mA412/min):"</span>,</span>
<span id="cb42-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median replicate-level R^2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-11"></span>
<span id="cb42-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_rates: rate-window results restricted to sample wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_rates)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 21%">
<col style="width: 12%">
<col style="width: 9%">
<col style="width: 20%">
<col style="width: 10%">
<col style="width: 17%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">t_start</th>
<th style="text-align: right;">t_end</th>
<th style="text-align: right;">slope_mOD_min</th>
<th style="text-align: right;">r2</th>
<th style="text-align: left;">rate_usable</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A1</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">7.75</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A10</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">9.90</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A11</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">10.25</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A12</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">10.40</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A2</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">7.85</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A3</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">7.20</td>
<td style="text-align: right;">0.9998</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A4</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">8.35</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A5</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">8.90</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A6</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">8.25</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A7</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">13.15</td>
<td style="text-align: right;">0.9997</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A8</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">13.70</td>
<td style="text-align: right;">0.9997</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A9</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">13.60</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B1</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">14</td>
<td style="text-align: right;">5.65</td>
<td style="text-align: right;">0.9998</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B10</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">14.80</td>
<td style="text-align: right;">0.9984</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B11</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">14.60</td>
<td style="text-align: right;">0.9982</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B12</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">14.80</td>
<td style="text-align: right;">0.9984</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B2</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">5.70</td>
<td style="text-align: right;">0.9997</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B3</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">5.50</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B4</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">13.40</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B5</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">13.55</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B6</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">13.90</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B7</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">11.15</td>
<td style="text-align: right;">0.9999</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B8</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">11.45</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B9</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">11.30</td>
<td style="text-align: right;">0.9997</td>
<td style="text-align: left;">TRUE</td>
</tr>
</tbody>
</table>
<p>Extracted rate window, sample wells</p>
<pre><code>Sample wells with a usable rate: 24 / 24 
Sample rate range (mA412/min): 5.50 - 14.80 
Median replicate-level R^2: 0.9997 

--- sample_rates: rate-window results restricted to sample wells ---

tibble [24 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:24] "A1" "A10" "A11" "A12" ...
 $ well_type             : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:24] "F05_01_ambient" "F05_04_ambient" "F05_04_ambient" "F05_04_ambient" ...
 $ std_nmol              : num [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:24] 4 2 0 0 2 2 4 2 2 0 ...
 $ t_end                 : num [1:24] 12 10 8 8 10 10 12 10 10 8 ...
 $ slope_mOD_min         : num [1:24] 7.75 9.9 10.25 10.4 7.85 ...
 $ r2                    : num [1:24] 1 1 1 1 1 ...
 $ max_abs_slope_mOD_min : num [1:24] 7.75 9.9 10.25 10.4 7.85 ...
 $ abs_window_is_negative: logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ net_change            : num [1:24] 0.145 0.172 0.177 0.179 0.148 0.138 0.155 0.161 0.152 0.186 ...
 $ frac_rising           : num [1:24] 1 1 1 1 1 1 1 1 1 1 ...
 $ od_max                : num [1:24] 0.28 0.293 0.297 0.301 0.268 0.257 0.274 0.285 0.271 0.314 ...
 $ flag_decreasing       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ glitch_at_min         : num [1:24] 20 20 20 20 2 2 20 20 2 14 ...
 $ flag_bg_active        : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
 $ glitch_in_window      : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:24] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<p>Every one of the 24 sample wells clears the R<sup>2</sup> &gt;= 0.80 and positive-net-change usability bar; every replicate-level R<sup>2</sup> exceeds 0.998 (median 0.9997). No well needed to be excluded from rate extraction on this plate – a direct consequence of the clean, monotonically-rising traces noted above. Sample rates range 5.50-14.80 mA412/min, a considerably wider spread than the raw rates seen on this same family’s 36 °C plate, reflecting real inter-individual variation among these ambient-temperature homogenates (see CITRATE SYNTHASE ACTIVITY below).</p>
</section>
<section id="positive-control" class="level2">
<h2 class="anchored" data-anchor-id="positive-control">6.2 Positive control</h2>
<div class="sourceCode" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1">pos_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_positive_control</span>(well_rates, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope, assay_params)</span>
<span id="cb44-2"></span>
<span id="cb44-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(pos_control <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, t_start, t_end, slope_mOD_min, r2, net_change, activity_mU_uL),</span>
<span id="cb44-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb44-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control replicates"</span>)</span>
<span id="cb44-6"></span>
<span id="cb44-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control mean rate:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control CV:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>,</span>
<span id="cb44-9">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All replicates rising and linear (R^2 &gt; 0.99):"</span>,</span>
<span id="cb44-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-12"></span>
<span id="cb44-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- pos_control: positive control rate and R^2 per replicate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(pos_control)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 12%">
<col style="width: 9%">
<col style="width: 20%">
<col style="width: 10%">
<col style="width: 16%">
<col style="width: 21%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: right;">t_start</th>
<th style="text-align: right;">t_end</th>
<th style="text-align: right;">slope_mOD_min</th>
<th style="text-align: right;">r2</th>
<th style="text-align: right;">net_change</th>
<th style="text-align: right;">activity_mU_uL</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">D7</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.00</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: right;">0.036</td>
<td style="text-align: right;">0.0309</td>
</tr>
<tr class="even">
<td style="text-align: left;">D8</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">2.95</td>
<td style="text-align: right;">0.9968</td>
<td style="text-align: right;">0.057</td>
<td style="text-align: right;">0.0456</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D9</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">3.15</td>
<td style="text-align: right;">0.9992</td>
<td style="text-align: right;">0.059</td>
<td style="text-align: right;">0.0487</td>
</tr>
</tbody>
</table>
<p>Positive control replicates</p>
<pre><code>Positive control mean rate: 2.700 mA412/min
Positive control CV: 22.8 %
All replicates rising and linear (R^2 &gt; 0.99): TRUE 

--- pos_control: positive control rate and R^2 per replicate ---

tibble [3 × 22] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:3] "D7" "D8" "D9"
 $ well_type             : chr [1:3] "positive_control" "positive_control" "positive_control"
 $ sample_id             : chr [1:3] NA NA NA
 $ std_nmol              : num [1:3] NA NA NA
 $ t_start               : num [1:3] 12 10 12
 $ t_end                 : num [1:3] 20 18 20
 $ slope_mOD_min         : num [1:3] 2 2.95 3.15
 $ r2                    : num [1:3] 1 0.997 0.999
 $ max_abs_slope_mOD_min : num [1:3] 2 2.95 3.15
 $ abs_window_is_negative: logi [1:3] FALSE FALSE FALSE
 $ net_change            : num [1:3] 0.036 0.057 0.059
 $ frac_rising           : num [1:3] 1 1 1
 $ od_max                : num [1:3] 0.202 0.317 0.34
 $ flag_decreasing       : logi [1:3] FALSE FALSE FALSE
 $ flag_over_range       : logi [1:3] FALSE FALSE FALSE
 $ flag_glitch           : logi [1:3] FALSE FALSE FALSE
 $ glitch_at_min         : num [1:3] 2 2 2
 $ flag_bg_active        : logi [1:3] FALSE FALSE FALSE
 $ n_flags               : int [1:3] 0 0 0
 $ glitch_in_window      : logi [1:3] FALSE FALSE FALSE
 $ rate_usable           : logi [1:3] TRUE TRUE TRUE
 $ activity_mU_uL        : num [1:3] 0.0309 0.0456 0.0487</code></pre>
<p>The positive control rose linearly in all three replicates (R<sup>2</sup> 0.997-1.000), confirming that the core reaction chemistry and reader were functioning. Its <strong>replicate-to-replicate precision is notably worse than on prior plates</strong>, though: <code>D7</code> rose at only 2.00 mA412/min versus 2.95 and 3.15 mA412/min for <code>D8</code>/<code>D9</code>, a 22.8% CV across the triplicate (well above the 15% technical-CV threshold applied to samples). Because the positive control is a validity check on assay chemistry, not an input to any sample’s activity calculation, this does not affect the results table below – but it is flagged again in the SUMMARY as a caution for future plates.</p>
</section>
</section>
<section id="background-correction" class="level1">
<h1>7 BACKGROUND CORRECTION</h1>
<p>Unlike the 2026-08-11 and 2026-08-14 plates, which paired each sample with its own triplicate background control, this plate uses a <strong>single pooled background control</strong> (note 3): the background rate is estimated once, from the flat (well-behaved) replicates of the <code>BG-citrate_synthase</code> triplicate, and the same corrected rate is subtracted from every sample.</p>
<div class="sourceCode" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1">background_correction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_background_correction</span>(well_rates)</span>
<span id="cb46-2"></span>
<span id="cb46-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pooled background rate (flat wells only):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(background_correction, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb46-5"></span>
<span id="cb46-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Background rate used for correction:"</span>,</span>
<span id="cb46-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min (from"</span>,</span>
<span id="cb46-8">    background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_bg_flat, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_bg_total, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"replicates)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median sample rate:"</span>,</span>
<span id="cb46-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background as % of median sample signal:"</span>,</span>
<span id="cb46-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb46-13">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-14"></span>
<span id="cb46-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- background_correction: pooled background rate estimate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(background_correction)</span></code></pre></div>
<pre><code>Pooled background rate (flat wells only):
 n_bg_total n_bg_flat bg_rate_flat bg_rate_all
          3         3        0.233       0.233

Background rate used for correction: 0.233 mA412/min (from 3 of 3 replicates)
Median sample rate: 10.78 mA412/min
Background as % of median sample signal: 2.2 %

--- background_correction: pooled background rate estimate ---

'data.frame':   1 obs. of  4 variables:
 $ n_bg_total  : int 3
 $ n_bg_flat   : int 3
 $ bg_rate_flat: num 0.233
 $ bg_rate_all : num 0.233</code></pre>
<p>All three background replicates are flat and are used in the estimate (0.233 mA412/min), a much smaller fraction of the sample signal (~2.2%) than the paired per-sample backgrounds on the 36 °C plate (~7%) – a consequence of the pooled background containing only 2 µL of a 1-in-8 pooled homogenate per well, rather than the full undiluted 2 µL of a single sample’s own homogenate.</p>
<section id="background-significance-test" class="level2">
<h2 class="anchored" data-anchor-id="background-significance-test">7.1 Background significance test</h2>
<p>The flat/active threshold classification above is backed by an explicit significance test: a Welch two-sample t-test of well-level rate (background vs.&nbsp;sample), plus an ANOVA on the OD trajectory over time. This mirrors the one-time background ANOVA validation done by Cattau et al.&nbsp;(2023) on the legacy version of this assay.</p>
<div class="sourceCode" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1">bg_sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb48-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))</span>
<span id="cb48-3"></span>
<span id="cb48-4">bg_significance_test <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t.test</span>(slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> bg_sample_rates)</span>
<span id="cb48-5"></span>
<span id="cb48-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- Welch two-sample t-test: well-level rate (background vs. sample) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_significance_test)</span>
<span id="cb48-8"></span>
<span id="cb48-9">bg_trend_anova <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> time_min,</span>
<span id="cb48-10">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))))</span>
<span id="cb48-11"></span>
<span id="cb48-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_trend_anova)</span>
<span id="cb48-14"></span>
<span id="cb48-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation: mean background-well rate is"</span>,</span>
<span id="cb48-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group background"</span>])),</span>
<span id="cb48-17">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min vs."</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group sample"</span>])),</span>
<span id="cb48-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min for sample wells (p ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format.pval</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb48-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Background wells are statistically distinct from, and far slower</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb48-20">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"than, reaction wells on this plate -- consistent with the pooled</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb48-21">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flat/active classification above.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-22"></span>
<span id="cb48-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_significance_test: Welch t-test result object ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_significance_test)</span>
<span id="cb48-25"></span>
<span id="cb48-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_trend_anova)</span></code></pre></div>
<pre><code>--- Welch two-sample t-test: well-level rate (background vs. sample) ---


    Welch Two Sample t-test

data:  slope_mOD_min by well_type
t = -16.416, df = 23.032, p-value = 3.317e-14
alternative hypothesis: true difference in means between group background and group sample is not equal to 0
95 percent confidence interval:
 -11.705749  -9.085918
sample estimates:
mean in group background     mean in group sample 
               0.2333333               10.6291667 


--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---

Analysis of Variance Table

Response: od
                    Df  Sum Sq Mean Sq F value    Pr(&gt;F)    
well_type            1 0.72937 0.72937 1026.15 &lt; 2.2e-16 ***
time_min             1 0.66510 0.66510  935.74 &lt; 2.2e-16 ***
well_type:time_min   1 0.07971 0.07971  112.14 &lt; 2.2e-16 ***
Residuals          293 0.20826 0.00071                      
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Interpretation: mean background-well rate is 0.23 mA412/min vs. 10.63 mA412/min for sample wells (p = 3.32e-14 ). Background wells are statistically distinct from, and far slower
 than, reaction wells on this plate -- consistent with the pooled
 flat/active classification above.

--- bg_significance_test: Welch t-test result object ---

List of 10
 $ statistic  : Named num -16.4
  ..- attr(*, "names")= chr "t"
 $ parameter  : Named num 23
  ..- attr(*, "names")= chr "df"
 $ p.value    : num 3.32e-14
 $ conf.int   : num [1:2] -11.71 -9.09
  ..- attr(*, "conf.level")= num 0.95
 $ estimate   : Named num [1:2] 0.233 10.629
  ..- attr(*, "names")= chr [1:2] "mean in group background" "mean in group sample"
 $ null.value : Named num 0
  ..- attr(*, "names")= chr "difference in means between group background and group sample"
 $ stderr     : num 0.633
 $ alternative: chr "two.sided"
 $ method     : chr "Welch Two Sample t-test"
 $ data.name  : chr "slope_mOD_min by well_type"
 - attr(*, "class")= chr "htest"

--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---

Classes 'anova' and 'data.frame':   4 obs. of  5 variables:
 $ Df     : int  1 1 1 293
 $ Sum Sq : num  0.7294 0.6651 0.0797 0.2083
 $ Mean Sq: num  0.729366 0.665104 0.079706 0.000711
 $ F value: num  1026 936 112 NA
 $ Pr(&gt;F) : num  9.90e-98 3.29e-93 2.12e-22 NA
 - attr(*, "heading")= chr [1:2] "Analysis of Variance Table\n" "Response: od"</code></pre>
</section>
</section>
<section id="technical-replicate-precision" class="level1">
<h1>8 TECHNICAL REPLICATE PRECISION</h1>
<p>Coefficient of variation across the three technical replicates of each sample, computed on the extracted rate. Both <strong>all</strong> and <strong>usable replicates only</strong> are reported; here they are identical for every sample because no replicate was excluded.</p>
<div class="sourceCode" id="cb50" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1">cv_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_replicate_cv</span>(well_rates, protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, assay_params)</span>
<span id="cb50-2"></span>
<span id="cb50-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all,</span>
<span id="cb50-4">                            n_usable, mean_usable, sd_usable, cv_usable,</span>
<span id="cb50-5">                            excluded_wells),</span>
<span id="cb50-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb50-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>,</span>
<span id="cb50-8">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Excluded wells"</span>),</span>
<span id="cb50-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate CV of the extracted rate (mA412/min), "</span>,</span>
<span id="cb50-10">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all replicates vs. usable replicates only"</span>))</span>
<span id="cb50-11"></span>
<span id="cb50-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb50-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on ALL replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-15">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-16">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb50-17"></span>
<span id="cb50-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb50-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on USABLE replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-21">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_usable, mean_usable, sd_usable, cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-22">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb50-23"></span>
<span id="cb50-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb50-25"></span>
<span id="cb50-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cv_summary: per-sample technical replicate CV, both variants ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cv_summary)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th style="text-align: right;">CV (%)</th>
<th>n usable</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th style="text-align: right;">CV (%)</th>
<th style="text-align: left;">Excluded wells</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.60</td>
<td style="text-align: right;">0.35</td>
<td style="text-align: right;">4.6</td>
<td>3</td>
<td style="text-align: right;">7.60</td>
<td style="text-align: right;">0.35</td>
<td style="text-align: right;">4.6</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">0.35</td>
<td style="text-align: right;">4.1</td>
<td>3</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">0.35</td>
<td style="text-align: right;">4.1</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">13.48</td>
<td style="text-align: right;">0.29</td>
<td style="text-align: right;">2.2</td>
<td>3</td>
<td style="text-align: right;">13.48</td>
<td style="text-align: right;">0.29</td>
<td style="text-align: right;">2.2</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">10.18</td>
<td style="text-align: right;">0.26</td>
<td style="text-align: right;">2.5</td>
<td>3</td>
<td style="text-align: right;">10.18</td>
<td style="text-align: right;">0.26</td>
<td style="text-align: right;">2.5</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">5.62</td>
<td style="text-align: right;">0.10</td>
<td style="text-align: right;">1.9</td>
<td>3</td>
<td style="text-align: right;">5.62</td>
<td style="text-align: right;">0.10</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">13.62</td>
<td style="text-align: right;">0.26</td>
<td style="text-align: right;">1.9</td>
<td>3</td>
<td style="text-align: right;">13.62</td>
<td style="text-align: right;">0.26</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">11.30</td>
<td style="text-align: right;">0.15</td>
<td style="text-align: right;">1.3</td>
<td>3</td>
<td style="text-align: right;">11.30</td>
<td style="text-align: right;">0.15</td>
<td style="text-align: right;">1.3</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">14.73</td>
<td style="text-align: right;">0.12</td>
<td style="text-align: right;">0.8</td>
<td>3</td>
<td style="text-align: right;">14.73</td>
<td style="text-align: right;">0.12</td>
<td style="text-align: right;">0.8</td>
<td style="text-align: left;">-</td>
</tr>
</tbody>
</table>
<p>Technical replicate CV of the extracted rate (mA412/min), all replicates vs.&nbsp;usable replicates only</p>
<pre><code>Samples exceeding CV 15% on ALL replicates: 0 / 8 
[1] sample_id n_all     mean_all  sd_all    cv_all   
&lt;0 rows&gt; (or 0-length row.names)

Samples exceeding CV 15% on USABLE replicates: 0 
[1] sample_id   n_usable    mean_usable sd_usable   cv_usable  
&lt;0 rows&gt; (or 0-length row.names)

--- cv_summary: per-sample technical replicate CV, both variants ---

'data.frame':   8 obs. of  12 variables:
 $ sample_id      : chr  "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ n_all          : int  3 3 3 3 3 3 3 3
 $ mean_all       : num  7.6 8.5 13.48 10.18 5.62 ...
 $ sd_all         : num  0.35 0.35 0.293 0.257 0.104 ...
 $ cv_all         : num  4.61 4.12 2.17 2.52 1.85 ...
 $ n_usable       : int  3 3 3 3 3 3 3 3
 $ mean_usable    : num  7.6 8.5 13.48 10.18 5.62 ...
 $ sd_usable      : num  0.35 0.35 0.293 0.257 0.104 ...
 $ cv_usable      : num  4.61 4.12 2.17 2.52 1.85 ...
 $ excluded_wells : Named chr  "-" "-" "-" "-" ...
  ..- attr(*, "names")= chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ fails_cv_all   : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ fails_cv_usable: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<p><strong>No sample exceeds the 15% CV threshold on this plate.</strong> The highest is <code>F05_01_ambient</code> at 4.6%; the lowest is <code>F05_08_ambient</code> at 0.8%, and every sample falls in the 0.8-4.6% range – tighter than the positive control’s own 22.8% CV noted above.</p>
<section id="plot-replicate-spread" class="level2">
<h2 class="anchored" data-anchor-id="plot-replicate-spread">8.1 Plot replicate spread</h2>
<div class="sourceCode" id="cb52" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb52-1">cv_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb52-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb52-3"></span>
<span id="cb52-4">cv_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(cv_plot_data, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> slope_mOD_min)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> rate_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> rate_usable),</span>
<span id="cb52-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fun =</span> mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"crossbar"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb52-8">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb52-10">                                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV %.0f%%"</span>, cv_all)),</span>
<span id="cb52-11">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb52-12">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>),</span>
<span id="cb52-14">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb52-16">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate spread in extracted rate"</span>,</span>
<span id="cb52-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Crossbar = mean of all three replicates; CV computed on all three. "</span>,</span>
<span id="cb52-19">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Threshold "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%."</span>),</span>
<span id="cb52-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate (mA412/min)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb52-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb52-23">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb52-24"></span>
<span id="cb52-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.png"</span>), cv_plot,</span>
<span id="cb52-26">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb52-27"></span>
<span id="cb52-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cv_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb52-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(cv_plot)</span>
<span id="cb52-30"></span>
<span id="cb52-31">cv_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient_files/figure-gfm/plot-replicate-cv-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- cv_plot: ggplot object structure ---

data: well, well_type, sample_id, std_nmol, t_start, t_end,
  slope_mOD_min, r2, max_abs_slope_mOD_min, abs_window_is_negative,
  net_change, frac_rising, od_max, flag_decreasing, flag_over_range,
  flag_glitch, glitch_at_min, flag_bg_active, n_flags,
  glitch_in_window, rate_usable, cv_all [24x22]
mapping:  x = ~sample_id, y = ~slope_mOD_min
scales:   colour, shape 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: colour = ~rate_usable, shape = ~rate_usable 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_jitter 

geom_crossbar: na.rm = FALSE, orientation = NA, width = 0.5
stat_summary: fun.data = NULL, fun = function (x, ...) 
UseMethod("mean"), fun.max = NULL, fun.min = NULL, fun.args = list(), na.rm = FALSE, orientation = NA
position_identity 

mapping: x = ~sample_id, y = Inf, label = ~sprintf("CV %.0f%%", cv_all) 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge </code></pre>
</section>
</section>
<section id="citrate-synthase-activity" class="level1">
<h1>9 CITRATE SYNTHASE ACTIVITY</h1>
<section id="calculation" class="level2">
<h2 class="anchored" data-anchor-id="calculation">9.1 Calculation</h2>
<p>Following Abcam Section 10.3:</p>
<p><code>Sample CS activity = B / (dT x V) x D</code> nmol/min/µL (= mU/µL)</p>
<ol type="1">
<li><strong>Rate</strong> (A412/min) = max-increasing sliding-window slope / 1000</li>
<li><strong>Background-corrected rate</strong> = sample rate - the single pooled background rate (note 3), applied identically to every sample</li>
<li><strong>B/dT</strong> (nmol/min) = background-corrected rate / standard curve slope (0.03234 A412 per nmol, from the outlier-excluded fit)</li>
<li><strong>Activity</strong> (mU/µL) = (B/dT) / <em>V</em> x <em>D</em>, with <em>V</em> = 2 µL and <em>D</em> = 1</li>
<li><strong>Protein-normalized</strong> (mU/mg protein) = activity x <code>homogenate_volume_uL</code> (350 µL, measured) / total protein (mg)</li>
</ol>
<div class="sourceCode" id="cb54" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb54-1">cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calculate_cs_activity</span>(well_rates, protein_by_sample, background_correction,</span>
<span id="cb54-2">                                      std_slope, std_nmol_max, assay_params, plate_long)</span>
<span id="cb54-3"></span>
<span id="cb54-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with a computed activity:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cs_activity), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb54-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/uL):"</span>,</span>
<span id="cb54-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb54-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/mg protein):"</span>,</span>
<span id="cb54-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb54-9"></span>
<span id="cb54-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cs_activity: per-sample citrate synthase activity ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb54-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cs_activity)</span></code></pre></div>
<pre><code>Samples with a computed activity: 8 / 8 
Activity range (mU/uL): 0.0832 - 0.2242 
Activity range (mU/mg protein): 82.906 - 136.192 

--- cs_activity: per-sample citrate synthase activity ---

tibble [8 × 19] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ n_reps_used               : int [1:8] 3 3 3 3 3 3 3 3
 $ mean_rate_mOD_min         : num [1:8] 7.6 8.5 13.48 10.18 5.62 ...
 $ sd_rate                   : num [1:8] 0.35 0.35 0.293 0.257 0.104 ...
 $ cv_rate                   : num [1:8] 4.61 4.12 2.17 2.52 1.85 ...
 $ family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ individual                : chr [1:8] "01" "02" "03" "04" ...
 $ temperature               : chr [1:8] "ambient" "ambient" "ambient" "ambient" ...
 $ conc_ug_mL                : num [1:8] 876 1039 1900 1129 712 ...
 $ total_protein_mg          : num [1:8] 0.307 0.364 0.665 0.395 0.249 ...
 $ bg_rate_mOD_min           : num [1:8] 0.233 0.233 0.233 0.233 0.233 ...
 $ corrected_mOD_min         : num [1:8] 7.37 8.27 13.25 9.95 5.38 ...
 $ rate_OD_min               : num [1:8] 0.00737 0.00827 0.01325 0.00995 0.00538 ...
 $ nmol_per_min              : num [1:8] 0.228 0.256 0.41 0.308 0.166 ...
 $ activity_mU_per_uL        : num [1:8] 0.1139 0.1278 0.2048 0.1538 0.0832 ...
 $ total_mU_in_homogenate    : num [1:8] 39.9 44.7 71.7 53.8 29.1 ...
 $ activity_mU_per_mg_protein: num [1:8] 130 123 108 136 117 ...
 $ nmol_in_window            : num [1:8] 4.56 5.11 8.19 6.15 3.33 ...
 $ within_std_range          : logi [1:8] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
</section>
<section id="results-table" class="level2">
<h2 class="anchored" data-anchor-id="results-table">9.2 Results table</h2>
<div class="sourceCode" id="cb56" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb56-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_results_table</span>(cs_activity, cv_summary, baseline_per_sample, assay_params)</span>
<span id="cb56-2"></span>
<span id="cb56-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table,</span>
<span id="cb56-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, family F05 ambient (mU/mg protein uses "</span>,</span>
<span id="cb56-5">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"measured protein concentration x the "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb56-6">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume)"</span>))</span>
<span id="cb56-7"></span>
<span id="cb56-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation summary:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(results_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(Interpretation, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_samples"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb56-10">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb56-11"></span>
<span id="cb56-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_results.csv"</span>),</span>
<span id="cb56-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb56-14"></span>
<span id="cb56-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- results_table: formatted per-sample results written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(results_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">Protein conc (ug/mL)</th>
<th style="text-align: right;">Total protein (mg)</th>
<th style="text-align: left;">Reps used</th>
<th>CV all reps (%)</th>
<th style="text-align: right;">CV used reps (%)</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">BG rate (mA412/min)</th>
<th style="text-align: right;">Corrected rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/uL)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th style="text-align: left;">CV flag</th>
<th style="text-align: left;">Elevated baseline reps</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">876.1</td>
<td style="text-align: right;">0.307</td>
<td style="text-align: left;">3/3</td>
<td>4.6</td>
<td style="text-align: right;">4.6</td>
<td style="text-align: right;">7.60</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">7.37</td>
<td style="text-align: right;">0.1139</td>
<td style="text-align: right;">129.985</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1038.9</td>
<td style="text-align: right;">0.364</td>
<td style="text-align: left;">3/3</td>
<td>4.1</td>
<td style="text-align: right;">4.1</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">8.27</td>
<td style="text-align: right;">0.1278</td>
<td style="text-align: right;">123.008</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1900.4</td>
<td style="text-align: right;">0.665</td>
<td style="text-align: left;">3/3</td>
<td>2.2</td>
<td style="text-align: right;">2.2</td>
<td style="text-align: right;">13.48</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">13.25</td>
<td style="text-align: right;">0.2048</td>
<td style="text-align: right;">107.782</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1129.4</td>
<td style="text-align: right;">0.395</td>
<td style="text-align: left;">3/3</td>
<td>2.5</td>
<td style="text-align: right;">2.5</td>
<td style="text-align: right;">10.18</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">9.95</td>
<td style="text-align: right;">0.1538</td>
<td style="text-align: right;">136.192</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">711.7</td>
<td style="text-align: right;">0.249</td>
<td style="text-align: left;">3/3</td>
<td>1.9</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: right;">5.62</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">5.38</td>
<td style="text-align: right;">0.0832</td>
<td style="text-align: right;">116.931</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">2232.4</td>
<td style="text-align: right;">0.781</td>
<td style="text-align: left;">3/3</td>
<td>1.9</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: right;">13.62</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">13.38</td>
<td style="text-align: right;">0.2069</td>
<td style="text-align: right;">92.676</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1687.8</td>
<td style="text-align: right;">0.591</td>
<td style="text-align: left;">3/3</td>
<td>1.3</td>
<td style="text-align: right;">1.3</td>
<td style="text-align: right;">11.30</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">11.07</td>
<td style="text-align: right;">0.1711</td>
<td style="text-align: right;">101.361</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">2703.7</td>
<td style="text-align: right;">0.946</td>
<td style="text-align: left;">3/3</td>
<td>0.8</td>
<td style="text-align: right;">0.8</td>
<td style="text-align: right;">14.73</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">14.50</td>
<td style="text-align: right;">0.2242</td>
<td style="text-align: right;">82.906</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>Citrate synthase activity, family F05 ambient (mU/mg protein uses measured protein concentration x the 350 uL homogenization volume)</p>
<pre><code>Interpretation summary:
 Interpretation n_samples
         usable         8

--- results_table: formatted per-sample results written to CSV ---

tibble [8 × 17] (S3: tbl_df/tbl/data.frame)
 $ Sample                    : chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ Family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ Individual                : chr [1:8] "01" "02" "03" "04" ...
 $ Temperature               : chr [1:8] "ambient" "ambient" "ambient" "ambient" ...
 $ Protein conc (ug/mL)      : num [1:8] 876 1039 1900 1129 712 ...
 $ Total protein (mg)        : num [1:8] 0.307 0.364 0.665 0.395 0.249 0.781 0.591 0.946
 $ Reps used                 : chr [1:8] "3/3" "3/3" "3/3" "3/3" ...
 $ CV all reps (%)           : num [1:8] 4.6 4.1 2.2 2.5 1.9 1.9 1.3 0.8
 $ CV used reps (%)          : num [1:8] 4.6 4.1 2.2 2.5 1.9 1.9 1.3 0.8
 $ Rate (mA412/min)          : num [1:8] 7.6 8.5 13.48 10.18 5.62 ...
 $ BG rate (mA412/min)       : num [1:8] 0.233 0.233 0.233 0.233 0.233 0.233 0.233 0.233
 $ Corrected rate (mA412/min): num [1:8] 7.37 8.27 13.25 9.95 5.38 ...
 $ Activity (mU/uL)          : num [1:8] 0.1139 0.1278 0.2048 0.1538 0.0832 ...
 $ Activity (mU/mg protein)  : num [1:8] 130 123 108 136 117 ...
 $ CV flag                   : chr [1:8] "pass" "pass" "pass" "pass" ...
 $ Elevated baseline reps    : chr [1:8] "0/3" "0/3" "0/3" "0/3" ...
 $ Interpretation            : chr [1:8] "usable" "usable" "usable" "usable" ...</code></pre>
<p>All eight samples are usable on this plate – no CV flag, no elevated baseline replicate.</p>
</section>
<section id="plot-activity" class="level2">
<h2 class="anchored" data-anchor-id="plot-activity">9.3 Plot activity</h2>
<div class="sourceCode" id="cb58" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb58-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Three-level quality scheme, kept for consistency with other plate</span></span>
<span id="cb58-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># documents even though no sample here falls in the flagged categories.</span></span>
<span id="cb58-3">qual_levels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clean"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV &gt; "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb58-4">                 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all reps baseline-compromised"</span>)</span>
<span id="cb58-5">qual_cols   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey60"</span>), qual_levels)</span>
<span id="cb58-6"></span>
<span id="cb58-7">activity_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated, n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_flag =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb58-11">                            n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n                              <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb58-12">                            cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct       <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb58-13">                            <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                                        <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb58-14">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> qual_levels),</span>
<span id="cb58-15">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3 reps"</span>,</span>
<span id="cb58-16">                          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - DISQUALIFIED"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)))</span>
<span id="cb58-17"></span>
<span id="cb58-18">activity_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb58-19">                        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(sample_id, activity_mU_per_uL),</span>
<span id="cb58-20">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_uL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> cv_flag)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> label_n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">clip =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"off"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand_limits</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, M. gigas ctenidia, family F05 ambient"</span>,</span>
<span id="cb58-27">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background-corrected, mean of all three technical replicates (all usable on this plate)."</span>,</span>
<span id="cb58-28">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/uL homogenate)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb58-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb58-31">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb58-32"></span>
<span id="cb58-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity.png"</span>), activity_plot,</span>
<span id="cb58-34">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb58-35"></span>
<span id="cb58-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- activity_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb58-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(activity_plot)</span>
<span id="cb58-38"></span>
<span id="cb58-39">activity_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient_files/figure-gfm/plot-activity-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- activity_plot: ggplot object structure ---

data: sample_id, n_reps_used, mean_rate_mOD_min, sd_rate, cv_rate,
  family, individual, temperature, conc_ug_mL, total_protein_mg,
  bg_rate_mOD_min, corrected_mOD_min, rate_OD_min, nmol_per_min,
  activity_mU_per_uL, total_mU_in_homogenate,
  activity_mU_per_mg_protein, nmol_in_window, within_std_range, cv_all,
  n_elevated, n, cv_flag, label_n [8x24]
mapping:  x = ~reorder(sample_id, activity_mU_per_uL), y = ~activity_mU_per_uL, fill = ~cv_flag
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_col: na.rm = FALSE, just = 0.5, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_stack 

mapping: label = ~label_n 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge 

mapping: y = ~y 
geom_blank: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
<p>Raw activity (mU/µL) spans a real 2.7-fold range across the eight individuals – 0.0832 (<code>F05_05_ambient</code>) to 0.2242 (<code>F05_08_ambient</code>) – against a technical CV of under 5% for any single sample, so this spread reflects genuine plate-to-plate biological/extraction variation rather than measurement noise.</p>
</section>
<section id="protein-normalized-activity" class="level2">
<h2 class="anchored" data-anchor-id="protein-normalized-activity">9.4 Protein-normalized activity</h2>
<div class="sourceCode" id="cb60" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb60-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># All eight samples are clean on this plate, so the trend fit uses all of them.</span></span>
<span id="cb60-2">norm_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> activity_plot_data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_flag <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb60-3"></span>
<span id="cb60-4">norm_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb60-5">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> total_protein_mg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_mg_protein)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> norm_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb60-7">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey35"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey85"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> cv_flag), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> individual), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein-normalized CS activity vs. total extracted protein"</span>,</span>
<span id="cb60-12">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Point labels = individual ID. Total protein = measured protein "</span>,</span>
<span id="cb60-13">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration x the same</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb60-14">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume used for every sample. Grey line = fit to "</span>,</span>
<span id="cb60-15">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all 8</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">samples (all clean on this plate); a positive raw-rate/protein "</span>,</span>
<span id="cb60-16">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"relationship would suggest</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">normalization is correcting for real "</span>,</span>
<span id="cb60-17">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"extraction-efficiency differences rather than introducing an artifact."</span>),</span>
<span id="cb60-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total extracted protein (mg)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/mg protein)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb60-21">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb60-22"></span>
<span id="cb60-23">protein_trend <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb60-24">protein_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb60-25">uL_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)</span>
<span id="cb60-26"></span>
<span id="cb60-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_normalized.png"</span>), norm_plot,</span>
<span id="cb60-28">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb60-29"></span>
<span id="cb60-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Correlation of mU/mg protein with total extracted protein</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb60-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  all %d samples      : r = %+.3f, p = %.4f</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-32">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(activity_plot_data), protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value))</span>
<span id="cb60-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean samples only  : r = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-34">            protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb60-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/mg protein range: %.3f to %.3f (%.2f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-36">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein),</span>
<span id="cb60-37">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)))</span>
<span id="cb60-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/uL range: %.4f to %.4f (%.2f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-39">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL),</span>
<span id="cb60-40">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)))</span>
<span id="cb60-41"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Artifact check: r(total protein, mU/uL raw rate) = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-42">            uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb60-43"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"If mU/uL itself trends with total protein while mU/mg protein trends oppositely,</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-44">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-45">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-- but a STRONG raw-rate/protein relationship (as seen here) instead argues that</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb60-46">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"protein normalization is correcting for genuine extraction-efficiency differences.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb60-47"></span>
<span id="cb60-48"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_trend_clean: correlation test on clean samples ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb60-49"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_trend_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb60-50"></span>
<span id="cb60-51"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- norm_clean: clean samples used for the trend fit ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb60-52"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(norm_clean)</span>
<span id="cb60-53"></span>
<span id="cb60-54">norm_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/Gen5-20260824-mgig-sormi-citrate_synthase-F05-ambient_files/figure-gfm/plot-activity-normalized-1.png" class="img-fluid"><!-- --></p>
<pre><code>Correlation of mU/mg protein with total extracted protein
  all 8 samples      : r = -0.888, p = 0.0032
  clean samples only  : r = -0.888, p = 0.0032  (n = 8)
  clean-sample mU/mg protein range: 82.906 to 136.192 (1.64-fold)
  clean-sample mU/uL range: 0.0832 to 0.2242 (2.69-fold)

Artifact check: r(total protein, mU/uL raw rate) = +0.956, p = 0.0002  (n = 8)
If mU/uL itself trends with total protein while mU/mg protein trends oppositely,
the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate
-- but a STRONG raw-rate/protein relationship (as seen here) instead argues that
protein normalization is correcting for genuine extraction-efficiency differences.

--- protein_trend_clean: correlation test on clean samples ---

List of 9
 $ statistic  : Named num -4.74
 $ parameter  : Named int 6
 $ p.value    : num 0.00318
 $ estimate   : Named num -0.888
 $ null.value : Named num 0
 $ alternative: chr "two.sided"
 $ method     : chr "Pearson's product-moment correlation"
 $ data.name  : chr "norm_clean$total_protein_mg and norm_clean$activity_mU_per_mg_protein"
 $ conf.int   : num [1:2] -0.98 -0.492

--- norm_clean: clean samples used for the trend fit ---

tibble [8 × 24] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ n_reps_used               : int [1:8] 3 3 3 3 3 3 3 3
 $ mean_rate_mOD_min         : num [1:8] 7.6 8.5 13.48 10.18 5.62 ...
 $ sd_rate                   : num [1:8] 0.35 0.35 0.293 0.257 0.104 ...
 $ cv_rate                   : num [1:8] 4.61 4.12 2.17 2.52 1.85 ...
 $ family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ individual                : chr [1:8] "01" "02" "03" "04" ...
 $ temperature               : chr [1:8] "ambient" "ambient" "ambient" "ambient" ...
 $ conc_ug_mL                : num [1:8] 876 1039 1900 1129 712 ...
 $ total_protein_mg          : num [1:8] 0.307 0.364 0.665 0.395 0.249 ...
 $ bg_rate_mOD_min           : num [1:8] 0.233 0.233 0.233 0.233 0.233 ...
 $ corrected_mOD_min         : num [1:8] 7.37 8.27 13.25 9.95 5.38 ...
 $ rate_OD_min               : num [1:8] 0.00737 0.00827 0.01325 0.00995 0.00538 ...
 $ nmol_per_min              : num [1:8] 0.228 0.256 0.41 0.308 0.166 ...
 $ activity_mU_per_uL        : num [1:8] 0.1139 0.1278 0.2048 0.1538 0.0832 ...
 $ total_mU_in_homogenate    : num [1:8] 39.9 44.7 71.7 53.8 29.1 ...
 $ activity_mU_per_mg_protein: num [1:8] 130 123 108 136 117 ...
 $ nmol_in_window            : num [1:8] 4.56 5.11 8.19 6.15 3.33 ...
 $ within_std_range          : logi [1:8] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ cv_all                    : num [1:8] 4.61 4.12 2.17 2.52 1.85 ...
 $ n_elevated                : int [1:8] 0 0 0 0 0 0 0 0
 $ n                         : int [1:8] 3 3 3 3 3 3 3 3
 $ cv_flag                   : Factor w/ 3 levels "clean","CV &gt; 15%",..: 1 1 1 1 1 1 1 1
 $ label_n                   : chr [1:8] "3/3 reps" "3/3 reps" "3/3 reps" "3/3 reps" ...</code></pre>
<p>This plate tells a <strong>different story from the 20260814 (36 °C) plate</strong>: raw activity (mU/µL) rises strongly and significantly with total extracted protein (r = +0.956, p = 0.0002), while mU/mg protein correlates negatively with total extracted protein (r = -0.888, p = 0.0032, n = 8, all 8 samples clean on this plate). Because raw signal genuinely increases with more protein loaded – consistent with more CS enzyme being present when more protein was extracted – <strong>the negative mU/mg protein trend here is more consistent with protein normalization doing its intended job</strong> (correcting for real inter-sample extraction-efficiency differences) than with a pure division artifact. Protein normalization also compresses the inter-individual spread, from a 2.69-fold raw range down to a 1.64-fold range in mU/mg protein, the opposite direction from the 36 °C plate (where normalizing widened, rather than narrowed, the apparent spread).</p>
</section>
</section>
<section id="qc-summary" class="level1">
<h1>10 QC SUMMARY</h1>
<div class="sourceCode" id="cb62" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb62-1">qc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_qc_summary_table</span>(layout_wells, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary, std_curve,</span>
<span id="cb62-2">                                      well_diagnostics, well_rates, cv_summary,</span>
<span id="cb62-3">                                      baseline_per_sample, pos_control, assay_params)</span>
<span id="cb62-4"></span>
<span id="cb62-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(qc_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"QC check"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Result"</span>),</span>
<span id="cb62-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quality control summary for this plate"</span>)</span>
<span id="cb62-7"></span>
<span id="cb62-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(qc_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"qc_summary.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb62-9"></span>
<span id="cb62-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- qc_summary: consolidated QC checks for the run ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb62-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(qc_summary)</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">QC check</th>
<th style="text-align: left;">Result</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Occupied wells in layout</td>
<td style="text-align: left;">48</td>
</tr>
<tr class="even">
<td style="text-align: left;">Layout wells missing from absorbance CSV</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Max disagreement between absorbance CSV and full report</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard concentrations with replicate CV &gt; threshold</td>
<td style="text-align: left;"></td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard wells flagged as outliers</td>
<td style="text-align: left;">0/18 ()</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard curve R^2 (outlier-excluded, replicate level)</td>
<td style="text-align: left;">0.9983</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard curve R^2 (all wells, replicate level)</td>
<td style="text-align: left;">0.9983</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard wells that LOST signal over the run</td>
<td style="text-align: left;">13/18</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standards above photometric linearity ceiling</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;">Background control wells behaving as active reactions</td>
<td style="text-align: left;">0/3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells with a decreasing trace</td>
<td style="text-align: left;">0/24</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with an elevated starting A412</td>
<td style="text-align: left;">0/24 ()</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with ALL THREE replicates baseline-compromised</td>
<td style="text-align: left;">0/8 ()</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with a read glitch</td>
<td style="text-align: left;">0/24</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells usable for rate extraction</td>
<td style="text-align: left;">24/24</td>
</tr>
<tr class="even">
<td style="text-align: left;">Samples with technical CV &gt; threshold (all reps)</td>
<td style="text-align: left;">0/8</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with technical CV &gt; threshold (usable reps)</td>
<td style="text-align: left;">0/8</td>
</tr>
<tr class="even">
<td style="text-align: left;">Positive control replicates rising and linear</td>
<td style="text-align: left;">3/3</td>
</tr>
</tbody>
</table>
<p>Quality control summary for this plate</p>
<pre><code>--- qc_summary: consolidated QC checks for the run ---

'data.frame':   18 obs. of  2 variables:
 $ check: chr  "Occupied wells in layout" "Layout wells missing from absorbance CSV" "Max disagreement between absorbance CSV and full report" "Standard concentrations with replicate CV &gt; threshold" ...
 $ value: chr  "48" "0" "0" "" ...</code></pre>
<section id="auto-generated-findings" class="level2">
<h2 class="anchored" data-anchor-id="auto-generated-findings">10.1 Auto-generated findings</h2>
<p>The bullets below are generated programmatically from the QC/CV/anomaly objects above by <code>generate_qc_findings()</code>, so the same logic that flags a problem here is guaranteed to be the logic that flagged it upstream.</p>
<div class="sourceCode" id="cb64" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb64-1">qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">generate_qc_findings</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb64-2">                                     baseline_per_sample, std_curve, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary,</span>
<span id="cb64-3">                                     assay_params)</span>
<span id="cb64-4"></span>
<span id="cb64-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"- "</span>, qc_findings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>- **Kinetic sources agree.** absorbance CSV and full report agree exactly on all 528 shared well x timepoint readings; all layout wells are present.

- **Standard signal decay.** 13 of 18 standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0.

- **Standard curve fit (outlier-excluded):** slope = 0.03234 A412/nmol, R^2 = 0.9983 (all-wells R^2 = 0.9983).

- **Technical replicate CV.** All 8 samples are within 15% CV across all three replicates.</code></pre>
</section>
</section>
<section id="summary" class="level1">
<h1>11 SUMMARY</h1>
<section id="anomalies-found" class="level2">
<h2 class="anchored" data-anchor-id="anomalies-found">11.1 Anomalies found</h2>
<ol type="1">
<li><strong>No sample well, positive-control well, or background well is flagged for anything on this plate.</strong> No decreasing kinetics, no read glitches, no elevated starting absorbance, and no background well behaving as an active reaction (all three pooled-background replicates are flat).</li>
<li><strong>Widespread but harmless GSH standard signal decay.</strong> 13 of 15 (strict drift &lt; 0) to 15 of 18 (including exact-zero ties) non-zero-concentration standard wells lose signal between t = 0 and t = 20 min, consistent with TNB<sup>2-</sup> instability. This is a larger fraction than on prior plates, but the standard curve is calibrated at t = 0, so it has no effect on the fit (R<sup>2</sup> = 0.9983, zero flagged outlier wells).</li>
<li><strong>Elevated positive-control replicate CV.</strong> The three positive-control replicates rise linearly (R<sup>2</sup> 0.997-1.000) but disagree in rate by 22.8% CV (<code>D7</code> at 2.00 mA412/min vs.&nbsp;<code>D8</code>/<code>D9</code> at 2.95-3.15 mA412/min), worse precision than any individual sample’s technical triplicate on this plate. This does not affect sample activity values (the positive control is a chemistry validity check only), but is worth watching on future plates.</li>
</ol>
</section>
<section id="technical-replicate-precision-1" class="level2">
<h2 class="anchored" data-anchor-id="technical-replicate-precision-1">11.2 Technical replicate precision</h2>
<p><strong>All eight samples pass the 15% CV threshold</strong> — the highest is <code>F05_01_ambient</code> at 4.6%, and the lowest is <code>F05_08_ambient</code> at 0.8% (<code>F05_02_ambient</code> 4.1%, <code>F05_03_ambient</code> 2.2%, <code>F05_04_ambient</code> 2.5%, <code>F05_05_ambient</code> 1.9%, <code>F05_06_ambient</code> 1.9%, <code>F05_07_ambient</code> 1.3%). No replicate is excluded from any sample’s rate calculation on this plate, so the “all reps” and “usable reps only” CVs are identical throughout.</p>
</section>
<section id="assay-validity" class="level2">
<h2 class="anchored" data-anchor-id="assay-validity">11.3 Assay validity</h2>
<p>The <strong>positive control worked</strong> in the sense that matters for calibration: all three replicates rise linearly (R<sup>2</sup> &gt; 0.997), confirming the core reaction chemistry and reader were functioning. Its elevated replicate-to-replicate CV (22.8%, note above) is a caution rather than a disqualifier, since it does not enter the activity calculation. The GSH standard curve has zero flagged outlier wells and every sample well’s kinetics are clean, so this plate’s activity values carry low calibration uncertainty.</p>
</section>
<section id="recommendation" class="level2">
<h2 class="anchored" data-anchor-id="recommendation">11.4 Recommendation</h2>
<p>Treat the activity values here as reliable:</p>
<ol type="1">
<li><strong>This plate does not need re-assay.</strong> No sample is disqualified, no replicate is excluded, and the standard curve has no outlier wells.</li>
<li><strong>Protein normalization looks appropriate for this plate, not artifactual.</strong> Raw rate (mU/µL) is strongly and significantly correlated with total extracted protein (r = +0.96, p = 0.0002), the opposite pattern from the 20260814 (36 °C) plate, so the negative mU/mg-protein trend here is better explained by genuine extraction-efficiency differences between samples than by a division artifact. mU/mg protein is therefore a reasonable basis for comparison on this plate.</li>
<li><strong>Watch the positive control’s replicate precision on future plates.</strong> A 22.8% CV across a positive-control triplicate is unusually high; if it recurs, it is worth checking pipetting consistency for that specific reagent (e.g., undissolved/settled positive control stock, or a multichannel-pipetting order effect).</li>
<li><strong>The pooled-background design cuts the well count needed for background control roughly 8-fold</strong> (3 wells vs.&nbsp;24 on the paired per-sample design) at the cost of losing any per-sample background estimate; on this plate the background rate is a small fraction of the sample signal (~2.2%) either way, so the simplification appears low-risk here, but a pooled design should be re-validated if background ever becomes a larger fraction of the raw signal.</li>
</ol>
</section>
<section id="what-can-be-used-from-this-plate" class="level2">
<h2 class="anchored" data-anchor-id="what-can-be-used-from-this-plate">11.5 What can be used from this plate</h2>
<p>All eight samples are usable, and unlike the 36 °C plate, this ambient plate shows real, well-resolved inter-individual variation in CS activity: background-corrected rates range 5.38 to 14.50 mA412/min across the eight <code>F05</code> individuals at ambient temperature, a 169% spread against 0.8-4.6% technical CV per sample – far larger than the technical noise floor, and in the opposite direction from the essentially uniform activity seen across this same family at 36 °C.</p>
<ul>
<li><strong>Protein-normalized activity (mU/mg protein) is the recommended basis for downstream comparison on this plate</strong>, since raw activity correlates strongly with total extracted protein (see note above) – normalizing is removing a real extraction-efficiency covariate here, not introducing an artifact.</li>
<li><strong>The elevated positive-control CV (22.8%) is a plate-level caution</strong>, not a sample-level one: it does not touch any individual sample’s activity value, but should inform how much weight this plate’s absolute activity values carry relative to future re-assays with tighter positive-control precision.</li>
</ul>


</section>
</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>citrate synthase</category>
  <category>ABCAM</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia-Re-assay/</guid>
  <pubDate>Mon, 24 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Citrate Synthase Assay - SORMI June 2026 M.gigas Family 7 Ambient and 36C Ctenidia</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Citrate synthase activity in ctenidia of sixteen <em>Magallana gigas</em> (Pacific oyster) individuals from <strong>Family 7</strong> — eight held at <strong>ambient</strong> temperature and eight at <strong>36°C</strong> — assayed together on a single plate using the Citrate Synthase Assay Kit (ABCAM; cat: ab239712). Combining both temperature exposures on one plate removes the between-plate variability that complicates the Family 5 ambient-vs-36°C comparison, where the two exposures were run on separate plates with different read durations. Samples had been <a href="../../../posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/index.html">previously homogenized on 20260811</a> (Notebook entry), and protein concentrations for normalization were <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">determined on 20260813</a> (Notebook entry).</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p><strong>The background control on this plate failed — the reported rates are raw, uncorrected rates.</strong></p>
<p>Reaction Mix (containing CS Substrate) appears to have been added to all three pooled-background wells (<code>F10</code>-<code>F12</code>) instead of Background Control Mix. All three replicates rise substantially over the run (net change 0.067-0.119 A412, vs.&nbsp;&lt;0.05 for a flat background well) rather than staying flat, and this has been confirmed as a pipetting mix-up rather than genuine background signal.</p>
<p>Because 0 of 3 replicates are flat, no background rate can be estimated, and per the pipeline’s existing fallback the background correction applied to every sample on this plate is <strong>0</strong> — i.e.&nbsp;<strong>corrected rate = raw rate</strong> throughout.</p>
<p>Where a pooled background control has worked correctly, it has been a small term (roughly 2-7% of the sample signal), so the values here are likely only a modest overestimate of true background-corrected activity — but that cannot be confirmed without a working background control. <strong>These rates should not be pooled directly with background-corrected values from other assays without accounting for the difference.</strong> Re-running just the background triplicate would let this plate’s existing sample, standard-curve, and positive-control data be corrected without re-collecting everything else.</p>
<p>To reduce the risk of this recurring: physically separate the Reaction Mix and Background Control Mix reservoirs/tips, or pipette the background wells first, before switching reagents for the sample wells.</p>
</div>
</div>
<p>All data/code/analysis is available here:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase">https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase</a></li>
</ul>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<section id="citrate-synthase-assay" class="level2">
<h2 class="anchored" data-anchor-id="citrate-synthase-assay">Citrate Synthase Assay</h2>
<p>The Citrate Synthase Assay Kit (ABCAM; cat: ab239712) was used according to the manufacturer’s instructions (<a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf</a> (GitHub; PDF)). The kit is a coupled kinetic assay: citrate synthase condenses acetyl-CoA and oxaloacetate to release free CoA-SH, the liberated thiol reduces DTNB to TNB<sup>2-</sup>, and the rate of absorbance increase at 412 nm is proportional to citrate synthase activity. Absolute nmol of thiol are assigned from a reduced glutathione (GSH) standard curve read on the same plate.</p>
<p>Per reaction well, 2 µL of undiluted homogenate was combined with 48 µL of Assay Buffer 7, followed by 50 µL of Reaction Mix. All sixteen samples — eight ambient and eight 36°C — were assayed in technical triplicate on a single clear, flat-bottomed 96-well plate. A six-point GSH standard curve (0, 8, 16, 24, 32, 40 nmol/well) and a CS positive control were included in triplicate on the same plate.</p>
<p>REACTION MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>43</td>
<td>77</td>
<td>3311</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>77</td>
<td>385</td>
</tr>
<tr class="odd">
<td>CS Substrate</td>
<td>2</td>
<td>77</td>
<td>154</td>
</tr>
</tbody>
</table>
<p>BACKGROUND MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>45</td>
<td>4</td>
<td>180</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>4</td>
<td>20</td>
</tr>
</tbody>
</table>
<p>Absorbance was read at 412 nm in kinetic mode at 25°C on a Synergy HTX plate reader (Agilent), every 2 minutes for 20 minutes (11 reads).</p>
</section>
<section id="normalization" class="level2">
<h2 class="anchored" data-anchor-id="normalization">Normalization</h2>
<p>Activity was normalized to total extracted protein rather than tissue weight. Tissue was homogenized in 350 µL of Assay Buffer 7, and protein concentration in each homogenate was <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">quantified on 20260813</a> (Notebook entry) using the Bradford assay. Total protein mass per sample is that concentration multiplied by the 350 µL homogenization volume. Tissue weights are recorded in the plate layout labels for provenance only and play no role in the activity calculation. Protein values come from two assays run on 20260813: the F07 plate (12 of the 16 samples) and a follow-up re-assay plate (<code>F07_05_36C</code>, <code>F07_01_ambient</code>, <code>F07_04_ambient</code>, <code>F07_06_ambient</code>, re-assayed at dilution after failing QC on the first pass).</p>
</section>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<p>Data were analyzed in R. The Rmd file is here (GitHub):</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C.Rmd">Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C.Rmd</a></li>
</ul>
<p>Knitted markdown is below.</p>
<p>Background correction was intended to use a <strong>single pooled background control</strong> rather than a paired per-sample background. A pool was made from 5 µL of each sample homogenate, and 2 µL of that pool (matching the 2 µL sample volume used for every reaction well) was run in triplicate with Background Control Mix (no CS Substrate Mix), producing wells <code>BG-citrate_synthase</code> (F10-F12). As described in the callout above, Reaction Mix was added to these wells instead, so no background correction could be applied.</p>
</section>
<section id="data-files" class="level2">
<h2 class="anchored" data-anchor-id="data-files">Data files</h2>
<section id="plate-reader-files" class="level3">
<h3 class="anchored" data-anchor-id="plate-reader-files">Plate reader files</h3>
<p>Plate reader files (<code>*.xpt</code>) are available here (require Gen5 software to open):</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/plate_reader_files</li>
</ul>
</section>
<section id="raw-absorbance-data" class="level3">
<h3 class="anchored" data-anchor-id="raw-absorbance-data">Raw absorbance data</h3>
<p>Raw absorbance data (<code>*.csv</code>), plate layouts, and Gen5 full reports are available here:</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/raw_absorbance</li>
</ul>
</section>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Apart from the background control, the plate ran well. The positive control was clean (2.6% CV, R<sup>2</sup> 0.998-1.000) and the GSH standard curve has zero flagged outlier wells (R<sup>2</sup> = 0.9992), so calibration uncertainty is low. Fifteen of sixteen samples are fully clean, with every non-failing sample under 3.1% CV on all three raw replicates and most under 2%.</p>
<p>The one failure is <code>A7</code> (<code>F07_03_ambient</code>), a dead well reading a constant A412 of 0.099 across all 11 timepoints (net change = 0, R<sup>2</sup> = 0) rather than a slow reaction. Its two siblings are normal, so <code>F07_03_ambient</code>’s activity is computed from 2 of 3 replicates with a 6.4% usable-replicate CV. Its <code>CV flag</code> column still reads <code>FAIL &gt;15%</code> because that column is deliberately computed on all raw replicates including the dead well — the two figures report different things and both are correct.</p>
<p>Within this plate, raw activity spans <strong>0.0547-0.1356 mU/µL</strong>, a real 2.5-fold range against &lt;6.5% technical CV per sample. Protein normalization looks appropriate rather than artifactual: raw rate correlates strongly and significantly with total extracted protein (r = +0.93, p = 0.0000), so mU/mg protein is the recommended basis for downstream comparison.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Reps used</th>
<th style="text-align: right;">CV all reps (%)</th>
<th style="text-align: right;">CV used reps (%)</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/uL)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th style="text-align: left;">CV flag</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: right;">3.43</td>
<td style="text-align: right;">0.0547</td>
<td style="text-align: right;">207.819</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: right;">7.43</td>
<td style="text-align: right;">0.1184</td>
<td style="text-align: right;">109.600</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: left;">2/3</td>
<td style="text-align: right;">86.9</td>
<td style="text-align: right;">6.4</td>
<td style="text-align: right;">7.18</td>
<td style="text-align: right;">0.1143</td>
<td style="text-align: right;">98.879</td>
<td style="text-align: left;">FAIL &gt;15%</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">4.97</td>
<td style="text-align: right;">0.0791</td>
<td style="text-align: right;">141.243</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.6</td>
<td style="text-align: right;">1.6</td>
<td style="text-align: right;">6.53</td>
<td style="text-align: right;">0.1040</td>
<td style="text-align: right;">157.813</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: right;">7.20</td>
<td style="text-align: right;">0.1147</td>
<td style="text-align: right;">102.432</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">8.22</td>
<td style="text-align: right;">0.1309</td>
<td style="text-align: right;">79.566</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.6</td>
<td style="text-align: right;">0.6</td>
<td style="text-align: right;">4.88</td>
<td style="text-align: right;">0.0778</td>
<td style="text-align: right;">138.824</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">4.93</td>
<td style="text-align: right;">0.0786</td>
<td style="text-align: right;">118.446</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: right;">7.48</td>
<td style="text-align: right;">0.1192</td>
<td style="text-align: right;">127.815</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">3.1</td>
<td style="text-align: right;">3.1</td>
<td style="text-align: right;">8.28</td>
<td style="text-align: right;">0.1319</td>
<td style="text-align: right;">109.428</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.5</td>
<td style="text-align: right;">1.5</td>
<td style="text-align: right;">8.52</td>
<td style="text-align: right;">0.1356</td>
<td style="text-align: right;">86.544</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">4.37</td>
<td style="text-align: right;">0.0695</td>
<td style="text-align: right;">162.517</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: right;">3.70</td>
<td style="text-align: right;">0.0589</td>
<td style="text-align: right;">118.679</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">7.05</td>
<td style="text-align: right;">0.1123</td>
<td style="text-align: right;">108.153</td>
<td style="text-align: left;">pass</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.0581</td>
<td style="text-align: right;">200.578</td>
<td style="text-align: left;">pass</td>
</tr>
</tbody>
</table>
<p>All sixteen samples are classified <code>usable</code>. Since both exposures share one plate, one standard curve, and one positive control, the ambient-vs-36°C contrast within Family 7 is not confounded by between-plate differences — though the failed background control means the comparison rests on raw rates.</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Citrate synthase (CS) activity in ctenidia of sixteen <em>Magallana gigas</em> (Pacific oyster) individuals from <strong>family F07</strong> – eight held at <strong>ambient</strong> temperature and eight at <strong>36 °C</strong> – assayed together on a single plate 2026-08-24 with the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">Abcam Citrate Synthase Assay Kit (ab239712), v4a</a>. Both temperature exposures for <code>F07</code> are combined on this one plate. <strong>This plate also has a confirmed reagent mix-up affecting its background control (note 4) – background-corrected rates on this plate equal the raw rates.</strong></p>
<p>The kit is a <strong>coupled kinetic</strong> assay. CS condenses acetyl-CoA and oxaloacetate, releasing free CoA-SH; the liberated thiol reduces DTNB to TNB<sup>2-</sup>, which absorbs at 412 nm. The <strong>rate</strong> of A412 increase is proportional to CS activity, and absolute nmol of thiol are assigned from a <strong>GSH (reduced glutathione) standard curve</strong> read on the same plate.</p>
<p>Absorbance was read at 412 nm in kinetic mode, 25 °C, every 2 min for 20 min (11 reads) on a Synergy HTX. See note 1.</p>
<p>Total extracted protein per homogenate (used for normalization, note 2) was not measured on this plate; it comes from two BCA/Bradford-style protein-quantification assays run 2026-08-13: <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260813-mgig-sormi-BSA-F07-protein.Rmd"><code>Gen5-20260813-mgig-sormi-BSA-F07-protein.Rmd</code></a> (12 of the 16 samples) and a follow-up re-assay plate (the remaining 4 – <code>F07_05_36C</code>, <code>F07_01_ambient</code>, <code>F07_04_ambient</code>, <code>F07_06_ambient</code> – which were re-assayed at dilution after failing QC on the first pass). Homogenization used 350 µL of Assay Buffer 7 per sample (reported by the bench operator; see the lab notebook homogenization post for this assay).</p>
<p>This document is fully self-contained: layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are all defined directly below (see <code>## Pipeline functions</code> under SETUP) rather than sourced from a separate script, so the whole analysis can be reproduced from this one file.</p>
<section id="sample-naming-convention" class="level2">
<h2 class="anchored" data-anchor-id="sample-naming-convention">1.1 Sample naming convention</h2>
<p>Well labels follow <code>&lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;-&lt;assay_type&gt;-&lt;weight&gt;-df.&lt;n&gt;</code> for sample wells (e.g.&nbsp;<code>F07_01_ambient-citrate_synthase-7.3-df.0</code>, <code>F07_01_36C-citrate_synthase-9.0-df.0</code>), <code>STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</code> for GSH standards, <code>POS-&lt;assay_type&gt;</code> for the positive control, and <code>BG-&lt;assay_type&gt;</code> for the pooled background control (see note 3) – the background label carries no weight or dilution suffix, since it is not tied to any single individual’s tissue. Because both temperature exposures are present on this one plate, <code>&lt;temperature&gt;</code> genuinely varies (<code>ambient</code> or <code>36C</code>) within this document; nothing in the parsing below hardcodes a temperature. The trailing number in the sample label (e.g.&nbsp;<code>7.3</code>) is tissue weight in mg, which is <strong>not</strong> used for normalization here (note 2); it is parsed and validated but plays no role in the activity calculation.</p>
</section>
<section id="notes" class="level2">
<h2 class="anchored" data-anchor-id="notes">1.2 Notes</h2>
<ol type="1">
<li><strong>Read duration for this plate is 20 minutes</strong> (11 reads at 2-min intervals). The assay parameters below set <code>read_duration_min = 20</code> to match. Rate extraction uses a fixed-width sliding window (<code>rate_window_n = 5</code> points = 8 min) rather than the full trace; see the KINETIC TRACES section for whether the assay is still in its linear phase over this window.</li>
<li><strong>Activity is normalized to total extracted protein, not tissue weight</strong>, because protein concentration was measured directly (BCA-style assay), and controls for extraction efficiency in a way tissue weight cannot. No <code>Sample</code> string in either protein-concentration source needed correction for this plate’s samples.</li>
<li><strong>Background correction uses a single pooled background control</strong>, rather than a paired per-sample background for each individual. A pool was made from 5 µL of each sample homogenate, and 2 µL of that pool (matching <code>sample_volume_uL</code> used for every reaction well) was run in triplicate with Background Control Mix (no CS Substrate Mix) to produce wells <code>BG-citrate_synthase</code> (F10-F12). Because there is only one background estimate for the whole plate, the same background-corrected rate would normally be subtracted from every sample – but see note 4.</li>
<li><strong>Reaction Mix (containing CS Substrate) appears to have been added to all three pooled-background wells on this plate instead of Background Control Mix.</strong> All three <code>BG-citrate_synthase</code> replicates rise substantially over the run (net change 0.067-0.119 A412, vs.&nbsp;&lt;0.05 for a flat background well) rather than staying flat, and this has been confirmed as a pipetting mix-up rather than genuine background signal. Because 0 of 3 replicates are flat, <code>compute_background_correction()</code> cannot estimate a background rate (<code>bg_rate_flat</code> is <code>NA</code>) and, per its existing fallback, the background correction used for every sample on this plate is 0 – i.e., <strong>corrected rate = raw rate</strong> throughout. See BACKGROUND CORRECTION and the SUMMARY for what this means for this plate’s results.</li>
</ol>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="pipeline-functions" class="level2">
<h2 class="anchored" data-anchor-id="pipeline-functions">1.3 Pipeline functions</h2>
<p>All layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are defined directly in this document (rather than sourced from a separate script) so that it is fully self-contained and reproducible from this single file. The functions are grouped below by pipeline stage; each is called in the DATA / KINETIC TRACES / ANOMALY DETECTION / GSH STANDARD CURVE / RATE EXTRACTION / BACKGROUND CORRECTION / TECHNICAL REPLICATE PRECISION / CITRATE SYNTHASE ACTIVITY / QC SUMMARY sections that follow. Nothing plate-specific (typo fixes, disqualified samples, thresholds) is hardcoded in any function – it is always passed in as an argument, from the <code>assay_params</code> list defined further below or from a plate-specific fix list.</p>
<section id="data-import-and-layout-parsing" class="level3">
<h3 class="anchored" data-anchor-id="data-import-and-layout-parsing">1.3.1 Data import and layout parsing</h3>
<p>Reads the raw Gen5 exports (kinetic absorbance CSV, full-report text backup, plate-layout CSV), reconciles them against each other, and attaches well-type/sample-id/replicate metadata plus measured protein concentrations to every well.</p>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## elapsed_to_min()</span></span>
<span id="cb4-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert Gen5 "H:MM:SS" elapsed-time strings to decimal minutes.</span></span>
<span id="cb4-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : x - character vector of "H:MM:SS" strings</span></span>
<span id="cb4-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of elapsed minutes, same length as x</span></span>
<span id="cb4-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-7">elapsed_to_min <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb4-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-9">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p)</span>
<span id="cb4-10">    p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span></span>
<span id="cb4-11">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb4-12">}</span>
<span id="cb4-13"></span>
<span id="cb4-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-15"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_absorbance_csv()</span></span>
<span id="cb4-16"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "absorbance-*.csv" kinetic export: wavelength</span></span>
<span id="cb4-17"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           header, a "Time," row, a temperature row, then one row per well</span></span>
<span id="cb4-18"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well ID in column 1, one OD reading per timepoint thereafter).</span></span>
<span id="cb4-19"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the absorbance-*.csv file</span></span>
<span id="cb4-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-23">read_absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-24">  ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-25">  time_i   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time,"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-26">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[time_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb4-27">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> time_str[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>time_str <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time"</span>)]</span>
<span id="cb4-28">  tmin     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(time_str)</span>
<span id="cb4-29"></span>
<span id="cb4-30">  well_ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2},"</span>, ln)]</span>
<span id="cb4-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(well_ln, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-33">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(tmin) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb4-34">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-35">  }))</span>
<span id="cb4-36">}</span>
<span id="cb4-37"></span>
<span id="cb4-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_full_report()</span></span>
<span id="cb4-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "full_report-*.txt" export: tab-delimited, wells</span></span>
<span id="cb4-41"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across columns, timepoints down rows. Used only as an</span></span>
<span id="cb4-42"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           independent cross-check against the absorbance CSV, never as a</span></span>
<span id="cb4-43"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           primary data source.</span></span>
<span id="cb4-44"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the full_report-*.txt file</span></span>
<span id="cb4-45"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-46"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-47"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-48">read_full_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-49">  ln  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-50">  hdr_i <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.*</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">A1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-51">  hdr   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[hdr_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]])</span>
<span id="cb4-52">  rows  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[0-9]:[0-9]{2}:[0-9]{2}</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)]</span>
<span id="cb4-53">  m     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">do.call</span>(rbind, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(rows, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>))</span>
<span id="cb4-54">  tmin  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb4-55"></span>
<span id="cb4-56">  well_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2}$"</span>, hdr))</span>
<span id="cb4-57">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(well_cols, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(j) {</span>
<span id="cb4-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> hdr[j], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-59">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(m[, j]), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-60">  }))</span>
<span id="cb4-61">}</span>
<span id="cb4-62"></span>
<span id="cb4-63"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-64"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## parse_plate_layout()</span></span>
<span id="cb4-65"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert a raw Gen5 plate-layout CSV export into one row per</span></span>
<span id="cb4-66"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           occupied well with its descriptive label. Auto-detects two</span></span>
<span id="cb4-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           export formats seen in practice:</span></span>
<span id="cb4-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "single"  - one row per plate row (row 1 = column numbers,</span></span>
<span id="cb4-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         column 1 = row letter, last column = "Name" tag);</span></span>
<span id="cb4-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         each cell already holds the full descriptive label.</span></span>
<span id="cb4-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "double"  - each plate row is exported as TWO rows: a</span></span>
<span id="cb4-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         "Well ID" row (SPL codes) immediately followed by</span></span>
<span id="cb4-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         a "Name" row (the descriptive label actually used</span></span>
<span id="cb4-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         downstream).</span></span>
<span id="cb4-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           The format is detected from column 1: if a value repeats twice</span></span>
<span id="cb4-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           in a row (once for the well-ID row, once for the label row)</span></span>
<span id="cb4-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           immediately below a numeric header, it is treated as "double".</span></span>
<span id="cb4-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the layout-*.csv file</span></span>
<span id="cb4-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per occupied well:</span></span>
<span id="cb4-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr, e.g. "A1"), plate_row (chr), plate_col (int),</span></span>
<span id="cb4-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label (chr, trimmed descriptive label)</span></span>
<span id="cb4-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-83">parse_plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-84">  plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-85"></span>
<span id="cb4-86">  col1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1)</span>
<span id="cb4-87">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "double" format: row letters appear twice in a row in column 1</span></span>
<span id="cb4-88">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (once tagging the Well-ID row, once tagging the Name row), e.g.</span></span>
<span id="cb4-89">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "A", "A", "B", "B", ... Detect by checking whether non-empty,</span></span>
<span id="cb4-90">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># non-header values in col1 are each immediately followed by a repeat.</span></span>
<span id="cb4-91">  data_rows   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(col1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(col1))[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># drop header row (row 1)</span></span>
<span id="cb4-92">  is_double <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb4-93">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]][<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))])</span>
<span id="cb4-94"></span>
<span id="cb4-95">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (is_double) {</span>
<span id="cb4-96">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pair each row-letter row with the following label row.</span></span>
<span id="cb4-97">    row_letter_rows <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]</span>
<span id="cb4-98">    label_rows      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]</span>
<span id="cb4-99">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(row_letter_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(label_rows))</span>
<span id="cb4-100"></span>
<span id="cb4-101">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pair_idx =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(row_letter_rows),</span>
<span id="cb4-102">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-103">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-104">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> col1[row_letter_rows[pair_idx]],</span>
<span id="cb4-105">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-106">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-107">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j],</span>
<span id="cb4-108">                                   label_rows[pair_idx], col_idx))</span>
<span id="cb4-109">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-110">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-111">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-112">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-113">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb4-114">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "single" format: row 1 = column numbers, column 1 = row letters,</span></span>
<span id="cb4-115">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># last column = "Name" tag; each cell already holds the full label.</span></span>
<span id="cb4-116">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(plate_layout),</span>
<span id="cb4-117">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-118">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-119">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1[row_idx],</span>
<span id="cb4-120">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-121">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-122">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j], row_idx, col_idx))</span>
<span id="cb4-123">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-124">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-126">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-127">  }</span>
<span id="cb4-128"></span>
<span id="cb4-129">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(out, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(is_double, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"double"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"single"</span>)</span>
<span id="cb4-130">  out</span>
<span id="cb4-131">}</span>
<span id="cb4-132"></span>
<span id="cb4-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-134"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## reconcile_kinetic_sources()</span></span>
<span id="cb4-135"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Cross-check the absorbance CSV (primary data source) against</span></span>
<span id="cb4-136"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the full_report text export (independent instrument export)</span></span>
<span id="cb4-137"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and the plate layout (expected well set). Fails loudly</span></span>
<span id="cb4-138"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (stopifnot) if any layout well is missing from the CSV, or if</span></span>
<span id="cb4-139"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the two kinetic sources disagree on any shared reading.</span></span>
<span id="cb4-140"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : absorbance_csv - long-format data.frame from read_absorbance_csv()</span></span>
<span id="cb4-141"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           full_report    - long-format data.frame from read_full_report()</span></span>
<span id="cb4-142"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-143"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerance      - max allowed |CSV - report| absolute difference</span></span>
<span id="cb4-144"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            (default 1e-9, i.e. exact agreement)</span></span>
<span id="cb4-145"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(plate_readings, overlap_check, summary), where</span></span>
<span id="cb4-146"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_readings = absorbance_csv with a `source` column added,</span></span>
<span id="cb4-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           summary        = named list of counts for reporting</span></span>
<span id="cb4-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-149">reconcile_kinetic_sources <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(absorbance_csv, full_report, layout_wells,</span>
<span id="cb4-150">                                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tolerance =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>) {</span>
<span id="cb4-151">  wells_csv    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-152">  wells_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-153"></span>
<span id="cb4-154">  wells_report_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_report, wells_csv)</span>
<span id="cb4-155">  wells_layout_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, wells_csv)</span>
<span id="cb4-156">  wells_csv_not_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_csv, layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-157"></span>
<span id="cb4-158">  overlap_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">inner_join</span>(absorbance_csv, full_report,</span>
<span id="cb4-159">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"time_min"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_csv"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_report"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-160">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_diff =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(od_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_report))</span>
<span id="cb4-161"></span>
<span id="cb4-162">  max_disagreement <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(overlap_check<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>abs_diff) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb4-163"></span>
<span id="cb4-164">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-165">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb4-166">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> tolerance</span>
<span id="cb4-167">  )</span>
<span id="cb4-168"></span>
<span id="cb4-169">  plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> absorbance_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance_csv"</span>)</span>
<span id="cb4-170"></span>
<span id="cb4-171">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-172">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_readings =</span> plate_readings,</span>
<span id="cb4-173">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overlap_check  =</span> overlap_check,</span>
<span id="cb4-174">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">summary =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-175">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv),</span>
<span id="cb4-176">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report            =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report),</span>
<span id="cb4-177">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report_not_csv),</span>
<span id="cb4-178">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_layout_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv),</span>
<span id="cb4-179">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv_not_layout    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv_not_layout),</span>
<span id="cb4-180">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_shared_readings         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check),</span>
<span id="cb4-181">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_disagreement          =</span> max_disagreement</span>
<span id="cb4-182">    )</span>
<span id="cb4-183">  )</span>
<span id="cb4-184">}</span>
<span id="cb4-185"></span>
<span id="cb4-186"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-187"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## annotate_wells()</span></span>
<span id="cb4-188"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Join layout labels onto the kinetic readings and parse each</span></span>
<span id="cb4-189"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label into well_type, sample_id, family, individual,</span></span>
<span id="cb4-190"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           temperature, tissue weight, and standard concentration.</span></span>
<span id="cb4-191"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Expected label grammar:</span></span>
<span id="cb4-192"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             sample              : &lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;-&lt;assay_type&gt;-&lt;weight&gt;-df.&lt;n&gt;</span></span>
<span id="cb4-193"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             standard            : STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</span></span>
<span id="cb4-194"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             positive control    : POS-&lt;assay_type&gt;</span></span>
<span id="cb4-195"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             background (pooled) : BG-&lt;assay_type&gt;</span></span>
<span id="cb4-196"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Unlike the paired per-sample background design used on earlier</span></span>
<span id="cb4-197"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plates (`_BG` appended to a sample's own label), this plate's</span></span>
<span id="cb4-198"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background wells are a single pooled control with no sample_id,</span></span>
<span id="cb4-199"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           family, individual, or weight of their own (note 3) -- so</span></span>
<span id="cb4-200"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id/family/individual/temperature/weight_mg parsing is</span></span>
<span id="cb4-201"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           restricted to well_type == "sample" only.</span></span>
<span id="cb4-202"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Label typos (e.g. a misspelled assay_type) are corrected before</span></span>
<span id="cb4-203"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           parsing via `label_fixes`, a named character vector of</span></span>
<span id="cb4-204"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           c(pattern = replacement) pairs applied in order with gsub().</span></span>
<span id="cb4-205"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_readings - data.frame from reconcile_kinetic_sources()$plate_readings</span></span>
<span id="cb4-206"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-207"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label_fixes    - optional named character vector, e.g.</span></span>
<span id="cb4-208"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            c("citrate_synthasse" = "citrate_synthase")</span></span>
<span id="cb4-209"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : plate_long - fully annotated long-format data.frame, one row</span></span>
<span id="cb4-210"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           per well x timepoint, with well_type, sample_id, family,</span></span>
<span id="cb4-211"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           individual, temperature, weight_mg, std_nmol columns added</span></span>
<span id="cb4-212"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-213">annotate_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_readings, layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-214">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_readings <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-215">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-216">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-217">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb4-218">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-219">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^POS-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>,</span>
<span id="cb4-220">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^BG-"</span>,  label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>,</span>
<span id="cb4-221">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span></span>
<span id="cb4-222">      ),</span>
<span id="cb4-223">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_clean =</span> label</span>
<span id="cb4-224">    )</span>
<span id="cb4-225"></span>
<span id="cb4-226">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(label_fixes)) {</span>
<span id="cb4-227">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(label_fixes)) {</span>
<span id="cb4-228">      plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, label_fixes[[pat]], plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean)</span>
<span id="cb4-229">    }</span>
<span id="cb4-230">  }</span>
<span id="cb4-231"></span>
<span id="cb4-232">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-233">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-234">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb4-235">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-[a-zA-Z_]+-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-236">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^(F[0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-237">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_([0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-238">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_[0-9]+_(.*)$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-239">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight_mg   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb4-240">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-[a-zA-Z_]+-([0-9.]+)-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">..*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean)),</span>
<span id="cb4-241">                           <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb4-242">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-243">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-[a-zA-Z_]+-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean)), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb4-244">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-245">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well_type, sample_id, well, time_min)</span>
<span id="cb4-246"></span>
<span id="cb4-247">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fail loudly rather than silently dropping malformed labels</span></span>
<span id="cb4-248">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-249">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type)),</span>
<span id="cb4-250">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>])),</span>
<span id="cb4-251">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>]))</span>
<span id="cb4-252">  )</span>
<span id="cb4-253"></span>
<span id="cb4-254">  plate_long</span>
<span id="cb4-255">}</span>
<span id="cb4-256"></span>
<span id="cb4-257"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-258"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## load_protein_concentrations()</span></span>
<span id="cb4-259"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Load one or more BCA/Bradford-style protein-concentration CSV</span></span>
<span id="cb4-260"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exports, concatenate them, and match each plate sample to</span></span>
<span id="cb4-261"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exactly one protein-concentration record. Fails loudly if any</span></span>
<span id="cb4-262"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate sample has zero or more than one match. Converts</span></span>
<span id="cb4-263"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration (ug/mL) to total protein mass (mg) in the full</span></span>
<span id="cb4-264"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate using the measured homogenization volume.</span></span>
<span id="cb4-265"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : protein_files        - character vector of CSV paths, each with</span></span>
<span id="cb4-266"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   columns `Sample` and</span></span>
<span id="cb4-267"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   `Calculated concentration (ug/mL)`</span></span>
<span id="cb4-268"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_sample_ids     - character vector of this plate's sample IDs</span></span>
<span id="cb4-269"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate_volume_uL - measured homogenization volume (uL),</span></span>
<span id="cb4-270"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   applied identically to every sample</span></span>
<span id="cb4-271"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_fixes      - optional named character vector of</span></span>
<span id="cb4-272"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   c(pattern = replacement) label-typo</span></span>
<span id="cb4-273"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   corrections applied to the protein</span></span>
<span id="cb4-274"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   file's Sample column before matching</span></span>
<span id="cb4-275"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per plate sample:</span></span>
<span id="cb4-276"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id, source_file, conc_ug_mL, total_protein_mg</span></span>
<span id="cb4-277"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-278">load_protein_concentrations <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(protein_files, plate_sample_ids,</span>
<span id="cb4-279">                                         homogenate_volume_uL,</span>
<span id="cb4-280">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-281">  protein_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_files <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-282">    purrr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(.x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-283">                      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source_file =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(.x))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-284">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_protein =</span> Sample, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc_ug_mL =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Calculated concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-285">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id_protein, source_file, conc_ug_mL)</span>
<span id="cb4-286"></span>
<span id="cb4-287">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(sample_id_fixes)) {</span>
<span id="cb4-288">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(sample_id_fixes)) {</span>
<span id="cb4-289">      protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, sample_id_fixes[[pat]],</span>
<span id="cb4-290">                                             protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein)</span>
<span id="cb4-291">    }</span>
<span id="cb4-292">  }</span>
<span id="cb4-293"></span>
<span id="cb4-294">  protein_matches <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_id_protein <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> plate_sample_ids)</span>
<span id="cb4-295">  match_counts    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(sample_id_protein, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_matches"</span>)</span>
<span id="cb4-296"></span>
<span id="cb4-297">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-298">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(plate_sample_ids <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> protein_matches<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein),</span>
<span id="cb4-299">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(match_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-300">  )</span>
<span id="cb4-301"></span>
<span id="cb4-302">  protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-303">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-304">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_protein_mg =</span> conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> homogenate_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-305">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb4-306">}</span></code></pre></div>
</section>
<section id="well-level-kinetic-qc" class="level3">
<h3 class="anchored" data-anchor-id="well-level-kinetic-qc">1.3.2 Well-level kinetic QC</h3>
<p>Flags read glitches, non-rising (‘decreasing’) traces, elevated t0 baselines, and other well-level anomalies before any rate is trusted.</p>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## local_step_excess()</span></span>
<span id="cb5-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For a kinetic trace, measure how much each read-to-read step</span></span>
<span id="cb5-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           departs from the AVERAGE of its two immediate neighbouring</span></span>
<span id="cb5-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           steps. A large local excess flags a read glitch; comparing to</span></span>
<span id="cb5-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           local neighbours (rather than the trace's overall median step)</span></span>
<span id="cb5-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerates traces that smoothly decelerate throughout.</span></span>
<span id="cb5-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : od - numeric vector of OD readings in time order</span></span>
<span id="cb5-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of length length(od) - 1 (one per step)</span></span>
<span id="cb5-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-11">local_step_excess <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(od) {</span>
<span id="cb5-12">  d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)</span>
<span id="cb5-13">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(d)</span>
<span id="cb5-14">  local_expect <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb5-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(d[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n))])</span>
<span id="cb5-16">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb5-17">  d <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> local_expect</span>
<span id="cb5-18">}</span>
<span id="cb5-19"></span>
<span id="cb5-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_diagnostics()</span></span>
<span id="cb5-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute four independent per-well trace-shape diagnostics from</span></span>
<span id="cb5-23"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the raw kinetic trace, before any rate fitting: direction</span></span>
<span id="cb5-24"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (net change), monotonicity (fraction of rising steps),</span></span>
<span id="cb5-25"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           over-range (any read above the photometric linearity ceiling),</span></span>
<span id="cb5-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and discontinuity (a read-to-read glitch via local_step_excess).</span></span>
<span id="cb5-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Also flags an elevated starting absorbance for sample wells,</span></span>
<span id="cb5-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and background wells that behave like active reactions.</span></span>
<span id="cb5-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb5-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with od_linear_max, glitch_excess_od,</span></span>
<span id="cb5-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          sample_baseline_od, bg_flat_od_max,</span></span>
<span id="cb5-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          bg_flat_drift_max</span></span>
<span id="cb5-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_diagnostics - one row per well, with od_first, od_last,</span></span>
<span id="cb5-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           od_max, net_change, frac_rising, max_step, typical_step,</span></span>
<span id="cb5-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           step_excess, glitch_at_min, and flag_* / n_flags columns</span></span>
<span id="cb5-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-37">compute_well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb5-38">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-39">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-40">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, plate_row, plate_col, well_type, sample_id, label, std_nmol, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb5-42">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_first        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-43">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_last         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od),</span>
<span id="cb5-44">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_max          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(od),</span>
<span id="cb5-45">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_change      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-46">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">frac_rising     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb5-47">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_step        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)))],</span>
<span id="cb5-48">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typical_step    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od))),</span>
<span id="cb5-49">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_excess     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)))],</span>
<span id="cb5-50">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_at_min   =</span> time_min[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L],</span>
<span id="cb5-51">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb5-52">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb5-54">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_ratio      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(max_step) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmax</span>(typical_step, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>),</span>
<span id="cb5-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_decreasing =</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb5-56">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_over_range =</span> od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb5-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_glitch     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(step_excess) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glitch_excess_od,</span>
<span id="cb5-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_high_baseline =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_bg_active  =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb5-60">                        (od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb5-61">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(net_change) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_drift_max),</span>
<span id="cb5-62">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_flags         =</span> flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_over_range <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-63">                        flag_bg_active <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_high_baseline</span>
<span id="cb5-64">    )</span>
<span id="cb5-65">}</span>
<span id="cb5-66"></span>
<span id="cb5-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_baseline_diagnostics()</span></span>
<span id="cb5-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Classify sample/background wells by starting absorbance</span></span>
<span id="cb5-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (elevated vs. normal) and summarize, per sample, how many of</span></span>
<span id="cb5-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           its replicates are baseline-compromised. A sample with all</span></span>
<span id="cb5-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           replicates elevated has no clean replicate at all.</span></span>
<span id="cb5-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb5-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with sample_baseline_od</span></span>
<span id="cb5-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(baseline_check, baseline_per_sample)</span></span>
<span id="cb5-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-77">compute_baseline_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, assay_params) {</span>
<span id="cb5-78">  baseline_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-79">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-80">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-81">                             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-82">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(od_first))</span>
<span id="cb5-83"></span>
<span id="cb5-84">  baseline_per_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_check <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-85">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-87">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_elevated =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb5-88">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-89">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(n_elevated))</span>
<span id="cb5-90"></span>
<span id="cb5-91">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_check =</span> baseline_check, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_per_sample =</span> baseline_per_sample)</span>
<span id="cb5-92">}</span></code></pre></div>
</section>
<section id="standard-curve-and-rate-extraction" class="level3">
<h3 class="anchored" data-anchor-id="standard-curve-and-rate-extraction">1.3.3 Standard curve and rate extraction</h3>
<p>Fits the GSH standard curve, extracts each well’s rate via a sliding-window linear regression gated on R-squared, and summarizes the positive control.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## fit_standard_curve()</span></span>
<span id="cb6-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Extract t=0 GSH standard readings, quantify signal drift over</span></span>
<span id="cb6-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the run, compute per-concentration replicate statistics, flag</span></span>
<span id="cb6-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           outlier wells by deviation from their triplicate median, and</span></span>
<span id="cb6-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit three candidate calibration lines (all wells, per-</span></span>
<span id="cb6-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration means, outlier-excluded). The outlier-excluded</span></span>
<span id="cb6-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit is the calibration used downstream.</span></span>
<span id="cb6-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb6-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with std_outlier_od</span></span>
<span id="cb6-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list with standards_t0, standard_drift, standard_summary,</span></span>
<span id="cb6-12"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           standards_flagged, fit_all_wells, fit_means, fit_no_outliers,</span></span>
<span id="cb6-13"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit_comparison, std_slope, std_intercept, std_r2, std_nmol_max</span></span>
<span id="cb6-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-15">fit_standard_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb6-16">  standards_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, time_min, od, source)</span>
<span id="cb6-19"></span>
<span id="cb6-20">  standards_t0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-24"></span>
<span id="cb6-25">  standard_drift <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t0 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t40 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(time_min)],</span>
<span id="cb6-28">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drift =</span> od_t40 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_t0, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-30"></span>
<span id="cb6-31">  standard_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od),</span>
<span id="cb6-34">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_pct =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od),</span>
<span id="cb6-35">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-36">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-37">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_od =</span> mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean_od[std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>],</span>
<span id="cb6-38">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_per_nmol =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, net_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_nmol, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>))</span>
<span id="cb6-39"></span>
<span id="cb6-40">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-42">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">triplicate_median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od),</span>
<span id="cb6-43">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">deviation =</span> od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> triplicate_median,</span>
<span id="cb6-44">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_outlier =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation)))</span>
<span id="cb6-47"></span>
<span id="cb6-48">  fit_all_wells   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged)</span>
<span id="cb6-49">  fit_means       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standard_summary)</span>
<span id="cb6-50">  fit_no_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier))</span>
<span id="cb6-51"></span>
<span id="cb6-52">  fit_comparison <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb6-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all wells"</span>,          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_all_wells),</span>
<span id="cb6-54">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-55">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration means"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_means),</span>
<span id="cb6-57">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-58">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_means)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier-excluded"</span>,   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_no_outliers),</span>
<span id="cb6-60">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-61">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared)</span>
<span id="cb6-62">  )</span>
<span id="cb6-63"></span>
<span id="cb6-64">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb6-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_all      =</span> standards_all,</span>
<span id="cb6-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_t0       =</span> standards_t0,</span>
<span id="cb6-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_drift     =</span> standard_drift,</span>
<span id="cb6-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_summary   =</span> standard_summary,</span>
<span id="cb6-69">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_flagged  =</span> standards_flagged,</span>
<span id="cb6-70">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_all_wells      =</span> fit_all_wells,</span>
<span id="cb6-71">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_means          =</span> fit_means,</span>
<span id="cb6-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_no_outliers    =</span> fit_no_outliers,</span>
<span id="cb6-73">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_comparison     =</span> fit_comparison,</span>
<span id="cb6-74">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_slope          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]),</span>
<span id="cb6-75">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_intercept      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb6-76">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_r2             =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared,</span>
<span id="cb6-77">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol_max       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol)</span>
<span id="cb6-78">  )</span>
<span id="cb6-79">}</span>
<span id="cb6-80"></span>
<span id="cb6-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## window_slopes()</span></span>
<span id="cb6-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Fit every sliding window of `w` consecutive timepoints on one</span></span>
<span id="cb6-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           kinetic trace and return the slope (mOD/min) and R^2 of each.</span></span>
<span id="cb6-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : t - numeric vector of timepoints (min)</span></span>
<span id="cb6-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           y - numeric vector of OD readings, same length as t</span></span>
<span id="cb6-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           w - window width in number of points</span></span>
<span id="cb6-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per window: t_start, t_end,</span></span>
<span id="cb6-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2</span></span>
<span id="cb6-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-91">window_slopes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(t, y, w) {</span>
<span id="cb6-92">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(y)</span>
<span id="cb6-93">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb6-94">    i  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> s<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-95">    f  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(y[i] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> t[i])</span>
<span id="cb6-96">    r2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(f)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb6-97">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> t[i[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> t[i[w]],</span>
<span id="cb6-98">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(f)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb6-99">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(r2), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, r2))</span>
<span id="cb6-100">  }))</span>
<span id="cb6-101">}</span>
<span id="cb6-102"></span>
<span id="cb6-103"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-104"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_rates()</span></span>
<span id="cb6-105"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For every well, scan all sliding windows of assay_params$</span></span>
<span id="cb6-106"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           rate_window_n consecutive reads and record the max-increasing</span></span>
<span id="cb6-107"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           window (used for activity) and the max-absolute window</span></span>
<span id="cb6-108"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (diagnostic only -- matches Gen5's own `Max V` convention,</span></span>
<span id="cb6-109"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           which can report large negative "rates" for degrading wells).</span></span>
<span id="cb6-110"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           A rate is `rate_usable` only if its R^2 clears the floor, the</span></span>
<span id="cb6-111"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well's net change is positive, and no read glitch falls inside</span></span>
<span id="cb6-112"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the fitted window.</span></span>
<span id="cb6-113"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long       - data.frame from annotate_wells()</span></span>
<span id="cb6-114"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb6-115"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with rate_window_n, rate_min_r2</span></span>
<span id="cb6-116"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_rates - one row per well: t_start, t_end, slope_mOD_min,</span></span>
<span id="cb6-117"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           r2, max_abs_slope_mOD_min, abs_window_is_negative,</span></span>
<span id="cb6-118"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           glitch_in_window, rate_usable (plus diagnostic columns joined in)</span></span>
<span id="cb6-119"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-120">compute_well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, well_diagnostics, assay_params) {</span>
<span id="cb6-121">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-122">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-123">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, well_type, sample_id, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-124">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_modify</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> {</span>
<span id="cb6-125">      w   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">window_slopes</span>(.x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min, .x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_window_n)</span>
<span id="cb6-126">      inc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min), ]</span>
<span id="cb6-127">      abs_ <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), ]</span>
<span id="cb6-128">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb6-129">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_start, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_end,</span>
<span id="cb6-130">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2,</span>
<span id="cb6-131">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_abs_slope_mOD_min =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min,</span>
<span id="cb6-132">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_window_is_negative =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb6-133">      )</span>
<span id="cb6-134">    }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-135">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-136">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, net_change, frac_rising, od_max,</span>
<span id="cb6-137">                                          flag_decreasing, flag_over_range,</span>
<span id="cb6-138">                                          flag_glitch, glitch_at_min,</span>
<span id="cb6-139">                                          flag_bg_active, n_flags),</span>
<span id="cb6-140">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-141">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb6-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_in_window =</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> t_start <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> t_end,</span>
<span id="cb6-143">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_usable      =</span> r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_min_r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>glitch_in_window</span>
<span id="cb6-144">    )</span>
<span id="cb6-145">}</span>
<span id="cb6-146"></span>
<span id="cb6-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_positive_control()</span></span>
<span id="cb6-149"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute the CS Positive Control's rate and activity, and check</span></span>
<span id="cb6-150"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           that its replicates rose linearly -- the plate's proof that the</span></span>
<span id="cb6-151"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reaction chemistry (DTNB, coupling, reader) worked, independent</span></span>
<span id="cb6-152"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           of any sample-specific problem.</span></span>
<span id="cb6-153"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates   - data.frame from compute_well_rates()</span></span>
<span id="cb6-154"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope    - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb6-155"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with sample_volume_uL, dilution_factor</span></span>
<span id="cb6-156"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : pos_control - one row per positive-control well: t_start, t_end,</span></span>
<span id="cb6-157"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2, net_change, activity_mU_uL</span></span>
<span id="cb6-158"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-159">compute_positive_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, std_slope, assay_params) {</span>
<span id="cb6-160">  well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-161">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-162">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_uL =</span> (slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb6-163">                            assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor)</span>
<span id="cb6-164">}</span></code></pre></div>
</section>
<section id="background-correction-replicate-cv-and-activity-calculation" class="level3">
<h3 class="anchored" data-anchor-id="background-correction-replicate-cv-and-activity-calculation">1.3.4 Background correction, replicate CV, and activity calculation</h3>
<p>Estimates a single pooled background rate from the flat (well-behaved) background replicates, computes technical-replicate coefficients of variation, and converts corrected rates into protein-normalized CS activity.</p>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_background_correction()</span></span>
<span id="cb7-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Estimate a single, plate-wide background rate from the flat</span></span>
<span id="cb7-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well-behaved) replicates of the pooled background control</span></span>
<span id="cb7-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (note 3), since anomalous background wells do not measure</span></span>
<span id="cb7-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background. This plate has one background triplicate for the</span></span>
<span id="cb7-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           whole plate, so the estimate is a single row rather than one</span></span>
<span id="cb7-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           row per sample_id.</span></span>
<span id="cb7-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates - data.frame from compute_well_rates()</span></span>
<span id="cb7-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : background_correction - one-row data.frame: n_bg_total,</span></span>
<span id="cb7-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           n_bg_flat, bg_rate_flat (NA if no flat replicate exists),</span></span>
<span id="cb7-12"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           bg_rate_all</span></span>
<span id="cb7-13"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-14">compute_background_correction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates) {</span>
<span id="cb7-15">  bg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)</span>
<span id="cb7-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb7-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_total   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg),</span>
<span id="cb7-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_flat    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active),</span>
<span id="cb7-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_flat =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb7-20">                          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active]), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb7-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_all  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(bg<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)</span>
<span id="cb7-22">  )</span>
<span id="cb7-23">}</span>
<span id="cb7-24"></span>
<span id="cb7-25"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_replicate_cv()</span></span>
<span id="cb7-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute technical-replicate coefficient of variation (CV%) on</span></span>
<span id="cb7-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the extracted rate, both across ALL three replicates and</span></span>
<span id="cb7-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across USABLE replicates only (rate_usable == TRUE). Flags any</span></span>
<span id="cb7-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample whose CV exceeds assay_params$cv_threshold_pct.</span></span>
<span id="cb7-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates       - data.frame from compute_well_rates()</span></span>
<span id="cb7-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_order  - character vector giving the row order /</span></span>
<span id="cb7-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              complete sample-ID set to report (typically</span></span>
<span id="cb7-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              the plate's sample IDs, e.g. from</span></span>
<span id="cb7-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              protein_by_sample$sample_id)</span></span>
<span id="cb7-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with cv_threshold_pct</span></span>
<span id="cb7-37"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cv_summary - one row per sample: n_all, mean_all, sd_all,</span></span>
<span id="cb7-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_all, n_usable, mean_usable, sd_usable, cv_usable,</span></span>
<span id="cb7-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           excluded_wells, fails_cv_all, fails_cv_usable</span></span>
<span id="cb7-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-41">compute_replicate_cv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, sample_id_order, assay_params) {</span>
<span id="cb7-42">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-43"></span>
<span id="cb7-44">  cv_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-47">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_all =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-48"></span>
<span id="cb7-49">  cv_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-50">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-51">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-53">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-54">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_usable =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-55"></span>
<span id="cb7-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_order, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-57">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_all, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-60">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">excluded_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(sample_id, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb7-61">        w <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable]</span>
<span id="cb7-62">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(w) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(w, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)</span>
<span id="cb7-63">      }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb7-64">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_all    =</span> cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_usable =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> cv_usable <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct</span>
<span id="cb7-66">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-67">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-68">}</span>
<span id="cb7-69"></span>
<span id="cb7-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## calculate_cs_activity()</span></span>
<span id="cb7-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute per-sample CS activity following Abcam sec 10.3, using</span></span>
<span id="cb7-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           only usable replicates, corrected for the single pooled</span></span>
<span id="cb7-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background rate (note 3), scaled through the standard curve,</span></span>
<span id="cb7-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and normalized to total extracted protein (rather than tissue</span></span>
<span id="cb7-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           weight).</span></span>
<span id="cb7-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates            - data.frame from compute_well_rates()</span></span>
<span id="cb7-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           protein_by_sample     - data.frame from load_protein_concentrations()</span></span>
<span id="cb7-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background_correction - one-row data.frame from</span></span>
<span id="cb7-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    compute_background_correction()</span></span>
<span id="cb7-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope             - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb7-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_nmol_max          - max calibrated GSH concentration, from fit_standard_curve()</span></span>
<span id="cb7-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params          - list with sample_volume_uL, dilution_factor,</span></span>
<span id="cb7-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    homogenate_volume_uL, read_duration_min</span></span>
<span id="cb7-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_long            - data.frame from annotate_wells(), used to</span></span>
<span id="cb7-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    attach family/individual/temperature</span></span>
<span id="cb7-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cs_activity - one row per sample: n_reps_used, mean_rate_mOD_min,</span></span>
<span id="cb7-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sd_rate, cv_rate, family, individual, temperature, conc_ug_mL,</span></span>
<span id="cb7-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           total_protein_mg, bg_rate_mOD_min, corrected_mOD_min,</span></span>
<span id="cb7-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_uL, total_mU_in_homogenate,</span></span>
<span id="cb7-91"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_mg_protein, within_std_range</span></span>
<span id="cb7-92"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-93">calculate_cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, protein_by_sample, background_correction,</span>
<span id="cb7-94">                                   std_slope, std_nmol_max, assay_params, plate_long) {</span>
<span id="cb7-95">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-96"></span>
<span id="cb7-97">  bg_rate <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat)</span>
<span id="cb7-98"></span>
<span id="cb7-99">  sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-100">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-101">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-102">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_reps_used =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_rate_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-103">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_rate =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-104">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_rate =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-105">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-106">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb7-107">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-108">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, conc_ug_mL, total_protein_mg),</span>
<span id="cb7-109">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-110">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-111">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_mOD_min       =</span> bg_rate,</span>
<span id="cb7-112">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">corrected_mOD_min     =</span> mean_rate_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> bg_rate_mOD_min,</span>
<span id="cb7-113">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_OD_min           =</span> corrected_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb7-114">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_per_min          =</span> rate_OD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope,</span>
<span id="cb7-115">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_uL    =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span></span>
<span id="cb7-116">                              assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor,</span>
<span id="cb7-117">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_mU_in_homogenate =</span> activity_mU_per_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb7-118">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_mg_protein =</span> total_mU_in_homogenate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> total_protein_mg,</span>
<span id="cb7-119">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_in_window        =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>read_duration_min),</span>
<span id="cb7-120">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">within_std_range      =</span> nmol_in_window <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> std_nmol_max</span>
<span id="cb7-121">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-122">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-123">}</span>
<span id="cb7-124"></span>
<span id="cb7-125"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-126"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_results_table()</span></span>
<span id="cb7-127"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Assemble the final, presentation-ready per-sample results</span></span>
<span id="cb7-128"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           table from cs_activity, cv_summary and baseline diagnostics,</span></span>
<span id="cb7-129"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           with a plain-language Interpretation column.</span></span>
<span id="cb7-130"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : cs_activity          - data.frame from calculate_cs_activity()</span></span>
<span id="cb7-131"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary           - data.frame from compute_replicate_cv()</span></span>
<span id="cb7-132"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample  - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb7-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params         - list with cv_threshold_pct, homogenate_volume_uL</span></span>
<span id="cb7-134"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : results_table - formatted data.frame, ready for kable()/write.csv()</span></span>
<span id="cb7-135"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-136">build_results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(cs_activity, cv_summary, baseline_per_sample, assay_params) {</span>
<span id="cb7-137">  cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-138">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-139">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-140">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb7-141">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample                       =</span> sample_id,</span>
<span id="cb7-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family                       =</span> family,</span>
<span id="cb7-143">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual                   =</span> individual,</span>
<span id="cb7-144">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature                  =</span> temperature,</span>
<span id="cb7-145">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Protein conc (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-146">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Total protein (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(total_protein_mg, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-147">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Reps used</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, n_all),</span>
<span id="cb7-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV all reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>            <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_all, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-149">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV used reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_rate, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-150">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-151">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">BG rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(bg_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-152">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Corrected rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(corrected_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-153">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/uL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_uL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb7-154">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/mg protein)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_mg_protein, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-155">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV flag</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-156">                                            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FAIL &gt;"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pass"</span>),</span>
<span id="cb7-157">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Elevated baseline reps</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_elevated, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3"</span>),</span>
<span id="cb7-158">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Interpretation               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb7-159">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DO NOT USE - no clean replicate"</span>,</span>
<span id="cb7-160">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - some reps compromised"</span>,</span>
<span id="cb7-161">        cv_rate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_rate) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - imprecise"</span>,</span>
<span id="cb7-162">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span></span>
<span id="cb7-163">      )</span>
<span id="cb7-164">    )</span>
<span id="cb7-165">}</span></code></pre></div>
</section>
<section id="qc-summary-and-narrative-generation" class="level3">
<h3 class="anchored" data-anchor-id="qc-summary-and-narrative-generation">1.3.5 QC summary and narrative generation</h3>
<p>Assembles the per-well QC summary table and auto-generates the plain-language QC findings bullets used in the QC SUMMARY section below.</p>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_qc_summary_table()</span></span>
<span id="cb8-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Consolidate every QC check performed across the pipeline into a</span></span>
<span id="cb8-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           single two-column (check, value) table, suitable for kable() and</span></span>
<span id="cb8-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           for writing to qc_summary.csv. Mirrors the individual find</span></span>
<span id="cb8-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           functions but as compact, at-a-glance figures rather than prose.</span></span>
<span id="cb8-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : layout_wells, reconcile_summary, std_curve, well_diagnostics,</span></span>
<span id="cb8-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates, cv_summary, baseline_per_sample, pos_control,</span></span>
<span id="cb8-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params</span></span>
<span id="cb8-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : qc_summary - data.frame with columns check, value (both chr)</span></span>
<span id="cb8-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-12">build_qc_summary_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(layout_wells, reconcile_summary, std_curve,</span>
<span id="cb8-13">                                    well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-14">                                    baseline_per_sample, pos_control, assay_params) {</span>
<span id="cb8-15">  standard_summary  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-16">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb8-17">  standard_drift    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb8-18">  sample_rates      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb8-19"></span>
<span id="cb8-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb8-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-22">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout"</span>,</span>
<span id="cb8-23">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from absorbance CSV"</span>,</span>
<span id="cb8-24">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max disagreement between absorbance CSV and full report"</span>,</span>
<span id="cb8-25">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard concentrations with replicate CV &gt; threshold"</span>,</span>
<span id="cb8-26">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers"</span>,</span>
<span id="cb8-27">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (outlier-excluded, replicate level)"</span>,</span>
<span id="cb8-28">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (all wells, replicate level)"</span>,</span>
<span id="cb8-29">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells that LOST signal over the run"</span>,</span>
<span id="cb8-30">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards above photometric linearity ceiling"</span>,</span>
<span id="cb8-31">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background control wells behaving as active reactions"</span>,</span>
<span id="cb8-32">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a decreasing trace"</span>,</span>
<span id="cb8-33">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with an elevated starting A412"</span>,</span>
<span id="cb8-34">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with ALL THREE replicates baseline-compromised"</span>,</span>
<span id="cb8-35">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a read glitch"</span>,</span>
<span id="cb8-36">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells usable for rate extraction"</span>,</span>
<span id="cb8-37">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (all reps)"</span>,</span>
<span id="cb8-38">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (usable reps)"</span>,</span>
<span id="cb8-39">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control replicates rising and linear"</span></span>
<span id="cb8-40">    ),</span>
<span id="cb8-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-42">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells),</span>
<span id="cb8-43">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv,</span>
<span id="cb8-44">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.g"</span>, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement),</span>
<span id="cb8-45">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb8-46">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-47">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-48">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-49">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2),</span>
<span id="cb8-50">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb8-51">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift)),</span>
<span id="cb8-52">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max],</span>
<span id="cb8-53">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-54">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-55">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)),</span>
<span id="cb8-56">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-57">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-58">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-59">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-60">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-61">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-62">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(baseline_per_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-63">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id[baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n],</span>
<span id="cb8-64">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-65">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-66">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-67">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_rates)),</span>
<span id="cb8-68">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-69">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-70">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pos_control))</span>
<span id="cb8-71">    ),</span>
<span id="cb8-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-73">  )</span>
<span id="cb8-74">}</span>
<span id="cb8-75"></span>
<span id="cb8-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## generate_qc_findings()</span></span>
<span id="cb8-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Walk the QC/CV/anomaly objects for a plate and emit a</span></span>
<span id="cb8-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           consistent, generic-language markdown bullet list of findings</span></span>
<span id="cb8-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (decreasing/glitched/high-baseline wells, background-control</span></span>
<span id="cb8-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           mix-ups, standard-curve QC failures, CV failures, disqualified</span></span>
<span id="cb8-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           samples). Intended to seed the SUMMARY section of a plate's</span></span>
<span id="cb8-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           .Rmd; a short hand-written subsection for plate-specific</span></span>
<span id="cb8-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           interpretation should follow it.</span></span>
<span id="cb8-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics    - data.frame from compute_well_diagnostics()</span></span>
<span id="cb8-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates          - data.frame from compute_well_rates()</span></span>
<span id="cb8-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary          - data.frame from compute_replicate_cv()</span></span>
<span id="cb8-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb8-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_curve           - list from fit_standard_curve()</span></span>
<span id="cb8-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reconcile_summary   - list from reconcile_kinetic_sources()$summary</span></span>
<span id="cb8-91"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params        - list with cv_threshold_pct, od_linear_max</span></span>
<span id="cb8-92"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : character vector, one markdown bullet per finding (empty</span></span>
<span id="cb8-93"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           findings are omitted, so a clean plate returns a short list)</span></span>
<span id="cb8-94"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-95">generate_qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-96">                                  baseline_per_sample, std_curve,</span>
<span id="cb8-97">                                  reconcile_summary, assay_params) {</span>
<span id="cb8-98">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-99"></span>
<span id="cb8-100">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Source reconciliation</span></span>
<span id="cb8-101">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span></span>
<span id="cb8-102">      (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>)) {</span>
<span id="cb8-103">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-104">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic source disagreement.** %d layout well(s) missing from the absorbance CSV; max disagreement between absorbance CSV and full report was %.4g A412."</span>,</span>
<span id="cb8-105">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement))</span>
<span id="cb8-106">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-107">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-108">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic sources agree.** absorbance CSV and full report agree exactly on all %d shared well x timepoint readings; all layout wells are present."</span>,</span>
<span id="cb8-109">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings))</span>
<span id="cb8-110">  }</span>
<span id="cb8-111"></span>
<span id="cb8-112">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sample wells with decreasing kinetics</span></span>
<span id="cb8-113">  dec_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_decreasing)</span>
<span id="cb8-114">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-115">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-116">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Decreasing kinetics.** %d sample well(s) end lower than (or equal to) their starting A412 and are excluded from rate extraction: %s."</span>,</span>
<span id="cb8-117">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(dec_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-118">  }</span>
<span id="cb8-119"></span>
<span id="cb8-120">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Read glitches</span></span>
<span id="cb8-121">  glitch_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_glitch)</span>
<span id="cb8-122">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-123">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-124">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Read glitches.** %d sample well(s) contain a single read-to-read step inconsistent with its neighbours: %s (only disqualifying if it falls inside the fitted rate window)."</span>,</span>
<span id="cb8-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(glitch_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-126">  }</span>
<span id="cb8-127"></span>
<span id="cb8-128">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Elevated baseline</span></span>
<span id="cb8-129">  high_baseline <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_high_baseline)</span>
<span id="cb8-130">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-131">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-132">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Elevated starting absorbance.** %d sample well(s) start above the baseline threshold (A412 &gt; %s), indicating pre-existing thiol/contamination before the reaction began: %s."</span>,</span>
<span id="cb8-133">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(high_baseline<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-134">  }</span>
<span id="cb8-135"></span>
<span id="cb8-136">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Samples fully disqualified by baseline</span></span>
<span id="cb8-137">  disqualified <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n)</span>
<span id="cb8-138">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(disqualified) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-139">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-140">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Sample(s) with no clean replicate.** Every replicate of %s has an elevated starting A412; these samples have no usable measurement on this plate regardless of CV."</span>,</span>
<span id="cb8-141">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(disqualified<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-142">  }</span>
<span id="cb8-143"></span>
<span id="cb8-144">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Over-range wells</span></span>
<span id="cb8-145">  over_range <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(flag_over_range)</span>
<span id="cb8-146">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-147">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Over-range wells.** %d well(s) exceed the photometric linearity ceiling (A412 &gt; %s): %s."</span>,</span>
<span id="cb8-149">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-150">  }</span>
<span id="cb8-151"></span>
<span id="cb8-152">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Background wells behaving as active reactions</span></span>
<span id="cb8-153">  bg_active <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>, flag_bg_active)</span>
<span id="cb8-154">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-155">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-156">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Background control wells behaving as active reactions.** %d of %d background wells show a starting A412 or drift inconsistent with a flat, inactive well: %s."</span>,</span>
<span id="cb8-157">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb8-158">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(bg_active<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-159">  }</span>
<span id="cb8-160"></span>
<span id="cb8-161">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standard curve QC</span></span>
<span id="cb8-162">  std_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-163">  cv_fail_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct)</span>
<span id="cb8-164">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-165">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-166">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**GSH standard curve replicate imprecision.** %d of %d concentrations exceed %s%% CV: %s nmol/well."</span>,</span>
<span id="cb8-167">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-168">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(cv_fail_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-169">  }</span>
<span id="cb8-170">  n_std_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier)</span>
<span id="cb8-171">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_std_outliers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-172">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-173">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard outlier wells.** %d of %d standard wells deviate from their triplicate median by more than %s A412: %s."</span>,</span>
<span id="cb8-174">      n_std_outliers, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od,</span>
<span id="cb8-175">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-176">  }</span>
<span id="cb8-177">  over_range_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max)</span>
<span id="cb8-178">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-179">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-180">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standards above the photometric linear range.** %s nmol/well read above A412 %s; the calibration is trustworthy only below these concentrations."</span>,</span>
<span id="cb8-181">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max))</span>
<span id="cb8-182">  }</span>
<span id="cb8-183">  n_drift_neg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-184">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_drift_neg <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-185">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-186">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard signal decay.** %d of %d standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0."</span>,</span>
<span id="cb8-187">      n_drift_neg, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift)))</span>
<span id="cb8-188">  }</span>
<span id="cb8-189">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-190">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard curve fit (outlier-excluded):** slope = %.5f A412/nmol, R^2 = %.4f (all-wells R^2 = %.4f)."</span>,</span>
<span id="cb8-191">    std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared))</span>
<span id="cb8-192"></span>
<span id="cb8-193">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Technical replicate CV failures</span></span>
<span id="cb8-194">  fail_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all)</span>
<span id="cb8-195">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-196">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-197">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% (all replicates).** %d of %d samples: %s."</span>,</span>
<span id="cb8-198">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary),</span>
<span id="cb8-199">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%)"</span>, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-200">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-201">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-202">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV.** All %d samples are within %s%% CV across all three replicates."</span>,</span>
<span id="cb8-203">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct))</span>
<span id="cb8-204">  }</span>
<span id="cb8-205">  fail_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable)</span>
<span id="cb8-206">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-207">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-208">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% persists after excluding flagged replicates.** %s."</span>,</span>
<span id="cb8-209">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-210">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%, n=%d)"</span>, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_usable,</span>
<span id="cb8-211">                    fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_usable), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-212">  }</span>
<span id="cb8-213"></span>
<span id="cb8-214">  bullets</span>
<span id="cb8-215">}</span></code></pre></div>
</section>
</section>
<section id="assay-parameters" class="level2">
<h2 class="anchored" data-anchor-id="assay-parameters">1.4 Assay parameters</h2>
<p>All assay constants and QC thresholds are collected here so nothing downstream hard-codes a number.</p>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">assay_params <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb9-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># homogenate volume per reaction well (V in Abcam formula); also the pooled-background volume (note 3)</span></span>
<span id="cb9-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">buffer_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">48</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Assay Buffer 7 added to reach 50 uL pre-Reaction Mix</span></span>
<span id="cb9-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_factor       =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># D; layout `df.0` = undiluted homogenate</span></span>
<span id="cb9-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_volume_uL  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MEASURED buffer volume tissue was homogenized in (see note 2)</span></span>
<span id="cb9-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_wavelength_nm    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">412</span>,</span>
<span id="cb9-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_interval_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb9-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_duration_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># see note 1</span></span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_window_n         =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># points per sliding regression window (5 pts = 8 min)</span></span>
<span id="cb9-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_min_r2           =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.80</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># min R^2 for a rate window to be trusted</span></span>
<span id="cb9-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_excess_od      =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |step - mean of neighbouring steps| flagging a read glitch</span></span>
<span id="cb9-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_threshold_pct      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># technical-replicate CV QC threshold</span></span>
<span id="cb9-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_linear_max         =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># upper A412 bound for reliable photometry</span></span>
<span id="cb9-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_outlier_od        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |deviation from triplicate median| flagging a standard well</span></span>
<span id="cb9-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_baseline_od    =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># max acceptable t0 A412 for a sample well</span></span>
<span id="cb9-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_od_max        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a well-behaved background well starts below this A412</span></span>
<span id="cb9-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_drift_max     =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ...and drifts less than this over the whole run</span></span>
<span id="cb9-18">)</span>
<span id="cb9-19"></span>
<span id="cb9-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- assay_params: assay constants and QC thresholds ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb9-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(assay_params)</span></code></pre></div>
<pre><code>--- assay_params: assay constants and QC thresholds ---

List of 16
 $ sample_volume_uL    : num 2
 $ buffer_volume_uL    : num 48
 $ dilution_factor     : num 1
 $ homogenate_volume_uL: num 350
 $ read_wavelength_nm  : num 412
 $ read_interval_min   : num 2
 $ read_duration_min   : num 20
 $ rate_window_n       : num 5
 $ rate_min_r2         : num 0.8
 $ glitch_excess_od    : num 0.02
 $ cv_threshold_pct    : num 15
 $ od_linear_max       : num 1.5
 $ std_outlier_od      : num 0.15
 $ sample_baseline_od  : num 0.35
 $ bg_flat_od_max      : num 0.15
 $ bg_flat_drift_max   : num 0.05</code></pre>
</section>
<section id="output-directory" class="level2">
<h2 class="anchored" data-anchor-id="output-directory">1.5 Output directory</h2>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Output directory for this analysis (matches this file's name, per ../code/README.md)</span></span>
<span id="cb11-2">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C"</span></span>
<span id="cb11-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb11-4"></span>
<span id="cb11-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- output_dir: destination for all figures and tables ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb11-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(output_dir)</span></code></pre></div>
<pre><code>--- output_dir: destination for all figures and tables ---
 chr "../outputs/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C"</code></pre>
</section>
</section>
<section id="data" class="level1">
<h1>2 DATA</h1>
<p>Data are read from the local repo (<code>../data/raw_absorbance/</code>) so this document renders before/after the files are pushed to GitHub.</p>
<section id="plate-layout" class="level2">
<h2 class="anchored" data-anchor-id="plate-layout">2.1 Plate layout</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">data_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/raw_absorbance"</span></span>
<span id="cb13-2">run_stem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C"</span></span>
<span id="cb13-3"></span>
<span id="cb13-4">layout_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_layout</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb13-5"></span>
<span id="cb13-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout format detected:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(layout_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-8"></span>
<span id="cb13-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- layout_wells: one row per occupied well, with its descriptive label ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(layout_wells)</span></code></pre></div>
<pre><code>Layout format detected: single 
Occupied wells in layout: 72 

--- layout_wells: one row per occupied well, with its descriptive label ---

'data.frame':   72 obs. of  4 variables:
 $ well     : chr  "A1" "A2" "A3" "A4" ...
 $ plate_row: chr  "A" "A" "A" "A" ...
 $ plate_col: int  1 2 3 4 5 6 7 8 9 10 ...
 $ label    : chr  "F07_01_ambient-citrate_synthase-7.3-df.0" "F07_01_ambient-citrate_synthase-7.3-df.0" "F07_01_ambient-citrate_synthase-7.3-df.0" "F07_02_ambient-citrate_synthase-19.4-df.0" ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "row_idx" "col_idx"
  ..$ dimnames:List of 2
  .. ..$ row_idx: chr [1:8] "row_idx=2" "row_idx=3" "row_idx=4" "row_idx=5" ...
  .. ..$ col_idx: chr [1:12] "col_idx= 2" "col_idx= 3" "col_idx= 4" "col_idx= 5" ...
 - attr(*, "layout_format")= chr "single"</code></pre>
</section>
<section id="kinetic-readers" class="level2">
<h2 class="anchored" data-anchor-id="kinetic-readers">2.2 Kinetic readers</h2>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_absorbance_csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb15-2">full_report    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_full_report</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full_report-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".txt"</span>)))</span>
<span id="cb15-3"></span>
<span id="cb15-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance CSV : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-5">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full report    : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-7">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-8"></span>
<span id="cb15-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- absorbance_csv: long-format readings from absorbance-*.csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(absorbance_csv)</span>
<span id="cb15-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- full_report: long-format readings from full_report-*.txt ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(full_report)</span></code></pre></div>
<pre><code>absorbance CSV : 72 wells x 11 timepoints
full report    : 72 wells x 11 timepoints

--- absorbance_csv: long-format readings from absorbance-*.csv ---

'data.frame':   792 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.114 0.12 0.127 0.134 0.141 0.147 0.154 0.161 0.167 0.173 ...

--- full_report: long-format readings from full_report-*.txt ---

'data.frame':   792 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.114 0.12 0.127 0.134 0.141 0.147 0.154 0.161 0.167 0.173 ...</code></pre>
</section>
<section id="cross-check-against-the-full-report" class="level2">
<h2 class="anchored" data-anchor-id="cross-check-against-the-full-report">2.3 Cross-check against the full report</h2>
<p><code>absorbance-*.csv</code> is used for every well; <code>full_report-*.txt</code> is used only to confirm the CSV is trustworthy: every well it reports should also be in the CSV, every well the layout expects should be in the CSV, and every reading the two files share should agree exactly.</p>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">recon <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reconcile_kinetic_sources</span>(absorbance_csv, full_report, layout_wells)</span>
<span id="cb17-2">plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_readings</span>
<span id="cb17-3"></span>
<span id="cb17-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in absorbance CSV          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report             :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report not in CSV  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from CSV    :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CSV wells not in layout          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv_not_layout, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shared well x timepoints         :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max |CSV - report| disagreement  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-11"></span>
<span id="cb17-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- recon$overlap_check: per-reading comparison of the two raw files ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>overlap_check)</span>
<span id="cb17-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_readings: readings for all occupied wells, from absorbance_csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_readings)</span></code></pre></div>
<pre><code>Wells in absorbance CSV          : 72 
Wells in full report             : 72 
Wells in full report not in CSV  : 0 
Layout wells missing from CSV    : 0 
CSV wells not in layout          : 0 
Shared well x timepoints         : 792 
Max |CSV - report| disagreement  : 0 

--- recon$overlap_check: per-reading comparison of the two raw files ---

'data.frame':   792 obs. of  5 variables:
 $ well     : chr  "A1" "A1" "A1" "A1" ...
 $ time_min : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od_csv   : num  0.114 0.12 0.127 0.134 0.141 0.147 0.154 0.161 0.167 0.173 ...
 $ od_report: num  0.114 0.12 0.127 0.134 0.141 0.147 0.154 0.161 0.167 0.173 ...
 $ abs_diff : num  0 0 0 0 0 0 0 0 0 0 ...

--- plate_readings: readings for all occupied wells, from absorbance_csv ---

'data.frame':   792 obs. of  4 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.114 0.12 0.127 0.134 0.141 0.147 0.154 0.161 0.167 0.173 ...
 $ source  : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...</code></pre>
<p>This plate’s <code>absorbance-*.csv</code> covers the full 72 occupied wells (48 sample + 18 standard + 3 positive-control + 3 pooled-background, note 3) and the layout carries no spelling typo, so no label fix is needed here. An earlier export of this file was missing 6 wells (the <code>BG</code> triplicate and the <code>STD-0</code> triplicate) relative to the layout and <code>full_report</code>; it was re-exported from Gen5 before this analysis was run, and the check above now passes cleanly.</p>
</section>
<section id="annotate-wells-and-parse-metadata" class="level2">
<h2 class="anchored" data-anchor-id="annotate-wells-and-parse-metadata">2.4 Annotate wells and parse metadata</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate_wells</span>(plate_readings, layout_wells))</span>
<span id="cb19-2"></span>
<span id="cb19-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells per type:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(well, well_type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_wells"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-5">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb19-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards (nmol/well):"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-8"></span>
<span id="cb19-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_long: fully annotated long-format plate, one row per well x timepoint ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_long)</span></code></pre></div>
<pre><code>Wells per type:
        well_type n_wells
       background       3
 positive_control       3
           sample      48
         standard      18

Samples: F07_01_36C, F07_01_ambient, F07_02_36C, F07_02_ambient, F07_03_36C, F07_03_ambient, F07_04_36C, F07_04_ambient, F07_05_36C, F07_05_ambient, F07_06_36C, F07_06_ambient, F07_07_36C, F07_07_ambient, F07_08_36C, F07_08_ambient 
Standards (nmol/well): 0, 8, 16, 24, 32, 40 

--- plate_long: fully annotated long-format plate, one row per well x timepoint ---

'data.frame':   792 obs. of  15 variables:
 $ well       : chr  "F10" "F10" "F10" "F10" ...
 $ time_min   : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od         : num  0.156 0.176 0.196 0.213 0.227 0.239 0.249 0.257 0.263 0.269 ...
 $ source     : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ plate_row  : chr  "F" "F" "F" "F" ...
 $ plate_col  : int  10 10 10 10 10 10 10 10 10 10 ...
 $ label      : chr  "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" ...
 $ well_type  : chr  "background" "background" "background" "background" ...
 $ label_clean: chr  "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" "BG-citrate_synthase" ...
 $ sample_id  : chr  NA NA NA NA ...
 $ family     : chr  NA NA NA NA ...
 $ individual : chr  NA NA NA NA ...
 $ temperature: chr  NA NA NA NA ...
 $ weight_mg  : num  NA NA NA NA NA NA NA NA NA NA ...
 $ std_nmol   : num  NA NA NA NA NA NA NA NA NA NA ...</code></pre>
<p><code>annotate_wells()</code> emits a harmless <code>NAs introduced by coercion</code> warning (suppressed above), because its <code>weight_mg</code> parser only applies to <code>sample</code> wells and returns <code>NA</code> for standards/positive control/background by construction (background is a pooled control with no individual weight of its own, note 3). No <code>weight_mg</code> value is actually missing for a sample well; <code>annotate_wells()</code>’s internal <code>stopifnot()</code> would halt otherwise.</p>
</section>
<section id="protein-concentration-normalization-factor" class="level2">
<h2 class="anchored" data-anchor-id="protein-concentration-normalization-factor">2.5 Protein concentration (normalization factor)</h2>
<p>Activity is normalized to total extracted protein rather than tissue weight (note 2). Protein concentration for each sample was measured on a separate BCA/Bradford-style plate (595 nm): 12 of this plate’s 16 samples come from the primary <code>F07</code> protein-quantification run, and the remaining 4 (flagged for re-assay in that run) come from a follow-up re-assay plate. No <code>Sample</code> string typo needed correction for this plate’s samples.</p>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">protein_files <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb21-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/sample_protein_concentrations_2.csv"</span>,</span>
<span id="cb21-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260813-mgig-BSA-F07/sample_protein_concentrations.csv"</span></span>
<span id="cb21-4">)</span>
<span id="cb21-5"></span>
<span id="cb21-6">plate_sample_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)))</span>
<span id="cb21-7"></span>
<span id="cb21-8">protein_by_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">load_protein_concentrations</span>(protein_files, plate_sample_ids,</span>
<span id="cb21-9">                                                  assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-11">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb21-12">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb21-13"></span>
<span id="cb21-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples matched to a protein concentration record:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample),</span>
<span id="cb21-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(plate_sample_ids), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein concentration range (ug/mL):"</span>,</span>
<span id="cb21-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_ug_mL), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total protein per homogenate range (mg):"</span>,</span>
<span id="cb21-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, source_file, conc_ug_mL, total_protein_mg) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-21">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb21-22"></span>
<span id="cb21-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_by_sample: matched protein concentration and total protein per homogenate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_by_sample)</span></code></pre></div>
<pre><code>Samples matched to a protein concentration record: 16 / 16 
Protein concentration range (ug/mL): 263.1 - 1644.6 
Total protein per homogenate range (mg): 0.092 - 0.576 

      sample_id                         source_file conc_ug_mL total_protein_mg
     F07_01_36C   sample_protein_concentrations.csv      663.3         0.232155
 F07_01_ambient sample_protein_concentrations_2.csv      263.1         0.092085
     F07_02_36C   sample_protein_concentrations.csv      932.4         0.326340
 F07_02_ambient   sample_protein_concentrations.csv     1080.1         0.378035
     F07_03_36C   sample_protein_concentrations.csv     1205.5         0.421925
 F07_03_ambient   sample_protein_concentrations.csv     1155.6         0.404460
     F07_04_36C   sample_protein_concentrations.csv     1567.2         0.548520
 F07_04_ambient sample_protein_concentrations_2.csv      560.0         0.196000
     F07_05_36C sample_protein_concentrations_2.csv      427.9         0.149765
 F07_05_ambient   sample_protein_concentrations.csv      659.3         0.230755
     F07_06_36C   sample_protein_concentrations.csv      496.5         0.173775
 F07_06_ambient sample_protein_concentrations_2.csv     1119.4         0.391790
     F07_07_36C   sample_protein_concentrations.csv     1038.1         0.363335
 F07_07_ambient   sample_protein_concentrations.csv     1644.6         0.575610
     F07_08_36C   sample_protein_concentrations.csv      289.8         0.101430
 F07_08_ambient   sample_protein_concentrations.csv      560.2         0.196070

--- protein_by_sample: matched protein concentration and total protein per homogenate ---

'data.frame':   16 obs. of  7 variables:
 $ sample_id       : chr  "F07_01_36C" "F07_01_ambient" "F07_02_36C" "F07_02_ambient" ...
 $ source_file     : chr  "sample_protein_concentrations.csv" "sample_protein_concentrations_2.csv" "sample_protein_concentrations.csv" "sample_protein_concentrations.csv" ...
 $ conc_ug_mL      : num  663 263 932 1080 1206 ...
 $ total_protein_mg: num  0.2322 0.0921 0.3263 0.378 0.4219 ...
 $ family          : chr  "F07" "F07" "F07" "F07" ...
 $ individual      : chr  "01" "01" "02" "02" ...
 $ temperature     : chr  "36C" "ambient" "36C" "ambient" ...</code></pre>
</section>
</section>
<section id="kinetic-traces" class="level1">
<h1>3 KINETIC TRACES</h1>
<p>Every trace is plotted before any rate is extracted. In this assay the <strong>shape</strong> of the trace is the primary diagnostic: CS activity must produce a monotonically <em>rising</em> A412, and only a genuinely linear stretch may be used for a rate.</p>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">trace_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plate_long, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> plate_row <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> plate_col, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>,</span>
<span id="cb23-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labeller =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row, d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>,</span>
<span id="cb23-8">                                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">positive_control =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6a51a3"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 kinetic traces, all occupied wells"</span>,</span>
<span id="cb23-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dotted line = assumed photometric linearity ceiling (A412 = "</span>,</span>
<span id="cb23-11">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-12">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Rising traces only are usable for rate extraction."</span>),</span>
<span id="cb23-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (min)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb23-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>),</span>
<span id="cb23-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb23-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb23-19"></span>
<span id="cb23-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kinetic_traces_all_wells.png"</span>), trace_plot,</span>
<span id="cb23-21">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb23-22"></span>
<span id="cb23-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- trace_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb23-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(trace_plot)</span>
<span id="cb23-25"></span>
<span id="cb23-26">trace_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C_files/figure-gfm/plot-kinetic-traces-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- trace_plot: ggplot object structure ---

data: well, time_min, od, source, plate_row, plate_col, label,
  well_type, label_clean, sample_id, family, individual, temperature,
  weight_mg, std_nmol [792x15]
mapping:  x = ~time_min, y = ~od, group = ~well, colour = ~well_type
scales:   colour 
faceting:  ~plate_row, ~plate_col 
-----------------------------------
geom_line: na.rm = FALSE, orientation = NA, arrow = NULL, arrow.fill = NULL, lineend = butt, linejoin = round, linemitre = 10
stat_identity: na.rm = FALSE
position_identity 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
<p>Nearly every sample and positive-control trace on this plate rises across the full 20-minute window (replicate-level R<sup>2</sup> &gt; 0.99 for the fitted rate window on 47 of the 48 sample wells, computed below) – the sole exception, <code>A7</code> (<code>F07_03_ambient</code>), is completely flat at A412 0.099 for all 11 reads, a dead/failed well rather than a slow reaction (see ANOMALY DETECTION). The three pooled-background traces (<code>F10</code>-<code>F12</code>) are <strong>not</strong> flat here – they rise at a rate closer to a sample well than a background well, the signature of the confirmed Reaction Mix mix-up (note 4).</p>
</section>
<section id="anomaly-detection" class="level1">
<h1>4 ANOMALY DETECTION</h1>
<section id="per-well-trace-diagnostics" class="level2">
<h2 class="anchored" data-anchor-id="per-well-trace-diagnostics">4.1 Per-well trace diagnostics</h2>
<p>Four independent checks, computed from the raw trace before any rate fitting:</p>
<ol type="1">
<li><strong>Direction</strong> — net A412 change from first to last read. A CS-containing well must be positive.</li>
<li><strong>Monotonicity</strong> — fraction of the 10 read-to-read intervals that rise.</li>
<li><strong>Over-range</strong> — any read above the photometric linearity ceiling.</li>
<li><strong>Discontinuity</strong> — a single read-to-read step that departs from its two <em>neighbouring</em> steps, catching read glitches rather than biology.</li>
</ol>
<p>Two further checks specific to well role: an elevated starting A412 (pre-existing thiol/contamination) for sample wells, and a background well whose trace is not flat (indicating it received Reaction Mix rather than Background Control Mix).</p>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_diagnostics</span>(plate_long, assay_params)</span>
<span id="cb25-2"></span>
<span id="cb25-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Flag counts across all"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">starts_with</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flag_"</span>), sum)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-5">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb25-6"></span>
<span id="cb25-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Wells with at least one flag:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-8"></span>
<span id="cb25-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- well_diagnostics: per-well trace diagnostics and anomaly flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_diagnostics)</span></code></pre></div>
<pre><code>Flag counts across all 72 wells:
 flag_decreasing flag_over_range flag_glitch flag_high_baseline flag_bg_active
              16               0           0                  0              3

Wells with at least one flag: 19 / 72 

--- well_diagnostics: per-well trace diagnostics and anomaly flags ---

tibble [72 × 24] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:72] "A1" "A10" "A11" "A12" ...
 $ plate_row         : chr [1:72] "A" "A" "A" "A" ...
 $ plate_col         : int [1:72] 1 10 11 12 2 3 4 5 6 7 ...
 $ well_type         : chr [1:72] "sample" "sample" "sample" "sample" ...
 $ sample_id         : chr [1:72] "F07_01_ambient" "F07_04_ambient" "F07_04_ambient" "F07_04_ambient" ...
 $ label             : chr [1:72] "F07_01_ambient-citrate_synthase-7.3-df.0" "F07_04_ambient-citrate_synthase-10.7-df.0" "F07_04_ambient-citrate_synthase-10.7-df.0" "F07_04_ambient-citrate_synthase-10.7-df.0" ...
 $ std_nmol          : num [1:72] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:72] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:72] 0.114 0.126 0.126 0.126 0.115 0.115 0.147 0.148 0.146 0.099 ...
 $ od_last           : num [1:72] 0.18 0.22 0.22 0.221 0.182 0.181 0.263 0.268 0.263 0.099 ...
 $ od_max            : num [1:72] 0.18 0.22 0.22 0.221 0.182 0.181 0.263 0.268 0.263 0.099 ...
 $ net_change        : num [1:72] 0.066 0.094 0.094 0.095 0.067 0.066 0.116 0.12 0.117 0 ...
 $ frac_rising       : num [1:72] 1 1 1 1 1 1 1 1 1 0 ...
 $ max_step          : num [1:72] 0.007 0.01 0.01 0.01 0.007 0.007 0.016 0.016 0.016 0 ...
 $ typical_step      : num [1:72] 0.007 0.0095 0.0095 0.0095 0.007 ...
 $ step_excess       : num [1:72] 0.001 0.0015 -0.001 -0.001 -0.001 ...
 $ glitch_at_min     : num [1:72] 20 14 18 10 18 2 2 6 2 2 ...
 $ step_ratio        : num [1:72] 1 1.05 1.05 1.05 1 ...
 $ flag_decreasing   : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range   : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags           : int [1:72] 0 0 0 0 0 0 0 0 0 1 ...</code></pre>
</section>
<section id="anomaly-table" class="level2">
<h2 class="anchored" data-anchor-id="anomaly-table">4.2 Anomaly table</h2>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">anomaly_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, well_type, od_first, net_change, n_flags,</span>
<span id="cb27-4">         flag_decreasing, flag_over_range, flag_glitch,</span>
<span id="cb27-5">         flag_high_baseline, flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(n_flags), well)</span>
<span id="cb27-7"></span>
<span id="cb27-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(anomaly_table, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb27-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells with at least one anomaly flag"</span>)</span>
<span id="cb27-10"></span>
<span id="cb27-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Total flagged wells:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(anomaly_table), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-12"></span>
<span id="cb27-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- anomaly_table: all flagged wells with their specific flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(anomaly_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: left;">well_type</th>
<th style="text-align: right;">od_first</th>
<th style="text-align: right;">net_change</th>
<th style="text-align: right;">n_flags</th>
<th style="text-align: left;">flag_decreasing</th>
<th style="text-align: left;">flag_over_range</th>
<th style="text-align: left;">flag_glitch</th>
<th style="text-align: left;">flag_high_baseline</th>
<th style="text-align: left;">flag_bg_active</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A7</td>
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">0.099</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E10</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.849</td>
<td style="text-align: right;">-0.013</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E11</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.854</td>
<td style="text-align: right;">-0.011</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E12</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.856</td>
<td style="text-align: right;">-0.013</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E4</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.364</td>
<td style="text-align: right;">-0.004</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E5</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.373</td>
<td style="text-align: right;">-0.004</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E6</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.373</td>
<td style="text-align: right;">-0.003</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E7</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.636</td>
<td style="text-align: right;">-0.007</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E8</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.627</td>
<td style="text-align: right;">-0.007</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E9</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0.617</td>
<td style="text-align: right;">-0.005</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F1</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.107</td>
<td style="text-align: right;">-0.029</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F10</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">background</td>
<td style="text-align: right;">0.156</td>
<td style="text-align: right;">0.119</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F11</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">background</td>
<td style="text-align: right;">0.152</td>
<td style="text-align: right;">0.119</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F12</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">background</td>
<td style="text-align: right;">0.118</td>
<td style="text-align: right;">0.067</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F2</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.118</td>
<td style="text-align: right;">-0.018</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F3</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.098</td>
<td style="text-align: right;">-0.018</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F4</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.370</td>
<td style="text-align: right;">-0.027</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F5</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.367</td>
<td style="text-align: right;">-0.024</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F6</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.360</td>
<td style="text-align: right;">-0.027</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
</tbody>
</table>
<p>Wells with at least one anomaly flag</p>
<pre><code>Total flagged wells: 19 / 72 

--- anomaly_table: all flagged wells with their specific flags ---

tibble [19 × 11] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:19] "A7" "E10" "E11" "E12" ...
 $ sample_id         : chr [1:19] "F07_03_ambient" NA NA NA ...
 $ well_type         : chr [1:19] "sample" "standard" "standard" "standard" ...
 $ od_first          : num [1:19] 0.099 0.849 0.854 0.856 0.364 0.373 0.373 0.636 0.627 0.617 ...
 $ net_change        : num [1:19] 0 -0.013 -0.011 -0.013 -0.004 ...
 $ n_flags           : int [1:19] 1 1 1 1 1 1 1 1 1 1 ...
 $ flag_decreasing   : logi [1:19] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ flag_over_range   : logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<p>19 of the 72 wells are flagged, in three distinct groups:</p>
<ol type="1">
<li><strong>15 GSH standard wells</strong> are flagged <code>flag_decreasing</code> – all five non-zero concentrations (8, 16, 24, 32, 40 nmol) end at or below their own starting A412 over the 20-minute window, consistent with TNB<sup>2-</sup> signal decay (see GSH STANDARD CURVE below). Because the standard curve is calibrated at t = 0 (not from the endpoint), this does not compromise the calibration (R<sup>2</sup> = 0.9992, no outlier wells).</li>
<li><strong>All 3 pooled-background wells</strong> (<code>F10</code>, <code>F11</code>, <code>F12</code>) are flagged <code>flag_bg_active</code> – the confirmed Reaction Mix mix-up (note 4). See BACKGROUND CORRECTION for what this means for this plate’s activity values.</li>
<li><strong>One sample well</strong>, <code>A7</code> (<code>F07_03_ambient</code>), is flagged <code>flag_decreasing</code> – it is completely flat (net change = 0.000, A412 = 0.099 for all 11 reads), not a slow-rising reaction. Its two sibling replicates (<code>A8</code>, <code>A9</code>) rise normally, so <code>F07_03_ambient</code>’s activity is still computed from 2 of 3 replicates (see RATE EXTRACTION and TECHNICAL REPLICATE PRECISION).</li>
</ol>
<p>No sample well shows a read glitch or an elevated starting baseline, and no sample well besides <code>A7</code> fails to rise.</p>
</section>
<section id="background-wells-behaving-as-active-reactions" class="level2">
<h2 class="anchored" data-anchor-id="background-wells-behaving-as-active-reactions">4.3 Background wells behaving as active reactions</h2>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">bg_active_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>, flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, od_first, net_change)</span>
<span id="cb29-4"></span>
<span id="cb29-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(bg_active_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb29-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background wells with a non-flat trace"</span>)</span>
<span id="cb29-7"></span>
<span id="cb29-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background wells behaving as active reactions:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active_wells),</span>
<span id="cb29-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-10"></span>
<span id="cb29-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_active_wells: background wells excluded from the background-rate estimate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_active_wells)</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">od_first</th>
<th style="text-align: right;">net_change</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F10</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">0.156</td>
<td style="text-align: right;">0.119</td>
</tr>
<tr class="even">
<td style="text-align: left;">F11</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">0.152</td>
<td style="text-align: right;">0.119</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F12</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">0.118</td>
<td style="text-align: right;">0.067</td>
</tr>
</tbody>
</table>
<p>Background wells with a non-flat trace</p>
<pre><code>Background wells behaving as active reactions: 3 / 3 

--- bg_active_wells: background wells excluded from the background-rate estimate ---

tibble [3 × 4] (S3: tbl_df/tbl/data.frame)
 $ well      : chr [1:3] "F10" "F11" "F12"
 $ sample_id : chr [1:3] NA NA NA
 $ od_first  : num [1:3] 0.156 0.152 0.118
 $ net_change: num [1:3] 0.119 0.119 0.067</code></pre>
<p><strong>All three pooled-background replicates are flagged.</strong> <code>F10</code> and <code>F11</code> start slightly above the 0.15 A412 threshold (0.156, 0.152) and <code>F12</code> starts just under it (0.118), but all three fail on drift regardless: net change 0.067-0.119 A412 over 20 minutes, 1.3-2.4x the 0.05 flat-well threshold and of the same order of magnitude as a real sample’s signal. This is the confirmed Reaction Mix mix-up (note 4), not genuine background activity. Because 0 of 3 replicates are flat, none are used in a background-rate estimate – see BACKGROUND CORRECTION.</p>
</section>
<section id="baseline-diagnostic-elevated-starting-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="baseline-diagnostic-elevated-starting-absorbance">4.4 Baseline diagnostic (elevated starting absorbance)</h2>
<div class="sourceCode" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1">bd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_baseline_diagnostics</span>(well_diagnostics, assay_params)</span>
<span id="cb31-2">baseline_check       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_check</span>
<span id="cb31-3">baseline_per_sample  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_per_sample</span>
<span id="cb31-4"></span>
<span id="cb31-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample/background wells with elevated starting A412 (&gt; "</span>,</span>
<span id="cb31-6">    assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"):"</span>,</span>
<span id="cb31-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline_check<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(baseline_check), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb31-8"></span>
<span id="cb31-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(baseline_per_sample, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb31-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Elevated-baseline replicate count per sample"</span>)</span>
<span id="cb31-11"></span>
<span id="cb31-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_check: per-well baseline classification ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb31-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_check)</span>
<span id="cb31-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_per_sample: elevated-replicate count per sample ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb31-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_per_sample)</span></code></pre></div>
<pre><code>Sample/background wells with elevated starting A412 (&gt; 0.35):0/51</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">n_elevated</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">median_baseline</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.131</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.115</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.150</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.147</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.156</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.140</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.159</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.126</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.123</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.141</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.120</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.151</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.141</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.159</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.117</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.128</td>
</tr>
</tbody>
</table>
<p>Elevated-baseline replicate count per sample</p>
<pre><code>--- baseline_check: per-well baseline classification ---

tibble [51 × 25] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:51] "B9" "C10" "B7" "B8" ...
 $ plate_row         : chr [1:51] "B" "C" "B" "B" ...
 $ plate_col         : int [1:51] 9 10 7 8 12 11 8 7 10 5 ...
 $ well_type         : chr [1:51] "sample" "sample" "sample" "sample" ...
 $ sample_id         : chr [1:51] "F07_07_ambient" "F07_04_36C" "F07_07_ambient" "F07_07_ambient" ...
 $ label             : chr [1:51] "F07_07_ambient-citrate_synthase-20.6-df.0" "F07_04_36C-citrate_synthase-16.9-df.0" "F07_07_ambient-citrate_synthase-20.6-df.0" "F07_07_ambient-citrate_synthase-20.6-df.0" ...
 $ std_nmol          : num [1:51] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:51] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:51] 0.161 0.161 0.159 0.159 0.159 0.158 0.157 0.156 0.156 0.153 ...
 $ od_last           : num [1:51] 0.281 0.281 0.277 0.279 0.283 0.279 0.282 0.28 0.275 0.274 ...
 $ od_max            : num [1:51] 0.281 0.281 0.277 0.279 0.283 0.279 0.282 0.28 0.275 0.274 ...
 $ net_change        : num [1:51] 0.12 0.12 0.118 0.12 0.124 0.121 0.125 0.124 0.119 0.121 ...
 $ frac_rising       : num [1:51] 1 1 1 1 1 1 1 1 1 1 ...
 $ max_step          : num [1:51] 0.018 0.018 0.018 0.018 0.019 ...
 $ typical_step      : num [1:51] 0.012 0.012 0.0115 0.0115 0.0125 0.012 0.012 0.0125 0.011 0.0125 ...
 $ step_excess       : num [1:51] -0.001 0.001 0.0015 -0.0015 -0.001 ...
 $ glitch_at_min     : num [1:51] 20 4 14 16 20 16 8 20 4 2 ...
 $ step_ratio        : num [1:51] 1.5 1.5 1.57 1.57 1.52 ...
 $ flag_decreasing   : logi [1:51] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range   : logi [1:51] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:51] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:51] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:51] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags           : int [1:51] 0 0 0 0 0 0 0 0 1 0 ...
 $ baseline          : chr [1:51] "normal" "normal" "normal" "normal" ...

--- baseline_per_sample: elevated-replicate count per sample ---

tibble [16 × 4] (S3: tbl_df/tbl/data.frame)
 $ sample_id      : chr [1:16] "F07_01_36C" "F07_01_ambient" "F07_02_36C" "F07_02_ambient" ...
 $ n_elevated     : int [1:16] 0 0 0 0 0 0 0 0 0 0 ...
 $ n              : int [1:16] 3 3 3 3 3 3 3 3 3 3 ...
 $ median_baseline: num [1:16] 0.131 0.115 0.15 0.147 0.156 0.14 0.159 0.126 0.123 0.141 ...</code></pre>
<p>No sample or background well anywhere on this plate starts above A412 0.35 — sample wells start within a 0.099-0.161 range (the low end is <code>A7</code>‘s dead well) and the pooled background wells start within 0.118-0.156, both well below the 0.35 threshold. No sample has any elevated-baseline replicate, and none is disqualified on this basis – the background wells’ problem is their <em>drift</em>, not their starting absorbance (note 4).</p>
</section>
<section id="plot-starting-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="plot-starting-absorbance">4.5 Plot starting absorbance</h2>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">baseline_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(baseline_check, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(well, od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od_first,</span>
<span id="cb34-2">                                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb34-5">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Starting A412 (t = 0) for every sample/background well"</span>,</span>
<span id="cb34-8">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dashed line = elevated-baseline threshold (A412 = "</span>,</span>
<span id="cb34-9">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). No well on this plate exceeds it."</span>),</span>
<span id="cb34-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 at t = 0"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb34-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb34-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb34-15"></span>
<span id="cb34-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"starting_absorbance.png"</span>), baseline_plot,</span>
<span id="cb34-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb34-18"></span>
<span id="cb34-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- baseline_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(baseline_plot)</span>
<span id="cb34-21"></span>
<span id="cb34-22">baseline_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C_files/figure-gfm/plot-baseline-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- baseline_plot: ggplot object structure ---

data: well, plate_row, plate_col, well_type, sample_id, label,
  std_nmol, source, od_first, od_last, od_max, net_change, frac_rising,
  max_step, typical_step, step_excess, glitch_at_min, step_ratio,
  flag_decreasing, flag_over_range, flag_glitch, flag_high_baseline,
  flag_bg_active, n_flags, baseline [51x25]
mapping:  x = ~reorder(well, od_first), y = ~od_first, fill = ~well_type
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_col: na.rm = FALSE, just = 0.5, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_stack 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
</section>
<section id="gsh-standard-curve" class="level1">
<h1>5 GSH STANDARD CURVE</h1>
<p>The GSH standard is a <strong>stoichiometric endpoint</strong>, not an enzymatic reaction: free thiol reduces DTNB immediately on mixing. The standard curve is therefore read from a single timepoint, and t = 0 is used because TNB<sup>2-</sup> degrades over the run (quantified below).</p>
<section id="fit-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="fit-the-standard-curve">5.1 Fit the standard curve</h2>
<p>Three candidate fits are compared:</p>
<ul>
<li><strong>all wells</strong> — every standard replicate, no exclusions</li>
<li><strong>concentration means</strong> — the conventional fit, on per-concentration means</li>
<li><strong>outlier-excluded</strong> — replicate-level fit after dropping flagged wells</li>
</ul>
<p>The outlier-excluded fit is used for activity calculation.</p>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">std_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit_standard_curve</span>(plate_long, assay_params)</span>
<span id="cb36-2"></span>
<span id="cb36-3">standards_t0       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_t0</span>
<span id="cb36-4">standard_drift     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb36-5">standard_summary   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb36-6">standards_flagged  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb36-7">fit_all_wells      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells</span>
<span id="cb36-8">fit_comparison     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_comparison</span>
<span id="cb36-9">std_slope          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope</span>
<span id="cb36-10">std_intercept      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_intercept</span>
<span id="cb36-11">std_r2             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2</span>
<span id="cb36-12">std_nmol_max       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol_max</span>
<span id="cb36-13"></span>
<span id="cb36-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_t0), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"at"</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(standards_t0<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol),</span>
<span id="cb36-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentrations</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard drift over 20 min (dA412): median"</span>,</span>
<span id="cb36-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)),</span>
<span id="cb36-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| range"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" to "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards that LOST signal (drift &lt; 0):"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-20"></span>
<span id="cb36-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standard_summary: per-concentration mean/SD/CV of t0 absorbance ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standard_summary)</span>
<span id="cb36-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standard_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb36-24">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve, per-concentration summary at t = 0"</span>)</span>
<span id="cb36-25"></span>
<span id="cb36-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Concentrations exceeding"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"% replicate CV:"</span>,</span>
<span id="cb36-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb36-28">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-29"></span>
<span id="cb36-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standards_flagged: every standard well with its deviation from the triplicate median ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_flagged)</span>
<span id="cb36-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_outlier) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, triplicate_median, deviation),</span>
<span id="cb36-33">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers (|deviation| &gt; 0.15 A412)"</span>)</span>
<span id="cb36-34"></span>
<span id="cb36-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- fit_comparison: slope/intercept/R^2 for all three candidate fits ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(fit_comparison)</span>
<span id="cb36-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># row.names = FALSE: coef() attaches the predictor's name ("std_nmol") to the</span></span>
<span id="cb36-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># slope/intercept elements, which data.frame() otherwise promotes to a mangled</span></span>
<span id="cb36-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># row label (e.g. "std_nmol...1") that breaks pandoc's pipe-table parser.</span></span>
<span id="cb36-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(fit_comparison, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb36-41">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve fit comparison (outlier-excluded fit used downstream)"</span>)</span></code></pre></div>
<pre><code>Standard wells: 18 at 6 concentrations
Standard drift over 20 min (dA412): median -0.009 | range -0.029 to 0.002 
Standards that LOST signal (drift &lt; 0): 15 / 18 

--- standard_summary: per-concentration mean/SD/CV of t0 absorbance ---

tibble [6 × 9] (S3: tbl_df/tbl/data.frame)
 $ std_nmol   : num [1:6] 0 8 16 24 32 40
 $ n          : int [1:6] 3 3 3 3 3 3
 $ mean_od    : num [1:6] 0.0953 0.37 0.6267 0.853 1.1077 ...
 $ sd_od      : num [1:6] 0.00462 0.0052 0.0095 0.00361 0.01002 ...
 $ se_od      : num [1:6] 0.00267 0.003 0.00549 0.00208 0.00578 ...
 $ cv_pct     : num [1:6] 4.845 1.404 1.517 0.423 0.904 ...
 $ median_od  : num [1:6] 0.098 0.373 0.627 0.854 1.107 ...
 $ net_od     : num [1:6] 0 0.275 0.531 0.758 1.012 ...
 $ od_per_nmol: num [1:6] NA 0.0343 0.0332 0.0316 0.0316 ...</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 6%">
<col style="width: 11%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">std_nmol</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">mean_od</th>
<th style="text-align: right;">sd_od</th>
<th style="text-align: right;">se_od</th>
<th style="text-align: right;">cv_pct</th>
<th style="text-align: right;">median_od</th>
<th style="text-align: right;">net_od</th>
<th style="text-align: right;">od_per_nmol</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.095</td>
<td style="text-align: right;">0.0046</td>
<td style="text-align: right;">0.0027</td>
<td style="text-align: right;">4.84</td>
<td style="text-align: right;">0.098</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td style="text-align: right;">8</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.370</td>
<td style="text-align: right;">0.0052</td>
<td style="text-align: right;">0.0030</td>
<td style="text-align: right;">1.40</td>
<td style="text-align: right;">0.373</td>
<td style="text-align: right;">0.275</td>
<td style="text-align: right;">0.0343</td>
</tr>
<tr class="odd">
<td style="text-align: right;">16</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.627</td>
<td style="text-align: right;">0.0095</td>
<td style="text-align: right;">0.0055</td>
<td style="text-align: right;">1.52</td>
<td style="text-align: right;">0.627</td>
<td style="text-align: right;">0.531</td>
<td style="text-align: right;">0.0332</td>
</tr>
<tr class="even">
<td style="text-align: right;">24</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.853</td>
<td style="text-align: right;">0.0036</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">0.42</td>
<td style="text-align: right;">0.854</td>
<td style="text-align: right;">0.758</td>
<td style="text-align: right;">0.0316</td>
</tr>
<tr class="odd">
<td style="text-align: right;">32</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.108</td>
<td style="text-align: right;">0.0100</td>
<td style="text-align: right;">0.0058</td>
<td style="text-align: right;">0.90</td>
<td style="text-align: right;">1.107</td>
<td style="text-align: right;">1.012</td>
<td style="text-align: right;">0.0316</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.366</td>
<td style="text-align: right;">0.0051</td>
<td style="text-align: right;">0.0030</td>
<td style="text-align: right;">0.38</td>
<td style="text-align: right;">1.367</td>
<td style="text-align: right;">1.270</td>
<td style="text-align: right;">0.0318</td>
</tr>
</tbody>
</table>
<p>GSH standard curve, per-concentration summary at t = 0</p>
<pre><code>Concentrations exceeding 15 % replicate CV:  

--- standards_flagged: every standard well with its deviation from the triplicate median ---

tibble [18 × 7] (S3: tbl_df/tbl/data.frame)
 $ well             : chr [1:18] "F2" "E9" "E4" "E7" ...
 $ std_nmol         : num [1:18] 32 16 8 16 32 0 40 24 40 24 ...
 $ od               : num [1:18] 1.118 0.617 0.364 0.636 1.098 ...
 $ source           : chr [1:18] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ triplicate_median: num [1:18] 1.107 0.627 0.373 0.627 1.107 ...
 $ deviation        : num [1:18] 0.011 -0.01 -0.009 0.009 -0.009 ...
 $ is_outlier       : logi [1:18] FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<dl>
<dt>well std_nmol od triplicate_median deviation —— ———- —- ——————- ———–</dt>
<dd>
<p>Standard wells flagged as outliers (|deviation| &gt; 0.15 A412)</p>
<p>— fit_comparison: slope/intercept/R^2 for all three candidate fits —</p>
<p>‘data.frame’: 3 obs. of 5 variables: $ fit : chr “all wells” “concentration means” “outlier-excluded” $ n : int 18 6 18 $ slope : num 0.0314 0.0314 0.0314 $ intercept: num 0.108 0.108 0.108 $ r_squared: num 0.999 0.999 0.999</p>
</dd>
</dl>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">fit</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">slope</th>
<th style="text-align: right;">intercept</th>
<th style="text-align: right;">r_squared</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">all wells</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">0.0314</td>
<td style="text-align: right;">0.1085</td>
<td style="text-align: right;">0.99925</td>
</tr>
<tr class="even">
<td style="text-align: left;">concentration means</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0.0314</td>
<td style="text-align: right;">0.1085</td>
<td style="text-align: right;">0.99942</td>
</tr>
<tr class="odd">
<td style="text-align: left;">outlier-excluded</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">0.0314</td>
<td style="text-align: right;">0.1085</td>
<td style="text-align: right;">0.99925</td>
</tr>
</tbody>
</table>
<p>Standard curve fit comparison (outlier-excluded fit used downstream)</p>
<p><strong>No standard well is flagged as an outlier on this plate</strong> – every concentration’s triplicate CV is under 5% (highest: the 0 nmol blank at 4.8%; every non-zero concentration is under 1.6%), and no well deviates from its triplicate median by more than the 0.15 A412 threshold. Because there are no outliers to exclude, the “outlier-excluded” and “all wells” fits are identical: slope = 0.03140 A412/nmol, R<sup>2</sup> = 0.9992. <strong>All 15 non-zero-concentration standard replicates lose signal</strong> (drift &lt; 0) between t = 0 and t = 20 min, consistent with TNB<sup>2-</sup> instability – the 0 nmol blank replicates, which have no thiol to lose, instead drift very slightly upward. This exactly matches the 15 standard wells flagged <code>flag_decreasing</code> above. Because the curve is read at t = 0, this decay affects none of the values used for calibration.</p>
</section>
<section id="plot-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="plot-the-standard-curve">5.2 Plot the standard curve</h2>
<div class="sourceCode" id="cb39" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1">std_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(standards_flagged, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb39-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> is_outlier), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb39-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier),</span>
<span id="cb39-4">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a1d99b"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb39-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>),</span>
<span id="cb39-6">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"included"</span>),</span>
<span id="cb39-7">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb39-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve (t = 0), family F07 (ambient and 36°C)"</span>,</span>
<span id="cb39-9">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outlier-excluded fit: slope = %.5f A412/nmol, R² = %.4f (n = %d)"</span>,</span>
<span id="cb39-10">                          std_slope, std_r2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier))),</span>
<span id="cb39-11">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH (nmol/well)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 at t = 0"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb39-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb39-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb39-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb39-15"></span>
<span id="cb39-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gsh_standard_curve.png"</span>), std_plot,</span>
<span id="cb39-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb39-18"></span>
<span id="cb39-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- std_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb39-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_plot)</span>
<span id="cb39-21"></span>
<span id="cb39-22">std_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C_files/figure-gfm/plot-standard-curve-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- std_plot: ggplot object structure ---

data: well, std_nmol, od, source, triplicate_median, deviation,
  is_outlier [18x7]
mapping:  x = ~std_nmol, y = ~od
scales:   colour 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: colour = ~is_outlier 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

geom_smooth: na.rm = FALSE, orientation = NA, se = TRUE
stat_smooth: na.rm = FALSE, orientation = NA, se = TRUE, method = lm
position_identity </code></pre>
<p>The top standard (40 nmol) stays comfortably within the photometric linear range here – the highest reading is A412 1.37, below the 1.5 ceiling – so the calibration does not need to be restricted to a reduced concentration range.</p>
</section>
</section>
<section id="rate-extraction" class="level1">
<h1>6 RATE EXTRACTION</h1>
<p>Rates are extracted with a sliding-window approach: for each well, the 5-point (8-minute) window of steepest <em>positive</em> slope is taken as the rate, with its R<sup>2</sup> retained for the usability check.</p>
<div class="sourceCode" id="cb41" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1">well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_rates</span>(plate_long, well_diagnostics, assay_params)</span>
<span id="cb41-2"></span>
<span id="cb41-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- well_rates: extracted rate window per well ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb41-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_rates)</span></code></pre></div>
<pre><code>--- well_rates: extracted rate window per well ---

tibble [72 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:72] "A1" "A10" "A11" "A12" ...
 $ well_type             : chr [1:72] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:72] "F07_01_ambient" "F07_04_ambient" "F07_04_ambient" "F07_04_ambient" ...
 $ std_nmol              : num [1:72] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:72] 0 2 2 0 8 2 0 0 0 0 ...
 $ t_end                 : num [1:72] 8 10 10 8 16 10 8 8 8 8 ...
 $ slope_mOD_min         : num [1:72] 3.4 4.9 5 5 3.4 ...
 $ r2                    : num [1:72] 0.999 1 1 1 0.999 ...
 $ max_abs_slope_mOD_min : num [1:72] 3.4 4.9 5 5 3.4 ...
 $ abs_window_is_negative: logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ net_change            : num [1:72] 0.066 0.094 0.094 0.095 0.067 0.066 0.116 0.12 0.117 0 ...
 $ frac_rising           : num [1:72] 1 1 1 1 1 1 1 1 1 0 ...
 $ od_max                : num [1:72] 0.18 0.22 0.22 0.221 0.182 0.181 0.263 0.268 0.263 0.099 ...
 $ flag_decreasing       : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range       : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ glitch_at_min         : num [1:72] 20 14 18 10 18 2 2 6 2 2 ...
 $ flag_bg_active        : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:72] 0 0 0 0 0 0 0 0 0 1 ...
 $ glitch_in_window      : logi [1:72] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:72] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<section id="rate-tables-by-well-type" class="level2">
<h2 class="anchored" data-anchor-id="rate-tables-by-well-type">6.1 Rate tables by well type</h2>
<div class="sourceCode" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1">sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb43-2"></span>
<span id="cb43-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, t_start, t_end, slope_mOD_min, r2, rate_usable),</span>
<span id="cb43-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb43-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Extracted rate window, sample wells"</span>)</span>
<span id="cb43-6"></span>
<span id="cb43-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Sample wells with a usable rate:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_rates), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample rate range (mA412/min):"</span>,</span>
<span id="cb43-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median replicate-level R^2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-11"></span>
<span id="cb43-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_rates: rate-window results restricted to sample wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_rates)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 21%">
<col style="width: 12%">
<col style="width: 9%">
<col style="width: 20%">
<col style="width: 10%">
<col style="width: 17%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">t_start</th>
<th style="text-align: right;">t_end</th>
<th style="text-align: right;">slope_mOD_min</th>
<th style="text-align: right;">r2</th>
<th style="text-align: left;">rate_usable</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A1</td>
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">3.40</td>
<td style="text-align: right;">0.9991</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A10</td>
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">4.90</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A11</td>
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">5.00</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A12</td>
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">5.00</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A2</td>
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">3.40</td>
<td style="text-align: right;">0.9991</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A3</td>
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">3.50</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A4</td>
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.35</td>
<td style="text-align: right;">0.9991</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A5</td>
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.60</td>
<td style="text-align: right;">0.9993</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A6</td>
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.35</td>
<td style="text-align: right;">0.9991</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A7</td>
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A8</td>
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">6.85</td>
<td style="text-align: right;">0.9990</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A9</td>
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.50</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B1</td>
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">6.50</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B10</td>
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">4.90</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B11</td>
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">4.85</td>
<td style="text-align: right;">0.9997</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B12</td>
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">14</td>
<td style="text-align: right;">4.90</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B2</td>
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">6.65</td>
<td style="text-align: right;">0.9989</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B3</td>
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">6.45</td>
<td style="text-align: right;">0.9993</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B4</td>
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.10</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B5</td>
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.35</td>
<td style="text-align: right;">0.9991</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B6</td>
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.15</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B7</td>
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.15</td>
<td style="text-align: right;">0.9978</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B8</td>
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.25</td>
<td style="text-align: right;">0.9987</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B9</td>
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.25</td>
<td style="text-align: right;">0.9987</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C1</td>
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">4.90</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C10</td>
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C11</td>
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">0.9975</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C12</td>
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.65</td>
<td style="text-align: right;">0.9980</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C2</td>
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">5.00</td>
<td style="text-align: right;">0.9992</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C3</td>
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">4.90</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C4</td>
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.35</td>
<td style="text-align: right;">0.9991</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C5</td>
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.50</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C6</td>
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.60</td>
<td style="text-align: right;">0.9998</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C7</td>
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.35</td>
<td style="text-align: right;">0.9993</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C8</td>
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">0.9990</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C9</td>
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.00</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D1</td>
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">4.40</td>
<td style="text-align: right;">0.9995</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D10</td>
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D11</td>
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">14</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D12</td>
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D2</td>
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">4.35</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D3</td>
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">4.35</td>
<td style="text-align: right;">0.9996</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D4</td>
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">14</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D5</td>
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">3.80</td>
<td style="text-align: right;">0.9993</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D6</td>
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D7</td>
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.10</td>
<td style="text-align: right;">0.9998</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D8</td>
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.00</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D9</td>
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.05</td>
<td style="text-align: right;">0.9994</td>
<td style="text-align: left;">TRUE</td>
</tr>
</tbody>
</table>
<p>Extracted rate window, sample wells</p>
<pre><code>Sample wells with a usable rate: 47 / 48 
Sample rate range (mA412/min): 0.00 - 8.65 
Median replicate-level R^2: 0.9994 

--- sample_rates: rate-window results restricted to sample wells ---

tibble [48 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:48] "A1" "A10" "A11" "A12" ...
 $ well_type             : chr [1:48] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:48] "F07_01_ambient" "F07_04_ambient" "F07_04_ambient" "F07_04_ambient" ...
 $ std_nmol              : num [1:48] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:48] 0 2 2 0 8 2 0 0 0 0 ...
 $ t_end                 : num [1:48] 8 10 10 8 16 10 8 8 8 8 ...
 $ slope_mOD_min         : num [1:48] 3.4 4.9 5 5 3.4 ...
 $ r2                    : num [1:48] 0.999 1 1 1 0.999 ...
 $ max_abs_slope_mOD_min : num [1:48] 3.4 4.9 5 5 3.4 ...
 $ abs_window_is_negative: logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ net_change            : num [1:48] 0.066 0.094 0.094 0.095 0.067 0.066 0.116 0.12 0.117 0 ...
 $ frac_rising           : num [1:48] 1 1 1 1 1 1 1 1 1 0 ...
 $ od_max                : num [1:48] 0.18 0.22 0.22 0.221 0.182 0.181 0.263 0.268 0.263 0.099 ...
 $ flag_decreasing       : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range       : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ glitch_at_min         : num [1:48] 20 14 18 10 18 2 2 6 2 2 ...
 $ flag_bg_active        : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:48] 0 0 0 0 0 0 0 0 0 1 ...
 $ glitch_in_window      : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:48] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<p>47 of the 48 sample wells clear the R<sup>2</sup> &gt;= 0.80 and positive-net-change usability bar; every usable replicate-level R<sup>2</sup> exceeds 0.997 (median 0.9994). The one exclusion is <code>A7</code> (<code>F07_03_ambient</code>), the dead well noted above (slope = 0.00 mA412/min, R<sup>2</sup> = 0, <code>rate_usable = FALSE</code>); its two siblings (<code>A8</code>, <code>A9</code>) are both usable. Among the 47 usable wells, rates range 3.40-8.65 mA412/min.</p>
</section>
<section id="positive-control" class="level2">
<h2 class="anchored" data-anchor-id="positive-control">6.2 Positive control</h2>
<div class="sourceCode" id="cb45" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb45-1">pos_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_positive_control</span>(well_rates, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope, assay_params)</span>
<span id="cb45-2"></span>
<span id="cb45-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(pos_control <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, t_start, t_end, slope_mOD_min, r2, net_change, activity_mU_uL),</span>
<span id="cb45-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb45-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control replicates"</span>)</span>
<span id="cb45-6"></span>
<span id="cb45-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control mean rate:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb45-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control CV:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>,</span>
<span id="cb45-9">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb45-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All replicates rising and linear (R^2 &gt; 0.99):"</span>,</span>
<span id="cb45-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb45-12"></span>
<span id="cb45-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- pos_control: positive control rate and R^2 per replicate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb45-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(pos_control)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 12%">
<col style="width: 9%">
<col style="width: 20%">
<col style="width: 10%">
<col style="width: 16%">
<col style="width: 21%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: right;">t_start</th>
<th style="text-align: right;">t_end</th>
<th style="text-align: right;">slope_mOD_min</th>
<th style="text-align: right;">r2</th>
<th style="text-align: right;">net_change</th>
<th style="text-align: right;">activity_mU_uL</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F7</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.95</td>
<td style="text-align: right;">0.9980</td>
<td style="text-align: right;">0.055</td>
<td style="text-align: right;">0.0470</td>
</tr>
<tr class="even">
<td style="text-align: left;">F8</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">2.85</td>
<td style="text-align: right;">0.9991</td>
<td style="text-align: right;">0.054</td>
<td style="text-align: right;">0.0454</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F9</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">3.00</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: right;">0.055</td>
<td style="text-align: right;">0.0478</td>
</tr>
</tbody>
</table>
<p>Positive control replicates</p>
<pre><code>Positive control mean rate: 2.933 mA412/min
Positive control CV: 2.6 %
All replicates rising and linear (R^2 &gt; 0.99): TRUE 

--- pos_control: positive control rate and R^2 per replicate ---

tibble [3 × 22] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:3] "F7" "F8" "F9"
 $ well_type             : chr [1:3] "positive_control" "positive_control" "positive_control"
 $ sample_id             : chr [1:3] NA NA NA
 $ std_nmol              : num [1:3] NA NA NA
 $ t_start               : num [1:3] 12 8 12
 $ t_end                 : num [1:3] 20 16 20
 $ slope_mOD_min         : num [1:3] 2.95 2.85 3
 $ r2                    : num [1:3] 0.998 0.999 1
 $ max_abs_slope_mOD_min : num [1:3] 2.95 2.85 3
 $ abs_window_is_negative: logi [1:3] FALSE FALSE FALSE
 $ net_change            : num [1:3] 0.055 0.054 0.055
 $ frac_rising           : num [1:3] 1 1 1
 $ od_max                : num [1:3] 0.295 0.298 0.297
 $ flag_decreasing       : logi [1:3] FALSE FALSE FALSE
 $ flag_over_range       : logi [1:3] FALSE FALSE FALSE
 $ flag_glitch           : logi [1:3] FALSE FALSE FALSE
 $ glitch_at_min         : num [1:3] 20 4 2
 $ flag_bg_active        : logi [1:3] FALSE FALSE FALSE
 $ n_flags               : int [1:3] 0 0 0
 $ glitch_in_window      : logi [1:3] FALSE FALSE FALSE
 $ rate_usable           : logi [1:3] TRUE TRUE TRUE
 $ activity_mU_uL        : num [1:3] 0.047 0.0454 0.0478</code></pre>
<p>The positive control rose linearly in all three replicates (R<sup>2</sup> 0.998-1.000) at a consistent 2.85-3.00 mA412/min, a 2.6% CV across the triplicate – confirming that the core reaction chemistry and reader were functioning normally on this plate. This is a tight, well-behaved positive control.</p>
</section>
</section>
<section id="background-correction" class="level1">
<h1>7 BACKGROUND CORRECTION</h1>
<p>This plate uses a <strong>single pooled background control</strong> (note 3): the background rate is normally estimated once, from the flat (well-behaved) replicates of the <code>BG-citrate_synthase</code> triplicate, and the same corrected rate is subtracted from every sample. <strong>On this plate, none of the three background replicates are flat</strong> (note 4) – <code>compute_background_correction()</code> therefore cannot produce a background-rate estimate, and its documented fallback applies: a missing (<code>NA</code>) <code>bg_rate_flat</code> is treated as 0. Every sample’s corrected rate on this plate is therefore identical to its raw rate.</p>
<div class="sourceCode" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">background_correction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_background_correction</span>(well_rates)</span>
<span id="cb47-2"></span>
<span id="cb47-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Pooled background rate (flat wells only):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(background_correction, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb47-5"></span>
<span id="cb47-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Background rate used for correction:"</span>,</span>
<span id="cb47-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min (from"</span>,</span>
<span id="cb47-8">    background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_bg_flat, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_bg_total, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"replicates)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median sample rate:"</span>,</span>
<span id="cb47-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background as % of median sample signal:"</span>,</span>
<span id="cb47-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> background_correction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb47-13">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-14"></span>
<span id="cb47-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- background_correction: pooled background rate estimate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(background_correction)</span></code></pre></div>
<pre><code>Pooled background rate (flat wells only):
 n_bg_total n_bg_flat bg_rate_flat bg_rate_all
          3         0           NA         7.7

Background rate used for correction: NA mA412/min (from 0 of 3 replicates)
Median sample rate: 6.58 mA412/min
Background as % of median sample signal: NA %

--- background_correction: pooled background rate estimate ---

'data.frame':   1 obs. of  4 variables:
 $ n_bg_total  : int 3
 $ n_bg_flat   : int 0
 $ bg_rate_flat: num NA
 $ bg_rate_all : num 7.7</code></pre>
<p><code>n_bg_flat</code> is 0 of 3, so <code>bg_rate_flat</code> is <code>NA</code> and is treated as 0 downstream. For reference only (<strong>not used</strong> in any activity calculation), the mean rate across all three – compromised – background replicates is 7.7 mA412/min, actually <em>higher</em> than the median sample rate of 6.58 mA412/min, underscoring that these wells behaved as active reactions rather than anything resembling a background control.</p>
<section id="background-significance-test" class="level2">
<h2 class="anchored" data-anchor-id="background-significance-test">7.1 Background significance test</h2>
<p>The flat/active threshold classification above is backed by an explicit significance test: a Welch two-sample t-test of well-level rate (background vs.&nbsp;sample), plus an ANOVA on the OD trajectory over time. This mirrors the one-time background ANOVA validation done by Cattau et al.&nbsp;(2023) on the legacy version of this assay. <strong>On a well-behaved plate this test should show background wells statistically slower than sample wells; on this plate, given the confirmed mix-up, no such difference is expected</strong> – it is run here mainly to document that expectation quantitatively rather than as a validity check.</p>
<div class="sourceCode" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1">bg_sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb49-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))</span>
<span id="cb49-3"></span>
<span id="cb49-4">bg_significance_test <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t.test</span>(slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> bg_sample_rates)</span>
<span id="cb49-5"></span>
<span id="cb49-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- Welch two-sample t-test: well-level rate (background vs. sample) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_significance_test)</span>
<span id="cb49-8"></span>
<span id="cb49-9">bg_trend_anova <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> time_min,</span>
<span id="cb49-10">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))))</span>
<span id="cb49-11"></span>
<span id="cb49-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_trend_anova)</span>
<span id="cb49-14"></span>
<span id="cb49-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation: mean background-well rate is"</span>,</span>
<span id="cb49-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group background"</span>])),</span>
<span id="cb49-17">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min vs."</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group sample"</span>])),</span>
<span id="cb49-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min for sample wells (p ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format.pval</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb49-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Background wells are NOT statistically slower than sample wells on</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb49-20">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"this plate (n = 3 background replicates limits power, but the point</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb49-21">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"estimate itself is not lower) -- consistent with the confirmed Reaction</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb49-22">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mix mix-up (note 4) rather than a genuine, if imprecise, background.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-23"></span>
<span id="cb49-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_significance_test: Welch t-test result object ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_significance_test)</span>
<span id="cb49-26"></span>
<span id="cb49-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_trend_anova)</span></code></pre></div>
<pre><code>--- Welch two-sample t-test: well-level rate (background vs. sample) ---


    Welch Two Sample t-test

data:  slope_mOD_min by well_type
t = 1.3803, df = 2.2186, p-value = 0.2901
alternative hypothesis: true difference in means between group background and group sample is not equal to 0
95 percent confidence interval:
 -3.194340  6.665174
sample estimates:
mean in group background     mean in group sample 
                7.700000                 5.964583 


--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---

Analysis of Variance Table

Response: od
                    Df  Sum Sq Mean Sq  F value  Pr(&gt;F)    
well_type            1 0.00494 0.00494   4.5694 0.03298 *  
time_min             1 0.57624 0.57624 532.8372 &lt; 2e-16 ***
well_type:time_min   1 0.00004 0.00004   0.0332 0.85558    
Residuals          557 0.60237 0.00108                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Interpretation: mean background-well rate is 7.70 mA412/min vs. 5.96 mA412/min for sample wells (p = 0.29 ). Background wells are NOT statistically slower than sample wells on
 this plate (n = 3 background replicates limits power, but the point
 estimate itself is not lower) -- consistent with the confirmed Reaction
 Mix mix-up (note 4) rather than a genuine, if imprecise, background.

--- bg_significance_test: Welch t-test result object ---

List of 10
 $ statistic  : Named num 1.38
  ..- attr(*, "names")= chr "t"
 $ parameter  : Named num 2.22
  ..- attr(*, "names")= chr "df"
 $ p.value    : num 0.29
 $ conf.int   : num [1:2] -3.19 6.67
  ..- attr(*, "conf.level")= num 0.95
 $ estimate   : Named num [1:2] 7.7 5.96
  ..- attr(*, "names")= chr [1:2] "mean in group background" "mean in group sample"
 $ null.value : Named num 0
  ..- attr(*, "names")= chr "difference in means between group background and group sample"
 $ stderr     : num 1.26
 $ alternative: chr "two.sided"
 $ method     : chr "Welch Two Sample t-test"
 $ data.name  : chr "slope_mOD_min by well_type"
 - attr(*, "class")= chr "htest"

--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---

Classes 'anova' and 'data.frame':   4 obs. of  5 variables:
 $ Df     : int  1 1 1 557
 $ Sum Sq : num  4.94e-03 5.76e-01 3.59e-05 6.02e-01
 $ Mean Sq: num  4.94e-03 5.76e-01 3.59e-05 1.08e-03
 $ F value: num  4.5694 532.8372 0.0332 NA
 $ Pr(&gt;F) : num  3.30e-02 3.15e-83 8.56e-01 NA
 - attr(*, "heading")= chr [1:2] "Analysis of Variance Table\n" "Response: od"</code></pre>
</section>
</section>
<section id="technical-replicate-precision" class="level1">
<h1>8 TECHNICAL REPLICATE PRECISION</h1>
<p>Coefficient of variation across the three technical replicates of each sample, computed on the extracted rate. Both <strong>all</strong> and <strong>usable replicates only</strong> are reported; they differ only for <code>F07_03_ambient</code>, whose dead <code>A7</code> well is excluded from the “usable” calculation.</p>
<div class="sourceCode" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1">cv_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_replicate_cv</span>(well_rates, protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, assay_params)</span>
<span id="cb51-2"></span>
<span id="cb51-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all,</span>
<span id="cb51-4">                            n_usable, mean_usable, sd_usable, cv_usable,</span>
<span id="cb51-5">                            excluded_wells),</span>
<span id="cb51-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb51-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>,</span>
<span id="cb51-8">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Excluded wells"</span>),</span>
<span id="cb51-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate CV of the extracted rate (mA412/min), "</span>,</span>
<span id="cb51-10">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all replicates vs. usable replicates only"</span>))</span>
<span id="cb51-11"></span>
<span id="cb51-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb51-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on ALL replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-15">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-16">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb51-17"></span>
<span id="cb51-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb51-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on USABLE replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-21">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_usable, mean_usable, sd_usable, cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-22">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb51-23"></span>
<span id="cb51-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb51-25"></span>
<span id="cb51-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cv_summary: per-sample technical replicate CV, both variants ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cv_summary)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th>CV (%)</th>
<th>n usable</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th style="text-align: right;">CV (%)</th>
<th style="text-align: left;">Excluded wells</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">4.93</td>
<td style="text-align: right;">0.06</td>
<td>1.2</td>
<td>3</td>
<td style="text-align: right;">4.93</td>
<td style="text-align: right;">0.06</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">3.43</td>
<td style="text-align: right;">0.06</td>
<td>1.7</td>
<td>3</td>
<td style="text-align: right;">3.43</td>
<td style="text-align: right;">0.06</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.48</td>
<td style="text-align: right;">0.13</td>
<td>1.7</td>
<td>3</td>
<td style="text-align: right;">7.48</td>
<td style="text-align: right;">0.13</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.43</td>
<td style="text-align: right;">0.14</td>
<td>1.9</td>
<td>3</td>
<td style="text-align: right;">7.43</td>
<td style="text-align: right;">0.14</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">8.28</td>
<td style="text-align: right;">0.26</td>
<td>3.1</td>
<td>3</td>
<td style="text-align: right;">8.28</td>
<td style="text-align: right;">0.26</td>
<td style="text-align: right;">3.1</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">4.78</td>
<td style="text-align: right;">4.16</td>
<td>86.9</td>
<td>2</td>
<td style="text-align: right;">7.18</td>
<td style="text-align: right;">0.46</td>
<td style="text-align: right;">6.4</td>
<td style="text-align: left;">A7</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">8.52</td>
<td style="text-align: right;">0.13</td>
<td>1.5</td>
<td>3</td>
<td style="text-align: right;">8.52</td>
<td style="text-align: right;">0.13</td>
<td style="text-align: right;">1.5</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">4.97</td>
<td style="text-align: right;">0.06</td>
<td>1.2</td>
<td>3</td>
<td style="text-align: right;">4.97</td>
<td style="text-align: right;">0.06</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">4.37</td>
<td style="text-align: right;">0.03</td>
<td>0.7</td>
<td>3</td>
<td style="text-align: right;">4.37</td>
<td style="text-align: right;">0.03</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">6.53</td>
<td style="text-align: right;">0.10</td>
<td>1.6</td>
<td>3</td>
<td style="text-align: right;">6.53</td>
<td style="text-align: right;">0.10</td>
<td style="text-align: right;">1.6</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">3.70</td>
<td style="text-align: right;">0.09</td>
<td>2.3</td>
<td>3</td>
<td style="text-align: right;">3.70</td>
<td style="text-align: right;">0.09</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.20</td>
<td style="text-align: right;">0.13</td>
<td>1.8</td>
<td>3</td>
<td style="text-align: right;">7.20</td>
<td style="text-align: right;">0.13</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.05</td>
<td style="text-align: right;">0.05</td>
<td>0.7</td>
<td>3</td>
<td style="text-align: right;">7.05</td>
<td style="text-align: right;">0.05</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">8.22</td>
<td style="text-align: right;">0.06</td>
<td>0.7</td>
<td>3</td>
<td style="text-align: right;">8.22</td>
<td style="text-align: right;">0.06</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.00</td>
<td>0.0</td>
<td>3</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">4.88</td>
<td style="text-align: right;">0.03</td>
<td>0.6</td>
<td>3</td>
<td style="text-align: right;">4.88</td>
<td style="text-align: right;">0.03</td>
<td style="text-align: right;">0.6</td>
<td style="text-align: left;">-</td>
</tr>
</tbody>
</table>
<p>Technical replicate CV of the extracted rate (mA412/min), all replicates vs.&nbsp;usable replicates only</p>
<pre><code>Samples exceeding CV 15% on ALL replicates: 1 / 16 
      sample_id n_all mean_all sd_all cv_all
 F07_03_ambient     3    4.783  4.155  86.87

Samples exceeding CV 15% on USABLE replicates: 0 
[1] sample_id   n_usable    mean_usable sd_usable   cv_usable  
&lt;0 rows&gt; (or 0-length row.names)

--- cv_summary: per-sample technical replicate CV, both variants ---

'data.frame':   16 obs. of  12 variables:
 $ sample_id      : chr  "F07_01_36C" "F07_01_ambient" "F07_02_36C" "F07_02_ambient" ...
 $ n_all          : int  3 3 3 3 3 3 3 3 3 3 ...
 $ mean_all       : num  4.93 3.43 7.48 7.43 8.28 ...
 $ sd_all         : num  0.0577 0.0577 0.1258 0.1443 0.2566 ...
 $ cv_all         : num  1.17 1.68 1.68 1.94 3.1 ...
 $ n_usable       : int  3 3 3 3 3 2 3 3 3 3 ...
 $ mean_usable    : num  4.93 3.43 7.48 7.43 8.28 ...
 $ sd_usable      : num  0.0577 0.0577 0.1258 0.1443 0.2566 ...
 $ cv_usable      : num  1.17 1.68 1.68 1.94 3.1 ...
 $ excluded_wells : Named chr  "-" "-" "-" "-" ...
  ..- attr(*, "names")= chr [1:16] "F07_01_36C" "F07_01_ambient" "F07_02_36C" "F07_02_ambient" ...
 $ fails_cv_all   : logi  FALSE FALSE FALSE FALSE FALSE TRUE ...
 $ fails_cv_usable: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<p><strong>Only one sample exceeds the 15% CV threshold, and only on the “all replicates” metric.</strong> <code>F07_03_ambient</code> shows an 86.9% CV across all three raw replicates, entirely driven by its dead <code>A7</code> well (slope 0.00 vs.&nbsp;6.85 and 7.50 mA412/min for <code>A8</code>/<code>A9</code>); its usable-replicate CV is a normal 6.4%. Every other sample is well under the threshold on both metrics – the highest of the remaining 15 is <code>F07_03_36C</code> at 3.1%, and most are under 2%.</p>
<section id="plot-replicate-spread" class="level2">
<h2 class="anchored" data-anchor-id="plot-replicate-spread">8.1 Plot replicate spread</h2>
<div class="sourceCode" id="cb53" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb53-1">cv_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb53-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb53-3"></span>
<span id="cb53-4">cv_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(cv_plot_data, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> slope_mOD_min)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> rate_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> rate_usable),</span>
<span id="cb53-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fun =</span> mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"crossbar"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb53-8">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb53-10">                                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV %.0f%%"</span>, cv_all)),</span>
<span id="cb53-11">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb53-12">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>),</span>
<span id="cb53-14">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb53-16">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate spread in extracted rate"</span>,</span>
<span id="cb53-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Crossbar = mean of all three replicates; CV computed on all three. "</span>,</span>
<span id="cb53-19">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Threshold "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%."</span>),</span>
<span id="cb53-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate (mA412/min)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb53-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb53-23">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb53-24"></span>
<span id="cb53-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.png"</span>), cv_plot,</span>
<span id="cb53-26">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb53-27"></span>
<span id="cb53-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cv_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb53-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(cv_plot)</span>
<span id="cb53-30"></span>
<span id="cb53-31">cv_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C_files/figure-gfm/plot-replicate-cv-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- cv_plot: ggplot object structure ---

data: well, well_type, sample_id, std_nmol, t_start, t_end,
  slope_mOD_min, r2, max_abs_slope_mOD_min, abs_window_is_negative,
  net_change, frac_rising, od_max, flag_decreasing, flag_over_range,
  flag_glitch, glitch_at_min, flag_bg_active, n_flags,
  glitch_in_window, rate_usable, cv_all [48x22]
mapping:  x = ~sample_id, y = ~slope_mOD_min
scales:   colour, shape 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: colour = ~rate_usable, shape = ~rate_usable 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_jitter 

geom_crossbar: na.rm = FALSE, orientation = NA, width = 0.5
stat_summary: fun.data = NULL, fun = function (x, ...) 
UseMethod("mean"), fun.max = NULL, fun.min = NULL, fun.args = list(), na.rm = FALSE, orientation = NA
position_identity 

mapping: x = ~sample_id, y = Inf, label = ~sprintf("CV %.0f%%", cv_all) 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge </code></pre>
</section>
</section>
<section id="citrate-synthase-activity" class="level1">
<h1>9 CITRATE SYNTHASE ACTIVITY</h1>
<section id="calculation" class="level2">
<h2 class="anchored" data-anchor-id="calculation">9.1 Calculation</h2>
<p>Following Abcam Section 10.3:</p>
<p><code>Sample CS activity = B / (dT x V) x D</code> nmol/min/µL (= mU/µL)</p>
<ol type="1">
<li><strong>Rate</strong> (A412/min) = max-increasing sliding-window slope / 1000</li>
<li><strong>Background-corrected rate</strong> = sample rate - the single pooled background rate (note 3), applied identically to every sample – on this plate that background rate is 0 for every sample (note 4), so corrected rate = raw rate throughout</li>
<li><strong>B/dT</strong> (nmol/min) = background-corrected rate / standard curve slope (0.03140 A412 per nmol, from the outlier-excluded fit)</li>
<li><strong>Activity</strong> (mU/µL) = (B/dT) / <em>V</em> x <em>D</em>, with <em>V</em> = 2 µL and <em>D</em> = 1</li>
<li><strong>Protein-normalized</strong> (mU/mg protein) = activity x <code>homogenate_volume_uL</code> (350 µL, measured) / total protein (mg)</li>
</ol>
<div class="sourceCode" id="cb55" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb55-1">cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calculate_cs_activity</span>(well_rates, protein_by_sample, background_correction,</span>
<span id="cb55-2">                                      std_slope, std_nmol_max, assay_params, plate_long)</span>
<span id="cb55-3"></span>
<span id="cb55-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with a computed activity:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cs_activity), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb55-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/uL):"</span>,</span>
<span id="cb55-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb55-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/mg protein):"</span>,</span>
<span id="cb55-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb55-9"></span>
<span id="cb55-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cs_activity: per-sample citrate synthase activity ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb55-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cs_activity)</span></code></pre></div>
<pre><code>Samples with a computed activity: 16 / 16 
Activity range (mU/uL): 0.0547 - 0.1356 
Activity range (mU/mg protein): 79.566 - 207.819 

--- cs_activity: per-sample citrate synthase activity ---

tibble [16 × 19] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:16] "F07_01_36C" "F07_01_ambient" "F07_02_36C" "F07_02_ambient" ...
 $ n_reps_used               : int [1:16] 3 3 3 3 3 2 3 3 3 3 ...
 $ mean_rate_mOD_min         : num [1:16] 4.93 3.43 7.48 7.43 8.28 ...
 $ sd_rate                   : num [1:16] 0.0577 0.0577 0.1258 0.1443 0.2566 ...
 $ cv_rate                   : num [1:16] 1.17 1.68 1.68 1.94 3.1 ...
 $ family                    : chr [1:16] "F07" "F07" "F07" "F07" ...
 $ individual                : chr [1:16] "01" "01" "02" "02" ...
 $ temperature               : chr [1:16] "36C" "ambient" "36C" "ambient" ...
 $ conc_ug_mL                : num [1:16] 663 263 932 1080 1206 ...
 $ total_protein_mg          : num [1:16] 0.2322 0.0921 0.3263 0.378 0.4219 ...
 $ bg_rate_mOD_min           : num [1:16] 0 0 0 0 0 0 0 0 0 0 ...
 $ corrected_mOD_min         : num [1:16] 4.93 3.43 7.48 7.43 8.28 ...
 $ rate_OD_min               : num [1:16] 0.00493 0.00343 0.00748 0.00743 0.00828 ...
 $ nmol_per_min              : num [1:16] 0.157 0.109 0.238 0.237 0.264 ...
 $ activity_mU_per_uL        : num [1:16] 0.0786 0.0547 0.1192 0.1184 0.1319 ...
 $ total_mU_in_homogenate    : num [1:16] 27.5 19.1 41.7 41.4 46.2 ...
 $ activity_mU_per_mg_protein: num [1:16] 118 208 128 110 109 ...
 $ nmol_in_window            : num [1:16] 3.14 2.19 4.77 4.74 5.28 ...
 $ within_std_range          : logi [1:16] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
</section>
<section id="results-table" class="level2">
<h2 class="anchored" data-anchor-id="results-table">9.2 Results table</h2>
<div class="sourceCode" id="cb57" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb57-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_results_table</span>(cs_activity, cv_summary, baseline_per_sample, assay_params)</span>
<span id="cb57-2"></span>
<span id="cb57-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table,</span>
<span id="cb57-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, family F07, ambient and 36°C (mU/mg protein uses "</span>,</span>
<span id="cb57-5">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"measured protein concentration x the "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb57-6">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume)"</span>))</span>
<span id="cb57-7"></span>
<span id="cb57-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation summary:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb57-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(results_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(Interpretation, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_samples"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb57-10">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb57-11"></span>
<span id="cb57-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_results.csv"</span>),</span>
<span id="cb57-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb57-14"></span>
<span id="cb57-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- results_table: formatted per-sample results written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb57-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(results_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">Protein conc (ug/mL)</th>
<th style="text-align: right;">Total protein (mg)</th>
<th style="text-align: left;">Reps used</th>
<th>CV all reps (%)</th>
<th style="text-align: right;">CV used reps (%)</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">BG rate (mA412/min)</th>
<th style="text-align: right;">Corrected rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/uL)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th>CV flag</th>
<th style="text-align: left;">Elevated baseline reps</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">663.3</td>
<td style="text-align: right;">0.232</td>
<td style="text-align: left;">3/3</td>
<td>1.2</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">4.93</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">4.93</td>
<td style="text-align: right;">0.0786</td>
<td style="text-align: right;">118.446</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">263.1</td>
<td style="text-align: right;">0.092</td>
<td style="text-align: left;">3/3</td>
<td>1.7</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: right;">3.43</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3.43</td>
<td style="text-align: right;">0.0547</td>
<td style="text-align: right;">207.819</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">932.4</td>
<td style="text-align: right;">0.326</td>
<td style="text-align: left;">3/3</td>
<td>1.7</td>
<td style="text-align: right;">1.7</td>
<td style="text-align: right;">7.48</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">7.48</td>
<td style="text-align: right;">0.1192</td>
<td style="text-align: right;">127.815</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1080.1</td>
<td style="text-align: right;">0.378</td>
<td style="text-align: left;">3/3</td>
<td>1.9</td>
<td style="text-align: right;">1.9</td>
<td style="text-align: right;">7.43</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">7.43</td>
<td style="text-align: right;">0.1184</td>
<td style="text-align: right;">109.600</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1205.5</td>
<td style="text-align: right;">0.422</td>
<td style="text-align: left;">3/3</td>
<td>3.1</td>
<td style="text-align: right;">3.1</td>
<td style="text-align: right;">8.28</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8.28</td>
<td style="text-align: right;">0.1319</td>
<td style="text-align: right;">109.428</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1155.6</td>
<td style="text-align: right;">0.404</td>
<td style="text-align: left;">2/3</td>
<td>86.9</td>
<td style="text-align: right;">6.4</td>
<td style="text-align: right;">7.18</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">7.18</td>
<td style="text-align: right;">0.1143</td>
<td style="text-align: right;">98.879</td>
<td>FAIL &gt;15%</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1567.2</td>
<td style="text-align: right;">0.549</td>
<td style="text-align: left;">3/3</td>
<td>1.5</td>
<td style="text-align: right;">1.5</td>
<td style="text-align: right;">8.52</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8.52</td>
<td style="text-align: right;">0.1356</td>
<td style="text-align: right;">86.544</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">560.0</td>
<td style="text-align: right;">0.196</td>
<td style="text-align: left;">3/3</td>
<td>1.2</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">4.97</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">4.97</td>
<td style="text-align: right;">0.0791</td>
<td style="text-align: right;">141.243</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">427.9</td>
<td style="text-align: right;">0.150</td>
<td style="text-align: left;">3/3</td>
<td>0.7</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">4.37</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">4.37</td>
<td style="text-align: right;">0.0695</td>
<td style="text-align: right;">162.517</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">659.3</td>
<td style="text-align: right;">0.231</td>
<td style="text-align: left;">3/3</td>
<td>1.6</td>
<td style="text-align: right;">1.6</td>
<td style="text-align: right;">6.53</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">6.53</td>
<td style="text-align: right;">0.1040</td>
<td style="text-align: right;">157.813</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">496.5</td>
<td style="text-align: right;">0.174</td>
<td style="text-align: left;">3/3</td>
<td>2.3</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: right;">3.70</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3.70</td>
<td style="text-align: right;">0.0589</td>
<td style="text-align: right;">118.679</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1119.4</td>
<td style="text-align: right;">0.392</td>
<td style="text-align: left;">3/3</td>
<td>1.8</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: right;">7.20</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">7.20</td>
<td style="text-align: right;">0.1147</td>
<td style="text-align: right;">102.432</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1038.1</td>
<td style="text-align: right;">0.363</td>
<td style="text-align: left;">3/3</td>
<td>0.7</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">7.05</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">7.05</td>
<td style="text-align: right;">0.1123</td>
<td style="text-align: right;">108.153</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1644.6</td>
<td style="text-align: right;">0.576</td>
<td style="text-align: left;">3/3</td>
<td>0.7</td>
<td style="text-align: right;">0.7</td>
<td style="text-align: right;">8.22</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8.22</td>
<td style="text-align: right;">0.1309</td>
<td style="text-align: right;">79.566</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">289.8</td>
<td style="text-align: right;">0.101</td>
<td style="text-align: left;">3/3</td>
<td>0.0</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3.65</td>
<td style="text-align: right;">0.0581</td>
<td style="text-align: right;">200.578</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: left;">F07</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">560.2</td>
<td style="text-align: right;">0.196</td>
<td style="text-align: left;">3/3</td>
<td>0.6</td>
<td style="text-align: right;">0.6</td>
<td style="text-align: right;">4.88</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">4.88</td>
<td style="text-align: right;">0.0778</td>
<td style="text-align: right;">138.824</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>Citrate synthase activity, family F07, ambient and 36°C (mU/mg protein uses measured protein concentration x the 350 uL homogenization volume)</p>
<pre><code>Interpretation summary:
 Interpretation n_samples
         usable        16

--- results_table: formatted per-sample results written to CSV ---

tibble [16 × 17] (S3: tbl_df/tbl/data.frame)
 $ Sample                    : chr [1:16] "F07_01_36C" "F07_01_ambient" "F07_02_36C" "F07_02_ambient" ...
 $ Family                    : chr [1:16] "F07" "F07" "F07" "F07" ...
 $ Individual                : chr [1:16] "01" "01" "02" "02" ...
 $ Temperature               : chr [1:16] "36C" "ambient" "36C" "ambient" ...
 $ Protein conc (ug/mL)      : num [1:16] 663 263 932 1080 1206 ...
 $ Total protein (mg)        : num [1:16] 0.232 0.092 0.326 0.378 0.422 0.404 0.549 0.196 0.15 0.231 ...
 $ Reps used                 : chr [1:16] "3/3" "3/3" "3/3" "3/3" ...
 $ CV all reps (%)           : num [1:16] 1.2 1.7 1.7 1.9 3.1 86.9 1.5 1.2 0.7 1.6 ...
 $ CV used reps (%)          : num [1:16] 1.2 1.7 1.7 1.9 3.1 6.4 1.5 1.2 0.7 1.6 ...
 $ Rate (mA412/min)          : num [1:16] 4.93 3.43 7.48 7.43 8.28 7.18 8.52 4.97 4.37 6.53 ...
 $ BG rate (mA412/min)       : num [1:16] 0 0 0 0 0 0 0 0 0 0 ...
 $ Corrected rate (mA412/min): num [1:16] 4.93 3.43 7.48 7.43 8.28 7.18 8.52 4.97 4.37 6.53 ...
 $ Activity (mU/uL)          : num [1:16] 0.0786 0.0547 0.1192 0.1184 0.1319 ...
 $ Activity (mU/mg protein)  : num [1:16] 118 208 128 110 109 ...
 $ CV flag                   : chr [1:16] "pass" "pass" "pass" "pass" ...
 $ Elevated baseline reps    : chr [1:16] "0/3" "0/3" "0/3" "0/3" ...
 $ Interpretation            : chr [1:16] "usable" "usable" "usable" "usable" ...</code></pre>
<p>All 16 samples are classified <code>usable</code> in the <code>Interpretation</code> column – <code>calculate_cs_activity()</code> already restricts each sample’s mean rate to its usable replicates, so <code>F07_03_ambient</code>’s activity value is computed from <code>A8</code>/<code>A9</code> only and its <em>usable</em>-replicate CV (6.4%) is what determines its Interpretation. Its <code>CV flag</code> column still reads <code>FAIL &gt;15%</code>, because that column is deliberately computed on <em>all</em> raw replicates (including the dead <code>A7</code>) as a stricter, unfiltered check – both are correct, and they are reporting different things (see TECHNICAL REPLICATE PRECISION above).</p>
</section>
<section id="plot-activity" class="level2">
<h2 class="anchored" data-anchor-id="plot-activity">9.3 Plot activity</h2>
<div class="sourceCode" id="cb59" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb59-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Three-level quality scheme. F07_03_ambient falls in the "CV &gt; 15%" tier</span></span>
<span id="cb59-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># here (cv_all, unfiltered) even though its activity value itself is</span></span>
<span id="cb59-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "usable" in the results table above (cv_rate, usable-replicates only).</span></span>
<span id="cb59-4">qual_levels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clean"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV &gt; "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb59-5">                 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all reps baseline-compromised"</span>)</span>
<span id="cb59-6">qual_cols   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey60"</span>), qual_levels)</span>
<span id="cb59-7"></span>
<span id="cb59-8">activity_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb59-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb59-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated, n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb59-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_flag =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb59-12">                            n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n                              <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb59-13">                            cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct       <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb59-14">                            <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                                        <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb59-15">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> qual_levels),</span>
<span id="cb59-16">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3 reps"</span>,</span>
<span id="cb59-17">                          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - DISQUALIFIED"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)))</span>
<span id="cb59-18"></span>
<span id="cb59-19">activity_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb59-20">                        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(sample_id, activity_mU_per_uL),</span>
<span id="cb59-21">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_uL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> cv_flag)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> label_n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">clip =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"off"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand_limits</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, M. gigas ctenidia, family F07 (ambient and 36°C)"</span>,</span>
<span id="cb59-28">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Not background-corrected (bg = 0 for every sample, note 4); mean of usable "</span>,</span>
<span id="cb59-29">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical replicates (2/3 for F07_03_ambient, 3/3 for every other sample)."</span>),</span>
<span id="cb59-30">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/uL homogenate)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb59-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb59-33">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb59-34"></span>
<span id="cb59-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity.png"</span>), activity_plot,</span>
<span id="cb59-36">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb59-37"></span>
<span id="cb59-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- activity_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb59-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(activity_plot)</span>
<span id="cb59-40"></span>
<span id="cb59-41">activity_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C_files/figure-gfm/plot-activity-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- activity_plot: ggplot object structure ---

data: sample_id, n_reps_used, mean_rate_mOD_min, sd_rate, cv_rate,
  family, individual, temperature, conc_ug_mL, total_protein_mg,
  bg_rate_mOD_min, corrected_mOD_min, rate_OD_min, nmol_per_min,
  activity_mU_per_uL, total_mU_in_homogenate,
  activity_mU_per_mg_protein, nmol_in_window, within_std_range, cv_all,
  n_elevated, n, cv_flag, label_n [16x24]
mapping:  x = ~reorder(sample_id, activity_mU_per_uL), y = ~activity_mU_per_uL, fill = ~cv_flag
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_col: na.rm = FALSE, just = 0.5, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_stack 

mapping: label = ~label_n 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge 

mapping: y = ~y 
geom_blank: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
<p>Raw activity (mU/µL) spans a real 2.5-fold range across the sixteen individuals – 0.0547 (<code>F07_01_ambient</code>) to 0.1356 (<code>F07_04_36C</code>) – against a usable-replicate technical CV under 6.5% for every sample, so this spread reflects genuine inter-individual biological/extraction variation rather than measurement noise. Because no background correction could be applied (note 4), these values are the raw, uncorrected rates.</p>
</section>
<section id="protein-normalized-activity" class="level2">
<h2 class="anchored" data-anchor-id="protein-normalized-activity">9.4 Protein-normalized activity</h2>
<div class="sourceCode" id="cb61" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb61-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 15 of 16 samples are "clean" here; F07_03_ambient (CV &gt; 15% on all raw</span></span>
<span id="cb61-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># reps, note above) is excluded from the trend fit.</span></span>
<span id="cb61-3">norm_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> activity_plot_data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_flag <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb61-4"></span>
<span id="cb61-5">norm_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb61-6">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> total_protein_mg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_mg_protein)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> norm_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb61-8">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey35"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey85"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> cv_flag), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> individual), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein-normalized CS activity vs. total extracted protein"</span>,</span>
<span id="cb61-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Point labels = individual ID. Total protein = measured protein "</span>,</span>
<span id="cb61-14">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration x the same</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb61-15">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume used for every sample. Grey line = fit to "</span>,</span>
<span id="cb61-16">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"15 of 16</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">samples (F07_03_ambient excluded, CV &gt; 15% on raw reps); a "</span>,</span>
<span id="cb61-17">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive raw-rate/protein</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">relationship would suggest normalization is "</span>,</span>
<span id="cb61-18">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"correcting for real extraction-efficiency</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">differences rather than "</span>,</span>
<span id="cb61-19">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"introducing an artifact."</span>),</span>
<span id="cb61-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total extracted protein (mg)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/mg protein)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb61-23">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb61-24"></span>
<span id="cb61-25">protein_trend <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb61-26">protein_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb61-27">uL_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)</span>
<span id="cb61-28"></span>
<span id="cb61-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_normalized.png"</span>), norm_plot,</span>
<span id="cb61-30">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb61-31"></span>
<span id="cb61-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Correlation of mU/mg protein with total extracted protein</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb61-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  all %d samples      : r = %+.3f, p = %.4f</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-34">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(activity_plot_data), protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value))</span>
<span id="cb61-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean samples only  : r = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-36">            protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb61-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/mg protein range: %.3f to %.3f (%.2f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-38">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein),</span>
<span id="cb61-39">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)))</span>
<span id="cb61-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/uL range: %.4f to %.4f (%.2f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-41">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL),</span>
<span id="cb61-42">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)))</span>
<span id="cb61-43"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Artifact check: r(total protein, mU/uL raw rate) = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-44">            uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb61-45"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"If mU/uL itself trends with total protein while mU/mg protein trends oppositely,</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-46">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-47">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-- but a STRONG raw-rate/protein relationship (as seen here) instead argues that</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-48">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"protein normalization is correcting for genuine extraction-efficiency differences.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb61-49"></span>
<span id="cb61-50"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_trend_clean: correlation test on clean samples ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb61-51"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_trend_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb61-52"></span>
<span id="cb61-53"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- norm_clean: clean samples used for the trend fit ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb61-54"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(norm_clean)</span>
<span id="cb61-55"></span>
<span id="cb61-56">norm_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/Gen5-20260824-mgig-sormi-citrate_synthase-F07-ambient_and_36C_files/figure-gfm/plot-activity-normalized-1.png" class="img-fluid"><!-- --></p>
<pre><code>Correlation of mU/mg protein with total extracted protein
  all 16 samples      : r = -0.874, p = 0.0000
  clean samples only  : r = -0.868, p = 0.0000  (n = 15)
  clean-sample mU/mg protein range: 79.566 to 207.819 (2.61-fold)
  clean-sample mU/uL range: 0.0547 to 0.1356 (2.48-fold)

Artifact check: r(total protein, mU/uL raw rate) = +0.935, p = 0.0000  (n = 15)
If mU/uL itself trends with total protein while mU/mg protein trends oppositely,
the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate
-- but a STRONG raw-rate/protein relationship (as seen here) instead argues that
protein normalization is correcting for genuine extraction-efficiency differences.

--- protein_trend_clean: correlation test on clean samples ---

List of 9
 $ statistic  : Named num -6.32
 $ parameter  : Named int 13
 $ p.value    : num 2.67e-05
 $ estimate   : Named num -0.868
 $ null.value : Named num 0
 $ alternative: chr "two.sided"
 $ method     : chr "Pearson's product-moment correlation"
 $ data.name  : chr "norm_clean$total_protein_mg and norm_clean$activity_mU_per_mg_protein"
 $ conf.int   : num [1:2] -0.956 -0.642

--- norm_clean: clean samples used for the trend fit ---

tibble [15 × 24] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:15] "F07_01_36C" "F07_01_ambient" "F07_02_36C" "F07_02_ambient" ...
 $ n_reps_used               : int [1:15] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_rate_mOD_min         : num [1:15] 4.93 3.43 7.48 7.43 8.28 ...
 $ sd_rate                   : num [1:15] 0.0577 0.0577 0.1258 0.1443 0.2566 ...
 $ cv_rate                   : num [1:15] 1.17 1.68 1.68 1.94 3.1 ...
 $ family                    : chr [1:15] "F07" "F07" "F07" "F07" ...
 $ individual                : chr [1:15] "01" "01" "02" "02" ...
 $ temperature               : chr [1:15] "36C" "ambient" "36C" "ambient" ...
 $ conc_ug_mL                : num [1:15] 663 263 932 1080 1206 ...
 $ total_protein_mg          : num [1:15] 0.2322 0.0921 0.3263 0.378 0.4219 ...
 $ bg_rate_mOD_min           : num [1:15] 0 0 0 0 0 0 0 0 0 0 ...
 $ corrected_mOD_min         : num [1:15] 4.93 3.43 7.48 7.43 8.28 ...
 $ rate_OD_min               : num [1:15] 0.00493 0.00343 0.00748 0.00743 0.00828 ...
 $ nmol_per_min              : num [1:15] 0.157 0.109 0.238 0.237 0.264 ...
 $ activity_mU_per_uL        : num [1:15] 0.0786 0.0547 0.1192 0.1184 0.1319 ...
 $ total_mU_in_homogenate    : num [1:15] 27.5 19.1 41.7 41.4 46.2 ...
 $ activity_mU_per_mg_protein: num [1:15] 118 208 128 110 109 ...
 $ nmol_in_window            : num [1:15] 3.14 2.19 4.77 4.74 5.28 ...
 $ within_std_range          : logi [1:15] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ cv_all                    : num [1:15] 1.17 1.68 1.68 1.94 3.1 ...
 $ n_elevated                : int [1:15] 0 0 0 0 0 0 0 0 0 0 ...
 $ n                         : int [1:15] 3 3 3 3 3 3 3 3 3 3 ...
 $ cv_flag                   : Factor w/ 3 levels "clean","CV &gt; 15%",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ label_n                   : chr [1:15] "3/3 reps" "3/3 reps" "3/3 reps" "3/3 reps" ...</code></pre>
<p>Raw activity (mU/µL) rises strongly and significantly with total extracted protein (r = +0.935, p = 0.0000), while mU/mg protein correlates negatively with total extracted protein (r = -0.868, p = 0.0000, n = 15, excluding <code>F07_03_ambient</code>). Because raw signal genuinely increases with more protein loaded – consistent with more CS enzyme being present when more protein was extracted – <strong>the negative mU/mg protein trend here is more consistent with protein normalization doing its intended job</strong> (correcting for real inter-sample extraction-efficiency differences) than with a pure division artifact. Normalizing here does not narrow the inter-individual spread – it is essentially unchanged, from a 2.48-fold raw range to a 2.61-fold range in mU/mg protein – so on this plate the case for normalization rests on the raw-rate/protein correlation itself, not on a visibly tighter normalized range.</p>
</section>
</section>
<section id="qc-summary" class="level1">
<h1>10 QC SUMMARY</h1>
<div class="sourceCode" id="cb63" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb63-1">qc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_qc_summary_table</span>(layout_wells, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary, std_curve,</span>
<span id="cb63-2">                                      well_diagnostics, well_rates, cv_summary,</span>
<span id="cb63-3">                                      baseline_per_sample, pos_control, assay_params)</span>
<span id="cb63-4"></span>
<span id="cb63-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(qc_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"QC check"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Result"</span>),</span>
<span id="cb63-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quality control summary for this plate"</span>)</span>
<span id="cb63-7"></span>
<span id="cb63-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(qc_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"qc_summary.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb63-9"></span>
<span id="cb63-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- qc_summary: consolidated QC checks for the run ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb63-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(qc_summary)</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">QC check</th>
<th style="text-align: left;">Result</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Occupied wells in layout</td>
<td style="text-align: left;">72</td>
</tr>
<tr class="even">
<td style="text-align: left;">Layout wells missing from absorbance CSV</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Max disagreement between absorbance CSV and full report</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard concentrations with replicate CV &gt; threshold</td>
<td style="text-align: left;"></td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard wells flagged as outliers</td>
<td style="text-align: left;">0/18 ()</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard curve R^2 (outlier-excluded, replicate level)</td>
<td style="text-align: left;">0.9992</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard curve R^2 (all wells, replicate level)</td>
<td style="text-align: left;">0.9992</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard wells that LOST signal over the run</td>
<td style="text-align: left;">15/18</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standards above photometric linearity ceiling</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;">Background control wells behaving as active reactions</td>
<td style="text-align: left;">3/3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells with a decreasing trace</td>
<td style="text-align: left;">1/48</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with an elevated starting A412</td>
<td style="text-align: left;">0/48 ()</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with ALL THREE replicates baseline-compromised</td>
<td style="text-align: left;">0/16 ()</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with a read glitch</td>
<td style="text-align: left;">0/48</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells usable for rate extraction</td>
<td style="text-align: left;">47/48</td>
</tr>
<tr class="even">
<td style="text-align: left;">Samples with technical CV &gt; threshold (all reps)</td>
<td style="text-align: left;">1/16</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with technical CV &gt; threshold (usable reps)</td>
<td style="text-align: left;">0/16</td>
</tr>
<tr class="even">
<td style="text-align: left;">Positive control replicates rising and linear</td>
<td style="text-align: left;">3/3</td>
</tr>
</tbody>
</table>
<p>Quality control summary for this plate</p>
<pre><code>--- qc_summary: consolidated QC checks for the run ---

'data.frame':   18 obs. of  2 variables:
 $ check: chr  "Occupied wells in layout" "Layout wells missing from absorbance CSV" "Max disagreement between absorbance CSV and full report" "Standard concentrations with replicate CV &gt; threshold" ...
 $ value: chr  "72" "0" "0" "" ...</code></pre>
<section id="auto-generated-findings" class="level2">
<h2 class="anchored" data-anchor-id="auto-generated-findings">10.1 Auto-generated findings</h2>
<p>The bullets below are generated programmatically from the QC/CV/anomaly objects above by <code>generate_qc_findings()</code>, so the same logic that flags a problem here is guaranteed to be the logic that flagged it upstream.</p>
<div class="sourceCode" id="cb65" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb65-1">qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">generate_qc_findings</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb65-2">                                     baseline_per_sample, std_curve, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary,</span>
<span id="cb65-3">                                     assay_params)</span>
<span id="cb65-4"></span>
<span id="cb65-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"- "</span>, qc_findings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>- **Kinetic sources agree.** absorbance CSV and full report agree exactly on all 792 shared well x timepoint readings; all layout wells are present.

- **Decreasing kinetics.** 1 sample well(s) end lower than (or equal to) their starting A412 and are excluded from rate extraction: A7.

- **Background control wells behaving as active reactions.** 3 of 3 background wells show a starting A412 or drift inconsistent with a flat, inactive well: F10, F11, F12.

- **Standard signal decay.** 15 of 18 standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0.

- **Standard curve fit (outlier-excluded):** slope = 0.03140 A412/nmol, R^2 = 0.9992 (all-wells R^2 = 0.9992).

- **Technical replicate CV &gt; 15% (all replicates).** 1 of 16 samples: F07_03_ambient (87%).</code></pre>
</section>
</section>
<section id="summary" class="level1">
<h1>11 SUMMARY</h1>
<section id="anomalies-found" class="level2">
<h2 class="anchored" data-anchor-id="anomalies-found">11.1 Anomalies found</h2>
<ol type="1">
<li><strong>All three pooled-background replicates are compromised by a confirmed Reaction Mix / Background Control Mix mix-up (note 4).</strong> <code>F10</code>-<code>F12</code> rise 0.067-0.119 A412 over the run – comparable to a real reaction, not a background – so <code>compute_background_correction()</code> cannot estimate a background rate. Every sample’s corrected rate on this plate equals its raw rate.</li>
<li><strong>One sample well is dead.</strong> <code>A7</code> (<code>F07_03_ambient</code>) reads a constant A412 0.099 across all 11 timepoints (net change = 0, R<sup>2</sup> = 0) rather than a slow reaction. Its two siblings (<code>A8</code>, <code>A9</code>) are normal, so <code>F07_03_ambient</code>’s activity is computed from 2 of 3 replicates with a 6.4% usable-replicate CV.</li>
<li><strong>Widespread but harmless GSH standard signal decay.</strong> All 15 non-zero-concentration standard wells lose signal between t = 0 and t = 20 min, consistent with TNB<sup>2-</sup> instability. Because the standard curve is calibrated at t = 0, this has no effect on the fit (R<sup>2</sup> = 0.9992, zero flagged outlier wells).</li>
<li><strong>The positive control was clean on this plate</strong> (2.6% CV, R<sup>2</sup> 0.998-1.000), confirming the core reaction chemistry and reader were functioning normally.</li>
</ol>
</section>
<section id="technical-replicate-precision-1" class="level2">
<h2 class="anchored" data-anchor-id="technical-replicate-precision-1">11.2 Technical replicate precision</h2>
<p><strong>Every sample is within the 15% CV threshold on usable replicates.</strong> <code>F07_03_ambient</code> is the only sample whose <em>all-replicates</em> CV fails (86.9%, driven entirely by the dead <code>A7</code> well); its usable-replicate CV is a normal 6.4%. Every other sample is under 3.1% CV on all three raw replicates, most under 2%.</p>
</section>
<section id="assay-validity" class="level2">
<h2 class="anchored" data-anchor-id="assay-validity">11.3 Assay validity</h2>
<p>The <strong>positive control and standard curve both worked well</strong>: all three positive-control replicates rise linearly (R<sup>2</sup> &gt; 0.997) with a tight 2.6% CV, and the GSH standard curve has zero flagged outlier wells (R<sup>2</sup> = 0.9992). <strong>The background control did not work</strong> (note 4) – this plate’s activity values are raw, uncorrected rates, not background-corrected ones. Where a pooled background control has worked correctly, it has been a small term (roughly 2-7% of the sample signal), so the raw values here are likely only a modest overestimate of true background-corrected activity, but this cannot be confirmed without a working background control.</p>
</section>
<section id="recommendation" class="level2">
<h2 class="anchored" data-anchor-id="recommendation">11.4 Recommendation</h2>
<ol type="1">
<li><strong>Samples, standard curve, and positive control do not need re-assay.</strong> Only <code>A7</code> (<code>F07_03_ambient</code>) failed outright, and that sample still has two clean, precise replicates.</li>
<li><strong>The background control should be re-run before treating this plate’s activity values as final.</strong> Consider physically separating the Reaction Mix and Background Control Mix reservoirs/tips, or pipetting the background wells first, before switching reagents for the sample wells, to reduce the risk of this mix-up recurring.</li>
<li><strong>Protein normalization looks appropriate for this plate, not artifactual</strong>: raw rate (mU/µL) is strongly and significantly correlated with total extracted protein (r = +0.93, p = 0.0000), so the negative mU/mg-protein trend is better explained by genuine extraction-efficiency differences between samples than by a division artifact.</li>
</ol>
</section>
<section id="what-can-be-used-from-this-plate" class="level2">
<h2 class="anchored" data-anchor-id="what-can-be-used-from-this-plate">11.5 What can be used from this plate</h2>
<p>15 of 16 samples are fully clean, and the 16th (<code>F07_03_ambient</code>) is still usable via 2 of 3 replicates. <strong>Because this plate’s rates are uncorrected</strong>, they should not be pooled directly with background-corrected values from other assays without accounting for that difference. Within this plate, raw activity spans 0.0547-0.1356 mU/uL, a real 2.5-fold range against &lt;6.5% technical CV per sample.</p>
<ul>
<li><strong>Re-running just the background triplicate</strong> (rather than the whole plate) would let this plate’s existing sample, standard-curve, and positive-control data be background-corrected without re-collecting everything else.</li>
<li><strong>Protein-normalized activity (mU/mg protein) is the recommended basis for downstream comparison on this plate</strong>: raw activity correlates strongly with total extracted protein, consistent with normalization correcting a real extraction-efficiency covariate rather than introducing one.</li>
</ul>


</section>
</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>citrate synthase</category>
  <category>ABCAM</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-24-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-7-Ambient-and-36C-Ctenidia/</guid>
  <pubDate>Mon, 24 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Citrate Synthase Assay - SORMI June 2026 M.gigas Family 5 36C Ctenidia</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Continuing citrate synthase assays on Family 5 from the June 2026 SORMI experiment, I assayed ctenidia from the eight <em>Magallana gigas</em> (Pacific oyster) Family 5 individuals held at <strong>36°C</strong> (heat-stress exposure) using the Citrate Synthase Assay Kit (ABCAM; cat: ab239712). Samples had been <a href="../../../posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/index.html">previously homogenized on 20260811</a> (Notebook entry), and protein concentrations for normalization were <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">determined on 20260813</a> (Notebook entry). This is the companion plate to the <a href="../../../posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/index.html">Family 5 ambient assay run on 20260811</a> (Notebook entry).</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p><strong>The plate reader assay time differed between this run and the 20260811 run.</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Run</th>
<th style="text-align: left;">Read duration</th>
<th style="text-align: left;">Reads</th>
<th style="text-align: left;">Interval</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><a href="../../../posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/index.html">20260811 - Family 5 ambient</a></td>
<td style="text-align: left;">40 min</td>
<td style="text-align: left;">21</td>
<td style="text-align: left;">2 min</td>
</tr>
<tr class="even">
<td style="text-align: left;">20260814 - Family 5 36°C (this run)</td>
<td style="text-align: left;">20 min</td>
<td style="text-align: left;">11</td>
<td style="text-align: left;">2 min</td>
</tr>
</tbody>
</table>
<p>This plate was read for <strong>20 minutes (11 reads)</strong>, half the 40-minute (21-read) kinetic window used on 20260811. Both runs used 2-minute read intervals at 412 nm and 25°C, so the difference is purely in how long the kinetics were followed.</p>
<p>Rate extraction uses a fixed-width sliding window (5 points = 8 min) rather than the full trace, so the shorter read does not change the width of the window a rate is fit over — only how many candidate windows are available to slide across. It does change <em>where</em> the steepest window lands. On this plate every sample well was fitted on the window running from <strong>12 to 20 min</strong> — the final five reads of the run. On 20260811, where traces rose immediately and then decelerated, the great majority of wells were fitted on the initial 0-8 min window.</p>
<p>The fits themselves are excellent (every sample well R<sup>2</sup> &gt; 0.99), so the reported rates are well determined over the window used. But since the steepest window here is the last one in the run, there is no read time after it to confirm the reaction had reached its maximum rate. Any ambient-vs-36°C comparison should note that the two plates did not sample the same portion of the kinetic curve, and read duration should be standardized before further families are run.</p>
</div>
</div>
<p>All data/code/analysis is available here:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase">https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase</a></li>
</ul>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<section id="citrate-synthase-assay" class="level2">
<h2 class="anchored" data-anchor-id="citrate-synthase-assay">Citrate Synthase Assay</h2>
<p>The Citrate Synthase Assay Kit (ABCAM; cat: ab239712) was used according to the manufacturer’s instructions (<a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf</a> (GitHub; PDF)).</p>
<p>Homogenates were thawed and 2 µL of undiluted homogenate was combined with 48 µL of Assay Buffer 7 per well, followed by 50 µL of Reaction Mix. Each sample was assayed in technical triplicate in a clear, flat-bottomed 96-well plate. Every sample also received a paired triplicate of background control wells, which receive Background Control Mix (no CS Substrate Mix) to correct for pre-existing free thiol in the homogenate. A six-point GSH standard curve (0, 8, 16, 24, 32, 40 nmol/well) and a CS positive control were included in triplicate on the same plate.</p>
<p>Master Mix Calcs</p>
<p>REACTION MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>43</td>
<td>50</td>
<td>2150</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>50</td>
<td>250</td>
</tr>
<tr class="odd">
<td>CS Substrate</td>
<td>2</td>
<td>50</td>
<td>100</td>
</tr>
</tbody>
</table>
<p>BACKGROUND MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>45</td>
<td>30</td>
<td>1350</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>30</td>
<td>150</td>
</tr>
</tbody>
</table>
<p>Absorbance was read at 412 nm in kinetic mode at 25°C on a Synergy HTX plate reader (Agilent), at 2-minute intervals. This plate was read for 20 minutes (11 reads); see the callout above.</p>
</section>
<section id="normalization" class="level2">
<h2 class="anchored" data-anchor-id="normalization">Normalization</h2>
<p>Activity was normalized to total extracted protein rather than tissue weight. Tissue was homogenized in 350 µL of Assay Buffer 7, and protein concentration in each homogenate was <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">quantified separately on 20260813</a> (Notebook entry) using the Bradford assay. Total protein mass per sample is that concentration multiplied by the 350 µL homogenization volume. Tissue weights are recorded in the plate layout labels for provenance only and play no role in the activity calculation.</p>
</section>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<p>Data were analyzed in R. The Rmd file is here (GitHub):</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260814-mgig-citrate_synthase-F05-36C.Rmd">Gen5-20260814-mgig-citrate_synthase-F05-36C.Rmd</a></li>
</ul>
<p>Knitted markdown is below.</p>
</section>
<section id="data-files" class="level2">
<h2 class="anchored" data-anchor-id="data-files">Data files</h2>
<section id="plate-reader-files" class="level3">
<h3 class="anchored" data-anchor-id="plate-reader-files">Plate reader files</h3>
<p>Plate reader files (<code>*.xpt</code>) are available here (require Gen5 software to open):</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/plate_reader_files</li>
</ul>
</section>
<section id="raw-absorbance-data" class="level3">
<h3 class="anchored" data-anchor-id="raw-absorbance-data">Raw absorbance data</h3>
<p>Raw absorbance data (<code>*.csv</code>), plate layouts, and Gen5 full reports are available here:</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/raw_absorbance</li>
</ul>
</section>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>This plate ran cleanly. All 24 sample wells rise monotonically with replicate-level R<sup>2</sup> &gt; 0.99, no well required exclusion, all eight samples pass the 15% technical CV threshold (highest is <code>F05_08_36C</code> at 7.8%), and the positive control was linear at 2.8-3.0 mA412/min. The GSH standard curve fails QC only by a single clearly-identified outlier well (<code>F5</code>, 40 nmol); excluding it drops that concentration’s CV from 15.9% to 0.5% and lifts the replicate-level R<sup>2</sup> to 0.9985. <strong>This plate does not need re-assay.</strong></p>
<p>Background-corrected rates cluster tightly — 2.13 to 2.30 mA412/min across all eight individuals, a spread of only 7.8% against 1-8% technical CV per sample. No striking within-family variation in raw CS activity is apparent at 36°C.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Reps used</th>
<th style="text-align: right;">CV all reps (%)</th>
<th style="text-align: right;">Corrected rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">3.3</td>
<td style="text-align: right;">2.17</td>
<td style="text-align: right;">37.0</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">2.22</td>
<td style="text-align: right;">66.0</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">3.5</td>
<td style="text-align: right;">2.30</td>
<td style="text-align: right;">56.0</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: right;">2.28</td>
<td style="text-align: right;">35.0</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">2.15</td>
<td style="text-align: right;">21.0</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">2.13</td>
<td style="text-align: right;">27.4</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">2.20</td>
<td style="text-align: right;">32.2</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">7.8</td>
<td style="text-align: right;">2.25</td>
<td style="text-align: right;">26.9</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>Two items still need follow-up. One background well (<code>C8</code>) showed the signature of a Reaction Mix / Background Control Mix swap — the same dispensing issue seen more extensively on the 20260811 plate — and is dropped automatically, leaving <code>F05_03_36C</code> with 2 of 3 background replicates. Separately, raw rate (mU/µL) is essentially flat against total extracted protein here (r = -0.48, p = 0.23) while mU/mg protein trends negatively with it, which points to the normalized figures reflecting a division artifact rather than a biological effect. Raw rate is the safer basis for downstream comparison until a dilution series resolves this.</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Citrate synthase (CS) activity in ctenidia of eight <em>Magallana gigas</em> (Pacific oyster) individuals from <strong>family F05</strong> held at <strong>36 °C</strong> (heat-stress exposure), assayed 2026-08-14 with the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">Abcam Citrate Synthase Assay Kit (ab239712), v4a</a>. The kit is a <strong>coupled kinetic</strong> assay. CS condenses acetyl-CoA and oxaloacetate, releasing free CoA-SH; the liberated thiol reduces DTNB to TNB<sup>2-</sup>, which absorbs at 412 nm. The <strong>rate</strong> of A412 increase is proportional to CS activity, and absolute nmol of thiol are assigned from a <strong>GSH (reduced glutathione) standard curve</strong> read on the same plate.</p>
<p>Absorbance was read at 412 nm in kinetic mode, 25 °C, every 2 min for 20 min (11 reads) on a Synergy HTX. See note 1.</p>
<p>This document is fully self-contained: layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are all defined directly below (see <code>## Pipeline functions</code> under SETUP) rather than sourced from a separate script, so the whole analysis can be reproduced from this one file.</p>
<section id="sample-naming-convention" class="level2">
<h2 class="anchored" data-anchor-id="sample-naming-convention">1.1 Sample naming convention</h2>
<p>Well labels follow <code>&lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;[_BG]-&lt;assay_type&gt;-&lt;weight&gt;-df.&lt;n&gt;</code> for sample/background wells (e.g.&nbsp;<code>F05_01_36C-citrate_synthase-12.8-df.0</code>), <code>STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</code> for GSH standards, and <code>POS-&lt;assay_type&gt;</code> for the positive control, with the temperature exposure encoded in the well label as <code>_36C</code>. The trailing number in the sample label (e.g.&nbsp;<code>12.8</code>) is tissue weight in mg, which is <strong>not</strong> used for normalization here (note 2); it is parsed and validated but plays no role in the activity calculation.</p>
</section>
<section id="notes" class="level2">
<h2 class="anchored" data-anchor-id="notes">1.2 Notes</h2>
<ol type="1">
<li><strong>Read duration for this plate is 20 minutes</strong> (11 reads at 2-min intervals). The assay parameters below set <code>read_duration_min = 20</code> to match. Rate extraction uses a fixed-width sliding window (<code>rate_window_n = 5</code> points = 8 min) rather than the full trace, so this only changes how many windows are available to slide across; see the KINETIC TRACES section for whether the assay is still in its linear phase over this window.</li>
<li><strong>Activity is normalized to total extracted protein, not tissue weight</strong>, because protein concentration was measured directly (BCA-style assay, <code>sample_protein_concentrations_*.csv</code>), and controls for extraction efficiency in a way tissue weight cannot.</li>
<li><strong>Protein concentrations are read from both supplied CSV files.</strong> This plate’s <code>F05_07_36C</code> record is only present in file 1, and under a slightly different string (<code>F-05_07_36C</code>, extra hyphen) — corrected via <code>sample_id_fixes</code> in the <code>protein-concentration</code> chunk.</li>
</ol>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="pipeline-functions" class="level2">
<h2 class="anchored" data-anchor-id="pipeline-functions">1.3 Pipeline functions</h2>
<p>All layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are defined directly in this document (rather than sourced from a separate script) so that it is fully self-contained and reproducible from this single file. The functions are grouped below by pipeline stage; each is called in the DATA / KINETIC TRACES / ANOMALY DETECTION / GSH STANDARD CURVE / RATE EXTRACTION / BACKGROUND CORRECTION / TECHNICAL REPLICATE PRECISION / CITRATE SYNTHASE ACTIVITY / QC SUMMARY sections that follow. Nothing plate-specific (typo fixes, disqualified samples, thresholds) is hardcoded in any function – it is always passed in as an argument, from the <code>assay_params</code> list defined further below or from a plate-specific fix list.</p>
<section id="data-import-and-layout-parsing" class="level3">
<h3 class="anchored" data-anchor-id="data-import-and-layout-parsing">1.3.1 Data import and layout parsing</h3>
<p>Reads the raw Gen5 exports (kinetic absorbance CSV, full-report text backup, plate-layout CSV), reconciles them against each other, and attaches well-type/sample-id/replicate metadata plus measured protein concentrations to every well.</p>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## elapsed_to_min()</span></span>
<span id="cb4-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert Gen5 "H:MM:SS" elapsed-time strings to decimal minutes.</span></span>
<span id="cb4-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : x - character vector of "H:MM:SS" strings</span></span>
<span id="cb4-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of elapsed minutes, same length as x</span></span>
<span id="cb4-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-7">elapsed_to_min <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb4-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-9">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p)</span>
<span id="cb4-10">    p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span></span>
<span id="cb4-11">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb4-12">}</span>
<span id="cb4-13"></span>
<span id="cb4-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-15"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_absorbance_csv()</span></span>
<span id="cb4-16"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "absorbance-*.csv" kinetic export: wavelength</span></span>
<span id="cb4-17"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           header, a "Time," row, a temperature row, then one row per well</span></span>
<span id="cb4-18"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well ID in column 1, one OD reading per timepoint thereafter).</span></span>
<span id="cb4-19"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the absorbance-*.csv file</span></span>
<span id="cb4-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-23">read_absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-24">  ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-25">  time_i   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time,"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-26">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[time_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb4-27">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> time_str[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>time_str <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time"</span>)]</span>
<span id="cb4-28">  tmin     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(time_str)</span>
<span id="cb4-29"></span>
<span id="cb4-30">  well_ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2},"</span>, ln)]</span>
<span id="cb4-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(well_ln, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-33">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(tmin) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb4-34">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-35">  }))</span>
<span id="cb4-36">}</span>
<span id="cb4-37"></span>
<span id="cb4-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_full_report()</span></span>
<span id="cb4-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "full_report-*.txt" export: tab-delimited, wells</span></span>
<span id="cb4-41"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across columns, timepoints down rows. Used only as an</span></span>
<span id="cb4-42"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           independent cross-check against the absorbance CSV, never as a</span></span>
<span id="cb4-43"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           primary data source.</span></span>
<span id="cb4-44"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the full_report-*.txt file</span></span>
<span id="cb4-45"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-46"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-47"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-48">read_full_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-49">  ln  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-50">  hdr_i <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.*</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">A1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-51">  hdr   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[hdr_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]])</span>
<span id="cb4-52">  rows  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[0-9]:[0-9]{2}:[0-9]{2}</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)]</span>
<span id="cb4-53">  m     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">do.call</span>(rbind, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(rows, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>))</span>
<span id="cb4-54">  tmin  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb4-55"></span>
<span id="cb4-56">  well_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2}$"</span>, hdr))</span>
<span id="cb4-57">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(well_cols, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(j) {</span>
<span id="cb4-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> hdr[j], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-59">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(m[, j]), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-60">  }))</span>
<span id="cb4-61">}</span>
<span id="cb4-62"></span>
<span id="cb4-63"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-64"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## parse_plate_layout()</span></span>
<span id="cb4-65"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert a raw Gen5 plate-layout CSV export into one row per</span></span>
<span id="cb4-66"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           occupied well with its descriptive label. Auto-detects two</span></span>
<span id="cb4-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           export formats seen in practice:</span></span>
<span id="cb4-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "single"  - one row per plate row (row 1 = column numbers,</span></span>
<span id="cb4-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         column 1 = row letter, last column = "Name" tag);</span></span>
<span id="cb4-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         each cell already holds the full descriptive label.</span></span>
<span id="cb4-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "double"  - each plate row is exported as TWO rows: a</span></span>
<span id="cb4-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         "Well ID" row (SPL codes) immediately followed by</span></span>
<span id="cb4-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         a "Name" row (the descriptive label actually used</span></span>
<span id="cb4-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         downstream).</span></span>
<span id="cb4-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           The format is detected from column 1: if a value repeats twice</span></span>
<span id="cb4-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           in a row (once for the well-ID row, once for the label row)</span></span>
<span id="cb4-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           immediately below a numeric header, it is treated as "double".</span></span>
<span id="cb4-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the layout-*.csv file</span></span>
<span id="cb4-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per occupied well:</span></span>
<span id="cb4-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr, e.g. "A1"), plate_row (chr), plate_col (int),</span></span>
<span id="cb4-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label (chr, trimmed descriptive label)</span></span>
<span id="cb4-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-83">parse_plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-84">  plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-85"></span>
<span id="cb4-86">  col1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1)</span>
<span id="cb4-87">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "double" format: row letters appear twice in a row in column 1</span></span>
<span id="cb4-88">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (once tagging the Well-ID row, once tagging the Name row), e.g.</span></span>
<span id="cb4-89">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "A", "A", "B", "B", ... Detect by checking whether non-empty,</span></span>
<span id="cb4-90">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># non-header values in col1 are each immediately followed by a repeat.</span></span>
<span id="cb4-91">  data_rows   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(col1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(col1))[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># drop header row (row 1)</span></span>
<span id="cb4-92">  is_double <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb4-93">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]][<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))])</span>
<span id="cb4-94"></span>
<span id="cb4-95">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (is_double) {</span>
<span id="cb4-96">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pair each row-letter row with the following label row.</span></span>
<span id="cb4-97">    row_letter_rows <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]</span>
<span id="cb4-98">    label_rows      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]</span>
<span id="cb4-99">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(row_letter_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(label_rows))</span>
<span id="cb4-100"></span>
<span id="cb4-101">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pair_idx =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(row_letter_rows),</span>
<span id="cb4-102">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-103">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-104">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> col1[row_letter_rows[pair_idx]],</span>
<span id="cb4-105">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-106">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-107">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j],</span>
<span id="cb4-108">                                   label_rows[pair_idx], col_idx))</span>
<span id="cb4-109">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-110">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-111">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-112">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-113">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb4-114">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "single" format: row 1 = column numbers, column 1 = row letters,</span></span>
<span id="cb4-115">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># last column = "Name" tag; each cell already holds the full label.</span></span>
<span id="cb4-116">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(plate_layout),</span>
<span id="cb4-117">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-118">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-119">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1[row_idx],</span>
<span id="cb4-120">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-121">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-122">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j], row_idx, col_idx))</span>
<span id="cb4-123">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-124">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-126">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-127">  }</span>
<span id="cb4-128"></span>
<span id="cb4-129">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(out, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(is_double, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"double"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"single"</span>)</span>
<span id="cb4-130">  out</span>
<span id="cb4-131">}</span>
<span id="cb4-132"></span>
<span id="cb4-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-134"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## reconcile_kinetic_sources()</span></span>
<span id="cb4-135"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Cross-check the absorbance CSV (primary data source) against</span></span>
<span id="cb4-136"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the full_report text export (independent instrument export)</span></span>
<span id="cb4-137"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and the plate layout (expected well set). Fails loudly</span></span>
<span id="cb4-138"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (stopifnot) if any layout well is missing from the CSV, or if</span></span>
<span id="cb4-139"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the two kinetic sources disagree on any shared reading.</span></span>
<span id="cb4-140"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : absorbance_csv - long-format data.frame from read_absorbance_csv()</span></span>
<span id="cb4-141"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           full_report    - long-format data.frame from read_full_report()</span></span>
<span id="cb4-142"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-143"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerance      - max allowed |CSV - report| absolute difference</span></span>
<span id="cb4-144"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            (default 1e-9, i.e. exact agreement)</span></span>
<span id="cb4-145"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(plate_readings, overlap_check, summary), where</span></span>
<span id="cb4-146"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_readings = absorbance_csv with a `source` column added,</span></span>
<span id="cb4-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           summary        = named list of counts for reporting</span></span>
<span id="cb4-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-149">reconcile_kinetic_sources <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(absorbance_csv, full_report, layout_wells,</span>
<span id="cb4-150">                                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tolerance =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>) {</span>
<span id="cb4-151">  wells_csv    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-152">  wells_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-153"></span>
<span id="cb4-154">  wells_report_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_report, wells_csv)</span>
<span id="cb4-155">  wells_layout_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, wells_csv)</span>
<span id="cb4-156">  wells_csv_not_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_csv, layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-157"></span>
<span id="cb4-158">  overlap_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">inner_join</span>(absorbance_csv, full_report,</span>
<span id="cb4-159">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"time_min"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_csv"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_report"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-160">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_diff =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(od_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_report))</span>
<span id="cb4-161"></span>
<span id="cb4-162">  max_disagreement <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(overlap_check<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>abs_diff) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb4-163"></span>
<span id="cb4-164">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-165">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb4-166">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> tolerance</span>
<span id="cb4-167">  )</span>
<span id="cb4-168"></span>
<span id="cb4-169">  plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> absorbance_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance_csv"</span>)</span>
<span id="cb4-170"></span>
<span id="cb4-171">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-172">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_readings =</span> plate_readings,</span>
<span id="cb4-173">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overlap_check  =</span> overlap_check,</span>
<span id="cb4-174">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">summary =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-175">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv),</span>
<span id="cb4-176">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report            =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report),</span>
<span id="cb4-177">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report_not_csv),</span>
<span id="cb4-178">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_layout_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv),</span>
<span id="cb4-179">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv_not_layout    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv_not_layout),</span>
<span id="cb4-180">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_shared_readings         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check),</span>
<span id="cb4-181">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_disagreement          =</span> max_disagreement</span>
<span id="cb4-182">    )</span>
<span id="cb4-183">  )</span>
<span id="cb4-184">}</span>
<span id="cb4-185"></span>
<span id="cb4-186"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-187"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## annotate_wells()</span></span>
<span id="cb4-188"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Join layout labels onto the kinetic readings and parse each</span></span>
<span id="cb4-189"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label into well_type, sample_id, family, individual,</span></span>
<span id="cb4-190"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           temperature, tissue weight, and standard concentration.</span></span>
<span id="cb4-191"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Expected label grammar:</span></span>
<span id="cb4-192"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             sample/background : &lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;[_BG]-&lt;assay_type&gt;-&lt;weight&gt;-df.&lt;n&gt;</span></span>
<span id="cb4-193"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             standard           : STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</span></span>
<span id="cb4-194"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             positive control   : POS-&lt;assay_type&gt;</span></span>
<span id="cb4-195"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Label typos (e.g. a misspelled assay_type) are corrected before</span></span>
<span id="cb4-196"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           parsing via `label_fixes`, a named character vector of</span></span>
<span id="cb4-197"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           c(pattern = replacement) pairs applied in order with gsub().</span></span>
<span id="cb4-198"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_readings - data.frame from reconcile_kinetic_sources()$plate_readings</span></span>
<span id="cb4-199"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-200"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label_fixes    - optional named character vector, e.g.</span></span>
<span id="cb4-201"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            c("citrate_synthasse" = "citrate_synthase")</span></span>
<span id="cb4-202"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : plate_long - fully annotated long-format data.frame, one row</span></span>
<span id="cb4-203"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           per well x timepoint, with well_type, sample_id, family,</span></span>
<span id="cb4-204"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           individual, temperature, weight_mg, std_nmol columns added</span></span>
<span id="cb4-205"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-206">annotate_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_readings, layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-207">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_readings <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-208">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-209">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-210">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb4-211">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-212">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^POS-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>,</span>
<span id="cb4-213">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_BG-"</span>,  label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>,</span>
<span id="cb4-214">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span></span>
<span id="cb4-215">      ),</span>
<span id="cb4-216">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_clean =</span> label</span>
<span id="cb4-217">    )</span>
<span id="cb4-218"></span>
<span id="cb4-219">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(label_fixes)) {</span>
<span id="cb4-220">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(label_fixes)) {</span>
<span id="cb4-221">      plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, label_fixes[[pat]], plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean)</span>
<span id="cb4-222">    }</span>
<span id="cb4-223">  }</span>
<span id="cb4-224"></span>
<span id="cb4-225">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-226">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-227">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb4-228">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(_BG)?-[a-zA-Z_]+-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-229">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^(F[0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-230">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_([0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-231">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_[0-9]+_(.*)$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-232">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight_mg   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb4-233">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-[a-zA-Z_]+-([0-9.]+)-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">..*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean)),</span>
<span id="cb4-234">                           <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb4-235">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-236">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-[a-zA-Z_]+-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean)), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb4-237">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-238">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well_type, sample_id, well, time_min)</span>
<span id="cb4-239"></span>
<span id="cb4-240">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fail loudly rather than silently dropping malformed labels</span></span>
<span id="cb4-241">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-242">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type)),</span>
<span id="cb4-243">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)])),</span>
<span id="cb4-244">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>]))</span>
<span id="cb4-245">  )</span>
<span id="cb4-246"></span>
<span id="cb4-247">  plate_long</span>
<span id="cb4-248">}</span>
<span id="cb4-249"></span>
<span id="cb4-250"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-251"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## load_protein_concentrations()</span></span>
<span id="cb4-252"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Load one or more BCA/Bradford-style protein-concentration CSV</span></span>
<span id="cb4-253"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exports, concatenate them, and match each plate sample to</span></span>
<span id="cb4-254"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exactly one protein-concentration record. Fails loudly if any</span></span>
<span id="cb4-255"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate sample has zero or more than one match. Converts</span></span>
<span id="cb4-256"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration (ug/mL) to total protein mass (mg) in the full</span></span>
<span id="cb4-257"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate using the measured homogenization volume.</span></span>
<span id="cb4-258"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : protein_files        - character vector of CSV paths, each with</span></span>
<span id="cb4-259"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   columns `Sample` and</span></span>
<span id="cb4-260"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   `Calculated concentration (ug/mL)`</span></span>
<span id="cb4-261"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_sample_ids     - character vector of this plate's sample IDs</span></span>
<span id="cb4-262"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate_volume_uL - measured homogenization volume (uL),</span></span>
<span id="cb4-263"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   applied identically to every sample</span></span>
<span id="cb4-264"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_fixes      - optional named character vector of</span></span>
<span id="cb4-265"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   c(pattern = replacement) label-typo</span></span>
<span id="cb4-266"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   corrections applied to the protein</span></span>
<span id="cb4-267"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   file's Sample column before matching,</span></span>
<span id="cb4-268"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   e.g. c("F-05_07_36C" = "F05_07_36C")</span></span>
<span id="cb4-269"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per plate sample:</span></span>
<span id="cb4-270"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id, source_file, conc_ug_mL, total_protein_mg</span></span>
<span id="cb4-271"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-272">load_protein_concentrations <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(protein_files, plate_sample_ids,</span>
<span id="cb4-273">                                         homogenate_volume_uL,</span>
<span id="cb4-274">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-275">  protein_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_files <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-276">    purrr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(.x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-277">                      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source_file =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(.x))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-278">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_protein =</span> Sample, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc_ug_mL =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Calculated concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-279">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id_protein, source_file, conc_ug_mL)</span>
<span id="cb4-280"></span>
<span id="cb4-281">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(sample_id_fixes)) {</span>
<span id="cb4-282">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(sample_id_fixes)) {</span>
<span id="cb4-283">      protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, sample_id_fixes[[pat]],</span>
<span id="cb4-284">                                             protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein)</span>
<span id="cb4-285">    }</span>
<span id="cb4-286">  }</span>
<span id="cb4-287"></span>
<span id="cb4-288">  protein_matches <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_id_protein <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> plate_sample_ids)</span>
<span id="cb4-289">  match_counts    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(sample_id_protein, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_matches"</span>)</span>
<span id="cb4-290"></span>
<span id="cb4-291">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-292">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(plate_sample_ids <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> protein_matches<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein),</span>
<span id="cb4-293">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(match_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-294">  )</span>
<span id="cb4-295"></span>
<span id="cb4-296">  protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-297">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-298">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_protein_mg =</span> conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> homogenate_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-299">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb4-300">}</span></code></pre></div>
</section>
<section id="well-level-kinetic-qc" class="level3">
<h3 class="anchored" data-anchor-id="well-level-kinetic-qc">1.3.2 Well-level kinetic QC</h3>
<p>Flags read glitches, non-rising (‘decreasing’) traces, elevated t0 baselines, and other well-level anomalies before any rate is trusted.</p>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## local_step_excess()</span></span>
<span id="cb5-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For a kinetic trace, measure how much each read-to-read step</span></span>
<span id="cb5-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           departs from the AVERAGE of its two immediate neighbouring</span></span>
<span id="cb5-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           steps. A large local excess flags a read glitch; comparing to</span></span>
<span id="cb5-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           local neighbours (rather than the trace's overall median step)</span></span>
<span id="cb5-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerates traces that smoothly decelerate throughout.</span></span>
<span id="cb5-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : od - numeric vector of OD readings in time order</span></span>
<span id="cb5-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of length length(od) - 1 (one per step)</span></span>
<span id="cb5-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-11">local_step_excess <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(od) {</span>
<span id="cb5-12">  d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)</span>
<span id="cb5-13">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(d)</span>
<span id="cb5-14">  local_expect <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb5-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(d[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n))])</span>
<span id="cb5-16">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb5-17">  d <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> local_expect</span>
<span id="cb5-18">}</span>
<span id="cb5-19"></span>
<span id="cb5-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_diagnostics()</span></span>
<span id="cb5-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute four independent per-well trace-shape diagnostics from</span></span>
<span id="cb5-23"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the raw kinetic trace, before any rate fitting: direction</span></span>
<span id="cb5-24"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (net change), monotonicity (fraction of rising steps),</span></span>
<span id="cb5-25"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           over-range (any read above the photometric linearity ceiling),</span></span>
<span id="cb5-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and discontinuity (a read-to-read glitch via local_step_excess).</span></span>
<span id="cb5-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Also flags an elevated starting absorbance for sample wells,</span></span>
<span id="cb5-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and background wells that behave like active reactions.</span></span>
<span id="cb5-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb5-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with od_linear_max, glitch_excess_od,</span></span>
<span id="cb5-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          sample_baseline_od, bg_flat_od_max,</span></span>
<span id="cb5-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          bg_flat_drift_max</span></span>
<span id="cb5-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_diagnostics - one row per well, with od_first, od_last,</span></span>
<span id="cb5-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           od_max, net_change, frac_rising, max_step, typical_step,</span></span>
<span id="cb5-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           step_excess, glitch_at_min, and flag_* / n_flags columns</span></span>
<span id="cb5-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-37">compute_well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb5-38">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-39">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-40">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, plate_row, plate_col, well_type, sample_id, label, std_nmol, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb5-42">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_first        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-43">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_last         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od),</span>
<span id="cb5-44">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_max          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(od),</span>
<span id="cb5-45">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_change      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-46">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">frac_rising     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb5-47">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_step        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)))],</span>
<span id="cb5-48">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typical_step    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od))),</span>
<span id="cb5-49">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_excess     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)))],</span>
<span id="cb5-50">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_at_min   =</span> time_min[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L],</span>
<span id="cb5-51">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb5-52">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb5-54">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_ratio      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(max_step) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmax</span>(typical_step, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>),</span>
<span id="cb5-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_decreasing =</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb5-56">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_over_range =</span> od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb5-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_glitch     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(step_excess) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glitch_excess_od,</span>
<span id="cb5-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_high_baseline =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_bg_active  =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb5-60">                        (od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb5-61">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(net_change) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_drift_max),</span>
<span id="cb5-62">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_flags         =</span> flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_over_range <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-63">                        flag_bg_active <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_high_baseline</span>
<span id="cb5-64">    )</span>
<span id="cb5-65">}</span>
<span id="cb5-66"></span>
<span id="cb5-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_baseline_diagnostics()</span></span>
<span id="cb5-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Classify sample/background wells by starting absorbance</span></span>
<span id="cb5-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (elevated vs. normal) and summarize, per sample, how many of</span></span>
<span id="cb5-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           its replicates are baseline-compromised. A sample with all</span></span>
<span id="cb5-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           replicates elevated has no clean replicate at all.</span></span>
<span id="cb5-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb5-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with sample_baseline_od</span></span>
<span id="cb5-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(baseline_check, baseline_per_sample)</span></span>
<span id="cb5-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-77">compute_baseline_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, assay_params) {</span>
<span id="cb5-78">  baseline_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-79">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-80">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-81">                             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-82">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(od_first))</span>
<span id="cb5-83"></span>
<span id="cb5-84">  baseline_per_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_check <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-85">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-87">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_elevated =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb5-88">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-89">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(n_elevated))</span>
<span id="cb5-90"></span>
<span id="cb5-91">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_check =</span> baseline_check, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_per_sample =</span> baseline_per_sample)</span>
<span id="cb5-92">}</span></code></pre></div>
</section>
<section id="standard-curve-and-rate-extraction" class="level3">
<h3 class="anchored" data-anchor-id="standard-curve-and-rate-extraction">1.3.3 Standard curve and rate extraction</h3>
<p>Fits the GSH standard curve, extracts each well’s rate via a sliding-window linear regression gated on R-squared, and summarizes the positive control.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## fit_standard_curve()</span></span>
<span id="cb6-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Extract t=0 GSH standard readings, quantify signal drift over</span></span>
<span id="cb6-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the run, compute per-concentration replicate statistics, flag</span></span>
<span id="cb6-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           outlier wells by deviation from their triplicate median, and</span></span>
<span id="cb6-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit three candidate calibration lines (all wells, per-</span></span>
<span id="cb6-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration means, outlier-excluded). The outlier-excluded</span></span>
<span id="cb6-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit is the calibration used downstream.</span></span>
<span id="cb6-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb6-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with std_outlier_od</span></span>
<span id="cb6-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list with standards_t0, standard_drift, standard_summary,</span></span>
<span id="cb6-12"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           standards_flagged, fit_all_wells, fit_means, fit_no_outliers,</span></span>
<span id="cb6-13"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit_comparison, std_slope, std_intercept, std_r2, std_nmol_max</span></span>
<span id="cb6-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-15">fit_standard_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb6-16">  standards_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, time_min, od, source)</span>
<span id="cb6-19"></span>
<span id="cb6-20">  standards_t0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-24"></span>
<span id="cb6-25">  standard_drift <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t0 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t40 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(time_min)],</span>
<span id="cb6-28">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drift =</span> od_t40 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_t0, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-30"></span>
<span id="cb6-31">  standard_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od),</span>
<span id="cb6-34">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_pct =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od),</span>
<span id="cb6-35">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-36">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-37">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_od =</span> mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean_od[std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>],</span>
<span id="cb6-38">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_per_nmol =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, net_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_nmol, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>))</span>
<span id="cb6-39"></span>
<span id="cb6-40">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-42">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">triplicate_median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od),</span>
<span id="cb6-43">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">deviation =</span> od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> triplicate_median,</span>
<span id="cb6-44">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_outlier =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation)))</span>
<span id="cb6-47"></span>
<span id="cb6-48">  fit_all_wells   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged)</span>
<span id="cb6-49">  fit_means       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standard_summary)</span>
<span id="cb6-50">  fit_no_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier))</span>
<span id="cb6-51"></span>
<span id="cb6-52">  fit_comparison <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb6-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all wells"</span>,          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_all_wells),</span>
<span id="cb6-54">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-55">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration means"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_means),</span>
<span id="cb6-57">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-58">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_means)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier-excluded"</span>,   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_no_outliers),</span>
<span id="cb6-60">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-61">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared)</span>
<span id="cb6-62">  )</span>
<span id="cb6-63"></span>
<span id="cb6-64">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb6-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_all      =</span> standards_all,</span>
<span id="cb6-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_t0       =</span> standards_t0,</span>
<span id="cb6-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_drift     =</span> standard_drift,</span>
<span id="cb6-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_summary   =</span> standard_summary,</span>
<span id="cb6-69">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_flagged  =</span> standards_flagged,</span>
<span id="cb6-70">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_all_wells      =</span> fit_all_wells,</span>
<span id="cb6-71">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_means          =</span> fit_means,</span>
<span id="cb6-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_no_outliers    =</span> fit_no_outliers,</span>
<span id="cb6-73">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_comparison     =</span> fit_comparison,</span>
<span id="cb6-74">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_slope          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]),</span>
<span id="cb6-75">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_intercept      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb6-76">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_r2             =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared,</span>
<span id="cb6-77">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol_max       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol)</span>
<span id="cb6-78">  )</span>
<span id="cb6-79">}</span>
<span id="cb6-80"></span>
<span id="cb6-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## window_slopes()</span></span>
<span id="cb6-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Fit every sliding window of `w` consecutive timepoints on one</span></span>
<span id="cb6-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           kinetic trace and return the slope (mOD/min) and R^2 of each.</span></span>
<span id="cb6-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : t - numeric vector of timepoints (min)</span></span>
<span id="cb6-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           y - numeric vector of OD readings, same length as t</span></span>
<span id="cb6-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           w - window width in number of points</span></span>
<span id="cb6-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per window: t_start, t_end,</span></span>
<span id="cb6-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2</span></span>
<span id="cb6-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-91">window_slopes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(t, y, w) {</span>
<span id="cb6-92">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(y)</span>
<span id="cb6-93">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb6-94">    i  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> s<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-95">    f  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(y[i] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> t[i])</span>
<span id="cb6-96">    r2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(f)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb6-97">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> t[i[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> t[i[w]],</span>
<span id="cb6-98">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(f)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb6-99">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(r2), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, r2))</span>
<span id="cb6-100">  }))</span>
<span id="cb6-101">}</span>
<span id="cb6-102"></span>
<span id="cb6-103"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-104"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_rates()</span></span>
<span id="cb6-105"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For every well, scan all sliding windows of assay_params$</span></span>
<span id="cb6-106"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           rate_window_n consecutive reads and record the max-increasing</span></span>
<span id="cb6-107"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           window (used for activity) and the max-absolute window</span></span>
<span id="cb6-108"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (diagnostic only -- matches Gen5's own `Max V` convention,</span></span>
<span id="cb6-109"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           which can report large negative "rates" for degrading wells).</span></span>
<span id="cb6-110"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           A rate is `rate_usable` only if its R^2 clears the floor, the</span></span>
<span id="cb6-111"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well's net change is positive, and no read glitch falls inside</span></span>
<span id="cb6-112"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the fitted window.</span></span>
<span id="cb6-113"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long       - data.frame from annotate_wells()</span></span>
<span id="cb6-114"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb6-115"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with rate_window_n, rate_min_r2</span></span>
<span id="cb6-116"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_rates - one row per well: t_start, t_end, slope_mOD_min,</span></span>
<span id="cb6-117"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           r2, max_abs_slope_mOD_min, abs_window_is_negative,</span></span>
<span id="cb6-118"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           glitch_in_window, rate_usable (plus diagnostic columns joined in)</span></span>
<span id="cb6-119"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-120">compute_well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, well_diagnostics, assay_params) {</span>
<span id="cb6-121">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-122">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-123">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, well_type, sample_id, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-124">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_modify</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> {</span>
<span id="cb6-125">      w   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">window_slopes</span>(.x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min, .x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_window_n)</span>
<span id="cb6-126">      inc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min), ]</span>
<span id="cb6-127">      abs_ <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), ]</span>
<span id="cb6-128">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb6-129">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_start, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_end,</span>
<span id="cb6-130">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2,</span>
<span id="cb6-131">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_abs_slope_mOD_min =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min,</span>
<span id="cb6-132">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_window_is_negative =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb6-133">      )</span>
<span id="cb6-134">    }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-135">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-136">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, net_change, frac_rising, od_max,</span>
<span id="cb6-137">                                          flag_decreasing, flag_over_range,</span>
<span id="cb6-138">                                          flag_glitch, glitch_at_min,</span>
<span id="cb6-139">                                          flag_bg_active, n_flags),</span>
<span id="cb6-140">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-141">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb6-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_in_window =</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> t_start <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> t_end,</span>
<span id="cb6-143">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_usable      =</span> r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_min_r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>glitch_in_window</span>
<span id="cb6-144">    )</span>
<span id="cb6-145">}</span>
<span id="cb6-146"></span>
<span id="cb6-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_positive_control()</span></span>
<span id="cb6-149"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute the CS Positive Control's rate and activity, and check</span></span>
<span id="cb6-150"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           that its replicates rose linearly -- the plate's proof that the</span></span>
<span id="cb6-151"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reaction chemistry (DTNB, coupling, reader) worked, independent</span></span>
<span id="cb6-152"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           of any sample-specific problem.</span></span>
<span id="cb6-153"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates   - data.frame from compute_well_rates()</span></span>
<span id="cb6-154"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope    - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb6-155"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with sample_volume_uL, dilution_factor</span></span>
<span id="cb6-156"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : pos_control - one row per positive-control well: t_start, t_end,</span></span>
<span id="cb6-157"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2, net_change, activity_mU_uL</span></span>
<span id="cb6-158"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-159">compute_positive_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, std_slope, assay_params) {</span>
<span id="cb6-160">  well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-161">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-162">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_uL =</span> (slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb6-163">                            assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor)</span>
<span id="cb6-164">}</span></code></pre></div>
</section>
<section id="background-correction-replicate-cv-and-activity-calculation" class="level3">
<h3 class="anchored" data-anchor-id="background-correction-replicate-cv-and-activity-calculation">1.3.4 Background correction, replicate CV, and activity calculation</h3>
<p>Estimates background rate from flat background wells, computes technical-replicate coefficients of variation, and converts corrected rates into protein-normalized CS activity.</p>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_background_correction()</span></span>
<span id="cb7-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Estimate each sample's background rate from its flat</span></span>
<span id="cb7-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well-behaved) background-control replicates only, since</span></span>
<span id="cb7-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           anomalous background wells do not measure background.</span></span>
<span id="cb7-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates - data.frame from compute_well_rates()</span></span>
<span id="cb7-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : background_per_sample - one row per sample: n_bg_total,</span></span>
<span id="cb7-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           n_bg_flat, bg_rate_flat (NA if no flat replicate exists),</span></span>
<span id="cb7-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           bg_rate_all</span></span>
<span id="cb7-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-11">compute_background_correction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates) {</span>
<span id="cb7-12">  well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb7-16">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_total    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb7-17">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_flat     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>flag_bg_active),</span>
<span id="cb7-18">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_flat  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb7-19">                             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>flag_bg_active]), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb7-20">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_all   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-21">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb7-22">    )</span>
<span id="cb7-23">}</span>
<span id="cb7-24"></span>
<span id="cb7-25"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_replicate_cv()</span></span>
<span id="cb7-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute technical-replicate coefficient of variation (CV%) on</span></span>
<span id="cb7-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the extracted rate, both across ALL three replicates and</span></span>
<span id="cb7-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across USABLE replicates only (rate_usable == TRUE). Flags any</span></span>
<span id="cb7-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample whose CV exceeds assay_params$cv_threshold_pct.</span></span>
<span id="cb7-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates       - data.frame from compute_well_rates()</span></span>
<span id="cb7-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_order  - character vector giving the row order /</span></span>
<span id="cb7-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              complete sample-ID set to report (typically</span></span>
<span id="cb7-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              the plate's sample IDs, e.g. from</span></span>
<span id="cb7-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              protein_by_sample$sample_id)</span></span>
<span id="cb7-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with cv_threshold_pct</span></span>
<span id="cb7-37"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cv_summary - one row per sample: n_all, mean_all, sd_all,</span></span>
<span id="cb7-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_all, n_usable, mean_usable, sd_usable, cv_usable,</span></span>
<span id="cb7-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           excluded_wells, fails_cv_all, fails_cv_usable</span></span>
<span id="cb7-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-41">compute_replicate_cv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, sample_id_order, assay_params) {</span>
<span id="cb7-42">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-43"></span>
<span id="cb7-44">  cv_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-47">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_all =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-48"></span>
<span id="cb7-49">  cv_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-50">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-51">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-53">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-54">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_usable =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-55"></span>
<span id="cb7-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_order, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-57">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_all, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-60">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">excluded_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(sample_id, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb7-61">        w <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable]</span>
<span id="cb7-62">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(w) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(w, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)</span>
<span id="cb7-63">      }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb7-64">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_all    =</span> cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_usable =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> cv_usable <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct</span>
<span id="cb7-66">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-67">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-68">}</span>
<span id="cb7-69"></span>
<span id="cb7-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## calculate_cs_activity()</span></span>
<span id="cb7-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute per-sample CS activity following Abcam sec 10.3, using</span></span>
<span id="cb7-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           only usable replicates, corrected for background rate, scaled</span></span>
<span id="cb7-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           through the standard curve, and normalized to total extracted</span></span>
<span id="cb7-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           protein (rather than tissue weight).</span></span>
<span id="cb7-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates            - data.frame from compute_well_rates()</span></span>
<span id="cb7-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           protein_by_sample     - data.frame from load_protein_concentrations()</span></span>
<span id="cb7-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background_per_sample - data.frame from compute_background_correction()</span></span>
<span id="cb7-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope             - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb7-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_nmol_max          - max calibrated GSH concentration, from fit_standard_curve()</span></span>
<span id="cb7-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params          - list with sample_volume_uL, dilution_factor,</span></span>
<span id="cb7-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    homogenate_volume_uL, read_duration_min</span></span>
<span id="cb7-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_long            - data.frame from annotate_wells(), used to</span></span>
<span id="cb7-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    attach family/individual/temperature</span></span>
<span id="cb7-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cs_activity - one row per sample: n_reps_used, mean_rate_mOD_min,</span></span>
<span id="cb7-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sd_rate, cv_rate, family, individual, temperature, conc_ug_mL,</span></span>
<span id="cb7-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           total_protein_mg, bg_rate_mOD_min, corrected_mOD_min,</span></span>
<span id="cb7-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_uL, total_mU_in_homogenate,</span></span>
<span id="cb7-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_mg_protein, within_std_range</span></span>
<span id="cb7-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-91">calculate_cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, protein_by_sample, background_per_sample,</span>
<span id="cb7-92">                                   std_slope, std_nmol_max, assay_params, plate_long) {</span>
<span id="cb7-93">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-94"></span>
<span id="cb7-95">  sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-96">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-97">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-98">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_reps_used =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_rate_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-99">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_rate =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-100">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_rate =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-101">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-102">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb7-103">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-104">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, conc_ug_mL, total_protein_mg),</span>
<span id="cb7-105">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-106">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(background_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, bg_rate_flat, n_bg_flat),</span>
<span id="cb7-107">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-108">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-109">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_mOD_min       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(bg_rate_flat), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, bg_rate_flat),</span>
<span id="cb7-110">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">corrected_mOD_min     =</span> mean_rate_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> bg_rate_mOD_min,</span>
<span id="cb7-111">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_OD_min           =</span> corrected_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb7-112">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_per_min          =</span> rate_OD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope,</span>
<span id="cb7-113">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_uL    =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span></span>
<span id="cb7-114">                              assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor,</span>
<span id="cb7-115">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_mU_in_homogenate =</span> activity_mU_per_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb7-116">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_mg_protein =</span> total_mU_in_homogenate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> total_protein_mg,</span>
<span id="cb7-117">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_in_window        =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>read_duration_min),</span>
<span id="cb7-118">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">within_std_range      =</span> nmol_in_window <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> std_nmol_max</span>
<span id="cb7-119">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-120">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-121">}</span>
<span id="cb7-122"></span>
<span id="cb7-123"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-124"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_results_table()</span></span>
<span id="cb7-125"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Assemble the final, presentation-ready per-sample results</span></span>
<span id="cb7-126"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           table from cs_activity, cv_summary and baseline diagnostics,</span></span>
<span id="cb7-127"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           with a plain-language Interpretation column.</span></span>
<span id="cb7-128"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : cs_activity          - data.frame from calculate_cs_activity()</span></span>
<span id="cb7-129"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary           - data.frame from compute_replicate_cv()</span></span>
<span id="cb7-130"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample  - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb7-131"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params         - list with cv_threshold_pct, homogenate_volume_uL</span></span>
<span id="cb7-132"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : results_table - formatted data.frame, ready for kable()/write.csv()</span></span>
<span id="cb7-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-134">build_results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(cs_activity, cv_summary, baseline_per_sample, assay_params) {</span>
<span id="cb7-135">  cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-136">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-137">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-138">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb7-139">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample                       =</span> sample_id,</span>
<span id="cb7-140">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family                       =</span> family,</span>
<span id="cb7-141">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual                   =</span> individual,</span>
<span id="cb7-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature                  =</span> temperature,</span>
<span id="cb7-143">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Protein conc (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-144">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Total protein (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(total_protein_mg, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-145">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Reps used</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, n_all),</span>
<span id="cb7-146">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV all reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>            <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_all, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-147">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV used reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_rate, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-149">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">BG rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(bg_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-150">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Corrected rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(corrected_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-151">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/uL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_uL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb7-152">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/mg protein)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_mg_protein, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-153">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV flag</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-154">                                            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FAIL &gt;"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pass"</span>),</span>
<span id="cb7-155">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Elevated baseline reps</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_elevated, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3"</span>),</span>
<span id="cb7-156">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Interpretation               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb7-157">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DO NOT USE - no clean replicate"</span>,</span>
<span id="cb7-158">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - some reps compromised"</span>,</span>
<span id="cb7-159">        cv_rate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_rate) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - imprecise"</span>,</span>
<span id="cb7-160">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span></span>
<span id="cb7-161">      )</span>
<span id="cb7-162">    )</span>
<span id="cb7-163">}</span></code></pre></div>
</section>
<section id="qc-summary-and-narrative-generation" class="level3">
<h3 class="anchored" data-anchor-id="qc-summary-and-narrative-generation">1.3.5 QC summary and narrative generation</h3>
<p>Assembles the per-well QC summary table and auto-generates the plain-language QC findings bullets used in the QC SUMMARY section below.</p>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_qc_summary_table()</span></span>
<span id="cb8-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Consolidate every QC check performed across the pipeline into a</span></span>
<span id="cb8-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           single two-column (check, value) table, suitable for kable() and</span></span>
<span id="cb8-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           for writing to qc_summary.csv. Mirrors the individual find</span></span>
<span id="cb8-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           functions but as compact, at-a-glance figures rather than prose.</span></span>
<span id="cb8-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : layout_wells, reconcile_summary, std_curve, well_diagnostics,</span></span>
<span id="cb8-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates, cv_summary, baseline_per_sample, pos_control,</span></span>
<span id="cb8-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params</span></span>
<span id="cb8-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : qc_summary - data.frame with columns check, value (both chr)</span></span>
<span id="cb8-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-12">build_qc_summary_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(layout_wells, reconcile_summary, std_curve,</span>
<span id="cb8-13">                                    well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-14">                                    baseline_per_sample, pos_control, assay_params) {</span>
<span id="cb8-15">  standard_summary  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-16">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb8-17">  standard_drift    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb8-18">  sample_rates      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb8-19"></span>
<span id="cb8-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb8-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-22">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout"</span>,</span>
<span id="cb8-23">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from absorbance CSV"</span>,</span>
<span id="cb8-24">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max disagreement between absorbance CSV and full report"</span>,</span>
<span id="cb8-25">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard concentrations with replicate CV &gt; threshold"</span>,</span>
<span id="cb8-26">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers"</span>,</span>
<span id="cb8-27">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (outlier-excluded, replicate level)"</span>,</span>
<span id="cb8-28">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (all wells, replicate level)"</span>,</span>
<span id="cb8-29">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells that LOST signal over the run"</span>,</span>
<span id="cb8-30">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards above photometric linearity ceiling"</span>,</span>
<span id="cb8-31">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background control wells behaving as active reactions"</span>,</span>
<span id="cb8-32">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a decreasing trace"</span>,</span>
<span id="cb8-33">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with an elevated starting A412"</span>,</span>
<span id="cb8-34">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with ALL THREE replicates baseline-compromised"</span>,</span>
<span id="cb8-35">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a read glitch"</span>,</span>
<span id="cb8-36">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells usable for rate extraction"</span>,</span>
<span id="cb8-37">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (all reps)"</span>,</span>
<span id="cb8-38">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (usable reps)"</span>,</span>
<span id="cb8-39">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control replicates rising and linear"</span></span>
<span id="cb8-40">    ),</span>
<span id="cb8-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-42">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells),</span>
<span id="cb8-43">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv,</span>
<span id="cb8-44">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.g"</span>, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement),</span>
<span id="cb8-45">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb8-46">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-47">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-48">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-49">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2),</span>
<span id="cb8-50">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb8-51">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift)),</span>
<span id="cb8-52">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max],</span>
<span id="cb8-53">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-54">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-55">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)),</span>
<span id="cb8-56">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-57">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-58">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-59">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-60">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-61">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-62">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(baseline_per_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-63">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id[baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n],</span>
<span id="cb8-64">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-65">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-66">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-67">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_rates)),</span>
<span id="cb8-68">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-69">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-70">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pos_control))</span>
<span id="cb8-71">    ),</span>
<span id="cb8-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-73">  )</span>
<span id="cb8-74">}</span>
<span id="cb8-75"></span>
<span id="cb8-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## generate_qc_findings()</span></span>
<span id="cb8-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Walk the QC/CV/anomaly objects for a plate and emit a</span></span>
<span id="cb8-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           consistent, generic-language markdown bullet list of findings</span></span>
<span id="cb8-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (decreasing/glitched/high-baseline wells, background-control</span></span>
<span id="cb8-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           mix-ups, standard-curve QC failures, CV failures, disqualified</span></span>
<span id="cb8-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           samples). Intended to seed the SUMMARY section of a plate's</span></span>
<span id="cb8-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           .Rmd; a short hand-written subsection for plate-specific</span></span>
<span id="cb8-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           interpretation should follow it.</span></span>
<span id="cb8-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics    - data.frame from compute_well_diagnostics()</span></span>
<span id="cb8-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates          - data.frame from compute_well_rates()</span></span>
<span id="cb8-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary          - data.frame from compute_replicate_cv()</span></span>
<span id="cb8-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb8-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_curve           - list from fit_standard_curve()</span></span>
<span id="cb8-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reconcile_summary   - list from reconcile_kinetic_sources()$summary</span></span>
<span id="cb8-91"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params        - list with cv_threshold_pct, od_linear_max</span></span>
<span id="cb8-92"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : character vector, one markdown bullet per finding (empty</span></span>
<span id="cb8-93"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           findings are omitted, so a clean plate returns a short list)</span></span>
<span id="cb8-94"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-95">generate_qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-96">                                  baseline_per_sample, std_curve,</span>
<span id="cb8-97">                                  reconcile_summary, assay_params) {</span>
<span id="cb8-98">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-99"></span>
<span id="cb8-100">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Source reconciliation</span></span>
<span id="cb8-101">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span></span>
<span id="cb8-102">      (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>)) {</span>
<span id="cb8-103">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-104">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic source disagreement.** %d layout well(s) missing from the absorbance CSV; max disagreement between absorbance CSV and full report was %.4g A412."</span>,</span>
<span id="cb8-105">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement))</span>
<span id="cb8-106">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-107">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-108">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic sources agree.** absorbance CSV and full report agree exactly on all %d shared well x timepoint readings; all layout wells are present."</span>,</span>
<span id="cb8-109">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings))</span>
<span id="cb8-110">  }</span>
<span id="cb8-111"></span>
<span id="cb8-112">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sample wells with decreasing kinetics</span></span>
<span id="cb8-113">  dec_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_decreasing)</span>
<span id="cb8-114">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-115">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-116">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Decreasing kinetics.** %d sample well(s) end lower than (or equal to) their starting A412 and are excluded from rate extraction: %s."</span>,</span>
<span id="cb8-117">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(dec_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-118">  }</span>
<span id="cb8-119"></span>
<span id="cb8-120">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Read glitches</span></span>
<span id="cb8-121">  glitch_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_glitch)</span>
<span id="cb8-122">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-123">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-124">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Read glitches.** %d sample well(s) contain a single read-to-read step inconsistent with its neighbours: %s (only disqualifying if it falls inside the fitted rate window)."</span>,</span>
<span id="cb8-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(glitch_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-126">  }</span>
<span id="cb8-127"></span>
<span id="cb8-128">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Elevated baseline</span></span>
<span id="cb8-129">  high_baseline <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_high_baseline)</span>
<span id="cb8-130">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-131">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-132">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Elevated starting absorbance.** %d sample well(s) start above the baseline threshold (A412 &gt; %s), indicating pre-existing thiol/contamination before the reaction began: %s."</span>,</span>
<span id="cb8-133">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(high_baseline<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-134">  }</span>
<span id="cb8-135"></span>
<span id="cb8-136">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Samples fully disqualified by baseline</span></span>
<span id="cb8-137">  disqualified <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n)</span>
<span id="cb8-138">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(disqualified) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-139">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-140">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Sample(s) with no clean replicate.** Every replicate of %s has an elevated starting A412; these samples have no usable measurement on this plate regardless of CV."</span>,</span>
<span id="cb8-141">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(disqualified<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-142">  }</span>
<span id="cb8-143"></span>
<span id="cb8-144">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Over-range wells</span></span>
<span id="cb8-145">  over_range <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(flag_over_range)</span>
<span id="cb8-146">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-147">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Over-range wells.** %d well(s) exceed the photometric linearity ceiling (A412 &gt; %s): %s."</span>,</span>
<span id="cb8-149">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-150">  }</span>
<span id="cb8-151"></span>
<span id="cb8-152">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Background wells behaving as active reactions</span></span>
<span id="cb8-153">  bg_active <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>, flag_bg_active)</span>
<span id="cb8-154">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-155">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-156">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Background control wells behaving as active reactions.** %d of %d background wells show a starting A412 or drift inconsistent with a flat, inactive well: %s."</span>,</span>
<span id="cb8-157">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb8-158">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(bg_active<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-159">  }</span>
<span id="cb8-160"></span>
<span id="cb8-161">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standard curve QC</span></span>
<span id="cb8-162">  std_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-163">  cv_fail_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct)</span>
<span id="cb8-164">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-165">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-166">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**GSH standard curve replicate imprecision.** %d of %d concentrations exceed %s%% CV: %s nmol/well."</span>,</span>
<span id="cb8-167">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-168">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(cv_fail_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-169">  }</span>
<span id="cb8-170">  n_std_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier)</span>
<span id="cb8-171">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_std_outliers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-172">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-173">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard outlier wells.** %d of %d standard wells deviate from their triplicate median by more than %s A412: %s."</span>,</span>
<span id="cb8-174">      n_std_outliers, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od,</span>
<span id="cb8-175">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-176">  }</span>
<span id="cb8-177">  over_range_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max)</span>
<span id="cb8-178">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-179">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-180">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standards above the photometric linear range.** %s nmol/well read above A412 %s; the calibration is trustworthy only below these concentrations."</span>,</span>
<span id="cb8-181">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max))</span>
<span id="cb8-182">  }</span>
<span id="cb8-183">  n_drift_neg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-184">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_drift_neg <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-185">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-186">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard signal decay.** %d of %d standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0."</span>,</span>
<span id="cb8-187">      n_drift_neg, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift)))</span>
<span id="cb8-188">  }</span>
<span id="cb8-189">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-190">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard curve fit (outlier-excluded):** slope = %.5f A412/nmol, R^2 = %.4f (all-wells R^2 = %.4f)."</span>,</span>
<span id="cb8-191">    std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared))</span>
<span id="cb8-192"></span>
<span id="cb8-193">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Technical replicate CV failures</span></span>
<span id="cb8-194">  fail_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all)</span>
<span id="cb8-195">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-196">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-197">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% (all replicates).** %d of %d samples: %s."</span>,</span>
<span id="cb8-198">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary),</span>
<span id="cb8-199">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%)"</span>, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-200">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-201">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-202">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV.** All %d samples are within %s%% CV across all three replicates."</span>,</span>
<span id="cb8-203">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct))</span>
<span id="cb8-204">  }</span>
<span id="cb8-205">  fail_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable)</span>
<span id="cb8-206">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-207">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-208">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% persists after excluding flagged replicates.** %s."</span>,</span>
<span id="cb8-209">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-210">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%, n=%d)"</span>, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_usable,</span>
<span id="cb8-211">                    fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_usable), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-212">  }</span>
<span id="cb8-213"></span>
<span id="cb8-214">  bullets</span>
<span id="cb8-215">}</span></code></pre></div>
</section>
</section>
<section id="assay-parameters" class="level2">
<h2 class="anchored" data-anchor-id="assay-parameters">1.4 Assay parameters</h2>
<p>All assay constants and QC thresholds are collected here so nothing downstream hard-codes a number.</p>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">assay_params <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb9-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># homogenate volume per reaction well (V in Abcam formula)</span></span>
<span id="cb9-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">buffer_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">48</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Assay Buffer 7 added to reach 50 uL pre-Reaction Mix</span></span>
<span id="cb9-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_factor       =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># D; layout `df.0` = undiluted homogenate</span></span>
<span id="cb9-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_volume_uL  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MEASURED buffer volume tissue was homogenized in (see note 2)</span></span>
<span id="cb9-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_wavelength_nm    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">412</span>,</span>
<span id="cb9-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_interval_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb9-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_duration_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># see note 1</span></span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_window_n         =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># points per sliding regression window (5 pts = 8 min)</span></span>
<span id="cb9-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_min_r2           =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.80</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># min R^2 for a rate window to be trusted</span></span>
<span id="cb9-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_excess_od      =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |step - mean of neighbouring steps| flagging a read glitch</span></span>
<span id="cb9-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_threshold_pct      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># technical-replicate CV QC threshold</span></span>
<span id="cb9-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_linear_max         =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># upper A412 bound for reliable photometry</span></span>
<span id="cb9-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_outlier_od        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |deviation from triplicate median| flagging a standard well</span></span>
<span id="cb9-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_baseline_od    =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># max acceptable t0 A412 for a sample well</span></span>
<span id="cb9-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_od_max        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a well-behaved background well starts below this A412</span></span>
<span id="cb9-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_drift_max     =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ...and drifts less than this over the whole run</span></span>
<span id="cb9-18">)</span>
<span id="cb9-19"></span>
<span id="cb9-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- assay_params: assay constants and QC thresholds ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb9-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(assay_params)</span></code></pre></div>
<pre><code>--- assay_params: assay constants and QC thresholds ---

List of 16
 $ sample_volume_uL    : num 2
 $ buffer_volume_uL    : num 48
 $ dilution_factor     : num 1
 $ homogenate_volume_uL: num 350
 $ read_wavelength_nm  : num 412
 $ read_interval_min   : num 2
 $ read_duration_min   : num 20
 $ rate_window_n       : num 5
 $ rate_min_r2         : num 0.8
 $ glitch_excess_od    : num 0.02
 $ cv_threshold_pct    : num 15
 $ od_linear_max       : num 1.5
 $ std_outlier_od      : num 0.15
 $ sample_baseline_od  : num 0.35
 $ bg_flat_od_max      : num 0.15
 $ bg_flat_drift_max   : num 0.05</code></pre>
</section>
<section id="output-directory" class="level2">
<h2 class="anchored" data-anchor-id="output-directory">1.5 Output directory</h2>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Output directory for this analysis (matches this file's name, per ../code/README.md)</span></span>
<span id="cb11-2">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260814-mgig-citrate_synthase-F05-36C"</span></span>
<span id="cb11-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb11-4"></span>
<span id="cb11-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- output_dir: destination for all figures and tables ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb11-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(output_dir)</span></code></pre></div>
<pre><code>--- output_dir: destination for all figures and tables ---
 chr "../outputs/Gen5-20260814-mgig-citrate_synthase-F05-36C"</code></pre>
</section>
</section>
<section id="data" class="level1">
<h1>2 DATA</h1>
<p>Data are read from the local repo (<code>../data/raw_absorbance/</code>) so this document renders before/after the files are pushed to GitHub.</p>
<section id="plate-layout" class="level2">
<h2 class="anchored" data-anchor-id="plate-layout">2.1 Plate layout</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">data_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/raw_absorbance"</span></span>
<span id="cb13-2">run_stem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260814-mgig-citrate_synthase-F05-36C"</span></span>
<span id="cb13-3"></span>
<span id="cb13-4">layout_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_layout</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb13-5"></span>
<span id="cb13-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout format detected:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(layout_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-8"></span>
<span id="cb13-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- layout_wells: one row per occupied well, with its descriptive label ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(layout_wells)</span></code></pre></div>
<pre><code>Layout format detected: single 
Occupied wells in layout: 69 

--- layout_wells: one row per occupied well, with its descriptive label ---

'data.frame':   69 obs. of  4 variables:
 $ well     : chr  "A1" "A2" "A3" "A4" ...
 $ plate_row: chr  "A" "A" "A" "A" ...
 $ plate_col: int  1 2 3 4 5 6 7 8 9 10 ...
 $ label    : chr  "F05_01_36C-citrate_synthase-12.8-df.0" "F05_01_36C-citrate_synthase-12.8-df.0" "F05_01_36C-citrate_synthase-12.8-df.0" "F05_02_36C-citrate_synthase-6.2-df.0" ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "row_idx" "col_idx"
  ..$ dimnames:List of 2
  .. ..$ row_idx: chr [1:8] "row_idx=2" "row_idx=3" "row_idx=4" "row_idx=5" ...
  .. ..$ col_idx: chr [1:12] "col_idx= 2" "col_idx= 3" "col_idx= 4" "col_idx= 5" ...
 - attr(*, "layout_format")= chr "single"</code></pre>
</section>
<section id="kinetic-readers" class="level2">
<h2 class="anchored" data-anchor-id="kinetic-readers">2.2 Kinetic readers</h2>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_absorbance_csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb15-2">full_report    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_full_report</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full_report-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".txt"</span>)))</span>
<span id="cb15-3"></span>
<span id="cb15-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance CSV : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-5">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full report    : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-7">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-8"></span>
<span id="cb15-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- absorbance_csv: long-format readings from absorbance-*.csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(absorbance_csv)</span>
<span id="cb15-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- full_report: long-format readings from full_report-*.txt ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(full_report)</span></code></pre></div>
<pre><code>absorbance CSV : 69 wells x 11 timepoints
full report    : 69 wells x 11 timepoints

--- absorbance_csv: long-format readings from absorbance-*.csv ---

'data.frame':   759 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.179 0.182 0.186 0.19 0.194 0.199 0.203 0.207 0.212 0.217 ...

--- full_report: long-format readings from full_report-*.txt ---

'data.frame':   759 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.179 0.182 0.186 0.19 0.194 0.199 0.203 0.207 0.212 0.217 ...</code></pre>
</section>
<section id="cross-check-against-the-full-report" class="level2">
<h2 class="anchored" data-anchor-id="cross-check-against-the-full-report">2.3 Cross-check against the full report</h2>
<p><code>absorbance-*.csv</code> is used for every well; <code>full_report-*.txt</code> is used only to confirm the CSV is trustworthy: every well it reports should also be in the CSV, every well the layout expects should be in the CSV, and every reading the two files share should agree exactly.</p>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">recon <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reconcile_kinetic_sources</span>(absorbance_csv, full_report, layout_wells)</span>
<span id="cb17-2">plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_readings</span>
<span id="cb17-3"></span>
<span id="cb17-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in absorbance CSV          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report             :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report not in CSV  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from CSV    :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CSV wells not in layout          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv_not_layout, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shared well x timepoints         :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max |CSV - report| disagreement  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-11"></span>
<span id="cb17-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- recon$overlap_check: per-reading comparison of the two raw files ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>overlap_check)</span>
<span id="cb17-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_readings: readings for all occupied wells, from absorbance_csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_readings)</span></code></pre></div>
<pre><code>Wells in absorbance CSV          : 69 
Wells in full report             : 69 
Wells in full report not in CSV  : 0 
Layout wells missing from CSV    : 0 
CSV wells not in layout          : 0 
Shared well x timepoints         : 759 
Max |CSV - report| disagreement  : 0 

--- recon$overlap_check: per-reading comparison of the two raw files ---

'data.frame':   759 obs. of  5 variables:
 $ well     : chr  "A1" "A1" "A1" "A1" ...
 $ time_min : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od_csv   : num  0.179 0.182 0.186 0.19 0.194 0.199 0.203 0.207 0.212 0.217 ...
 $ od_report: num  0.179 0.182 0.186 0.19 0.194 0.199 0.203 0.207 0.212 0.217 ...
 $ abs_diff : num  0 0 0 0 0 0 0 0 0 0 ...

--- plate_readings: readings for all occupied wells, from absorbance_csv ---

'data.frame':   759 obs. of  4 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.179 0.182 0.186 0.19 0.194 0.199 0.203 0.207 0.212 0.217 ...
 $ source  : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...</code></pre>
<p>This plate’s <code>absorbance-*.csv</code> covers the full 69 occupied wells and the layout carries no spelling typo, so no label fix is needed here.</p>
</section>
<section id="annotate-wells-and-parse-metadata" class="level2">
<h2 class="anchored" data-anchor-id="annotate-wells-and-parse-metadata">2.4 Annotate wells and parse metadata</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate_wells</span>(plate_readings, layout_wells))</span>
<span id="cb19-2"></span>
<span id="cb19-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells per type:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(well, well_type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_wells"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-5">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb19-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards (nmol/well):"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-8"></span>
<span id="cb19-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_long: fully annotated long-format plate, one row per well x timepoint ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_long)</span></code></pre></div>
<pre><code>Wells per type:
        well_type n_wells
       background      24
 positive_control       3
           sample      24
         standard      18

Samples: F05_01_36C, F05_02_36C, F05_03_36C, F05_04_36C, F05_05_36C, F05_06_36C, F05_07_36C, F05_08_36C 
Standards (nmol/well): 0, 8, 16, 24, 32, 40 

--- plate_long: fully annotated long-format plate, one row per well x timepoint ---

'data.frame':   759 obs. of  15 variables:
 $ well       : chr  "C1" "C1" "C1" "C1" ...
 $ time_min   : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od         : num  0.047 0.047 0.047 0.048 0.048 0.048 0.048 0.048 0.048 0.048 ...
 $ source     : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ plate_row  : chr  "C" "C" "C" "C" ...
 $ plate_col  : int  1 1 1 1 1 1 1 1 1 1 ...
 $ label      : chr  "F05_01_36C_BG-citrate_synthase-12.8-df.0" "F05_01_36C_BG-citrate_synthase-12.8-df.0" "F05_01_36C_BG-citrate_synthase-12.8-df.0" "F05_01_36C_BG-citrate_synthase-12.8-df.0" ...
 $ well_type  : chr  "background" "background" "background" "background" ...
 $ label_clean: chr  "F05_01_36C_BG-citrate_synthase-12.8-df.0" "F05_01_36C_BG-citrate_synthase-12.8-df.0" "F05_01_36C_BG-citrate_synthase-12.8-df.0" "F05_01_36C_BG-citrate_synthase-12.8-df.0" ...
 $ sample_id  : chr  "F05_01_36C" "F05_01_36C" "F05_01_36C" "F05_01_36C" ...
 $ family     : chr  "F05" "F05" "F05" "F05" ...
 $ individual : chr  "01" "01" "01" "01" ...
 $ temperature: chr  "36C" "36C" "36C" "36C" ...
 $ weight_mg  : num  12.8 12.8 12.8 12.8 12.8 12.8 12.8 12.8 12.8 12.8 ...
 $ std_nmol   : num  NA NA NA NA NA NA NA NA NA NA ...</code></pre>
<p><code>annotate_wells()</code> emits a harmless <code>NAs introduced by coercion</code> warning (suppressed above), because its <code>weight_mg</code> parser only applies to <code>sample</code>/<code>background</code> wells and returns <code>NA</code> for standards/positive control by construction. No <code>weight_mg</code> value is actually missing for a sample or background well; <code>annotate_wells()</code>’s internal <code>stopifnot()</code> would halt otherwise.</p>
</section>
<section id="protein-concentration-normalization-factor" class="level2">
<h2 class="anchored" data-anchor-id="protein-concentration-normalization-factor">2.5 Protein concentration (normalization factor)</h2>
<p>Activity is normalized to total extracted protein rather than tissue weight (note 2). Protein concentration for each sample was measured on a separate BCA/Bradford-style plate (595 nm) and supplied as two CSV exports covering different subsets of samples across families F05 and F07. This plate’s <code>F05_07_36C</code> record appears only in file 1, under the string <code>F-05_07_36C</code> (stray hyphen); it is corrected with <code>sample_id_fixes</code> before matching.</p>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">protein_files <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb21-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/sample_protein_concentrations_1.csv"</span>,</span>
<span id="cb21-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/sample_protein_concentrations_2.csv"</span></span>
<span id="cb21-4">)</span>
<span id="cb21-5"></span>
<span id="cb21-6">plate_sample_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)))</span>
<span id="cb21-7"></span>
<span id="cb21-8">protein_by_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">load_protein_concentrations</span>(protein_files, plate_sample_ids,</span>
<span id="cb21-9">                                                  assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb21-10">                                                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_fixes =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F-05_07_36C"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"F05_07_36C"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-12">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb21-13">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb21-14"></span>
<span id="cb21-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples matched to a protein concentration record:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample),</span>
<span id="cb21-16">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(plate_sample_ids), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein concentration range (ug/mL):"</span>,</span>
<span id="cb21-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_ug_mL), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total protein per homogenate range (mg):"</span>,</span>
<span id="cb21-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, source_file, conc_ug_mL, total_protein_mg) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-22">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb21-23"></span>
<span id="cb21-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_by_sample: matched protein concentration and total protein per homogenate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_by_sample)</span></code></pre></div>
<pre><code>Samples matched to a protein concentration record: 8 / 8 
Protein concentration range (ug/mL): 545.8 - 1666.8 
Total protein per homogenate range (mg): 0.191 - 0.583 

  sample_id                         source_file conc_ug_mL total_protein_mg
 F05_01_36C sample_protein_concentrations_1.csv      953.1         0.333585
 F05_02_36C sample_protein_concentrations_1.csv      545.8         0.191030
 F05_03_36C sample_protein_concentrations_1.csv      667.6         0.233660
 F05_04_36C sample_protein_concentrations_1.csv     1062.2         0.371770
 F05_05_36C sample_protein_concentrations_1.csv     1666.8         0.583380
 F05_06_36C sample_protein_concentrations_1.csv     1265.9         0.443065
 F05_07_36C sample_protein_concentrations_1.csv     1110.5         0.388675
 F05_08_36C sample_protein_concentrations_1.csv     1357.5         0.475125

--- protein_by_sample: matched protein concentration and total protein per homogenate ---

'data.frame':   8 obs. of  7 variables:
 $ sample_id       : chr  "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ source_file     : chr  "sample_protein_concentrations_1.csv" "sample_protein_concentrations_1.csv" "sample_protein_concentrations_1.csv" "sample_protein_concentrations_1.csv" ...
 $ conc_ug_mL      : num  953 546 668 1062 1667 ...
 $ total_protein_mg: num  0.334 0.191 0.234 0.372 0.583 ...
 $ family          : chr  "F05" "F05" "F05" "F05" ...
 $ individual      : chr  "01" "02" "03" "04" ...
 $ temperature     : chr  "36C" "36C" "36C" "36C" ...</code></pre>
</section>
</section>
<section id="kinetic-traces" class="level1">
<h1>3 KINETIC TRACES</h1>
<p>Every trace is plotted before any rate is extracted. In this assay the <strong>shape</strong> of the trace is the primary diagnostic: CS activity must produce a monotonically <em>rising</em> A412, and only a genuinely linear stretch may be used for a rate.</p>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">trace_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plate_long, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> plate_row <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> plate_col, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>,</span>
<span id="cb23-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labeller =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row, d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>,</span>
<span id="cb23-8">                                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">positive_control =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6a51a3"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 kinetic traces, all occupied wells"</span>,</span>
<span id="cb23-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dotted line = assumed photometric linearity ceiling (A412 = "</span>,</span>
<span id="cb23-11">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-12">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Rising traces only are usable for rate extraction."</span>),</span>
<span id="cb23-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (min)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb23-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>),</span>
<span id="cb23-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb23-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb23-19"></span>
<span id="cb23-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kinetic_traces_all_wells.png"</span>), trace_plot,</span>
<span id="cb23-21">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb23-22"></span>
<span id="cb23-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- trace_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb23-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(trace_plot)</span>
<span id="cb23-25"></span>
<span id="cb23-26">trace_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/Gen5-20260814-mgig-citrate_synthase-F05-36C_files/figure-gfm/plot-kinetic-traces-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- trace_plot: ggplot object structure ---

data: well, time_min, od, source, plate_row, plate_col, label,
  well_type, label_clean, sample_id, family, individual, temperature,
  weight_mg, std_nmol [759x15]
mapping:  x = ~time_min, y = ~od, group = ~well, colour = ~well_type
scales:   colour 
faceting:  ~plate_row, ~plate_col 
-----------------------------------
geom_line: na.rm = FALSE, orientation = NA, arrow = NULL, arrow.fill = NULL, lineend = butt, linejoin = round, linemitre = 10
stat_identity: na.rm = FALSE
position_identity 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
<p>Every sample and positive-control trace on this plate rises smoothly and close to linearly across the full 20-minute window (replicate-level R<sup>2</sup> &gt; 0.99 for a full-trace linear fit on every sample well, computed below). This plate shows no elevated-starting-absorbance or contamination signature in any well.</p>
</section>
<section id="anomaly-detection" class="level1">
<h1>4 ANOMALY DETECTION</h1>
<section id="per-well-trace-diagnostics" class="level2">
<h2 class="anchored" data-anchor-id="per-well-trace-diagnostics">4.1 Per-well trace diagnostics</h2>
<p>Four independent checks, computed from the raw trace before any rate fitting:</p>
<ol type="1">
<li><strong>Direction</strong> — net A412 change from first to last read. A CS-containing well must be positive.</li>
<li><strong>Monotonicity</strong> — fraction of the 10 read-to-read intervals that rise.</li>
<li><strong>Over-range</strong> — any read above the photometric linearity ceiling.</li>
<li><strong>Discontinuity</strong> — a single read-to-read step that departs from its two <em>neighbouring</em> steps, catching read glitches rather than biology.</li>
</ol>
<p>Two further checks specific to well role: an elevated starting A412 (pre-existing thiol/contamination) for sample wells, and a background well whose trace is not flat (indicating it received Reaction Mix rather than Background Control Mix).</p>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_diagnostics</span>(plate_long, assay_params)</span>
<span id="cb25-2"></span>
<span id="cb25-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Flag counts across all"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">starts_with</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flag_"</span>), sum)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-5">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb25-6"></span>
<span id="cb25-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Wells with at least one flag:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-8"></span>
<span id="cb25-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- well_diagnostics: per-well trace diagnostics and anomaly flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_diagnostics)</span></code></pre></div>
<pre><code>Flag counts across all 69 wells:
 flag_decreasing flag_over_range flag_glitch flag_high_baseline flag_bg_active
               4               0           1                  0              1

Wells with at least one flag: 5 / 69 

--- well_diagnostics: per-well trace diagnostics and anomaly flags ---

tibble [69 × 24] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:69] "A1" "A10" "A11" "A12" ...
 $ plate_row         : chr [1:69] "A" "A" "A" "A" ...
 $ plate_col         : int [1:69] 1 10 11 12 2 3 4 5 6 7 ...
 $ well_type         : chr [1:69] "sample" "sample" "sample" "sample" ...
 $ sample_id         : chr [1:69] "F05_01_36C" "F05_04_36C" "F05_04_36C" "F05_04_36C" ...
 $ label             : chr [1:69] "F05_01_36C-citrate_synthase-12.8-df.0" "F05_04_36C-citrate_synthase-12.8-df.0" "F05_04_36C-citrate_synthase-12.8-df.0" "F05_04_36C-citrate_synthase-12.8-df.0" ...
 $ std_nmol          : num [1:69] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:69] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:69] 0.179 0.185 0.183 0.183 0.182 0.18 0.184 0.183 0.182 0.182 ...
 $ od_last           : num [1:69] 0.222 0.228 0.227 0.228 0.224 0.221 0.226 0.226 0.224 0.227 ...
 $ od_max            : num [1:69] 0.222 0.228 0.227 0.228 0.224 0.221 0.226 0.226 0.224 0.227 ...
 $ net_change        : num [1:69] 0.043 0.043 0.044 0.045 0.042 0.041 0.042 0.043 0.042 0.045 ...
 $ frac_rising       : num [1:69] 1 1 1 1 1 1 1 1 1 1 ...
 $ max_step          : num [1:69] 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.005 ...
 $ typical_step      : num [1:69] 0.004 0.0045 0.0045 0.0045 0.004 ...
 $ step_excess       : num [1:69] -0.001 0.0015 -0.001 -0.0005 0.001 ...
 $ glitch_at_min     : num [1:69] 2 8 12 10 14 16 2 10 6 2 ...
 $ step_ratio        : num [1:69] 1.25 1.11 1.11 1.11 1.25 ...
 $ flag_decreasing   : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range   : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags           : int [1:69] 0 0 0 0 0 0 0 0 0 0 ...</code></pre>
</section>
<section id="anomaly-table" class="level2">
<h2 class="anchored" data-anchor-id="anomaly-table">4.2 Anomaly table</h2>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">anomaly_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, well_type, od_first, net_change, n_flags,</span>
<span id="cb27-4">         flag_decreasing, flag_over_range, flag_glitch,</span>
<span id="cb27-5">         flag_high_baseline, flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(n_flags), well)</span>
<span id="cb27-7"></span>
<span id="cb27-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(anomaly_table, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb27-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells with at least one anomaly flag"</span>)</span>
<span id="cb27-10"></span>
<span id="cb27-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Total flagged wells:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(anomaly_table), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-12"></span>
<span id="cb27-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- anomaly_table: all flagged wells with their specific flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(anomaly_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: left;">well_type</th>
<th style="text-align: right;">od_first</th>
<th style="text-align: right;">net_change</th>
<th style="text-align: right;">n_flags</th>
<th style="text-align: left;">flag_decreasing</th>
<th style="text-align: left;">flag_over_range</th>
<th style="text-align: left;">flag_glitch</th>
<th style="text-align: left;">flag_high_baseline</th>
<th style="text-align: left;">flag_bg_active</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">C8</td>
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: left;">background</td>
<td style="text-align: right;">0.252</td>
<td style="text-align: right;">-0.050</td>
<td style="text-align: right;">2</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F1</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.144</td>
<td style="text-align: right;">-0.004</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F4</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.433</td>
<td style="text-align: right;">-0.008</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F5</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.067</td>
<td style="text-align: right;">0.079</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F6</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1.422</td>
<td style="text-align: right;">-0.011</td>
<td style="text-align: right;">1</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
</tbody>
</table>
<p>Wells with at least one anomaly flag</p>
<pre><code>Total flagged wells: 5 / 69 

--- anomaly_table: all flagged wells with their specific flags ---

tibble [5 × 11] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:5] "C8" "F1" "F4" "F5" ...
 $ sample_id         : chr [1:5] "F05_03_36C" NA NA NA ...
 $ well_type         : chr [1:5] "background" "standard" "standard" "standard" ...
 $ od_first          : num [1:5] 0.252 1.144 1.433 1.067 1.422
 $ net_change        : num [1:5] -0.05 -0.004 -0.008 0.079 -0.011
 $ n_flags           : int [1:5] 2 1 1 1 1
 $ flag_decreasing   : logi [1:5] TRUE TRUE TRUE FALSE TRUE
 $ flag_over_range   : logi [1:5] FALSE FALSE FALSE FALSE FALSE
 $ flag_glitch       : logi [1:5] FALSE FALSE FALSE TRUE FALSE
 $ flag_high_baseline: logi [1:5] FALSE FALSE FALSE FALSE FALSE
 $ flag_bg_active    : logi [1:5] TRUE FALSE FALSE FALSE FALSE</code></pre>
<p>Only two wells are flagged on this entire plate, both isolated, single-flag cases with no counterpart pattern elsewhere on the plate:</p>
<ul>
<li><strong><code>C8</code></strong> (background, <code>F05_03_36C</code>) is flagged <code>flag_bg_active</code> and <code>flag_decreasing</code> together: it starts at A412 0.252 (above the <code>bg_flat_od_max</code> of 0.15) and then declines steadily to 0.202 (net change -0.050), rather than staying flat like a true background well. This pattern is consistent with Reaction Mix having been dispensed in place of Background Control Mix for this single well.</li>
<li><strong><code>F5</code></strong> (the 40 nmol GSH standard) is flagged <code>flag_glitch</code>: see the GSH STANDARD CURVE section below, where it is also the sole outlier by the <code>std_outlier_od</code> triplicate-deviation check.</li>
</ul>
<p>No sample well is flagged for anything on this plate.</p>
</section>
<section id="background-wells-behaving-as-active-reactions" class="level2">
<h2 class="anchored" data-anchor-id="background-wells-behaving-as-active-reactions">4.3 Background wells behaving as active reactions</h2>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">bg_active_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>, flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, od_first, net_change)</span>
<span id="cb29-4"></span>
<span id="cb29-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(bg_active_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb29-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background wells with a non-flat trace"</span>)</span>
<span id="cb29-7"></span>
<span id="cb29-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background wells behaving as active reactions:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active_wells),</span>
<span id="cb29-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-10"></span>
<span id="cb29-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_active_wells: background wells excluded from the background-rate estimate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_active_wells)</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">od_first</th>
<th style="text-align: right;">net_change</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">C8</td>
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: right;">0.252</td>
<td style="text-align: right;">-0.05</td>
</tr>
</tbody>
</table>
<p>Background wells with a non-flat trace</p>
<pre><code>Background wells behaving as active reactions: 1 / 24 

--- bg_active_wells: background wells excluded from the background-rate estimate ---

tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
 $ well      : chr "C8"
 $ sample_id : chr "F05_03_36C"
 $ od_first  : num 0.252
 $ net_change: num -0.05</code></pre>
<p>Only <code>C8</code> is affected — 1 of 24 background wells. Because <code>compute_background_correction()</code> estimates the background rate from only the flat replicates within each sample’s background triplicate, <code>C8</code> simply drops out of the <code>F05_03_36C</code> background estimate (2 of 3 remain), and every other sample’s background estimate is unaffected.</p>
</section>
<section id="baseline-diagnostic-elevated-starting-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="baseline-diagnostic-elevated-starting-absorbance">4.4 Baseline diagnostic (elevated starting absorbance)</h2>
<div class="sourceCode" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1">bd <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_baseline_diagnostics</span>(well_diagnostics, assay_params)</span>
<span id="cb31-2">baseline_check       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_check</span>
<span id="cb31-3">baseline_per_sample  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bd<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_per_sample</span>
<span id="cb31-4"></span>
<span id="cb31-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample/background wells with elevated starting A412 (&gt; "</span>,</span>
<span id="cb31-6">    assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"):"</span>,</span>
<span id="cb31-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline_check<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(baseline_check), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb31-8"></span>
<span id="cb31-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(baseline_per_sample, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb31-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Elevated-baseline replicate count per sample"</span>)</span>
<span id="cb31-11"></span>
<span id="cb31-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_check: per-well baseline classification ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb31-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_check)</span>
<span id="cb31-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_per_sample: elevated-replicate count per sample ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb31-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_per_sample)</span></code></pre></div>
<pre><code>Sample/background wells with elevated starting A412 (&gt; 0.35):0/48</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">n_elevated</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">median_baseline</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.180</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.183</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.182</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.183</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.190</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.183</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.184</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.185</td>
</tr>
</tbody>
</table>
<p>Elevated-baseline replicate count per sample</p>
<pre><code>--- baseline_check: per-well baseline classification ---

tibble [48 × 25] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:48] "C8" "B1" "B2" "B3" ...
 $ plate_row         : chr [1:48] "C" "B" "B" "B" ...
 $ plate_col         : int [1:48] 8 1 2 3 5 11 10 12 7 4 ...
 $ well_type         : chr [1:48] "background" "sample" "sample" "sample" ...
 $ sample_id         : chr [1:48] "F05_03_36C" "F05_05_36C" "F05_05_36C" "F05_05_36C" ...
 $ label             : chr [1:48] "F05_03_36C_BG-citrate_synthase-10.3-df.0" "F05_05_36C-citrate_synthase-22.7-df.0" "F05_05_36C-citrate_synthase-22.7-df.0" "F05_05_36C-citrate_synthase-22.7-df.0" ...
 $ std_nmol          : num [1:48] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:48] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:48] 0.252 0.192 0.19 0.19 0.188 0.186 0.185 0.185 0.185 0.184 ...
 $ od_last           : num [1:48] 0.202 0.235 0.231 0.231 0.23 0.227 0.228 0.23 0.227 0.226 ...
 $ od_max            : num [1:48] 0.254 0.235 0.231 0.231 0.23 0.227 0.228 0.23 0.227 0.226 ...
 $ net_change        : num [1:48] -0.05 0.043 0.041 0.041 0.042 0.041 0.043 0.045 0.042 0.042 ...
 $ frac_rising       : num [1:48] 0.1 1 1 1 1 1 1 1 1 1 ...
 $ max_step          : num [1:48] -0.008 0.005 0.005 0.005 0.005 0.005 0.005 0.006 0.005 0.005 ...
 $ typical_step      : num [1:48] 0.0055 0.004 0.004 0.004 0.004 ...
 $ step_excess       : num [1:48] 0.007 -0.0015 0.001 -0.001 -0.0015 ...
 $ glitch_at_min     : num [1:48] 2 6 2 2 8 14 8 2 2 2 ...
 $ step_ratio        : num [1:48] 1.45 1.25 1.25 1.25 1.25 ...
 $ flag_decreasing   : logi [1:48] TRUE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range   : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:48] TRUE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags           : int [1:48] 2 0 0 0 0 0 0 0 0 0 ...
 $ baseline          : chr [1:48] "normal" "normal" "normal" "normal" ...

--- baseline_per_sample: elevated-replicate count per sample ---

tibble [8 × 4] (S3: tbl_df/tbl/data.frame)
 $ sample_id      : chr [1:8] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ n_elevated     : int [1:8] 0 0 0 0 0 0 0 0
 $ n              : int [1:8] 3 3 3 3 3 3 3 3
 $ median_baseline: num [1:8] 0.18 0.183 0.182 0.183 0.19 0.183 0.184 0.185</code></pre>
<p>No sample or background well anywhere on this plate starts above A412 0.35 — sample wells all start within a tight 0.179-0.192 range (well below the 0.35 threshold), and no sample has any elevated-baseline replicate. No sample is disqualified on this basis.</p>
</section>
<section id="plot-starting-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="plot-starting-absorbance">4.5 Plot starting absorbance</h2>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">baseline_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(baseline_check, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(well, od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od_first,</span>
<span id="cb34-2">                                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb34-5">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Starting A412 (t = 0) for every sample/background well"</span>,</span>
<span id="cb34-8">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dashed line = elevated-baseline threshold (A412 = "</span>,</span>
<span id="cb34-9">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). No well on this plate exceeds it."</span>),</span>
<span id="cb34-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 at t = 0"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb34-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">90</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb34-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb34-15"></span>
<span id="cb34-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"starting_absorbance.png"</span>), baseline_plot,</span>
<span id="cb34-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb34-18"></span>
<span id="cb34-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- baseline_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(baseline_plot)</span>
<span id="cb34-21"></span>
<span id="cb34-22">baseline_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/Gen5-20260814-mgig-citrate_synthase-F05-36C_files/figure-gfm/plot-baseline-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- baseline_plot: ggplot object structure ---

data: well, plate_row, plate_col, well_type, sample_id, label,
  std_nmol, source, od_first, od_last, od_max, net_change, frac_rising,
  max_step, typical_step, step_excess, glitch_at_min, step_ratio,
  flag_decreasing, flag_over_range, flag_glitch, flag_high_baseline,
  flag_bg_active, n_flags, baseline [48x25]
mapping:  x = ~reorder(well, od_first), y = ~od_first, fill = ~well_type
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_col: na.rm = FALSE, just = 0.5, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_stack 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
</section>
<section id="gsh-standard-curve" class="level1">
<h1>5 GSH STANDARD CURVE</h1>
<p>The GSH standard is a <strong>stoichiometric endpoint</strong>, not an enzymatic reaction: free thiol reduces DTNB immediately on mixing. The standard curve is therefore read from a single timepoint, and t = 0 is used because TNB<sup>2-</sup> degrades over the run (quantified below).</p>
<section id="fit-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="fit-the-standard-curve">5.1 Fit the standard curve</h2>
<p>Three candidate fits are compared:</p>
<ul>
<li><strong>all wells</strong> — every standard replicate, no exclusions</li>
<li><strong>concentration means</strong> — the conventional fit, on per-concentration means</li>
<li><strong>outlier-excluded</strong> — replicate-level fit after dropping flagged wells</li>
</ul>
<p>The outlier-excluded fit is used for activity calculation.</p>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">std_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit_standard_curve</span>(plate_long, assay_params)</span>
<span id="cb36-2"></span>
<span id="cb36-3">standards_t0       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_t0</span>
<span id="cb36-4">standard_drift     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb36-5">standard_summary   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb36-6">standards_flagged  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb36-7">fit_all_wells      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells</span>
<span id="cb36-8">fit_comparison     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_comparison</span>
<span id="cb36-9">std_slope          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope</span>
<span id="cb36-10">std_intercept      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_intercept</span>
<span id="cb36-11">std_r2             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2</span>
<span id="cb36-12">std_nmol_max       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol_max</span>
<span id="cb36-13"></span>
<span id="cb36-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_t0), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"at"</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(standards_t0<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol),</span>
<span id="cb36-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentrations</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard drift over 20 min (dA412): median"</span>,</span>
<span id="cb36-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)),</span>
<span id="cb36-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| range"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" to "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards that LOST signal (drift &lt; 0):"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-20"></span>
<span id="cb36-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standard_summary: per-concentration mean/SD/CV of t0 absorbance ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standard_summary)</span>
<span id="cb36-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standard_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb36-24">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve, per-concentration summary at t = 0"</span>)</span>
<span id="cb36-25"></span>
<span id="cb36-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Concentrations exceeding"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"% replicate CV:"</span>,</span>
<span id="cb36-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb36-28">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-29"></span>
<span id="cb36-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standards_flagged: every standard well with its deviation from the triplicate median ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_flagged)</span>
<span id="cb36-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_outlier) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, triplicate_median, deviation),</span>
<span id="cb36-33">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers (|deviation| &gt; 0.15 A412)"</span>)</span>
<span id="cb36-34"></span>
<span id="cb36-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- fit_comparison: slope/intercept/R^2 for all three candidate fits ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(fit_comparison)</span>
<span id="cb36-37"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># row.names = FALSE: coef() attaches the predictor's name ("std_nmol") to the</span></span>
<span id="cb36-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># slope/intercept elements, which data.frame() otherwise promotes to a mangled</span></span>
<span id="cb36-39"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># row label (e.g. "std_nmol...1") that breaks pandoc's pipe-table parser.</span></span>
<span id="cb36-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(fit_comparison, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb36-41">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve fit comparison (outlier-excluded fit used downstream)"</span>)</span></code></pre></div>
<pre><code>Standard wells: 18 at 6 concentrations
Standard drift over 20 min (dA412): median 0.030 | range -0.011 to 0.079 
Standards that LOST signal (drift &lt; 0): 3 / 18 

--- standard_summary: per-concentration mean/SD/CV of t0 absorbance ---

tibble [6 × 9] (S3: tbl_df/tbl/data.frame)
 $ std_nmol   : num [1:6] 0 8 16 24 32 40
 $ n          : int [1:6] 3 3 3 3 3 3
 $ mean_od    : num [1:6] 0.17 0.448 0.692 0.918 1.153 ...
 $ sd_od      : num [1:6] 0.00802 0.00586 0.006 0.00929 0.01097 ...
 $ se_od      : num [1:6] 0.00463 0.00338 0.00346 0.00536 0.00633 ...
 $ cv_pct     : num [1:6] 4.727 1.309 0.867 1.012 0.952 ...
 $ median_od  : num [1:6] 0.169 0.45 0.692 0.921 1.149 ...
 $ net_od     : num [1:6] 0 0.278 0.522 0.749 0.983 ...
 $ od_per_nmol: num [1:6] NA 0.0348 0.0326 0.0312 0.0307 ...</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 6%">
<col style="width: 11%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">std_nmol</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">mean_od</th>
<th style="text-align: right;">sd_od</th>
<th style="text-align: right;">se_od</th>
<th style="text-align: right;">cv_pct</th>
<th style="text-align: right;">median_od</th>
<th style="text-align: right;">net_od</th>
<th style="text-align: right;">od_per_nmol</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.170</td>
<td style="text-align: right;">0.0080</td>
<td style="text-align: right;">0.0046</td>
<td style="text-align: right;">4.73</td>
<td style="text-align: right;">0.169</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td style="text-align: right;">8</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.448</td>
<td style="text-align: right;">0.0059</td>
<td style="text-align: right;">0.0034</td>
<td style="text-align: right;">1.31</td>
<td style="text-align: right;">0.450</td>
<td style="text-align: right;">0.278</td>
<td style="text-align: right;">0.0348</td>
</tr>
<tr class="odd">
<td style="text-align: right;">16</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.692</td>
<td style="text-align: right;">0.0060</td>
<td style="text-align: right;">0.0035</td>
<td style="text-align: right;">0.87</td>
<td style="text-align: right;">0.692</td>
<td style="text-align: right;">0.522</td>
<td style="text-align: right;">0.0326</td>
</tr>
<tr class="even">
<td style="text-align: right;">24</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.918</td>
<td style="text-align: right;">0.0093</td>
<td style="text-align: right;">0.0054</td>
<td style="text-align: right;">1.01</td>
<td style="text-align: right;">0.921</td>
<td style="text-align: right;">0.749</td>
<td style="text-align: right;">0.0312</td>
</tr>
<tr class="odd">
<td style="text-align: right;">32</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.153</td>
<td style="text-align: right;">0.0110</td>
<td style="text-align: right;">0.0063</td>
<td style="text-align: right;">0.95</td>
<td style="text-align: right;">1.149</td>
<td style="text-align: right;">0.983</td>
<td style="text-align: right;">0.0307</td>
</tr>
<tr class="even">
<td style="text-align: right;">40</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.307</td>
<td style="text-align: right;">0.2082</td>
<td style="text-align: right;">0.1202</td>
<td style="text-align: right;">15.93</td>
<td style="text-align: right;">1.422</td>
<td style="text-align: right;">1.138</td>
<td style="text-align: right;">0.0284</td>
</tr>
</tbody>
</table>
<p>GSH standard curve, per-concentration summary at t = 0</p>
<pre><code>Concentrations exceeding 15 % replicate CV: 40 

--- standards_flagged: every standard well with its deviation from the triplicate median ---

tibble [18 × 7] (S3: tbl_df/tbl/data.frame)
 $ well             : chr [1:18] "F5" "F2" "E12" "F4" ...
 $ std_nmol         : num [1:18] 40 32 24 40 8 0 0 16 16 32 ...
 $ od               : num [1:18] 1.067 1.165 0.908 1.433 0.441 ...
 $ source           : chr [1:18] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ triplicate_median: num [1:18] 1.422 1.149 0.921 1.422 0.45 ...
 $ deviation        : num [1:18] -0.355 0.016 -0.013 0.011 -0.009 ...
 $ is_outlier       : logi [1:18] TRUE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: right;">std_nmol</th>
<th style="text-align: right;">od</th>
<th style="text-align: right;">triplicate_median</th>
<th style="text-align: right;">deviation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F5</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">1.067</td>
<td style="text-align: right;">1.422</td>
<td style="text-align: right;">-0.355</td>
</tr>
</tbody>
</table>
<p>Standard wells flagged as outliers (|deviation| &gt; 0.15 A412)</p>
<pre><code>--- fit_comparison: slope/intercept/R^2 for all three candidate fits ---

'data.frame':   3 obs. of  5 variables:
 $ fit      : chr  "all wells" "concentration means" "outlier-excluded"
 $ n        : int  18 6 17
 $ slope    : num  0.0287 0.0287 0.0308
 $ intercept: num  0.208 0.208 0.186
 $ r_squared: num  0.964 0.994 0.999</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">fit</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">slope</th>
<th style="text-align: right;">intercept</th>
<th style="text-align: right;">r_squared</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">all wells</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">0.02868</td>
<td style="text-align: right;">0.2077</td>
<td style="text-align: right;">0.96356</td>
</tr>
<tr class="even">
<td style="text-align: left;">concentration means</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0.02868</td>
<td style="text-align: right;">0.2077</td>
<td style="text-align: right;">0.99385</td>
</tr>
<tr class="odd">
<td style="text-align: left;">outlier-excluded</td>
<td style="text-align: right;">17</td>
<td style="text-align: right;">0.03075</td>
<td style="text-align: right;">0.1856</td>
<td style="text-align: right;">0.99852</td>
</tr>
</tbody>
</table>
<p>Standard curve fit comparison (outlier-excluded fit used downstream)</p>
<p>Only <strong>one</strong> of six concentrations (40 nmol) exceeds the 15% CV threshold — 15.9% across its three replicates — and it is driven entirely by a single well, <code>F5</code> (A412 1.067 vs.&nbsp;1.433 and 1.422 for its <code>F4</code>/<code>F6</code> siblings, a deviation of -0.355 A412 from the triplicate median, well past the 0.15 outlier threshold). Excluding <code>F5</code>, the remaining two 40 nmol replicates agree to 0.5% CV. Every other concentration (0, 8, 16, 24, 32 nmol) is under 5% CV. The outlier-excluded fit reaches R<sup>2</sup> = 0.9985 (all-wells fit: R<sup>2</sup> = 0.9636).</p>
</section>
<section id="plot-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="plot-the-standard-curve">5.2 Plot the standard curve</h2>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">std_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(standards_flagged, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> is_outlier), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier),</span>
<span id="cb40-4">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a1d99b"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>),</span>
<span id="cb40-6">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"included"</span>),</span>
<span id="cb40-7">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve (t = 0), family F05 36°C"</span>,</span>
<span id="cb40-9">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outlier-excluded fit: slope = %.5f A412/nmol, R² = %.4f (n = %d)"</span>,</span>
<span id="cb40-10">                          std_slope, std_r2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier))),</span>
<span id="cb40-11">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH (nmol/well)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 at t = 0"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb40-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb40-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb40-15"></span>
<span id="cb40-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gsh_standard_curve.png"</span>), std_plot,</span>
<span id="cb40-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb40-18"></span>
<span id="cb40-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- std_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_plot)</span>
<span id="cb40-21"></span>
<span id="cb40-22">std_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/Gen5-20260814-mgig-citrate_synthase-F05-36C_files/figure-gfm/plot-standard-curve-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- std_plot: ggplot object structure ---

data: well, std_nmol, od, source, triplicate_median, deviation,
  is_outlier [18x7]
mapping:  x = ~std_nmol, y = ~od
scales:   colour 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: colour = ~is_outlier 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

geom_smooth: na.rm = FALSE, orientation = NA, se = TRUE
stat_smooth: na.rm = FALSE, orientation = NA, se = TRUE, method = lm
position_identity </code></pre>
<p>The top two standards (32, 40 nmol) stay within the photometric linear range here — the highest reading (<code>F4</code>, 40 nmol) is A412 1.433, comfortably below the 1.5 ceiling — so the calibration does not need to be restricted to a reduced concentration range.</p>
</section>
</section>
<section id="rate-extraction" class="level1">
<h1>6 RATE EXTRACTION</h1>
<p>Rates are extracted with a sliding-window approach: for each well, the 5-point (8-minute) window of steepest <em>positive</em> slope is taken as the rate, with its R<sup>2</sup> retained for the usability check.</p>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1">well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_rates</span>(plate_long, well_diagnostics, assay_params)</span>
<span id="cb42-2"></span>
<span id="cb42-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- well_rates: extracted rate window per well ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_rates)</span></code></pre></div>
<pre><code>--- well_rates: extracted rate window per well ---

tibble [69 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:69] "A1" "A10" "A11" "A12" ...
 $ well_type             : chr [1:69] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:69] "F05_01_36C" "F05_04_36C" "F05_04_36C" "F05_04_36C" ...
 $ std_nmol              : num [1:69] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:69] 12 12 12 12 12 12 12 12 12 12 ...
 $ t_end                 : num [1:69] 20 20 20 20 20 20 20 20 20 20 ...
 $ slope_mOD_min         : num [1:69] 2.4 2.4 2.5 2.5 2.35 ...
 $ r2                    : num [1:69] 0.998 0.998 1 1 0.999 ...
 $ max_abs_slope_mOD_min : num [1:69] 2.4 2.4 2.5 2.5 2.35 ...
 $ abs_window_is_negative: logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ net_change            : num [1:69] 0.043 0.043 0.044 0.045 0.042 0.041 0.042 0.043 0.042 0.045 ...
 $ frac_rising           : num [1:69] 1 1 1 1 1 1 1 1 1 1 ...
 $ od_max                : num [1:69] 0.222 0.228 0.227 0.228 0.224 0.221 0.226 0.226 0.224 0.227 ...
 $ flag_decreasing       : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range       : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ glitch_at_min         : num [1:69] 2 8 12 10 14 16 2 10 6 2 ...
 $ flag_bg_active        : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:69] 0 0 0 0 0 0 0 0 0 0 ...
 $ glitch_in_window      : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:69] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<section id="rate-tables-by-well-type" class="level2">
<h2 class="anchored" data-anchor-id="rate-tables-by-well-type">6.1 Rate tables by well type</h2>
<div class="sourceCode" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1">sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb44-2"></span>
<span id="cb44-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, t_start, t_end, slope_mOD_min, r2, rate_usable),</span>
<span id="cb44-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb44-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Extracted rate window, sample wells"</span>)</span>
<span id="cb44-6"></span>
<span id="cb44-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Sample wells with a usable rate:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_rates), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample rate range (mA412/min):"</span>,</span>
<span id="cb44-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median replicate-level R^2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-11"></span>
<span id="cb44-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_rates: rate-window results restricted to sample wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_rates)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 17%">
<col style="width: 12%">
<col style="width: 10%">
<col style="width: 21%">
<col style="width: 11%">
<col style="width: 18%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: left;">sample_id</th>
<th style="text-align: right;">t_start</th>
<th style="text-align: right;">t_end</th>
<th style="text-align: right;">slope_mOD_min</th>
<th style="text-align: right;">r2</th>
<th style="text-align: left;">rate_usable</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A1</td>
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A10</td>
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A11</td>
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.50</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A12</td>
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.50</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A2</td>
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A3</td>
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.25</td>
<td style="text-align: right;">0.9985</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A4</td>
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A5</td>
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A6</td>
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.30</td>
<td style="text-align: right;">0.9981</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A7</td>
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.50</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A8</td>
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A9</td>
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.50</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B1</td>
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B10</td>
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.30</td>
<td style="text-align: right;">0.9944</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B11</td>
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B12</td>
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.65</td>
<td style="text-align: right;">0.9989</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B2</td>
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.30</td>
<td style="text-align: right;">0.9981</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B3</td>
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B4</td>
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B5</td>
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B6</td>
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.30</td>
<td style="text-align: right;">0.9981</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B7</td>
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B8</td>
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.40</td>
<td style="text-align: right;">0.9983</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B9</td>
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">0.9986</td>
<td style="text-align: left;">TRUE</td>
</tr>
</tbody>
</table>
<p>Extracted rate window, sample wells</p>
<pre><code>Sample wells with a usable rate: 24 / 24 
Sample rate range (mA412/min): 2.25 - 2.65 
Median replicate-level R^2: 0.9986 

--- sample_rates: rate-window results restricted to sample wells ---

tibble [24 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:24] "A1" "A10" "A11" "A12" ...
 $ well_type             : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:24] "F05_01_36C" "F05_04_36C" "F05_04_36C" "F05_04_36C" ...
 $ std_nmol              : num [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:24] 12 12 12 12 12 12 12 12 12 12 ...
 $ t_end                 : num [1:24] 20 20 20 20 20 20 20 20 20 20 ...
 $ slope_mOD_min         : num [1:24] 2.4 2.4 2.5 2.5 2.35 ...
 $ r2                    : num [1:24] 0.998 0.998 1 1 0.999 ...
 $ max_abs_slope_mOD_min : num [1:24] 2.4 2.4 2.5 2.5 2.35 ...
 $ abs_window_is_negative: logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ net_change            : num [1:24] 0.043 0.043 0.044 0.045 0.042 0.041 0.042 0.043 0.042 0.045 ...
 $ frac_rising           : num [1:24] 1 1 1 1 1 1 1 1 1 1 ...
 $ od_max                : num [1:24] 0.222 0.228 0.227 0.228 0.224 0.221 0.226 0.226 0.224 0.227 ...
 $ flag_decreasing       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ glitch_at_min         : num [1:24] 2 8 12 10 14 16 2 10 6 2 ...
 $ flag_bg_active        : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:24] 0 0 0 0 0 0 0 0 0 0 ...
 $ glitch_in_window      : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:24] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<p>Every one of the 24 sample wells clears the R<sup>2</sup> &gt;= 0.80 and positive-net-change usability bar; in fact every replicate-level R<sup>2</sup> exceeds 0.99. No well needed to be excluded from rate extraction on this plate — a direct consequence of the clean, monotonically-rising traces noted above.</p>
</section>
<section id="positive-control" class="level2">
<h2 class="anchored" data-anchor-id="positive-control">6.2 Positive control</h2>
<div class="sourceCode" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1">pos_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_positive_control</span>(well_rates, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope, assay_params)</span>
<span id="cb46-2"></span>
<span id="cb46-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(pos_control <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, t_start, t_end, slope_mOD_min, r2, net_change, activity_mU_uL),</span>
<span id="cb46-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb46-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control replicates"</span>)</span>
<span id="cb46-6"></span>
<span id="cb46-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control mean rate:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control CV:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>,</span>
<span id="cb46-9">    <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All replicates rising and linear (R^2 &gt; 0.99):"</span>,</span>
<span id="cb46-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-12"></span>
<span id="cb46-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- pos_control: positive control rate and R^2 per replicate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb46-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(pos_control)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 12%">
<col style="width: 9%">
<col style="width: 20%">
<col style="width: 10%">
<col style="width: 16%">
<col style="width: 21%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well</th>
<th style="text-align: right;">t_start</th>
<th style="text-align: right;">t_end</th>
<th style="text-align: right;">slope_mOD_min</th>
<th style="text-align: right;">r2</th>
<th style="text-align: right;">net_change</th>
<th style="text-align: right;">activity_mU_uL</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F7</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">2.8</td>
<td style="text-align: right;">0.9987</td>
<td style="text-align: right;">0.050</td>
<td style="text-align: right;">0.0455</td>
</tr>
<tr class="even">
<td style="text-align: left;">F8</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">3.0</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: right;">0.053</td>
<td style="text-align: right;">0.0488</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F9</td>
<td style="text-align: right;">12</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">3.0</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: right;">0.054</td>
<td style="text-align: right;">0.0488</td>
</tr>
</tbody>
</table>
<p>Positive control replicates</p>
<pre><code>Positive control mean rate: 2.933 mA412/min
Positive control CV: 3.9 %
All replicates rising and linear (R^2 &gt; 0.99): TRUE 

--- pos_control: positive control rate and R^2 per replicate ---

tibble [3 × 22] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:3] "F7" "F8" "F9"
 $ well_type             : chr [1:3] "positive_control" "positive_control" "positive_control"
 $ sample_id             : chr [1:3] NA NA NA
 $ std_nmol              : num [1:3] NA NA NA
 $ t_start               : num [1:3] 12 12 12
 $ t_end                 : num [1:3] 20 20 20
 $ slope_mOD_min         : num [1:3] 2.8 3 3
 $ r2                    : num [1:3] 0.999 1 1
 $ max_abs_slope_mOD_min : num [1:3] 2.8 3 3
 $ abs_window_is_negative: logi [1:3] FALSE FALSE FALSE
 $ net_change            : num [1:3] 0.05 0.053 0.054
 $ frac_rising           : num [1:3] 1 1 1
 $ od_max                : num [1:3] 0.301 0.303 0.306
 $ flag_decreasing       : logi [1:3] FALSE FALSE FALSE
 $ flag_over_range       : logi [1:3] FALSE FALSE FALSE
 $ flag_glitch           : logi [1:3] FALSE FALSE FALSE
 $ glitch_at_min         : num [1:3] 2 2 12
 $ flag_bg_active        : logi [1:3] FALSE FALSE FALSE
 $ n_flags               : int [1:3] 0 0 0
 $ glitch_in_window      : logi [1:3] FALSE FALSE FALSE
 $ rate_usable           : logi [1:3] TRUE TRUE TRUE
 $ activity_mU_uL        : num [1:3] 0.0455 0.0488 0.0488</code></pre>
<p>The positive control again performed exactly as expected: all three replicates rise linearly (R<sup>2</sup> &gt; 0.998) at 2.8-3.0 mA412/min with low replicate CV, confirming the core reaction chemistry and reader were functioning normally on this plate.</p>
</section>
</section>
<section id="background-correction" class="level1">
<h1>7 BACKGROUND CORRECTION</h1>
<p>The background <em>rate</em> is estimated from only the flat (well-behaved) background replicates, since a well flagged <code>flag_bg_active</code> does not measure background.</p>
<div class="sourceCode" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1">background_per_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_background_correction</span>(well_rates)</span>
<span id="cb48-2"></span>
<span id="cb48-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background rate from flat wells only (mA412/min):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(background_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb48-5"></span>
<span id="cb48-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Median flat-background rate:"</span>,</span>
<span id="cb48-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(background_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)),</span>
<span id="cb48-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median sample rate:"</span>,</span>
<span id="cb48-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background as % of sample signal:"</span>,</span>
<span id="cb48-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(background_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb48-13">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-14"></span>
<span id="cb48-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- background_per_sample: per-sample background rate estimates ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(background_per_sample)</span></code></pre></div>
<pre><code>Background rate from flat wells only (mA412/min):
  sample_id n_bg_total n_bg_flat bg_rate_flat bg_rate_all
 F05_01_36C          3         3        0.167       0.167
 F05_02_36C          3         3        0.150       0.150
 F05_03_36C          3         2        0.150      -0.433
 F05_04_36C          3         3        0.183       0.183
 F05_05_36C          3         3        0.183       0.183
 F05_06_36C          3         3        0.233       0.233
 F05_07_36C          3         3        0.167       0.167
 F05_08_36C          3         3        0.183       0.183

Median flat-background rate: 0.175 mA412/min
Median sample rate: 2.37 mA412/min
Background as % of sample signal: 7.4 %

--- background_per_sample: per-sample background rate estimates ---

tibble [8 × 5] (S3: tbl_df/tbl/data.frame)
 $ sample_id   : chr [1:8] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ n_bg_total  : int [1:8] 3 3 3 3 3 3 3 3
 $ n_bg_flat   : int [1:8] 3 3 2 3 3 3 3 3
 $ bg_rate_flat: num [1:8] 0.167 0.15 0.15 0.183 0.183 ...
 $ bg_rate_all : num [1:8] 0.167 0.15 -0.433 0.183 0.183 ...</code></pre>
<p>Background correction remains a minor term (~7% of sample signal), and the one active-background well (<code>C8</code>, <code>F05_03_36C</code>) simply drops from that sample’s flat-well average without leaving any sample without a background estimate.</p>
<section id="background-significance-test" class="level2">
<h2 class="anchored" data-anchor-id="background-significance-test">7.1 Background significance test</h2>
<p>The flat/active threshold classification above is backed by an explicit significance test: a Welch two-sample t-test of well-level rate (background vs.&nbsp;sample), plus an ANOVA on the OD trajectory over time. This mirrors the one-time background ANOVA validation done by Cattau et al.&nbsp;(2023) on the legacy version of this assay.</p>
<div class="sourceCode" id="cb50" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1">bg_sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))</span>
<span id="cb50-3"></span>
<span id="cb50-4">bg_significance_test <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t.test</span>(slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> bg_sample_rates)</span>
<span id="cb50-5"></span>
<span id="cb50-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- Welch two-sample t-test: well-level rate (background vs. sample) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_significance_test)</span>
<span id="cb50-8"></span>
<span id="cb50-9">bg_trend_anova <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> time_min,</span>
<span id="cb50-10">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))))</span>
<span id="cb50-11"></span>
<span id="cb50-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_trend_anova)</span>
<span id="cb50-14"></span>
<span id="cb50-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation: mean background-well rate is"</span>,</span>
<span id="cb50-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group background"</span>])),</span>
<span id="cb50-17">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min vs."</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group sample"</span>])),</span>
<span id="cb50-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min for sample wells (p ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format.pval</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb50-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Background wells are statistically distinct from, and far slower</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb50-20">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"than, reaction wells on this plate -- consistent with the per-well</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb50-21">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flat/active classification above.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-22"></span>
<span id="cb50-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_significance_test: Welch t-test result object ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_significance_test)</span>
<span id="cb50-25"></span>
<span id="cb50-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_trend_anova)</span></code></pre></div>
<pre><code>--- Welch two-sample t-test: well-level rate (background vs. sample) ---


    Welch Two Sample t-test

data:  slope_mOD_min by well_type
t = -29.833, df = 25.695, p-value &lt; 2.2e-16
alternative hypothesis: true difference in means between group background and group sample is not equal to 0
95 percent confidence interval:
 -2.442975 -2.127858
sample estimates:
mean in group background     mean in group sample 
               0.1041667                2.3895833 


--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---

Analysis of Variance Table

Response: od
                    Df  Sum Sq Mean Sq  F value    Pr(&gt;F)    
well_type            1 2.50292 2.50292 4026.991 &lt; 2.2e-16 ***
time_min             1 0.02404 0.02404   38.683 1.020e-09 ***
well_type:time_min   1 0.02396 0.02396   38.545 1.089e-09 ***
Residuals          524 0.32568 0.00062                       
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Interpretation: mean background-well rate is 0.10 mA412/min vs. 2.39 mA412/min for sample wells (p = &lt;2e-16 ). Background wells are statistically distinct from, and far slower
 than, reaction wells on this plate -- consistent with the per-well
 flat/active classification above.

--- bg_significance_test: Welch t-test result object ---

List of 10
 $ statistic  : Named num -29.8
  ..- attr(*, "names")= chr "t"
 $ parameter  : Named num 25.7
  ..- attr(*, "names")= chr "df"
 $ p.value    : num 1.82e-21
 $ conf.int   : num [1:2] -2.44 -2.13
  ..- attr(*, "conf.level")= num 0.95
 $ estimate   : Named num [1:2] 0.104 2.39
  ..- attr(*, "names")= chr [1:2] "mean in group background" "mean in group sample"
 $ null.value : Named num 0
  ..- attr(*, "names")= chr "difference in means between group background and group sample"
 $ stderr     : num 0.0766
 $ alternative: chr "two.sided"
 $ method     : chr "Welch Two Sample t-test"
 $ data.name  : chr "slope_mOD_min by well_type"
 - attr(*, "class")= chr "htest"

--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---

Classes 'anova' and 'data.frame':   4 obs. of  5 variables:
 $ Df     : int  1 1 1 524
 $ Sum Sq : num  2.503 0.024 0.024 0.326
 $ Mean Sq: num  2.502918 0.024043 0.023957 0.000622
 $ F value: num  4027 38.7 38.5 NA
 $ Pr(&gt;F) : num  4.07e-248 1.02e-09 1.09e-09 NA
 - attr(*, "heading")= chr [1:2] "Analysis of Variance Table\n" "Response: od"</code></pre>
</section>
</section>
<section id="technical-replicate-precision" class="level1">
<h1>8 TECHNICAL REPLICATE PRECISION</h1>
<p>Coefficient of variation across the three technical replicates of each sample, computed on the extracted rate. Both <strong>all</strong> and <strong>usable replicates only</strong> are reported; here they are identical for every sample because no replicate was excluded.</p>
<div class="sourceCode" id="cb52" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb52-1">cv_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_replicate_cv</span>(well_rates, protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, assay_params)</span>
<span id="cb52-2"></span>
<span id="cb52-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all,</span>
<span id="cb52-4">                            n_usable, mean_usable, sd_usable, cv_usable,</span>
<span id="cb52-5">                            excluded_wells),</span>
<span id="cb52-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb52-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>,</span>
<span id="cb52-8">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Excluded wells"</span>),</span>
<span id="cb52-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate CV of the extracted rate (mA412/min), "</span>,</span>
<span id="cb52-10">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all replicates vs. usable replicates only"</span>))</span>
<span id="cb52-11"></span>
<span id="cb52-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb52-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on ALL replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb52-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb52-15">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb52-16">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb52-17"></span>
<span id="cb52-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb52-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on USABLE replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb52-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb52-21">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_usable, mean_usable, sd_usable, cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb52-22">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb52-23"></span>
<span id="cb52-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb52-25"></span>
<span id="cb52-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cv_summary: per-sample technical replicate CV, both variants ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb52-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cv_summary)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th>CV (%)</th>
<th>n usable</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th>CV (%)</th>
<th style="text-align: left;">Excluded wells</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">0.08</td>
<td>3.3</td>
<td>3</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">0.08</td>
<td>3.3</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.06</td>
<td>2.4</td>
<td>3</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.06</td>
<td>2.4</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.45</td>
<td style="text-align: right;">0.09</td>
<td>3.5</td>
<td>3</td>
<td style="text-align: right;">2.45</td>
<td style="text-align: right;">0.09</td>
<td>3.5</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.47</td>
<td style="text-align: right;">0.06</td>
<td>2.3</td>
<td>3</td>
<td style="text-align: right;">2.47</td>
<td style="text-align: right;">0.06</td>
<td>2.3</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">0.03</td>
<td>1.2</td>
<td>3</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">0.03</td>
<td>1.2</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.06</td>
<td>2.4</td>
<td>3</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.06</td>
<td>2.4</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.03</td>
<td>1.2</td>
<td>3</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.03</td>
<td>1.2</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2.43</td>
<td style="text-align: right;">0.19</td>
<td>7.8</td>
<td>3</td>
<td style="text-align: right;">2.43</td>
<td style="text-align: right;">0.19</td>
<td>7.8</td>
<td style="text-align: left;">-</td>
</tr>
</tbody>
</table>
<p>Technical replicate CV of the extracted rate (mA412/min), all replicates vs.&nbsp;usable replicates only</p>
<pre><code>Samples exceeding CV 15% on ALL replicates: 0 / 8 
[1] sample_id n_all     mean_all  sd_all    cv_all   
&lt;0 rows&gt; (or 0-length row.names)

Samples exceeding CV 15% on USABLE replicates: 0 
[1] sample_id   n_usable    mean_usable sd_usable   cv_usable  
&lt;0 rows&gt; (or 0-length row.names)

--- cv_summary: per-sample technical replicate CV, both variants ---

'data.frame':   8 obs. of  12 variables:
 $ sample_id      : chr  "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ n_all          : int  3 3 3 3 3 3 3 3
 $ mean_all       : num  2.33 2.37 2.45 2.47 2.33 ...
 $ sd_all         : num  0.0764 0.0577 0.0866 0.0577 0.0289 ...
 $ cv_all         : num  3.27 2.44 3.53 2.34 1.24 ...
 $ n_usable       : int  3 3 3 3 3 3 3 3
 $ mean_usable    : num  2.33 2.37 2.45 2.47 2.33 ...
 $ sd_usable      : num  0.0764 0.0577 0.0866 0.0577 0.0289 ...
 $ cv_usable      : num  3.27 2.44 3.53 2.34 1.24 ...
 $ excluded_wells : Named chr  "-" "-" "-" "-" ...
  ..- attr(*, "names")= chr [1:8] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ fails_cv_all   : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ fails_cv_usable: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
<p><strong>No sample exceeds the 15% CV threshold on this plate.</strong> The highest is <code>F05_08_36C</code> at 7.8%; every other sample is under 4%.</p>
<section id="plot-replicate-spread" class="level2">
<h2 class="anchored" data-anchor-id="plot-replicate-spread">8.1 Plot replicate spread</h2>
<div class="sourceCode" id="cb54" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb54-1">cv_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb54-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb54-3"></span>
<span id="cb54-4">cv_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(cv_plot_data, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> slope_mOD_min)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> rate_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> rate_usable),</span>
<span id="cb54-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fun =</span> mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"crossbar"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb54-8">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb54-10">                                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV %.0f%%"</span>, cv_all)),</span>
<span id="cb54-11">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb54-12">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>),</span>
<span id="cb54-14">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb54-16">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate spread in extracted rate"</span>,</span>
<span id="cb54-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Crossbar = mean of all three replicates; CV computed on all three. "</span>,</span>
<span id="cb54-19">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Threshold "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%."</span>),</span>
<span id="cb54-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate (mA412/min)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb54-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb54-23">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb54-24"></span>
<span id="cb54-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.png"</span>), cv_plot,</span>
<span id="cb54-26">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb54-27"></span>
<span id="cb54-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cv_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb54-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(cv_plot)</span>
<span id="cb54-30"></span>
<span id="cb54-31">cv_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/Gen5-20260814-mgig-citrate_synthase-F05-36C_files/figure-gfm/plot-replicate-cv-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- cv_plot: ggplot object structure ---

data: well, well_type, sample_id, std_nmol, t_start, t_end,
  slope_mOD_min, r2, max_abs_slope_mOD_min, abs_window_is_negative,
  net_change, frac_rising, od_max, flag_decreasing, flag_over_range,
  flag_glitch, glitch_at_min, flag_bg_active, n_flags,
  glitch_in_window, rate_usable, cv_all [24x22]
mapping:  x = ~sample_id, y = ~slope_mOD_min
scales:   colour, shape 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: colour = ~rate_usable, shape = ~rate_usable 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_jitter 

geom_crossbar: na.rm = FALSE, orientation = NA, width = 0.5
stat_summary: fun.data = NULL, fun = function (x, ...) 
UseMethod("mean"), fun.max = NULL, fun.min = NULL, fun.args = list(), na.rm = FALSE, orientation = NA
position_identity 

mapping: x = ~sample_id, y = Inf, label = ~sprintf("CV %.0f%%", cv_all) 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge </code></pre>
</section>
</section>
<section id="citrate-synthase-activity" class="level1">
<h1>9 CITRATE SYNTHASE ACTIVITY</h1>
<section id="calculation" class="level2">
<h2 class="anchored" data-anchor-id="calculation">9.1 Calculation</h2>
<p>Following Abcam Section 10.3:</p>
<p><code>Sample CS activity = B / (dT x V) x D</code> nmol/min/µL (= mU/µL)</p>
<ol type="1">
<li><strong>Rate</strong> (A412/min) = max-increasing sliding-window slope / 1000</li>
<li><strong>Background-corrected rate</strong> = sample rate - mean flat background rate</li>
<li><strong>B/dT</strong> (nmol/min) = background-corrected rate / standard curve slope (0.03075 A412 per nmol, from the outlier-excluded fit)</li>
<li><strong>Activity</strong> (mU/µL) = (B/dT) / <em>V</em> x <em>D</em>, with <em>V</em> = 2 µL and <em>D</em> = 1</li>
<li><strong>Protein-normalized</strong> (mU/mg protein) = activity x <code>homogenate_volume_uL</code> (350 µL, measured) / total protein (mg)</li>
</ol>
<div class="sourceCode" id="cb56" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb56-1">cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calculate_cs_activity</span>(well_rates, protein_by_sample, background_per_sample,</span>
<span id="cb56-2">                                      std_slope, std_nmol_max, assay_params, plate_long)</span>
<span id="cb56-3"></span>
<span id="cb56-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with a computed activity:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cs_activity), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/uL):"</span>,</span>
<span id="cb56-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/mg protein):"</span>,</span>
<span id="cb56-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-9"></span>
<span id="cb56-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cs_activity: per-sample citrate synthase activity ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cs_activity)</span></code></pre></div>
<pre><code>Samples with a computed activity: 8 / 8 
Activity range (mU/uL): 0.0347 - 0.0374 
Activity range (mU/mg protein): 20.972 - 66.031 

--- cs_activity: per-sample citrate synthase activity ---

tibble [8 × 21] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:8] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ n_reps_used               : int [1:8] 3 3 3 3 3 3 3 3
 $ mean_rate_mOD_min         : num [1:8] 2.33 2.37 2.45 2.47 2.33 ...
 $ sd_rate                   : num [1:8] 0.0764 0.0577 0.0866 0.0577 0.0289 ...
 $ cv_rate                   : num [1:8] 3.27 2.44 3.53 2.34 1.24 ...
 $ family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ individual                : chr [1:8] "01" "02" "03" "04" ...
 $ temperature               : chr [1:8] "36C" "36C" "36C" "36C" ...
 $ conc_ug_mL                : num [1:8] 953 546 668 1062 1667 ...
 $ total_protein_mg          : num [1:8] 0.334 0.191 0.234 0.372 0.583 ...
 $ bg_rate_flat              : num [1:8] 0.167 0.15 0.15 0.183 0.183 ...
 $ n_bg_flat                 : int [1:8] 3 3 2 3 3 3 3 3
 $ bg_rate_mOD_min           : num [1:8] 0.167 0.15 0.15 0.183 0.183 ...
 $ corrected_mOD_min         : num [1:8] 2.17 2.22 2.3 2.28 2.15 ...
 $ rate_OD_min               : num [1:8] 0.00217 0.00222 0.0023 0.00228 0.00215 ...
 $ nmol_per_min              : num [1:8] 0.0705 0.0721 0.0748 0.0742 0.0699 ...
 $ activity_mU_per_uL        : num [1:8] 0.0352 0.036 0.0374 0.0371 0.035 ...
 $ total_mU_in_homogenate    : num [1:8] 12.3 12.6 13.1 13 12.2 ...
 $ activity_mU_per_mg_protein: num [1:8] 37 66 56 34.9 21 ...
 $ nmol_in_window            : num [1:8] 1.41 1.44 1.5 1.48 1.4 ...
 $ within_std_range          : logi [1:8] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
</section>
<section id="results-table" class="level2">
<h2 class="anchored" data-anchor-id="results-table">9.2 Results table</h2>
<div class="sourceCode" id="cb58" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb58-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_results_table</span>(cs_activity, cv_summary, baseline_per_sample, assay_params)</span>
<span id="cb58-2"></span>
<span id="cb58-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table,</span>
<span id="cb58-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, family F05 36°C (mU/mg protein uses "</span>,</span>
<span id="cb58-5">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"measured protein concentration x the "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb58-6">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume)"</span>))</span>
<span id="cb58-7"></span>
<span id="cb58-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation summary:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb58-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(results_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(Interpretation, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_samples"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-10">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb58-11"></span>
<span id="cb58-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_results.csv"</span>),</span>
<span id="cb58-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb58-14"></span>
<span id="cb58-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- results_table: formatted per-sample results written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb58-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(results_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">Protein conc (ug/mL)</th>
<th style="text-align: right;">Total protein (mg)</th>
<th style="text-align: left;">Reps used</th>
<th>CV all reps (%)</th>
<th style="text-align: right;">CV used reps (%)</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">BG rate (mA412/min)</th>
<th style="text-align: right;">Corrected rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/uL)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th style="text-align: left;">CV flag</th>
<th style="text-align: left;">Elevated baseline reps</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">953.1</td>
<td style="text-align: right;">0.334</td>
<td style="text-align: left;">3/3</td>
<td>3.3</td>
<td style="text-align: right;">3.3</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">0.167</td>
<td style="text-align: right;">2.17</td>
<td style="text-align: right;">0.0352</td>
<td style="text-align: right;">36.960</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">545.8</td>
<td style="text-align: right;">0.191</td>
<td style="text-align: left;">3/3</td>
<td>2.4</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.150</td>
<td style="text-align: right;">2.22</td>
<td style="text-align: right;">0.0360</td>
<td style="text-align: right;">66.031</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">667.6</td>
<td style="text-align: right;">0.234</td>
<td style="text-align: left;">3/3</td>
<td>3.5</td>
<td style="text-align: right;">3.5</td>
<td style="text-align: right;">2.45</td>
<td style="text-align: right;">0.150</td>
<td style="text-align: right;">2.30</td>
<td style="text-align: right;">0.0374</td>
<td style="text-align: right;">56.014</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1062.2</td>
<td style="text-align: right;">0.372</td>
<td style="text-align: left;">3/3</td>
<td>2.3</td>
<td style="text-align: right;">2.3</td>
<td style="text-align: right;">2.47</td>
<td style="text-align: right;">0.183</td>
<td style="text-align: right;">2.28</td>
<td style="text-align: right;">0.0371</td>
<td style="text-align: right;">34.950</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1666.8</td>
<td style="text-align: right;">0.583</td>
<td style="text-align: left;">3/3</td>
<td>1.2</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">2.33</td>
<td style="text-align: right;">0.183</td>
<td style="text-align: right;">2.15</td>
<td style="text-align: right;">0.0350</td>
<td style="text-align: right;">20.972</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1265.9</td>
<td style="text-align: right;">0.443</td>
<td style="text-align: left;">3/3</td>
<td>2.4</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.233</td>
<td style="text-align: right;">2.13</td>
<td style="text-align: right;">0.0347</td>
<td style="text-align: right;">27.399</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1110.5</td>
<td style="text-align: right;">0.389</td>
<td style="text-align: left;">3/3</td>
<td>1.2</td>
<td style="text-align: right;">1.2</td>
<td style="text-align: right;">2.37</td>
<td style="text-align: right;">0.167</td>
<td style="text-align: right;">2.20</td>
<td style="text-align: right;">0.0358</td>
<td style="text-align: right;">32.210</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">1357.5</td>
<td style="text-align: right;">0.475</td>
<td style="text-align: left;">3/3</td>
<td>7.8</td>
<td style="text-align: right;">7.8</td>
<td style="text-align: right;">2.43</td>
<td style="text-align: right;">0.183</td>
<td style="text-align: right;">2.25</td>
<td style="text-align: right;">0.0366</td>
<td style="text-align: right;">26.948</td>
<td style="text-align: left;">pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>Citrate synthase activity, family F05 36°C (mU/mg protein uses measured protein concentration x the 350 uL homogenization volume)</p>
<pre><code>Interpretation summary:
 Interpretation n_samples
         usable         8

--- results_table: formatted per-sample results written to CSV ---

tibble [8 × 17] (S3: tbl_df/tbl/data.frame)
 $ Sample                    : chr [1:8] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ Family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ Individual                : chr [1:8] "01" "02" "03" "04" ...
 $ Temperature               : chr [1:8] "36C" "36C" "36C" "36C" ...
 $ Protein conc (ug/mL)      : num [1:8] 953 546 668 1062 1667 ...
 $ Total protein (mg)        : num [1:8] 0.334 0.191 0.234 0.372 0.583 0.443 0.389 0.475
 $ Reps used                 : chr [1:8] "3/3" "3/3" "3/3" "3/3" ...
 $ CV all reps (%)           : num [1:8] 3.3 2.4 3.5 2.3 1.2 2.4 1.2 7.8
 $ CV used reps (%)          : num [1:8] 3.3 2.4 3.5 2.3 1.2 2.4 1.2 7.8
 $ Rate (mA412/min)          : num [1:8] 2.33 2.37 2.45 2.47 2.33 2.37 2.37 2.43
 $ BG rate (mA412/min)       : num [1:8] 0.167 0.15 0.15 0.183 0.183 0.233 0.167 0.183
 $ Corrected rate (mA412/min): num [1:8] 2.17 2.22 2.3 2.28 2.15 2.13 2.2 2.25
 $ Activity (mU/uL)          : num [1:8] 0.0352 0.036 0.0374 0.0371 0.035 0.0347 0.0358 0.0366
 $ Activity (mU/mg protein)  : num [1:8] 37 66 56 35 21 ...
 $ CV flag                   : chr [1:8] "pass" "pass" "pass" "pass" ...
 $ Elevated baseline reps    : chr [1:8] "0/3" "0/3" "0/3" "0/3" ...
 $ Interpretation            : chr [1:8] "usable" "usable" "usable" "usable" ...</code></pre>
<p>All eight samples are usable on this plate — no CV flag, no elevated baseline replicate.</p>
</section>
<section id="plot-activity" class="level2">
<h2 class="anchored" data-anchor-id="plot-activity">9.3 Plot activity</h2>
<div class="sourceCode" id="cb60" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb60-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Three-level quality scheme, kept for consistency with other plate</span></span>
<span id="cb60-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># documents even though no sample here falls in the flagged categories.</span></span>
<span id="cb60-3">qual_levels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clean"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV &gt; "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb60-4">                 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all reps baseline-compromised"</span>)</span>
<span id="cb60-5">qual_cols   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey60"</span>), qual_levels)</span>
<span id="cb60-6"></span>
<span id="cb60-7">activity_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb60-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb60-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated, n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb60-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_flag =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb60-11">                            n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n                              <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb60-12">                            cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct       <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb60-13">                            <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                                        <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb60-14">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> qual_levels),</span>
<span id="cb60-15">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3 reps"</span>,</span>
<span id="cb60-16">                          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - DISQUALIFIED"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)))</span>
<span id="cb60-17"></span>
<span id="cb60-18">activity_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb60-19">                        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(sample_id, activity_mU_per_uL),</span>
<span id="cb60-20">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_uL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> cv_flag)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> label_n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">clip =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"off"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand_limits</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, M. gigas ctenidia, family F05 36°C"</span>,</span>
<span id="cb60-27">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background-corrected, mean of all three technical replicates (all usable on this plate)."</span>,</span>
<span id="cb60-28">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/uL homogenate)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb60-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb60-31">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb60-32"></span>
<span id="cb60-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity.png"</span>), activity_plot,</span>
<span id="cb60-34">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb60-35"></span>
<span id="cb60-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- activity_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb60-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(activity_plot)</span>
<span id="cb60-38"></span>
<span id="cb60-39">activity_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/Gen5-20260814-mgig-citrate_synthase-F05-36C_files/figure-gfm/plot-activity-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- activity_plot: ggplot object structure ---

data: sample_id, n_reps_used, mean_rate_mOD_min, sd_rate, cv_rate,
  family, individual, temperature, conc_ug_mL, total_protein_mg,
  bg_rate_flat, n_bg_flat, bg_rate_mOD_min, corrected_mOD_min,
  rate_OD_min, nmol_per_min, activity_mU_per_uL,
  total_mU_in_homogenate, activity_mU_per_mg_protein, nmol_in_window,
  within_std_range, cv_all, n_elevated, n, cv_flag, label_n [8x26]
mapping:  x = ~reorder(sample_id, activity_mU_per_uL), y = ~activity_mU_per_uL, fill = ~cv_flag
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_col: na.rm = FALSE, just = 0.5, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_stack 

mapping: label = ~label_n 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge 

mapping: y = ~y 
geom_blank: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
<p>Raw activity (mU/µL) is remarkably uniform across all eight individuals — 0.0347 to 0.0374, a spread of only 7.8%, against a technical CV of under 8% for any single sample.</p>
</section>
<section id="protein-normalized-activity" class="level2">
<h2 class="anchored" data-anchor-id="protein-normalized-activity">9.4 Protein-normalized activity</h2>
<div class="sourceCode" id="cb62" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb62-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># All eight samples are clean on this plate, so the trend fit uses all of them.</span></span>
<span id="cb62-2">norm_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> activity_plot_data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_flag <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb62-3"></span>
<span id="cb62-4">norm_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb62-5">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> total_protein_mg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_mg_protein)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb62-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> norm_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb62-7">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey35"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey85"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb62-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> cv_flag), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb62-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> individual), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb62-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb62-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein-normalized CS activity vs. total extracted protein"</span>,</span>
<span id="cb62-12">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Point labels = individual ID. Total protein = measured protein "</span>,</span>
<span id="cb62-13">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration x the same</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb62-14">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume used for every sample. Grey line = fit to "</span>,</span>
<span id="cb62-15">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all 8</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">samples (all clean on this plate); a negative slope would indicate the "</span>,</span>
<span id="cb62-16">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normalization</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">is not protein-independent."</span>),</span>
<span id="cb62-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total extracted protein (mg)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/mg protein)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb62-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb62-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb62-20">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb62-21"></span>
<span id="cb62-22">protein_trend <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb62-23">protein_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb62-24">uL_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)</span>
<span id="cb62-25"></span>
<span id="cb62-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_normalized.png"</span>), norm_plot,</span>
<span id="cb62-27">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb62-28"></span>
<span id="cb62-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Correlation of mU/mg protein with total extracted protein</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb62-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  all %d samples      : r = %+.3f, p = %.4f</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-31">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(activity_plot_data), protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value))</span>
<span id="cb62-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean samples only  : r = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-33">            protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb62-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/mg protein range: %.3f to %.3f (%.1f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-35">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein),</span>
<span id="cb62-36">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)))</span>
<span id="cb62-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/uL range: %.4f to %.4f (%.1f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-38">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL),</span>
<span id="cb62-39">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)))</span>
<span id="cb62-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Artifact check: r(total protein, mU/uL raw rate) = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-41">            uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb62-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"If mU/uL itself trends with total protein while mU/mg protein trends oppositely,</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-43">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb62-44">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rather than a biological difference in specific activity.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb62-45"></span>
<span id="cb62-46"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_trend_clean: correlation test on clean samples ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb62-47"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_trend_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb62-48"></span>
<span id="cb62-49"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- norm_clean: clean samples used for the trend fit ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb62-50"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(norm_clean)</span>
<span id="cb62-51"></span>
<span id="cb62-52">norm_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/Gen5-20260814-mgig-citrate_synthase-F05-36C_files/figure-gfm/plot-activity-normalized-1.png" class="img-fluid"><!-- --></p>
<pre><code>Correlation of mU/mg protein with total extracted protein
  all 8 samples      : r = -0.948, p = 0.0003
  clean samples only  : r = -0.948, p = 0.0003  (n = 8)
  clean-sample mU/mg protein range: 20.972 to 66.031 (3.1-fold)
  clean-sample mU/uL range: 0.0347 to 0.0374 (1.1-fold)

Artifact check: r(total protein, mU/uL raw rate) = -0.479, p = 0.2302  (n = 8)
If mU/uL itself trends with total protein while mU/mg protein trends oppositely,
the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate
rather than a biological difference in specific activity.

--- protein_trend_clean: correlation test on clean samples ---

List of 9
 $ statistic  : Named num -7.31
 $ parameter  : Named int 6
 $ p.value    : num 0.000335
 $ estimate   : Named num -0.948
 $ null.value : Named num 0
 $ alternative: chr "two.sided"
 $ method     : chr "Pearson's product-moment correlation"
 $ data.name  : chr "norm_clean$total_protein_mg and norm_clean$activity_mU_per_mg_protein"
 $ conf.int   : num [1:2] -0.991 -0.734

--- norm_clean: clean samples used for the trend fit ---

tibble [8 × 26] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:8] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ n_reps_used               : int [1:8] 3 3 3 3 3 3 3 3
 $ mean_rate_mOD_min         : num [1:8] 2.33 2.37 2.45 2.47 2.33 ...
 $ sd_rate                   : num [1:8] 0.0764 0.0577 0.0866 0.0577 0.0289 ...
 $ cv_rate                   : num [1:8] 3.27 2.44 3.53 2.34 1.24 ...
 $ family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ individual                : chr [1:8] "01" "02" "03" "04" ...
 $ temperature               : chr [1:8] "36C" "36C" "36C" "36C" ...
 $ conc_ug_mL                : num [1:8] 953 546 668 1062 1667 ...
 $ total_protein_mg          : num [1:8] 0.334 0.191 0.234 0.372 0.583 ...
 $ bg_rate_flat              : num [1:8] 0.167 0.15 0.15 0.183 0.183 ...
 $ n_bg_flat                 : int [1:8] 3 3 2 3 3 3 3 3
 $ bg_rate_mOD_min           : num [1:8] 0.167 0.15 0.15 0.183 0.183 ...
 $ corrected_mOD_min         : num [1:8] 2.17 2.22 2.3 2.28 2.15 ...
 $ rate_OD_min               : num [1:8] 0.00217 0.00222 0.0023 0.00228 0.00215 ...
 $ nmol_per_min              : num [1:8] 0.0705 0.0721 0.0748 0.0742 0.0699 ...
 $ activity_mU_per_uL        : num [1:8] 0.0352 0.036 0.0374 0.0371 0.035 ...
 $ total_mU_in_homogenate    : num [1:8] 12.3 12.6 13.1 13 12.2 ...
 $ activity_mU_per_mg_protein: num [1:8] 37 66 56 34.9 21 ...
 $ nmol_in_window            : num [1:8] 1.41 1.44 1.5 1.48 1.4 ...
 $ within_std_range          : logi [1:8] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ cv_all                    : num [1:8] 3.27 2.44 3.53 2.34 1.24 ...
 $ n_elevated                : int [1:8] 0 0 0 0 0 0 0 0
 $ n                         : int [1:8] 3 3 3 3 3 3 3 3
 $ cv_flag                   : Factor w/ 3 levels "clean","CV &gt; 15%",..: 1 1 1 1 1 1 1 1
 $ label_n                   : chr [1:8] "3/3 reps" "3/3 reps" "3/3 reps" "3/3 reps" ...</code></pre>
<p>mU/mg protein correlates negatively with total extracted protein at r = -0.948 (p = 0.0003, n = 8, all 8 samples clean on this plate), while raw mU/µL is essentially flat against protein (r = -0.479, p = 0.23). Because the raw signal used in the numerator is close to protein-independent here, <strong>the negative mU/mg protein trend on this plate is substantially closer to a pure division artifact</strong> (dividing a near-constant numerator by a 3-fold-varying denominator) than a genuine biological effect. This distinction matters directly for note 3 of the recommendations below.</p>
</section>
</section>
<section id="qc-summary" class="level1">
<h1>10 QC SUMMARY</h1>
<div class="sourceCode" id="cb64" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb64-1">qc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_qc_summary_table</span>(layout_wells, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary, std_curve,</span>
<span id="cb64-2">                                      well_diagnostics, well_rates, cv_summary,</span>
<span id="cb64-3">                                      baseline_per_sample, pos_control, assay_params)</span>
<span id="cb64-4"></span>
<span id="cb64-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(qc_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"QC check"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Result"</span>),</span>
<span id="cb64-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quality control summary for this plate"</span>)</span>
<span id="cb64-7"></span>
<span id="cb64-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(qc_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"qc_summary.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb64-9"></span>
<span id="cb64-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- qc_summary: consolidated QC checks for the run ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb64-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(qc_summary)</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">QC check</th>
<th style="text-align: left;">Result</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Occupied wells in layout</td>
<td style="text-align: left;">69</td>
</tr>
<tr class="even">
<td style="text-align: left;">Layout wells missing from absorbance CSV</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Max disagreement between absorbance CSV and full report</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard concentrations with replicate CV &gt; threshold</td>
<td style="text-align: left;">40</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard wells flagged as outliers</td>
<td style="text-align: left;">1/18 (F5)</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard curve R^2 (outlier-excluded, replicate level)</td>
<td style="text-align: left;">0.9985</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard curve R^2 (all wells, replicate level)</td>
<td style="text-align: left;">0.9636</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard wells that LOST signal over the run</td>
<td style="text-align: left;">3/18</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standards above photometric linearity ceiling</td>
<td style="text-align: left;"></td>
</tr>
<tr class="even">
<td style="text-align: left;">Background control wells behaving as active reactions</td>
<td style="text-align: left;">1/24</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells with a decreasing trace</td>
<td style="text-align: left;">0/24</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with an elevated starting A412</td>
<td style="text-align: left;">0/24 ()</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with ALL THREE replicates baseline-compromised</td>
<td style="text-align: left;">0/8 ()</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with a read glitch</td>
<td style="text-align: left;">0/24</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells usable for rate extraction</td>
<td style="text-align: left;">24/24</td>
</tr>
<tr class="even">
<td style="text-align: left;">Samples with technical CV &gt; threshold (all reps)</td>
<td style="text-align: left;">0/8</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with technical CV &gt; threshold (usable reps)</td>
<td style="text-align: left;">0/8</td>
</tr>
<tr class="even">
<td style="text-align: left;">Positive control replicates rising and linear</td>
<td style="text-align: left;">3/3</td>
</tr>
</tbody>
</table>
<p>Quality control summary for this plate</p>
<pre><code>--- qc_summary: consolidated QC checks for the run ---

'data.frame':   18 obs. of  2 variables:
 $ check: chr  "Occupied wells in layout" "Layout wells missing from absorbance CSV" "Max disagreement between absorbance CSV and full report" "Standard concentrations with replicate CV &gt; threshold" ...
 $ value: chr  "69" "0" "0" "40" ...</code></pre>
<section id="auto-generated-findings" class="level2">
<h2 class="anchored" data-anchor-id="auto-generated-findings">10.1 Auto-generated findings</h2>
<p>The bullets below are generated programmatically from the QC/CV/anomaly objects above by <code>generate_qc_findings()</code>, so the same logic that flags a problem here is guaranteed to be the logic that flagged it upstream.</p>
<div class="sourceCode" id="cb66" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb66-1">qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">generate_qc_findings</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb66-2">                                     baseline_per_sample, std_curve, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary,</span>
<span id="cb66-3">                                     assay_params)</span>
<span id="cb66-4"></span>
<span id="cb66-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"- "</span>, qc_findings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>- **Kinetic sources agree.** absorbance CSV and full report agree exactly on all 759 shared well x timepoint readings; all layout wells are present.

- **Background control wells behaving as active reactions.** 1 of 24 background wells show a starting A412 or drift inconsistent with a flat, inactive well: C8.

- **GSH standard curve replicate imprecision.** 1 of 6 concentrations exceed 15% CV: 40 nmol/well.

- **Standard outlier wells.** 1 of 18 standard wells deviate from their triplicate median by more than 0.15 A412: F5.

- **Standard signal decay.** 3 of 18 standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0.

- **Standard curve fit (outlier-excluded):** slope = 0.03075 A412/nmol, R^2 = 0.9985 (all-wells R^2 = 0.9636).

- **Technical replicate CV.** All 8 samples are within 15% CV across all three replicates.</code></pre>
</section>
</section>
<section id="summary" class="level1">
<h1>11 SUMMARY</h1>
<section id="anomalies-found" class="level2">
<h2 class="anchored" data-anchor-id="anomalies-found">11.1 Anomalies found</h2>
<ol type="1">
<li><strong>One background well behaves as an active reaction, not a background control.</strong> <code>C8</code> (<code>F05_03_36C</code>’s third background replicate) starts at A412 0.252 (above the 0.15 flat-well threshold) and declines to 0.202 (net change -0.050), rather than staying flat. This pattern is consistent with Reaction Mix having been dispensed instead of Background Control Mix for this single well. <code>compute_background_correction()</code> drops it automatically; <code>F05_03_36C</code>’s background estimate is still based on 2 of 3 replicates.</li>
<li><strong>One GSH standard well is an outlier.</strong> <code>F5</code> (40 nmol) reads A412 1.067 against triplicate siblings <code>F4</code>/<code>F6</code> at 1.433/1.422 — a deviation of -0.355 A412 from the triplicate median, and also flagged for an internal read-to-read glitch. Excluding it, the 40 nmol triplicate CV drops from 15.9% to 0.5%. It is the sole reason the 40 nmol concentration is the only one of six to exceed the 15% CV threshold.</li>
<li><strong>Three standard wells lost signal over the run</strong> (<code>F1</code>, <code>F4</code>, <code>F6</code> - the 32 and 40 nmol replicates; drift -0.004 to -0.011 A412), consistent with TNB<sup>2-</sup> instability over the run. The standard curve is read at t = 0 for this reason.</li>
<li><strong>No decreasing kinetics, no read glitches, and no elevated starting absorbance in any sample well.</strong> All 24 sample wells rise monotonically and cleanly (replicate-level R<sup>2</sup> &gt; 0.99), and none needs exclusion from rate extraction.</li>
<li><strong>No sample has an elevated starting absorbance or a disqualifying baseline artifact.</strong> Sample well starting A412 ranges only 0.179-0.192, well under the 0.35 threshold.</li>
</ol>
</section>
<section id="technical-replicate-precision-1" class="level2">
<h2 class="anchored" data-anchor-id="technical-replicate-precision-1">11.2 Technical replicate precision</h2>
<p><strong>All eight samples pass the 15% CV threshold</strong> — the highest is <code>F05_08_36C</code> at 7.8%, and every other sample is under 4% (<code>F05_01_36C</code> 3.3%, <code>F05_02_36C</code> 2.4%, <code>F05_03_36C</code> 3.5%, <code>F05_04_36C</code> 2.3%, <code>F05_05_36C</code> 1.2%, <code>F05_06_36C</code> 2.4%, <code>F05_07_36C</code> 1.2%). No replicate is excluded from any sample’s rate calculation on this plate, so the “all reps” and “usable reps only” CVs are identical throughout. No sample technical rep exceeds 15% CV on this plate.</p>
</section>
<section id="assay-validity" class="level2">
<h2 class="anchored" data-anchor-id="assay-validity">11.3 Assay validity</h2>
<p>The <strong>positive control worked</strong>: all three replicates rise linearly (R<sup>2</sup> &gt; 0.998) at 2.8-3.0 mA412/min with low replicate CV. The GSH standard curve has a single, clearly-identified outlier well and every sample well’s kinetics are clean, so this plate’s activity values carry low calibration uncertainty.</p>
</section>
<section id="recommendation" class="level2">
<h2 class="anchored" data-anchor-id="recommendation">11.4 Recommendation</h2>
<p>Treat the activity values here as reliable, though the open question about the raw-rate/protein relationship still bears on interpretation:</p>
<ol type="1">
<li><strong>This plate does not need re-assay.</strong> No sample is disqualified, no replicate is excluded, and the standard curve fails QC only by a single, clearly-identified outlier well.</li>
<li><strong>A dilution series is recommended before treating protein-normalized activity as reliable.</strong> Raw rate (mU/µL) is essentially flat against total extracted protein here (r = -0.48, p = 0.23), so a division artifact is the more likely explanation for the observed mU/mg-protein trend (see note 3) rather than a genuine effect of protein content on measured activity. A dilution series run on a single homogenate at multiple concentrations would directly test whether the assay’s raw rate is protein-independent.</li>
<li><strong>The mU/mg protein negative trend seen on this plate should be treated as attributable to division artifact rather than a biological effect.</strong> Because raw mU/µL is flat against protein while mU/mg protein trends negatively with it, the mU/mg protein figures largely reflect dividing a near-constant numerator by a varying denominator rather than a real difference in specific activity.</li>
<li><strong>Re-confirm the background-well dispensing step</strong>, since one well (<code>C8</code>) showed the signature of a Reaction Mix / Background Control Mix mix-up — worth checking whether it is a one-off pipetting error or a persistent low-rate issue in this step.</li>
</ol>
</section>
<section id="what-can-be-used-from-this-plate" class="level2">
<h2 class="anchored" data-anchor-id="what-can-be-used-from-this-plate">11.5 What can be used from this plate</h2>
<p>All eight samples are usable, and the raw-rate result is the more striking one for the within-family question this project asks: background-corrected rates cluster tightly — 2.13 to 2.30 mA412/min across all eight <code>F05</code> individuals at 36 °C, a spread of only 7.8% against 1-8% technical CV per sample. Once normalization artifacts are set aside, <strong>no striking within-family variation in raw CS activity is apparent at 36 °C.</strong></p>
<ul>
<li><strong>Raw rate is the safer basis for downstream comparison.</strong> The median background-corrected rate is ~2.21 mA412/min at 36 °C, with technical and normalization uncertainty small relative to this signal, and it does not require resolving the protein-normalization question first.</li>
<li><strong>The mU/mg protein figures on this plate should be treated with some caution.</strong> Since raw rate (mU/µL) is essentially flat against total extracted protein here (see note 3 above), the observed mU/mg-protein trend is more consistent with a division artifact than a biological effect of protein content on activity. A dilution series run on a single homogenate at multiple concentrations would help resolve whether the assay’s raw rate is genuinely protein-independent.</li>
</ul>


</section>
</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>citrate synthase</category>
  <category>ABCAM</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-14-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-36C-Ctenidia/</guid>
  <pubDate>Fri, 14 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Protein Quantification - June 2026 SORMI M.gigas Ctenidia from Famillies 5 and 7 for Citrate Synthase Assay</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>As part of the <a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase">June 2026 SORMI experiment citrate synthase assays</a> (GitHub repo), protein quantities were needed for proper normalization of the citrate synthase assays. I quantified protein in <a href="../../../posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/index.html">ctenidia samples from Families 5 and 7 homozenized on 20260811</a> (Notebook entry) using the Quick Start Bradford Protein Assay Kit 1 (Bio-Rad; cat: 5000201).</p>
<p>Families 5 &amp; 7 (Eight samples each family from each temperature treatment) were processed for protein quantification.</p>
<p>Due to poor replicates and/or samples falling outside of the standard curve, the BSA assay was repeated for those samples failing QC on the initial run.</p>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<section id="bsa-assay" class="level2">
<h2 class="anchored" data-anchor-id="bsa-assay">BSA Assay</h2>
<p>The Bradford Protein Assay was performed according to the manufacturer’s instructions (Bio-Rad, cat: 5000201) for microplate format. Clear, flat-bottomed 96-well plates were used for the assay.</p>
<p>Briefly, samples were thawed, spun at 10,000 rpm for 5 minutes, and stored on ice. A series of BSA standards were prepared and used to generate a standard curve. Samples (5uL) were then added to respective wells and 250uL of the Bradford reagent was added to each well (using a multichannel pipette; two rounds of 125uL) and mixed by pipetting. The plates were then incubated for 5 minutes at room temperature, and the absorbance was measured at 595 nm in a Synergy HTX plate reader (Agilent).</p>
</section>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<p>Data was analyzed in R. Respective Rmd files are here (GitHub):</p>
<ul>
<li><p><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260813-mgig-sormi-BSA-F05-protein.Rmd">Gen5-20260813-mgig-sormi-BSA-F05-protein.Rmd</a></p></li>
<li><p><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260813-mgig-sormi-BSA-F07-protein.Rmd">Gen5-20260813-mgig-sormi-BSA-F07-protein.Rmd</a></p></li>
<li><p><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260813-mgig-sormi-BSA-F05-F07-reassay-protein.Rmd">Gen5-20260813-mgig-sormi-BSA-F05-F07-reassay-protein.Rmd</a></p></li>
</ul>
<p>Knitted markdown from each is below.</p>
</section>
<section id="data-files" class="level2">
<h2 class="anchored" data-anchor-id="data-files">Data files</h2>
<section id="plate-reader-files" class="level3">
<h3 class="anchored" data-anchor-id="plate-reader-files">Plate reader files</h3>
<p>Plate reader files (<code>*.xpt</code>)are available here (require Gen5 software to open):</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/BSA/plate_reader_files</li>
</ul>
</section>
<section id="raw-absorbance-data" class="level3">
<h3 class="anchored" data-anchor-id="raw-absorbance-data">Raw absorbance data</h3>
<p>Raw absorbance data (<code>*.csv</code>) are available here:</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/BSA/raw_absorbance</li>
</ul>
</section>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Output files with sample concentrations can be found in each of the corresponding output files from the Rmd files above (https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/outputs) in a file named <code>sample_concentrations.csv</code>.</p>
<p>Below is a summary of the protein concentrations (ug/mL) for each sample:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>sample_name</th>
<th>concentration(ug/mL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>F05_01_36C</td>
<td>953.1</td>
</tr>
<tr class="even">
<td>F05_01_ambient</td>
<td>876.1</td>
</tr>
<tr class="odd">
<td>F05_02_36C</td>
<td>545.8</td>
</tr>
<tr class="even">
<td>F05_02_ambient</td>
<td>1038.9</td>
</tr>
<tr class="odd">
<td>F05_03_36C</td>
<td>667.6</td>
</tr>
<tr class="even">
<td>F05_03_ambient</td>
<td>1900.4</td>
</tr>
<tr class="odd">
<td>F05_04_36C</td>
<td>1062.2</td>
</tr>
<tr class="even">
<td>F05_04_ambient</td>
<td>1129.4</td>
</tr>
<tr class="odd">
<td>F05_05_36C</td>
<td>1666.8</td>
</tr>
<tr class="even">
<td>F05_05_ambient</td>
<td>711.7</td>
</tr>
<tr class="odd">
<td>F05_06_36C</td>
<td>1265.9</td>
</tr>
<tr class="even">
<td>F05_06_ambient</td>
<td>2232.4</td>
</tr>
<tr class="odd">
<td>F05_07_36C</td>
<td>1110.5</td>
</tr>
<tr class="even">
<td>F05_07_ambient</td>
<td>1687.8</td>
</tr>
<tr class="odd">
<td>F05_08_36C</td>
<td>1357.5</td>
</tr>
<tr class="even">
<td>F05_08_ambient</td>
<td>2703.7</td>
</tr>
<tr class="odd">
<td>F07_01_36C</td>
<td>663.3</td>
</tr>
<tr class="even">
<td>F07_01_ambient</td>
<td>263.1</td>
</tr>
<tr class="odd">
<td>F07_02_36C</td>
<td>932.4</td>
</tr>
<tr class="even">
<td>F07_02_ambient</td>
<td>1080.1</td>
</tr>
<tr class="odd">
<td>F07_03_36C</td>
<td>1205.5</td>
</tr>
<tr class="even">
<td>F07_03_ambient</td>
<td>1155.6</td>
</tr>
<tr class="odd">
<td>F07_04_36C</td>
<td>1567.2</td>
</tr>
<tr class="even">
<td>F07_04_ambient</td>
<td>560</td>
</tr>
<tr class="odd">
<td>F07_05_36C</td>
<td>427.9</td>
</tr>
<tr class="even">
<td>F07_05_ambient</td>
<td>659.3</td>
</tr>
<tr class="odd">
<td>F07_06_36C</td>
<td>496.5</td>
</tr>
<tr class="even">
<td>F07_06_ambient</td>
<td>1119.4</td>
</tr>
<tr class="odd">
<td>F07_07_36C</td>
<td>1038.1</td>
</tr>
<tr class="even">
<td>F07_07_ambient</td>
<td>1644.6</td>
</tr>
<tr class="odd">
<td>F07_08_36C</td>
<td>289.8</td>
</tr>
<tr class="even">
<td>F07_08_ambient</td>
<td>560.2</td>
</tr>
</tbody>
</table>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
</section>
<section id="family-5-analysis" class="level1">
<h1>FAMILY 5 ANALYSIS</h1>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Protein quantification (BCA/Bradford-style, 595&nbsp;nm) of <em>Magallana gigas</em> (Pacific oyster) SoRMI plate <code>F05</code>, 16 samples (<code>F05_01</code>-<code>F05_08</code>, ambient and 36°C exposure) plus an 8-point BSA standard curve, each measured in triplicate wells.</p>
<p>The raw Gen5 export (<code>Gen5-20260813-mgig-BSA-F05-absorbance.csv</code>) is a per-well table where each triplicate group’s first row carries the sample/standard ID and the instrument’s own pre-computed mean/SD/CV-of-concentration, and the two replicate rows below it carry only well-level data. This document ignores the instrument’s pre-computed summary columns and recomputes mean, SD, and CV independently in R via <code>dplyr</code>, for both the raw absorbance (595&nbsp;nm) and the concentration.</p>
<p><strong>CV QC metric used for exclusion:</strong> the &gt;15% technical-replicate CV exclusion rule (including for standard-curve points) is applied to <strong>CV of concentration</strong> (matching what the instrument’s own <code>CV (%)</code> column already represents for this export – verified against the raw file: e.g.&nbsp;<code>SPL1</code>’s given Mean/SD/CV of 971.656/77.065/7.931 are exactly the mean/SD/CV of its three <code>[Concentration]</code> values, not of its <code>595</code> values). Concentration CV is the more sensitive metric here: several groups exceed 15% on concentration while none do on raw absorbance, since back-calculation against a curve with a non-zero intercept amplifies small absorbance differences into larger relative concentration differences.</p>
<p>Two edge cases in the raw <code>[Concentration]</code> column need explicit handling:</p>
<ul>
<li><strong>Censored reads.</strong> Wells reading outside the instrument’s own internal standard-curve range are reported as <code>&lt;0.000</code> or <code>&gt;2100.000</code> rather than a number. These are parsed to a <code>_censored</code> flag plus the boundary value, and excluded from concentration mean/SD/CV calculations (their true value is unknown, not equal to the boundary).</li>
<li><strong>The zero (blank) BSA standard</strong> (<code>STD8</code>) is <em>always</em> censored (<code>&lt;0.000</code> on all three wells), by construction – a true-zero standard’s back-calculated concentration is not a meaningful quantity to compute a CV on, and this is not a data-quality problem. <code>STD8</code> is therefore exempt from the concentration-CV exclusion rule and is retained as the curve’s origin point on the strength of its (excellent) 595 CV instead.</li>
</ul>
<p>Any other group left with fewer than 2 valid (non-censored) concentration replicates – e.g.&nbsp;<code>SPL16</code> / <code>F05_08_ambient</code>, where 2 of 3 wells read above the top standard – has an undefined (<code>NA</code>) concentration CV and is treated as failing QC, consistent with the source file itself being unable to compute a CV there either (<code>?????</code>).</p>
</section>
<section id="setup" class="level1">
<h1>2 SETUP</h1>
<section id="libraries" class="level2">
<h2 class="anchored" data-anchor-id="libraries">2.1 Libraries</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="set-output-directory" class="level2">
<h2 class="anchored" data-anchor-id="set-output-directory">2.2 Set output directory</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260813-mgig-BSA-F05"</span></span>
<span id="cb4-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div>
</section>
</section>
<section id="data-import" class="level1">
<h1>3 DATA IMPORT</h1>
<p>The raw file is a Gen5 per-well export with non-syntactic column names (<code>[Concentration]</code>, <code>CV (%)</code>, etc.) and a UTF-8 byte-order mark on the first header cell, so columns are renamed by position immediately after import rather than referenced by their original names.</p>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">data_path <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/Gen5-20260813-mgig-BSA-F05-absorbance.csv"</span></span>
<span id="cb5-2"></span>
<span id="cb5-3">protein_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(data_path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb5-4">                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.strings =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NA"</span>))</span>
<span id="cb5-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(protein_raw) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"name"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"std_conc_known"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"abs_595"</span>,</span>
<span id="cb5-6">                           <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_concentration"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_count"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_mean"</span>,</span>
<span id="cb5-7">                           <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_sd"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_cv"</span>)</span>
<span id="cb5-8"></span>
<span id="cb5-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- protein_raw: as imported from the Gen5 export ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb5-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_raw)</span></code></pre></div>
<pre><code>--- protein_raw: as imported from the Gen5 export ---
'data.frame':   72 obs. of  10 variables:
 $ well_id           : chr  "SPL1" NA NA "SPL2" ...
 $ name              : chr  "F05_01_36C" NA NA "F05_02_36C" ...
 $ well              : chr  "A1" "A2" "A3" "A4" ...
 $ std_conc_known    : int  NA NA NA NA NA NA NA NA NA NA ...
 $ abs_595           : num  1.197 1.147 1.123 0.926 0.973 ...
 $ gen5_concentration: chr  "1056.125" "953.667" "905.177" "506.911" ...
 $ gen5_count        : int  3 NA NA 3 NA NA 3 NA NA 3 ...
 $ gen5_mean         : chr  "971.656" NA NA "579.274" ...
 $ gen5_sd           : chr  "77.065" NA NA "64.041" ...
 $ gen5_cv           : chr  "7.931" NA NA "11.055" ...</code></pre>
</section>
<section id="reshaping" class="level1">
<h1>4 RESHAPING</h1>
<p><code>well_id</code> and <code>name</code> are only populated on the first row of each triplicate group in the raw export, so they are filled downward. Each row is also classified as a <code>standard</code> (<code>well_id</code> starts with <code>STD</code>) or a <code>sample</code> (<code>SPL</code>), and the instrument’s censored concentration strings (<code>&lt;0.000</code>, <code>&gt;2100.000</code>) are parsed into a numeric value plus a <code>gen5_concentration_censored</code> flag.</p>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">protein_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, well, std_conc_known, abs_595, gen5_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fill</span>(well_id, name, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"down"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD"</span>, well_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>),</span>
<span id="cb7-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gen5_concentration_censored =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[&lt;&gt;]"</span>, gen5_concentration),</span>
<span id="cb7-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gen5_concentration_numeric  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[&lt;&gt;]"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, gen5_concentration))</span>
<span id="cb7-8">  )</span>
<span id="cb7-9"></span>
<span id="cb7-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- protein_long: one row per well, group identifiers filled down ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb7-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_long)</span></code></pre></div>
<pre><code>--- protein_long: one row per well, group identifiers filled down ---
'data.frame':   72 obs. of  9 variables:
 $ well_id                    : chr  "SPL1" "SPL1" "SPL1" "SPL2" ...
 $ name                       : chr  "F05_01_36C" "F05_01_36C" "F05_01_36C" "F05_02_36C" ...
 $ well                       : chr  "A1" "A2" "A3" "A4" ...
 $ std_conc_known             : int  NA NA NA NA NA NA NA NA NA NA ...
 $ abs_595                    : num  1.197 1.147 1.123 0.926 0.973 ...
 $ gen5_concentration         : chr  "1056.125" "953.667" "905.177" "506.911" ...
 $ type                       : chr  "sample" "sample" "sample" "sample" ...
 $ gen5_concentration_censored: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ gen5_concentration_numeric : num  1056 954 905 507 602 ...</code></pre>
</section>
<section id="mean-values" class="level1">
<h1>5 MEAN VALUES</h1>
<section id="mean-595-nm-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="mean-595-nm-absorbance">5.1 Mean 595 nm absorbance</h2>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">mean_595_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb9-4">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_595 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(abs_595),</span>
<span id="cb9-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb9-6"></span>
<span id="cb9-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- mean_595_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb9-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(mean_595_by_group)</span></code></pre></div>
<pre><code>--- mean_595_by_group ---
tibble [24 × 6] (S3: tbl_df/tbl/data.frame)
 $ well_id       : chr [1:24] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name          : chr [1:24] "F05_01_36C" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ type          : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ std_conc_known: int [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells       : int [1:24] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595      : num [1:24] 1.16 1.21 1.56 1.24 1.04 ...</code></pre>
</section>
<section id="mean-concentration" class="level2">
<h2 class="anchored" data-anchor-id="mean-concentration">5.2 Mean concentration</h2>
<p>Censored wells (reading outside the instrument’s own standard-curve range) are dropped before averaging, since their true concentration is unknown.</p>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1">mean_conc_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>gen5_concentration_censored) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_valid_conc  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb11-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_concentration  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(gen5_concentration_numeric),</span>
<span id="cb11-6">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb11-7"></span>
<span id="cb11-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- mean_conc_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb11-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(mean_conc_by_group)</span></code></pre></div>
<pre><code>--- mean_conc_by_group ---
tibble [23 × 6] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:23] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name              : chr [1:23] "F05_01_36C" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ type              : chr [1:23] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:23] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells_valid_conc: int [1:23] 3 3 3 3 3 3 3 1 3 3 ...
 $ mean_concentration: num [1:23] 972 1073 1796 1143 739 ...</code></pre>
</section>
</section>
<section id="standard-deviation-and-coefficient-of-variation" class="level1">
<h1>6 STANDARD DEVIATION AND COEFFICIENT OF VARIATION</h1>
<section id="sd-and-cv-of-595-nm-absorbance" class="level2">
<h2 class="anchored" data-anchor-id="sd-and-cv-of-595-nm-absorbance">6.1 SD and CV of 595 nm absorbance</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">sd_cv_595_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb13-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb13-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_595 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(abs_595),</span>
<span id="cb13-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_595   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(abs_595),</span>
<span id="cb13-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_595   =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> sd_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_595,</span>
<span id="cb13-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb13-9">  )</span>
<span id="cb13-10"></span>
<span id="cb13-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- sd_cv_595_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sd_cv_595_by_group)</span></code></pre></div>
<pre><code>--- sd_cv_595_by_group ---
tibble [24 × 8] (S3: tbl_df/tbl/data.frame)
 $ well_id       : chr [1:24] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name          : chr [1:24] "F05_01_36C" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ type          : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ std_conc_known: int [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells       : int [1:24] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595      : num [1:24] 1.16 1.21 1.56 1.24 1.04 ...
 $ sd_595        : num [1:24] 0.0378 0.1275 0.0528 0.0188 0.0146 ...
 $ cv_595        : num [1:24] 3.27 10.58 3.38 1.52 1.4 ...</code></pre>
</section>
<section id="sd-and-cv-of-concentration" class="level2">
<h2 class="anchored" data-anchor-id="sd-and-cv-of-concentration">6.2 SD and CV of concentration</h2>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">sd_cv_conc_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>gen5_concentration_censored) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb15-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_valid_conc  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb15-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_concentration  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(gen5_concentration_numeric),</span>
<span id="cb15-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_concentration    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(gen5_concentration_numeric),</span>
<span id="cb15-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_concentration    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> sd_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_concentration,</span>
<span id="cb15-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb15-10">  )</span>
<span id="cb15-11"></span>
<span id="cb15-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- sd_cv_conc_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sd_cv_conc_by_group)</span></code></pre></div>
<pre><code>--- sd_cv_conc_by_group ---
tibble [23 × 8] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:23] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name              : chr [1:23] "F05_01_36C" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ type              : chr [1:23] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:23] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells_valid_conc: int [1:23] 3 3 3 3 3 3 3 1 3 3 ...
 $ mean_concentration: num [1:23] 972 1073 1796 1143 739 ...
 $ sd_concentration  : num [1:23] 77.1 258.7 107.8 38.2 30.1 ...
 $ cv_concentration  : num [1:23] 7.93 24.1 6 3.34 4.07 ...</code></pre>
</section>
<section id="combined-per-group-summary" class="level2">
<h2 class="anchored" data-anchor-id="combined-per-group-summary">6.3 Combined per-group summary</h2>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sd_cv_595_by_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(</span>
<span id="cb17-3">    sd_cv_conc_by_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-4">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, mean_concentration, sd_concentration, cv_concentration, n_wells_valid_conc),</span>
<span id="cb17-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span></span>
<span id="cb17-6">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(type, well_id)</span>
<span id="cb17-8"></span>
<span id="cb17-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- group_stats: one row per sample/standard, 595- and concentration-level stats ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(group_stats)</span>
<span id="cb17-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(group_stats, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>--- group_stats: one row per sample/standard, 595- and concentration-level stats ---
tibble [24 × 12] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:24] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name              : chr [1:24] "F05_01_36C" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ type              : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells           : int [1:24] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595          : num [1:24] 1.16 1.21 1.56 1.24 1.04 ...
 $ sd_595            : num [1:24] 0.0378 0.1275 0.0528 0.0188 0.0146 ...
 $ cv_595            : num [1:24] 3.27 10.58 3.38 1.52 1.4 ...
 $ mean_concentration: num [1:24] 972 1073 1796 1143 739 ...
 $ sd_concentration  : num [1:24] 77.1 258.7 107.8 38.2 30.1 ...
 $ cv_concentration  : num [1:24] 7.93 24.1 6 3.34 4.07 ...
 $ n_wells_valid_conc: int [1:24] 3 3 3 3 3 3 3 1 3 3 ...</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: left;">name</th>
<th style="text-align: left;">type</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">n_wells</th>
<th style="text-align: right;">mean_595</th>
<th style="text-align: right;">sd_595</th>
<th style="text-align: right;">cv_595</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
<th style="text-align: right;">n_wells_valid_conc</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">SPL1</td>
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.156</td>
<td style="text-align: right;">0.038</td>
<td style="text-align: right;">3.267</td>
<td style="text-align: right;">971.656</td>
<td style="text-align: right;">77.065</td>
<td style="text-align: right;">7.931</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL10</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.206</td>
<td style="text-align: right;">0.128</td>
<td style="text-align: right;">10.575</td>
<td style="text-align: right;">1073.167</td>
<td style="text-align: right;">258.654</td>
<td style="text-align: right;">24.102</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL11</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.562</td>
<td style="text-align: right;">0.053</td>
<td style="text-align: right;">3.379</td>
<td style="text-align: right;">1795.714</td>
<td style="text-align: right;">107.767</td>
<td style="text-align: right;">6.001</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL12</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.240</td>
<td style="text-align: right;">0.019</td>
<td style="text-align: right;">1.518</td>
<td style="text-align: right;">1142.757</td>
<td style="text-align: right;">38.212</td>
<td style="text-align: right;">3.344</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL13</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.041</td>
<td style="text-align: right;">0.015</td>
<td style="text-align: right;">1.400</td>
<td style="text-align: right;">738.878</td>
<td style="text-align: right;">30.098</td>
<td style="text-align: right;">4.074</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL14</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.626</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">3.684</td>
<td style="text-align: right;">1925.899</td>
<td style="text-align: right;">121.472</td>
<td style="text-align: right;">6.307</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL15</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.506</td>
<td style="text-align: right;">0.076</td>
<td style="text-align: right;">5.036</td>
<td style="text-align: right;">1682.300</td>
<td style="text-align: right;">154.559</td>
<td style="text-align: right;">9.187</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL16</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.719</td>
<td style="text-align: right;">0.040</td>
<td style="text-align: right;">2.336</td>
<td style="text-align: right;">2030.183</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL2</td>
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.962</td>
<td style="text-align: right;">0.032</td>
<td style="text-align: right;">3.282</td>
<td style="text-align: right;">579.274</td>
<td style="text-align: right;">64.041</td>
<td style="text-align: right;">11.055</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL3</td>
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.020</td>
<td style="text-align: right;">0.025</td>
<td style="text-align: right;">2.411</td>
<td style="text-align: right;">696.136</td>
<td style="text-align: right;">49.535</td>
<td style="text-align: right;">7.116</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL4</td>
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.208</td>
<td style="text-align: right;">0.008</td>
<td style="text-align: right;">0.643</td>
<td style="text-align: right;">1077.834</td>
<td style="text-align: right;">15.456</td>
<td style="text-align: right;">1.434</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL5</td>
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.496</td>
<td style="text-align: right;">0.075</td>
<td style="text-align: right;">5.025</td>
<td style="text-align: right;">1661.606</td>
<td style="text-align: right;">153.165</td>
<td style="text-align: right;">9.218</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL6</td>
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.305</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">4.575</td>
<td style="text-align: right;">1274.228</td>
<td style="text-align: right;">121.807</td>
<td style="text-align: right;">9.559</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL7</td>
<td style="text-align: left;">F-05_07_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.231</td>
<td style="text-align: right;">0.064</td>
<td style="text-align: right;">5.218</td>
<td style="text-align: right;">1123.956</td>
<td style="text-align: right;">129.443</td>
<td style="text-align: right;">11.517</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL8</td>
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.348</td>
<td style="text-align: right;">0.054</td>
<td style="text-align: right;">4.022</td>
<td style="text-align: right;">1362.619</td>
<td style="text-align: right;">110.153</td>
<td style="text-align: right;">8.084</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL9</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.063</td>
<td style="text-align: right;">0.067</td>
<td style="text-align: right;">6.331</td>
<td style="text-align: right;">782.972</td>
<td style="text-align: right;">136.834</td>
<td style="text-align: right;">17.476</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD1</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">2000</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.560</td>
<td style="text-align: right;">0.059</td>
<td style="text-align: right;">3.802</td>
<td style="text-align: right;">1792.265</td>
<td style="text-align: right;">120.228</td>
<td style="text-align: right;">6.708</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD2</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1500</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.411</td>
<td style="text-align: right;">0.035</td>
<td style="text-align: right;">2.451</td>
<td style="text-align: right;">1490.640</td>
<td style="text-align: right;">69.690</td>
<td style="text-align: right;">4.675</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD3</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1000</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.299</td>
<td style="text-align: right;">0.025</td>
<td style="text-align: right;">1.887</td>
<td style="text-align: right;">1262.866</td>
<td style="text-align: right;">49.516</td>
<td style="text-align: right;">3.921</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD4</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">750</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.145</td>
<td style="text-align: right;">0.055</td>
<td style="text-align: right;">4.809</td>
<td style="text-align: right;">951.300</td>
<td style="text-align: right;">112.197</td>
<td style="text-align: right;">11.794</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD5</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">500</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.960</td>
<td style="text-align: right;">0.025</td>
<td style="text-align: right;">2.551</td>
<td style="text-align: right;">575.554</td>
<td style="text-align: right;">49.611</td>
<td style="text-align: right;">8.620</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD6</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">250</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.768</td>
<td style="text-align: right;">0.029</td>
<td style="text-align: right;">3.794</td>
<td style="text-align: right;">185.471</td>
<td style="text-align: right;">58.758</td>
<td style="text-align: right;">31.680</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD7</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.715</td>
<td style="text-align: right;">0.010</td>
<td style="text-align: right;">1.402</td>
<td style="text-align: right;">77.197</td>
<td style="text-align: right;">21.167</td>
<td style="text-align: right;">27.419</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD8</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.573</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: right;">0.524</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="cv-based-exclusion" class="level1">
<h1>7 CV-BASED EXCLUSION</h1>
<p>Groups with CV(concentration) &gt; 15% – or an undefined concentration CV due to insufficient valid (non-censored) replicates – are flagged and excluded from all downstream analysis, including standard-curve fitting. The zero BSA standard (<code>STD8</code>) is exempt from this rule (see Background) and is always retained.</p>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1">group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb19-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_zero_standard =</span> type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> std_conc_known <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb19-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">high_cv =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_zero_standard <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> cv_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>)</span>
<span id="cb19-5">  )</span>
<span id="cb19-6"></span>
<span id="cb19-7">excluded_groups <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(high_cv)</span>
<span id="cb19-8"></span>
<span id="cb19-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- excluded_groups: CV(concentration) &gt; 15% (or undefined), dropped from further analysis ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(excluded_groups)</span>
<span id="cb19-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_groups <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-12">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, type, std_conc_known, n_wells_valid_conc,</span>
<span id="cb19-13">               mean_concentration, sd_concentration, cv_concentration),</span>
<span id="cb19-14">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb19-15"></span>
<span id="cb19-16">clean_group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>high_cv)</span>
<span id="cb19-17"></span>
<span id="cb19-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Retained after CV exclusion:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(clean_group_stats), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(group_stats), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"groups</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(clean_group_stats)</span></code></pre></div>
<pre><code>--- excluded_groups: CV(concentration) &gt; 15% (or undefined), dropped from further analysis ---
tibble [5 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:5] "SPL10" "SPL16" "SPL9" "STD6" ...
 $ name              : chr [1:5] "F05_02_ambient" "F05_08_ambient" "F05_01_ambient" "BSA" ...
 $ type              : chr [1:5] "sample" "sample" "sample" "standard" ...
 $ std_conc_known    : int [1:5] NA NA NA 250 125
 $ n_wells           : int [1:5] 3 3 3 3 3
 $ mean_595          : num [1:5] 1.206 1.719 1.063 0.768 0.715
 $ sd_595            : num [1:5] 0.1275 0.0401 0.0673 0.0291 0.01
 $ cv_595            : num [1:5] 10.58 2.34 6.33 3.79 1.4
 $ mean_concentration: num [1:5] 1073.2 2030.2 783 185.5 77.2
 $ sd_concentration  : num [1:5] 258.7 NA 136.8 58.8 21.2
 $ cv_concentration  : num [1:5] 24.1 NA 17.5 31.7 27.4
 $ n_wells_valid_conc: int [1:5] 3 1 3 3 3
 $ is_zero_standard  : logi [1:5] FALSE FALSE FALSE FALSE FALSE
 $ high_cv           : logi [1:5] TRUE TRUE TRUE TRUE TRUE</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: left;">name</th>
<th style="text-align: left;">type</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">n_wells_valid_conc</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">SPL10</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1073.167</td>
<td style="text-align: right;">258.654</td>
<td style="text-align: right;">24.102</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL16</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">2030.183</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL9</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">782.972</td>
<td style="text-align: right;">136.834</td>
<td style="text-align: right;">17.476</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD6</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">250</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">185.471</td>
<td style="text-align: right;">58.758</td>
<td style="text-align: right;">31.680</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD7</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">77.197</td>
<td style="text-align: right;">21.167</td>
<td style="text-align: right;">27.419</td>
</tr>
</tbody>
</table>
<pre><code>Retained after CV exclusion: 19 of 24 groups
tibble [19 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:19] "SPL1" "SPL11" "SPL12" "SPL13" ...
 $ name              : chr [1:19] "F05_01_36C" "F05_03_ambient" "F05_04_ambient" "F05_05_ambient" ...
 $ type              : chr [1:19] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:19] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells           : int [1:19] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595          : num [1:19] 1.16 1.56 1.24 1.04 1.63 ...
 $ sd_595            : num [1:19] 0.0378 0.0528 0.0188 0.0146 0.0599 ...
 $ cv_595            : num [1:19] 3.27 3.38 1.52 1.4 3.68 ...
 $ mean_concentration: num [1:19] 972 1796 1143 739 1926 ...
 $ sd_concentration  : num [1:19] 77.1 107.8 38.2 30.1 121.5 ...
 $ cv_concentration  : num [1:19] 7.93 6 3.34 4.07 6.31 ...
 $ n_wells_valid_conc: int [1:19] 3 3 3 3 3 3 3 3 3 3 ...
 $ is_zero_standard  : logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ high_cv           : logi [1:19] FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
</section>
<section id="standard-curve" class="level1">
<h1>8 STANDARD CURVE</h1>
<p>Fit using only the retained (CV ≤ 15%) standard points: known BSA concentration (<code>Conc/Dil</code>) on the x-axis, mean 595&nbsp;nm absorbance on the y-axis.</p>
<div class="sourceCode" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1">standards_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> clean_group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>)</span>
<span id="cb22-2"></span>
<span id="cb22-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- standards_clean: standard points retained for curve fitting ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb22-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_clean)</span>
<span id="cb22-5"></span>
<span id="cb22-6">standard_curve_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean)</span>
<span id="cb22-7"></span>
<span id="cb22-8">curve_slope     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(standard_curve_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb22-9">curve_intercept <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(standard_curve_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb22-10">curve_r2        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(standard_curve_model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb22-11"></span>
<span id="cb22-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve fit: 595 ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"* concentration +"</span>,</span>
<span id="cb22-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_intercept, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb22-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(curve_r2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- standards_clean: standard points retained for curve fitting ---
tibble [6 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:6] "STD1" "STD2" "STD3" "STD4" ...
 $ name              : chr [1:6] "BSA" "BSA" "BSA" "BSA" ...
 $ type              : chr [1:6] "standard" "standard" "standard" "standard" ...
 $ std_conc_known    : int [1:6] 2000 1500 1000 750 500 0
 $ n_wells           : int [1:6] 3 3 3 3 3 3
 $ mean_595          : num [1:6] 1.56 1.41 1.3 1.15 0.96 ...
 $ sd_595            : num [1:6] 0.0593 0.0346 0.0245 0.0551 0.0245 ...
 $ cv_595            : num [1:6] 3.8 2.45 1.89 4.81 2.55 ...
 $ mean_concentration: num [1:6] 1792 1491 1263 951 576 ...
 $ sd_concentration  : num [1:6] 120.2 69.7 49.5 112.2 49.6 ...
 $ cv_concentration  : num [1:6] 6.71 4.68 3.92 11.79 8.62 ...
 $ n_wells_valid_conc: int [1:6] 3 3 3 3 3 NA
 $ is_zero_standard  : logi [1:6] FALSE FALSE FALSE FALSE FALSE TRUE
 $ high_cv           : logi [1:6] FALSE FALSE FALSE FALSE FALSE FALSE
Standard curve fit: 595 = 0.000476359 * concentration + 0.7017 
R2: 0.92345 </code></pre>
<section id="plot-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="plot-standard-curve">8.1 Plot standard curve</h2>
<div class="sourceCode" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1">eq_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scientific =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x + "</span>,</span>
<span id="cb24-2">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_intercept),</span>
<span id="cb24-3">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">R² = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_r2))</span>
<span id="cb24-4"></span>
<span id="cb24-5">standard_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb24-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb24-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> sd_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sd_595),</span>
<span id="cb24-8">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb24-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb24-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> eq_label,</span>
<span id="cb24-11">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.08</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb24-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard concentration (µg/mL)"</span>,</span>
<span id="cb24-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean absorbance (595 nm)"</span>,</span>
<span id="cb24-14">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard curve"</span>,</span>
<span id="cb24-15">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Points with technical-replicate CV(concentration) &gt; 15% excluded (see below)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb24-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb24-17"></span>
<span id="cb24-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(standard_curve_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/Gen5-20260813-mgig-sormi-BSA-F05-protein_files/figure-gfm/plot-standard-curve-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_595.png"</span>), standard_curve_plot,</span>
<span id="cb25-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
<p>Standard points excluded from the curve:</p>
<div class="sourceCode" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1">excluded_standards <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>, high_cv)</span>
<span id="cb26-2"></span>
<span id="cb26-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- excluded_standards ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb26-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(excluded_standards)</span>
<span id="cb26-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_standards <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb26-6">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, std_conc_known, mean_concentration, sd_concentration, cv_concentration),</span>
<span id="cb26-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>--- excluded_standards ---
tibble [2 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:2] "STD6" "STD7"
 $ name              : chr [1:2] "BSA" "BSA"
 $ type              : chr [1:2] "standard" "standard"
 $ std_conc_known    : int [1:2] 250 125
 $ n_wells           : int [1:2] 3 3
 $ mean_595          : num [1:2] 0.768 0.715
 $ sd_595            : num [1:2] 0.0291 0.01
 $ cv_595            : num [1:2] 3.79 1.4
 $ mean_concentration: num [1:2] 185.5 77.2
 $ sd_concentration  : num [1:2] 58.8 21.2
 $ cv_concentration  : num [1:2] 31.7 27.4
 $ n_wells_valid_conc: int [1:2] 3 3
 $ is_zero_standard  : logi [1:2] FALSE FALSE
 $ high_cv           : logi [1:2] TRUE TRUE</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 11%">
<col style="width: 19%">
<col style="width: 24%">
<col style="width: 22%">
<col style="width: 22%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">STD6</td>
<td style="text-align: right;">250</td>
<td style="text-align: right;">185.471</td>
<td style="text-align: right;">58.758</td>
<td style="text-align: right;">31.680</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD7</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">77.197</td>
<td style="text-align: right;">21.167</td>
<td style="text-align: right;">27.419</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="applying-the-standard-curve-to-samples" class="level1">
<h1>9 APPLYING THE STANDARD CURVE TO SAMPLES</h1>
<p>Samples that passed CV QC are back-calculated against the fitted curve. Samples whose mean 595 falls outside the retained standards’ absorbance range are flagged as extrapolated (e.g.&nbsp;<code>F05_08_ambient</code> read above the top standard on 2 of its 3 wells and was excluded above on CV grounds already, since only 1 of its wells had a defined, non-censored concentration).</p>
<div class="sourceCode" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1">samples_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> clean_group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb28-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_595                    =</span> sd_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(n_wells),</span>
<span id="cb28-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">calculated_concentration  =</span> (mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> curve_intercept) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> curve_slope,</span>
<span id="cb28-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_curve_range            =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(standards_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_595) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb28-7">                                  mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(standards_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_595)</span>
<span id="cb28-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(name)</span>
<span id="cb28-10"></span>
<span id="cb28-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- samples_clean: CV-QC-passing samples, quantified against the fitted standard curve ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb28-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples_clean)</span></code></pre></div>
<pre><code>--- samples_clean: CV-QC-passing samples, quantified against the fitted standard curve ---
tibble [13 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id                 : chr [1:13] "SPL7" "SPL1" "SPL2" "SPL3" ...
 $ name                    : chr [1:13] "F-05_07_36C" "F05_01_36C" "F05_02_36C" "F05_03_36C" ...
 $ type                    : chr [1:13] "sample" "sample" "sample" "sample" ...
 $ std_conc_known          : int [1:13] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells                 : int [1:13] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595                : num [1:13] 1.231 1.156 0.962 1.02 1.562 ...
 $ sd_595                  : num [1:13] 0.0642 0.0378 0.0316 0.0246 0.0528 ...
 $ cv_595                  : num [1:13] 5.22 3.27 3.28 2.41 3.38 ...
 $ mean_concentration      : num [1:13] 1124 972 579 696 1796 ...
 $ sd_concentration        : num [1:13] 129.4 77.1 64 49.5 107.8 ...
 $ cv_concentration        : num [1:13] 11.52 7.93 11.06 7.12 6 ...
 $ n_wells_valid_conc      : int [1:13] 3 3 3 3 3 3 3 3 3 3 ...
 $ is_zero_standard        : logi [1:13] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ high_cv                 : logi [1:13] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ se_595                  : num [1:13] 0.0371 0.0218 0.0182 0.0142 0.0305 ...
 $ calculated_concentration: num [1:13] 1111 953 546 668 1805 ...
 $ in_curve_range          : logi [1:13] TRUE TRUE TRUE TRUE FALSE TRUE ...</code></pre>
<div class="sourceCode" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with absorbance outside the retained standard curve's range (extrapolated):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_curve_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb30-3">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, mean_595, calculated_concentration),</span>
<span id="cb30-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>Samples with absorbance outside the retained standard curve's range (extrapolated):</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: left;">name</th>
<th style="text-align: right;">mean_595</th>
<th style="text-align: right;">calculated_concentration</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">SPL11</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">1.562</td>
<td style="text-align: right;">1805.383</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL14</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">1.626</td>
<td style="text-align: right;">1940.435</td>
</tr>
</tbody>
</table>
<section id="plot-samples-on-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="plot-samples-on-standard-curve">9.1 Plot samples on standard curve</h2>
<p>Every QC-passing sample is plotted at its own mean 595 and back-calculated concentration, with vertical error bars of ±1 standard error (of mean 595, across its 2-3 retained technical replicates), overlaid on the standard curve fit line and retained standard points.</p>
<div class="sourceCode" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1">samples_on_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595),</span>
<span id="cb32-3">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb32-4">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595),</span>
<span id="cb32-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> samples_clean,</span>
<span id="cb32-8">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> calculated_concentration,</span>
<span id="cb32-9">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_595),</span>
<span id="cb32-10">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> samples_clean,</span>
<span id="cb32-12">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> calculated_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_curve_range),</span>
<span id="cb32-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"firebrick"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb32-15">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"extrapolated"</span>),</span>
<span id="cb32-16">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample status"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Concentration (µg/mL)"</span>,</span>
<span id="cb32-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean absorbance (595 nm)"</span>,</span>
<span id="cb32-19">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard curve with QC-passing samples overlaid"</span>,</span>
<span id="cb32-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples plotted at their back-calculated concentration; error bars = ±1 SE of mean 595"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb32-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb32-22"></span>
<span id="cb32-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(samples_on_curve_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/Gen5-20260813-mgig-sormi-BSA-F05-protein_files/figure-gfm/plot-samples-on-curve-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_with_samples.png"</span>), samples_on_curve_plot,</span>
<span id="cb33-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
</section>
</section>
<section id="results-table" class="level1">
<h1>10 RESULTS TABLE</h1>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb34-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample                              =</span> name,</span>
<span id="cb34-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> well_id,</span>
<span id="cb34-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean 595</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_595, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb34-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV 595 (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_595, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb34-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV concentration (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>              <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb34-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Calculated concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(calculated_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb34-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In standard curve range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_curve_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO - extrapolated"</span>)</span>
<span id="cb34-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[0-9]+$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Za-z]+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)))</span>
<span id="cb34-12"></span>
<span id="cb34-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th>Well ID</th>
<th style="text-align: right;">Mean 595</th>
<th>CV 595 (%)</th>
<th style="text-align: right;">CV concentration (%)</th>
<th style="text-align: right;">Calculated concentration (ug/mL)</th>
<th style="text-align: left;">In standard curve range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_36C</td>
<td>SPL1</td>
<td style="text-align: right;">1.156</td>
<td>3.27</td>
<td style="text-align: right;">7.93</td>
<td style="text-align: right;">953.1</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_36C</td>
<td>SPL2</td>
<td style="text-align: right;">0.962</td>
<td>3.28</td>
<td style="text-align: right;">11.06</td>
<td style="text-align: right;">545.8</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_36C</td>
<td>SPL3</td>
<td style="text-align: right;">1.020</td>
<td>2.41</td>
<td style="text-align: right;">7.12</td>
<td style="text-align: right;">667.6</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_36C</td>
<td>SPL4</td>
<td style="text-align: right;">1.208</td>
<td>0.64</td>
<td style="text-align: right;">1.43</td>
<td style="text-align: right;">1062.2</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_36C</td>
<td>SPL5</td>
<td style="text-align: right;">1.496</td>
<td>5.03</td>
<td style="text-align: right;">9.22</td>
<td style="text-align: right;">1666.8</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_36C</td>
<td>SPL6</td>
<td style="text-align: right;">1.305</td>
<td>4.57</td>
<td style="text-align: right;">9.56</td>
<td style="text-align: right;">1265.9</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F-05_07_36C</td>
<td>SPL7</td>
<td style="text-align: right;">1.231</td>
<td>5.22</td>
<td style="text-align: right;">11.52</td>
<td style="text-align: right;">1110.5</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_36C</td>
<td>SPL8</td>
<td style="text-align: right;">1.348</td>
<td>4.02</td>
<td style="text-align: right;">8.08</td>
<td style="text-align: right;">1357.5</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td>SPL11</td>
<td style="text-align: right;">1.562</td>
<td>3.38</td>
<td style="text-align: right;">6.00</td>
<td style="text-align: right;">1805.4</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td>SPL12</td>
<td style="text-align: right;">1.240</td>
<td>1.52</td>
<td style="text-align: right;">3.34</td>
<td style="text-align: right;">1129.4</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td>SPL13</td>
<td style="text-align: right;">1.041</td>
<td>1.40</td>
<td style="text-align: right;">4.07</td>
<td style="text-align: right;">711.7</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td>SPL14</td>
<td style="text-align: right;">1.626</td>
<td>3.68</td>
<td style="text-align: right;">6.31</td>
<td style="text-align: right;">1940.4</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td>SPL15</td>
<td style="text-align: right;">1.506</td>
<td>5.04</td>
<td style="text-align: right;">9.19</td>
<td style="text-align: right;">1687.8</td>
<td style="text-align: left;">yes</td>
</tr>
</tbody>
</table>
<p>Only samples passing <em>all</em> QC – CV ≤ 15% and within the retained standard curve’s range (i.e.&nbsp;not extrapolated) – are written to the CSV output.</p>
<div class="sourceCode" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1">results_table_export <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In standard curve range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>)</span>
<span id="cb35-2"></span>
<span id="cb35-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- results_table_export: samples passing all QC (CV and in-range), written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb35-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(results_table_export)</span>
<span id="cb35-5"></span>
<span id="cb35-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table_export, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_protein_concentrations.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<pre><code>--- results_table_export: samples passing all QC (CV and in-range), written to CSV ---
tibble [11 × 7] (S3: tbl_df/tbl/data.frame)
 $ Sample                          : chr [1:11] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_04_36C" ...
 $ Well ID                         : chr [1:11] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ Mean 595                        : num [1:11] 1.156 0.962 1.02 1.208 1.496 ...
 $ CV 595 (%)                      : num [1:11] 3.27 3.28 2.41 0.64 5.03 4.57 5.22 4.02 1.52 1.4 ...
 $ CV concentration (%)            : num [1:11] 7.93 11.06 7.12 1.43 9.22 ...
 $ Calculated concentration (ug/mL): num [1:11] 953 546 668 1062 1667 ...
 $ In standard curve range         : chr [1:11] "yes" "yes" "yes" "yes" ...</code></pre>
</section>
<section id="summary" class="level1">
<h1>11 SUMMARY</h1>
<ul>
<li>24 sample/standard triplicate groups were imported (8 BSA standards, 16 samples).</li>
<li>5 group(s) exceeded 15% technical-replicate CV(concentration), or had an undefined CV from insufficient valid replicates, and were excluded from all downstream analysis: SPL10 (F05_02_ambient), SPL16 (F05_08_ambient), SPL9 (F05_01_ambient), STD6 (BSA), STD7 (BSA).</li>
<li>The BSA standard curve was fit on the 6 remaining standard points: slope = 0.0004764, intercept = 0.7017, R² = 0.9234.</li>
<li>2 CV-QC-passing sample(s) fell outside the retained standard curve’s absorbance range and are flagged as extrapolated in the results table above.</li>
</ul>
<section id="samples-passing-qc" class="level2">
<h2 class="anchored" data-anchor-id="samples-passing-qc">11.1 Samples passing QC</h2>
<p>Sample names are sorted naturally (e.g.&nbsp;<code>F05_02_ambient</code> before <code>F05_10_ambient</code>, and ignoring stray punctuation like the <code>F-05_07_36C</code> typo) rather than by plain lexicographic string order.</p>
<div class="sourceCode" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1">natural_sort_key <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^A-Za-z0-9]"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, x)</span></code></pre></div>
<div class="sourceCode" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1">passing_samples_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_name =</span> name,</span>
<span id="cb38-3">            <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">concentration(ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(calculated_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">natural_sort_key</span>(sample_name))</span>
<span id="cb38-5"></span>
<span id="cb38-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- passing_samples_table: samples passing CV QC, name + calculated concentration ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb38-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(passing_samples_table)</span>
<span id="cb38-8"></span>
<span id="cb38-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(passing_samples_table)</span></code></pre></div>
<pre><code>--- passing_samples_table: samples passing CV QC, name + calculated concentration ---
tibble [13 × 2] (S3: tbl_df/tbl/data.frame)
 $ sample_name         : chr [1:13] "F05_01_36C" "F05_02_36C" "F05_03_36C" "F05_03_ambient" ...
 $ concentration(ug/mL): num [1:13] 953 546 668 1805 1062 ...</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">sample_name</th>
<th style="text-align: right;">concentration(ug/mL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_36C</td>
<td style="text-align: right;">953.1</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_36C</td>
<td style="text-align: right;">545.8</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_36C</td>
<td style="text-align: right;">667.6</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">1805.4</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_04_36C</td>
<td style="text-align: right;">1062.2</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">1129.4</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_36C</td>
<td style="text-align: right;">1666.8</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">711.7</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_06_36C</td>
<td style="text-align: right;">1265.9</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">1940.4</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F-05_07_36C</td>
<td style="text-align: right;">1110.5</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">1687.8</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_08_36C</td>
<td style="text-align: right;">1357.5</td>
</tr>
</tbody>
</table>
</section>
<section id="samples-recommended-for-re-assay" class="level2">
<h2 class="anchored" data-anchor-id="samples-recommended-for-re-assay">11.2 Samples recommended for re-assay</h2>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">failed_qc_samples    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> excluded_groups <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(name)</span>
<span id="cb40-2">extrapolated_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_curve_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(name)</span>
<span id="cb40-3"></span>
<span id="cb40-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- failed_qc_samples: samples excluded from analysis on CV grounds ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(failed_qc_samples)</span>
<span id="cb40-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- extrapolated_samples: QC-passing samples outside the retained standard curve's range ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(extrapolated_samples)</span></code></pre></div>
<pre><code>--- failed_qc_samples: samples excluded from analysis on CV grounds ---
tibble [3 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:3] "SPL9" "SPL10" "SPL16"
 $ name              : chr [1:3] "F05_01_ambient" "F05_02_ambient" "F05_08_ambient"
 $ type              : chr [1:3] "sample" "sample" "sample"
 $ std_conc_known    : int [1:3] NA NA NA
 $ n_wells           : int [1:3] 3 3 3
 $ mean_595          : num [1:3] 1.06 1.21 1.72
 $ sd_595            : num [1:3] 0.0673 0.1275 0.0401
 $ cv_595            : num [1:3] 6.33 10.58 2.34
 $ mean_concentration: num [1:3] 783 1073 2030
 $ sd_concentration  : num [1:3] 137 259 NA
 $ cv_concentration  : num [1:3] 17.5 24.1 NA
 $ n_wells_valid_conc: int [1:3] 3 3 1
 $ is_zero_standard  : logi [1:3] FALSE FALSE FALSE
 $ high_cv           : logi [1:3] TRUE TRUE TRUE

--- extrapolated_samples: QC-passing samples outside the retained standard curve's range ---
tibble [2 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id                 : chr [1:2] "SPL11" "SPL14"
 $ name                    : chr [1:2] "F05_03_ambient" "F05_06_ambient"
 $ type                    : chr [1:2] "sample" "sample"
 $ std_conc_known          : int [1:2] NA NA
 $ n_wells                 : int [1:2] 3 3
 $ mean_595                : num [1:2] 1.56 1.63
 $ sd_595                  : num [1:2] 0.0528 0.0599
 $ cv_595                  : num [1:2] 3.38 3.68
 $ mean_concentration      : num [1:2] 1796 1926
 $ sd_concentration        : num [1:2] 108 121
 $ cv_concentration        : num [1:2] 6 6.31
 $ n_wells_valid_conc      : int [1:2] 3 3
 $ is_zero_standard        : logi [1:2] FALSE FALSE
 $ high_cv                 : logi [1:2] FALSE FALSE
 $ se_595                  : num [1:2] 0.0305 0.0346
 $ calculated_concentration: num [1:2] 1805 1940
 $ in_curve_range          : logi [1:2] FALSE FALSE</code></pre>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1">reassay_candidates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb42-2">  failed_qc_samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> name,</span>
<span id="cb42-4">              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rationale for re-assay</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(</span>
<span id="cb42-5">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_concentration),</span>
<span id="cb42-6">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV undefined (&lt; 2 valid replicates)"</span>,</span>
<span id="cb42-7">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV &gt; 15%"</span></span>
<span id="cb42-8">              ))),</span>
<span id="cb42-9">  extrapolated_samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> name,</span>
<span id="cb42-11">              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rationale for re-assay</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outside standard curve range"</span>)</span>
<span id="cb42-12">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">natural_sort_key</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>))</span>
<span id="cb42-14"></span>
<span id="cb42-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- reassay_candidates: all samples flagged for re-assay, with rationale ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(reassay_candidates)</span>
<span id="cb42-17"></span>
<span id="cb42-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(reassay_candidates)</span></code></pre></div>
<pre><code>--- reassay_candidates: all samples flagged for re-assay, with rationale ---
tibble [5 × 2] (S3: tbl_df/tbl/data.frame)
 $ Sample name           : chr [1:5] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ Rationale for re-assay: chr [1:5] "CV &gt; 15%" "CV &gt; 15%" "outside standard curve range" "outside standard curve range" ...</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Sample name</th>
<th style="text-align: left;">Rationale for re-assay</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">CV &gt; 15%</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">CV &gt; 15%</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">outside standard curve range</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">outside standard curve range</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">CV undefined (&lt; 2 valid replicates)</td>
</tr>
</tbody>
</table>
<hr>
</section>
</section>
<section id="family-7-analysis" class="level1">
<h1>FAMILY 7 ANALYSIS</h1>
</section>
<section id="background-1" class="level1">
<h1>1 BACKGROUND</h1>
<p>Protein quantification (BCA/Bradford-style, 595&nbsp;nm) of <em>Magallana gigas</em> (Pacific oyster) SoRMI plate <code>F07</code>, 16 samples (<code>F07_01</code>-<code>F07_08</code>, ambient and 36°C exposure) plus an 8-point BSA standard curve, each measured in triplicate wells.</p>
<p>The raw Gen5 export (<code>Gen5-20260813-mgig-BSA-F07-absorbance.csv</code>) is a per-well table where each triplicate group’s first row carries the sample/standard ID and the instrument’s own pre-computed mean/SD/CV-of-concentration, and the two replicate rows below it carry only well-level data. This document ignores the instrument’s pre-computed summary columns and recomputes mean, SD, and CV independently in R via <code>dplyr</code>, for both the raw absorbance (595&nbsp;nm) and the concentration.</p>
<p><strong>CV QC metric used for exclusion:</strong> the &gt;15% technical-replicate CV exclusion rule (including for standard-curve points) is applied to <strong>CV of concentration</strong> (matching what the instrument’s own <code>CV (%)</code> column already represents for this export – verified against the raw file: e.g.&nbsp;<code>SPL1</code>’s given Mean/SD/CV of 694.467/49.577/7.139 are exactly the mean/SD/CV of its three <code>[Concentration]</code> values, not of its <code>595</code> values). Concentration CV is the more sensitive metric here: several groups exceed 15% on concentration while none do on raw absorbance, since back-calculation against a curve with a non-zero intercept amplifies small absorbance differences into larger relative concentration differences.</p>
<p>Two edge cases in the raw <code>[Concentration]</code> column need explicit handling:</p>
<ul>
<li><strong>Censored reads.</strong> Wells reading outside the instrument’s own internal standard-curve range are reported as <code>&lt;0.000</code> or <code>&gt;2100.000</code> rather than a number. These are parsed to a <code>_censored</code> flag plus the boundary value, and excluded from concentration mean/SD/CV calculations (their true value is unknown, not equal to the boundary).</li>
<li><strong>The zero (blank) BSA standard</strong> (<code>STD8</code>) is <em>always</em> censored (<code>&lt;0.000</code> on all three wells), by construction – a true-zero standard’s back-calculated concentration is not a meaningful quantity to compute a CV on, and this is not a data-quality problem. <code>STD8</code> is therefore exempt from the concentration-CV exclusion rule and is retained as the curve’s origin point on the strength of its (excellent) 595 CV instead.</li>
</ul>
<p>Any other group left with fewer than 2 valid (non-censored) concentration replicates has an undefined (<code>NA</code>) concentration CV and is treated as failing QC, consistent with the source file itself being unable to compute a CV there either (<code>?????</code>). In this plate’s data, every sample well yields a numeric (non-censored) concentration, so this case only arises for the zero BSA standard (which is exempted, above).</p>
</section>
<section id="setup-1" class="level1">
<h1>2 SETUP</h1>
<section id="libraries-1" class="level2">
<h2 class="anchored" data-anchor-id="libraries-1">2.1 Libraries</h2>
<div class="sourceCode" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb44-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb44-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb46-2"></span>
<span id="cb46-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb46-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb46-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb46-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb46-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb46-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb46-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb46-10">)</span></code></pre></div>
</section>
<section id="set-output-directory-1" class="level2">
<h2 class="anchored" data-anchor-id="set-output-directory-1">2.2 Set output directory</h2>
<div class="sourceCode" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260813-mgig-BSA-F07"</span></span>
<span id="cb47-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div>
</section>
</section>
<section id="data-import-1" class="level1">
<h1>3 DATA IMPORT</h1>
<p>The raw file is a Gen5 per-well export with non-syntactic column names (<code>[Concentration]</code>, <code>CV (%)</code>, etc.) and a UTF-8 byte-order mark on the first header cell, so columns are renamed by position immediately after import rather than referenced by their original names.</p>
<div class="sourceCode" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1">data_path <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/Gen5-20260813-mgig-BSA-F07-absorbance.csv"</span></span>
<span id="cb48-2"></span>
<span id="cb48-3">protein_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(data_path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb48-4">                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.strings =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NA"</span>))</span>
<span id="cb48-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(protein_raw) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"name"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"std_conc_known"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"abs_595"</span>,</span>
<span id="cb48-6">                           <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_concentration"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_count"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_mean"</span>,</span>
<span id="cb48-7">                           <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_sd"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_cv"</span>)</span>
<span id="cb48-8"></span>
<span id="cb48-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- protein_raw: as imported from the Gen5 export ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb48-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_raw)</span></code></pre></div>
<pre><code>--- protein_raw: as imported from the Gen5 export ---
'data.frame':   72 obs. of  10 variables:
 $ well_id           : chr  "SPL1" NA NA "SPL2" ...
 $ name              : chr  "F07_01_36C" NA NA "F07_02_36C" ...
 $ well              : chr  "A1" "A2" "A3" "A4" ...
 $ std_conc_known    : int  NA NA NA NA NA NA NA NA NA NA ...
 $ abs_595           : num  1.01 1.04 1.07 1.15 1.15 ...
 $ gen5_concentration: chr  "645.965" "692.383" "745.053" "909.883" ...
 $ gen5_count        : int  3 NA NA 3 NA NA 3 NA NA 3 ...
 $ gen5_mean         : chr  "694.467" NA NA "953.017" ...
 $ gen5_sd           : chr  "49.577" NA NA "81.025" ...
 $ gen5_cv           : chr  "7.139" NA NA "8.502" ...</code></pre>
</section>
<section id="reshaping-1" class="level1">
<h1>4 RESHAPING</h1>
<p><code>well_id</code> and <code>name</code> are only populated on the first row of each triplicate group in the raw export, so they are filled downward. Each row is also classified as a <code>standard</code> (<code>well_id</code> starts with <code>STD</code>) or a <code>sample</code> (<code>SPL</code>), and the instrument’s censored concentration strings (<code>&lt;0.000</code>, <code>&gt;2100.000</code>) are parsed into a numeric value plus a <code>gen5_concentration_censored</code> flag.</p>
<div class="sourceCode" id="cb50" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1">protein_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, well, std_conc_known, abs_595, gen5_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fill</span>(well_id, name, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"down"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb50-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD"</span>, well_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>),</span>
<span id="cb50-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gen5_concentration_censored =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[&lt;&gt;]"</span>, gen5_concentration),</span>
<span id="cb50-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gen5_concentration_numeric  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[&lt;&gt;]"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, gen5_concentration))</span>
<span id="cb50-8">  )</span>
<span id="cb50-9"></span>
<span id="cb50-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- protein_long: one row per well, group identifiers filled down ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_long)</span></code></pre></div>
<pre><code>--- protein_long: one row per well, group identifiers filled down ---
'data.frame':   72 obs. of  9 variables:
 $ well_id                    : chr  "SPL1" "SPL1" "SPL1" "SPL2" ...
 $ name                       : chr  "F07_01_36C" "F07_01_36C" "F07_01_36C" "F07_02_36C" ...
 $ well                       : chr  "A1" "A2" "A3" "A4" ...
 $ std_conc_known             : int  NA NA NA NA NA NA NA NA NA NA ...
 $ abs_595                    : num  1.01 1.04 1.07 1.15 1.15 ...
 $ gen5_concentration         : chr  "645.965" "692.383" "745.053" "909.883" ...
 $ type                       : chr  "sample" "sample" "sample" "sample" ...
 $ gen5_concentration_censored: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ gen5_concentration_numeric : num  646 692 745 910 903 ...</code></pre>
</section>
<section id="mean-values-1" class="level1">
<h1>5 MEAN VALUES</h1>
<section id="mean-595-nm-absorbance-1" class="level2">
<h2 class="anchored" data-anchor-id="mean-595-nm-absorbance-1">5.1 Mean 595 nm absorbance</h2>
<div class="sourceCode" id="cb52" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb52-1">mean_595_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb52-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb52-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb52-4">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_595 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(abs_595),</span>
<span id="cb52-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb52-6"></span>
<span id="cb52-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- mean_595_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb52-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(mean_595_by_group)</span></code></pre></div>
<pre><code>--- mean_595_by_group ---
tibble [24 × 6] (S3: tbl_df/tbl/data.frame)
 $ well_id       : chr [1:24] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name          : chr [1:24] "F07_01_36C" "F07_02_ambient" "F07_03_ambient" "F07_04_ambient" ...
 $ type          : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ std_conc_known: int [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells       : int [1:24] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595      : num [1:24] 1.04 1.25 1.29 1.02 1.04 ...</code></pre>
</section>
<section id="mean-concentration-1" class="level2">
<h2 class="anchored" data-anchor-id="mean-concentration-1">5.2 Mean concentration</h2>
<p>Censored wells (reading outside the instrument’s own standard-curve range) are dropped before averaging, since their true concentration is unknown.</p>
<div class="sourceCode" id="cb54" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb54-1">mean_conc_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb54-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>gen5_concentration_censored) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb54-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb54-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_valid_conc  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb54-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_concentration  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(gen5_concentration_numeric),</span>
<span id="cb54-6">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb54-7"></span>
<span id="cb54-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- mean_conc_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb54-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(mean_conc_by_group)</span></code></pre></div>
<pre><code>--- mean_conc_by_group ---
tibble [23 × 6] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:23] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name              : chr [1:23] "F07_01_36C" "F07_02_ambient" "F07_03_ambient" "F07_04_ambient" ...
 $ type              : chr [1:23] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:23] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells_valid_conc: int [1:23] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_concentration: num [1:23] 694 1096 1168 652 691 ...</code></pre>
</section>
</section>
<section id="standard-deviation-and-coefficient-of-variation-1" class="level1">
<h1>6 STANDARD DEVIATION AND COEFFICIENT OF VARIATION</h1>
<section id="sd-and-cv-of-595-nm-absorbance-1" class="level2">
<h2 class="anchored" data-anchor-id="sd-and-cv-of-595-nm-absorbance-1">6.1 SD and CV of 595 nm absorbance</h2>
<div class="sourceCode" id="cb56" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb56-1">sd_cv_595_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb56-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb56-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb56-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb56-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_595 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(abs_595),</span>
<span id="cb56-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_595   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(abs_595),</span>
<span id="cb56-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_595   =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> sd_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_595,</span>
<span id="cb56-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb56-9">  )</span>
<span id="cb56-10"></span>
<span id="cb56-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- sd_cv_595_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb56-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sd_cv_595_by_group)</span></code></pre></div>
<pre><code>--- sd_cv_595_by_group ---
tibble [24 × 8] (S3: tbl_df/tbl/data.frame)
 $ well_id       : chr [1:24] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name          : chr [1:24] "F07_01_36C" "F07_02_ambient" "F07_03_ambient" "F07_04_ambient" ...
 $ type          : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ std_conc_known: int [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells       : int [1:24] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595      : num [1:24] 1.04 1.25 1.29 1.02 1.04 ...
 $ sd_595        : num [1:24] 0.0265 0.0505 0.073 0.0835 0.0481 ...
 $ cv_595        : num [1:24] 2.55 4.03 5.66 8.2 4.64 ...</code></pre>
</section>
<section id="sd-and-cv-of-concentration-1" class="level2">
<h2 class="anchored" data-anchor-id="sd-and-cv-of-concentration-1">6.2 SD and CV of concentration</h2>
<div class="sourceCode" id="cb58" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb58-1">sd_cv_conc_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>gen5_concentration_censored) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb58-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb58-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_valid_conc  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb58-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_concentration  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(gen5_concentration_numeric),</span>
<span id="cb58-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_concentration    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(gen5_concentration_numeric),</span>
<span id="cb58-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_concentration    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> sd_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_concentration,</span>
<span id="cb58-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb58-10">  )</span>
<span id="cb58-11"></span>
<span id="cb58-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- sd_cv_conc_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb58-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sd_cv_conc_by_group)</span></code></pre></div>
<pre><code>--- sd_cv_conc_by_group ---
tibble [23 × 8] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:23] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name              : chr [1:23] "F07_01_36C" "F07_02_ambient" "F07_03_ambient" "F07_04_ambient" ...
 $ type              : chr [1:23] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:23] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells_valid_conc: int [1:23] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_concentration: num [1:23] 694 1096 1168 652 691 ...
 $ sd_concentration  : num [1:23] 49.6 95.8 138.6 157.5 91.5 ...
 $ cv_concentration  : num [1:23] 7.14 8.74 11.87 24.15 13.24 ...</code></pre>
</section>
<section id="combined-per-group-summary-1" class="level2">
<h2 class="anchored" data-anchor-id="combined-per-group-summary-1">6.3 Combined per-group summary</h2>
<div class="sourceCode" id="cb60" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb60-1">group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sd_cv_595_by_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb60-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(</span>
<span id="cb60-3">    sd_cv_conc_by_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb60-4">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, mean_concentration, sd_concentration, cv_concentration, n_wells_valid_conc),</span>
<span id="cb60-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span></span>
<span id="cb60-6">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb60-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(type, well_id)</span>
<span id="cb60-8"></span>
<span id="cb60-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- group_stats: one row per sample/standard, 595- and concentration-level stats ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb60-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(group_stats)</span>
<span id="cb60-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(group_stats, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>--- group_stats: one row per sample/standard, 595- and concentration-level stats ---
tibble [24 × 12] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:24] "SPL1" "SPL10" "SPL11" "SPL12" ...
 $ name              : chr [1:24] "F07_01_36C" "F07_02_ambient" "F07_03_ambient" "F07_04_ambient" ...
 $ type              : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells           : int [1:24] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595          : num [1:24] 1.04 1.25 1.29 1.02 1.04 ...
 $ sd_595            : num [1:24] 0.0265 0.0505 0.073 0.0835 0.0481 ...
 $ cv_595            : num [1:24] 2.55 4.03 5.66 8.2 4.64 ...
 $ mean_concentration: num [1:24] 694 1096 1168 652 691 ...
 $ sd_concentration  : num [1:24] 49.6 95.8 138.6 157.5 91.5 ...
 $ cv_concentration  : num [1:24] 7.14 8.74 11.87 24.15 13.24 ...
 $ n_wells_valid_conc: int [1:24] 3 3 3 3 3 3 3 3 3 3 ...</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: left;">name</th>
<th style="text-align: left;">type</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">n_wells</th>
<th style="text-align: right;">mean_595</th>
<th style="text-align: right;">sd_595</th>
<th style="text-align: right;">cv_595</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
<th style="text-align: right;">n_wells_valid_conc</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">SPL1</td>
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.040</td>
<td style="text-align: right;">0.027</td>
<td style="text-align: right;">2.549</td>
<td style="text-align: right;">694.467</td>
<td style="text-align: right;">49.577</td>
<td style="text-align: right;">7.139</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL10</td>
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.252</td>
<td style="text-align: right;">0.051</td>
<td style="text-align: right;">4.035</td>
<td style="text-align: right;">1095.807</td>
<td style="text-align: right;">95.759</td>
<td style="text-align: right;">8.739</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL11</td>
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.290</td>
<td style="text-align: right;">0.073</td>
<td style="text-align: right;">5.658</td>
<td style="text-align: right;">1168.307</td>
<td style="text-align: right;">138.620</td>
<td style="text-align: right;">11.865</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL12</td>
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.018</td>
<td style="text-align: right;">0.083</td>
<td style="text-align: right;">8.203</td>
<td style="text-align: right;">652.091</td>
<td style="text-align: right;">157.509</td>
<td style="text-align: right;">24.154</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL13</td>
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.038</td>
<td style="text-align: right;">0.048</td>
<td style="text-align: right;">4.637</td>
<td style="text-align: right;">690.741</td>
<td style="text-align: right;">91.456</td>
<td style="text-align: right;">13.240</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL14</td>
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.296</td>
<td style="text-align: right;">0.099</td>
<td style="text-align: right;">7.647</td>
<td style="text-align: right;">1178.349</td>
<td style="text-align: right;">187.114</td>
<td style="text-align: right;">15.879</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL15</td>
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.538</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">3.922</td>
<td style="text-align: right;">1638.927</td>
<td style="text-align: right;">114.400</td>
<td style="text-align: right;">6.980</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL16</td>
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.988</td>
<td style="text-align: right;">0.022</td>
<td style="text-align: right;">2.184</td>
<td style="text-align: right;">595.253</td>
<td style="text-align: right;">41.154</td>
<td style="text-align: right;">6.914</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL2</td>
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.177</td>
<td style="text-align: right;">0.043</td>
<td style="text-align: right;">3.635</td>
<td style="text-align: right;">953.017</td>
<td style="text-align: right;">81.025</td>
<td style="text-align: right;">8.502</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL3</td>
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.315</td>
<td style="text-align: right;">0.024</td>
<td style="text-align: right;">1.841</td>
<td style="text-align: right;">1216.746</td>
<td style="text-align: right;">46.107</td>
<td style="text-align: right;">3.789</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL4</td>
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.499</td>
<td style="text-align: right;">0.016</td>
<td style="text-align: right;">1.048</td>
<td style="text-align: right;">1564.027</td>
<td style="text-align: right;">29.665</td>
<td style="text-align: right;">1.897</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL5</td>
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.878</td>
<td style="text-align: right;">0.031</td>
<td style="text-align: right;">3.585</td>
<td style="text-align: right;">388.299</td>
<td style="text-align: right;">59.694</td>
<td style="text-align: right;">15.373</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL6</td>
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.955</td>
<td style="text-align: right;">0.008</td>
<td style="text-align: right;">0.813</td>
<td style="text-align: right;">533.741</td>
<td style="text-align: right;">14.556</td>
<td style="text-align: right;">2.727</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL7</td>
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.230</td>
<td style="text-align: right;">0.033</td>
<td style="text-align: right;">2.689</td>
<td style="text-align: right;">1054.821</td>
<td style="text-align: right;">63.068</td>
<td style="text-align: right;">5.979</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL8</td>
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.850</td>
<td style="text-align: right;">0.023</td>
<td style="text-align: right;">2.675</td>
<td style="text-align: right;">334.997</td>
<td style="text-align: right;">42.754</td>
<td style="text-align: right;">12.762</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL9</td>
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.805</td>
<td style="text-align: right;">0.059</td>
<td style="text-align: right;">7.285</td>
<td style="text-align: right;">249.551</td>
<td style="text-align: right;">110.645</td>
<td style="text-align: right;">44.338</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD1</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">2000</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.600</td>
<td style="text-align: right;">0.023</td>
<td style="text-align: right;">1.442</td>
<td style="text-align: right;">1755.192</td>
<td style="text-align: right;">43.330</td>
<td style="text-align: right;">2.469</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD2</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1500</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.492</td>
<td style="text-align: right;">0.021</td>
<td style="text-align: right;">1.423</td>
<td style="text-align: right;">1549.754</td>
<td style="text-align: right;">40.397</td>
<td style="text-align: right;">2.607</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD3</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1000</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.342</td>
<td style="text-align: right;">0.031</td>
<td style="text-align: right;">2.328</td>
<td style="text-align: right;">1266.321</td>
<td style="text-align: right;">59.723</td>
<td style="text-align: right;">4.716</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD4</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">750</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.164</td>
<td style="text-align: right;">0.039</td>
<td style="text-align: right;">3.324</td>
<td style="text-align: right;">930.092</td>
<td style="text-align: right;">73.726</td>
<td style="text-align: right;">7.927</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD5</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">500</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.970</td>
<td style="text-align: right;">0.024</td>
<td style="text-align: right;">2.455</td>
<td style="text-align: right;">561.213</td>
<td style="text-align: right;">44.720</td>
<td style="text-align: right;">7.968</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD6</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">250</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.796</td>
<td style="text-align: right;">0.030</td>
<td style="text-align: right;">3.726</td>
<td style="text-align: right;">232.689</td>
<td style="text-align: right;">55.661</td>
<td style="text-align: right;">23.921</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD7</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.686</td>
<td style="text-align: right;">0.016</td>
<td style="text-align: right;">2.314</td>
<td style="text-align: right;">23.525</td>
<td style="text-align: right;">29.610</td>
<td style="text-align: right;">125.869</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD8</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.571</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: right;">1.165</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="cv-based-exclusion-1" class="level1">
<h1>7 CV-BASED EXCLUSION</h1>
<p>Groups with CV(concentration) &gt; 15% – or an undefined concentration CV due to insufficient valid (non-censored) replicates – are flagged and excluded from all downstream analysis, including standard-curve fitting. The zero BSA standard (<code>STD8</code>) is exempt from this rule (see Background) and is always retained.</p>
<div class="sourceCode" id="cb62" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb62-1">group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb62-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_zero_standard =</span> type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> std_conc_known <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb62-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">high_cv =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_zero_standard <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> cv_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>)</span>
<span id="cb62-5">  )</span>
<span id="cb62-6"></span>
<span id="cb62-7">excluded_groups <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(high_cv)</span>
<span id="cb62-8"></span>
<span id="cb62-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- excluded_groups: CV(concentration) &gt; 15% (or undefined), dropped from further analysis ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb62-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(excluded_groups)</span>
<span id="cb62-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_groups <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb62-12">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, type, std_conc_known, n_wells_valid_conc,</span>
<span id="cb62-13">               mean_concentration, sd_concentration, cv_concentration),</span>
<span id="cb62-14">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb62-15"></span>
<span id="cb62-16">clean_group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>high_cv)</span>
<span id="cb62-17"></span>
<span id="cb62-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Retained after CV exclusion:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(clean_group_stats), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(group_stats), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"groups</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb62-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(clean_group_stats)</span></code></pre></div>
<pre><code>--- excluded_groups: CV(concentration) &gt; 15% (or undefined), dropped from further analysis ---
tibble [6 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:6] "SPL12" "SPL14" "SPL5" "SPL9" ...
 $ name              : chr [1:6] "F07_04_ambient" "F07_06_ambient" "F07_05_36C" "F07_01_ambient" ...
 $ type              : chr [1:6] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:6] NA NA NA NA 250 125
 $ n_wells           : int [1:6] 3 3 3 3 3 3
 $ mean_595          : num [1:6] 1.018 1.296 0.878 0.805 0.796 ...
 $ sd_595            : num [1:6] 0.0835 0.0991 0.0315 0.0586 0.0297 ...
 $ cv_595            : num [1:6] 8.2 7.65 3.59 7.28 3.73 ...
 $ mean_concentration: num [1:6] 652 1178 388 250 233 ...
 $ sd_concentration  : num [1:6] 157.5 187.1 59.7 110.6 55.7 ...
 $ cv_concentration  : num [1:6] 24.2 15.9 15.4 44.3 23.9 ...
 $ n_wells_valid_conc: int [1:6] 3 3 3 3 3 3
 $ is_zero_standard  : logi [1:6] FALSE FALSE FALSE FALSE FALSE FALSE
 $ high_cv           : logi [1:6] TRUE TRUE TRUE TRUE TRUE TRUE</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: left;">name</th>
<th style="text-align: left;">type</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">n_wells_valid_conc</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">SPL12</td>
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">652.091</td>
<td style="text-align: right;">157.509</td>
<td style="text-align: right;">24.154</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL14</td>
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1178.349</td>
<td style="text-align: right;">187.114</td>
<td style="text-align: right;">15.879</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL5</td>
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">388.299</td>
<td style="text-align: right;">59.694</td>
<td style="text-align: right;">15.373</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL9</td>
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">249.551</td>
<td style="text-align: right;">110.645</td>
<td style="text-align: right;">44.338</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD6</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">250</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">232.689</td>
<td style="text-align: right;">55.661</td>
<td style="text-align: right;">23.921</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD7</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">23.525</td>
<td style="text-align: right;">29.610</td>
<td style="text-align: right;">125.869</td>
</tr>
</tbody>
</table>
<pre><code>Retained after CV exclusion: 18 of 24 groups
tibble [18 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:18] "SPL1" "SPL10" "SPL11" "SPL13" ...
 $ name              : chr [1:18] "F07_01_36C" "F07_02_ambient" "F07_03_ambient" "F07_05_ambient" ...
 $ type              : chr [1:18] "sample" "sample" "sample" "sample" ...
 $ std_conc_known    : int [1:18] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells           : int [1:18] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595          : num [1:18] 1.04 1.25 1.29 1.04 1.54 ...
 $ sd_595            : num [1:18] 0.0265 0.0505 0.073 0.0481 0.0603 ...
 $ cv_595            : num [1:18] 2.55 4.03 5.66 4.64 3.92 ...
 $ mean_concentration: num [1:18] 694 1096 1168 691 1639 ...
 $ sd_concentration  : num [1:18] 49.6 95.8 138.6 91.5 114.4 ...
 $ cv_concentration  : num [1:18] 7.14 8.74 11.87 13.24 6.98 ...
 $ n_wells_valid_conc: int [1:18] 3 3 3 3 3 3 3 3 3 3 ...
 $ is_zero_standard  : logi [1:18] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ high_cv           : logi [1:18] FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
</section>
<section id="standard-curve-1" class="level1">
<h1>8 STANDARD CURVE</h1>
<p>Fit using only the retained (CV ≤ 15%) standard points: known BSA concentration (<code>Conc/Dil</code>) on the x-axis, mean 595&nbsp;nm absorbance on the y-axis.</p>
<div class="sourceCode" id="cb65" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb65-1">standards_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> clean_group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>)</span>
<span id="cb65-2"></span>
<span id="cb65-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- standards_clean: standard points retained for curve fitting ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb65-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_clean)</span>
<span id="cb65-5"></span>
<span id="cb65-6">standard_curve_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean)</span>
<span id="cb65-7"></span>
<span id="cb65-8">curve_slope     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(standard_curve_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb65-9">curve_intercept <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(standard_curve_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb65-10">curve_r2        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(standard_curve_model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb65-11"></span>
<span id="cb65-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve fit: 595 ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"* concentration +"</span>,</span>
<span id="cb65-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_intercept, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb65-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(curve_r2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- standards_clean: standard points retained for curve fitting ---
tibble [6 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:6] "STD1" "STD2" "STD3" "STD4" ...
 $ name              : chr [1:6] "BSA" "BSA" "BSA" "BSA" ...
 $ type              : chr [1:6] "standard" "standard" "standard" "standard" ...
 $ std_conc_known    : int [1:6] 2000 1500 1000 750 500 0
 $ n_wells           : int [1:6] 3 3 3 3 3 3
 $ mean_595          : num [1:6] 1.6 1.49 1.34 1.16 0.97 ...
 $ sd_595            : num [1:6] 0.0231 0.0212 0.0312 0.0387 0.0238 ...
 $ cv_595            : num [1:6] 1.44 1.42 2.33 3.32 2.45 ...
 $ mean_concentration: num [1:6] 1755 1550 1266 930 561 ...
 $ sd_concentration  : num [1:6] 43.3 40.4 59.7 73.7 44.7 ...
 $ cv_concentration  : num [1:6] 2.47 2.61 4.72 7.93 7.97 ...
 $ n_wells_valid_conc: int [1:6] 3 3 3 3 3 NA
 $ is_zero_standard  : logi [1:6] FALSE FALSE FALSE FALSE FALSE TRUE
 $ high_cv           : logi [1:6] FALSE FALSE FALSE FALSE FALSE FALSE
Standard curve fit: 595 = 0.000507804 * concentration + 0.7032 
R2: 0.92166 </code></pre>
<section id="plot-standard-curve-1" class="level2">
<h2 class="anchored" data-anchor-id="plot-standard-curve-1">8.1 Plot standard curve</h2>
<div class="sourceCode" id="cb67" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb67-1">eq_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scientific =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x + "</span>,</span>
<span id="cb67-2">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_intercept),</span>
<span id="cb67-3">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">R² = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_r2))</span>
<span id="cb67-4"></span>
<span id="cb67-5">standard_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> sd_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sd_595),</span>
<span id="cb67-8">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> eq_label,</span>
<span id="cb67-11">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.08</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard concentration (µg/mL)"</span>,</span>
<span id="cb67-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean absorbance (595 nm)"</span>,</span>
<span id="cb67-14">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard curve"</span>,</span>
<span id="cb67-15">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Points with technical-replicate CV(concentration) &gt; 15% excluded (see below)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb67-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb67-17"></span>
<span id="cb67-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(standard_curve_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/Gen5-20260813-mgig-sormi-BSA-F07-protein_files/figure-gfm/plot-standard-curve-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb68" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb68-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_595.png"</span>), standard_curve_plot,</span>
<span id="cb68-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
<p>Standard points excluded from the curve:</p>
<div class="sourceCode" id="cb69" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb69-1">excluded_standards <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>, high_cv)</span>
<span id="cb69-2"></span>
<span id="cb69-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- excluded_standards ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb69-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(excluded_standards)</span>
<span id="cb69-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_standards <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb69-6">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, std_conc_known, mean_concentration, sd_concentration, cv_concentration),</span>
<span id="cb69-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>--- excluded_standards ---
tibble [2 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:2] "STD6" "STD7"
 $ name              : chr [1:2] "BSA" "BSA"
 $ type              : chr [1:2] "standard" "standard"
 $ std_conc_known    : int [1:2] 250 125
 $ n_wells           : int [1:2] 3 3
 $ mean_595          : num [1:2] 0.796 0.686
 $ sd_595            : num [1:2] 0.0297 0.0159
 $ cv_595            : num [1:2] 3.73 2.31
 $ mean_concentration: num [1:2] 232.7 23.5
 $ sd_concentration  : num [1:2] 55.7 29.6
 $ cv_concentration  : num [1:2] 23.9 125.9
 $ n_wells_valid_conc: int [1:2] 3 3
 $ is_zero_standard  : logi [1:2] FALSE FALSE
 $ high_cv           : logi [1:2] TRUE TRUE</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 11%">
<col style="width: 19%">
<col style="width: 24%">
<col style="width: 22%">
<col style="width: 22%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">STD6</td>
<td style="text-align: right;">250</td>
<td style="text-align: right;">232.689</td>
<td style="text-align: right;">55.661</td>
<td style="text-align: right;">23.921</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD7</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">23.525</td>
<td style="text-align: right;">29.610</td>
<td style="text-align: right;">125.869</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="applying-the-standard-curve-to-samples-1" class="level1">
<h1>9 APPLYING THE STANDARD CURVE TO SAMPLES</h1>
<p>Samples that passed CV QC are back-calculated against the fitted curve. Samples whose mean 595 falls outside the retained standards’ absorbance range are flagged as extrapolated.</p>
<div class="sourceCode" id="cb71" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb71-1">samples_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> clean_group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb71-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb71-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb71-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_595                    =</span> sd_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(n_wells),</span>
<span id="cb71-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">calculated_concentration  =</span> (mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> curve_intercept) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> curve_slope,</span>
<span id="cb71-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_curve_range            =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(standards_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_595) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb71-7">                                  mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(standards_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_595)</span>
<span id="cb71-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb71-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(name)</span>
<span id="cb71-10"></span>
<span id="cb71-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- samples_clean: CV-QC-passing samples, quantified against the fitted standard curve ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb71-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples_clean)</span></code></pre></div>
<pre><code>--- samples_clean: CV-QC-passing samples, quantified against the fitted standard curve ---
tibble [12 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id                 : chr [1:12] "SPL1" "SPL2" "SPL10" "SPL3" ...
 $ name                    : chr [1:12] "F07_01_36C" "F07_02_36C" "F07_02_ambient" "F07_03_36C" ...
 $ type                    : chr [1:12] "sample" "sample" "sample" "sample" ...
 $ std_conc_known          : int [1:12] NA NA NA NA NA NA NA NA NA NA ...
 $ n_wells                 : int [1:12] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595                : num [1:12] 1.04 1.18 1.25 1.32 1.29 ...
 $ sd_595                  : num [1:12] 0.0265 0.0428 0.0505 0.0242 0.073 ...
 $ cv_595                  : num [1:12] 2.55 3.63 4.03 1.84 5.66 ...
 $ mean_concentration      : num [1:12] 694 953 1096 1217 1168 ...
 $ sd_concentration        : num [1:12] 49.6 81 95.8 46.1 138.6 ...
 $ cv_concentration        : num [1:12] 7.14 8.5 8.74 3.79 11.87 ...
 $ n_wells_valid_conc      : int [1:12] 3 3 3 3 3 3 3 3 3 3 ...
 $ is_zero_standard        : logi [1:12] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ high_cv                 : logi [1:12] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ se_595                  : num [1:12] 0.0153 0.0247 0.0292 0.014 0.0421 ...
 $ calculated_concentration: num [1:12] 663 932 1080 1205 1156 ...
 $ in_curve_range          : logi [1:12] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<div class="sourceCode" id="cb73" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb73-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with absorbance outside the retained standard curve's range (extrapolated):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb73-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_curve_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb73-3">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, mean_595, calculated_concentration),</span>
<span id="cb73-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>Samples with absorbance outside the retained standard curve's range (extrapolated):</code></pre>
<p>well_id name mean_595 calculated_concentration ——— —— ———- ————————–</p>
<section id="plot-samples-on-standard-curve-1" class="level2">
<h2 class="anchored" data-anchor-id="plot-samples-on-standard-curve-1">9.1 Plot samples on standard curve</h2>
<p>Every QC-passing sample is plotted at its own mean 595 and back-calculated concentration, with vertical error bars of ±1 standard error (of mean 595, across its 2-3 retained technical replicates), overlaid on the standard curve fit line and retained standard points.</p>
<div class="sourceCode" id="cb75" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb75-1">samples_on_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb75-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595),</span>
<span id="cb75-3">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb75-4">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb75-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595),</span>
<span id="cb75-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb75-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> samples_clean,</span>
<span id="cb75-8">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> calculated_concentration,</span>
<span id="cb75-9">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_595),</span>
<span id="cb75-10">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb75-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> samples_clean,</span>
<span id="cb75-12">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> calculated_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_curve_range),</span>
<span id="cb75-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"firebrick"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb75-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb75-15">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"extrapolated"</span>),</span>
<span id="cb75-16">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample status"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb75-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Concentration (µg/mL)"</span>,</span>
<span id="cb75-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean absorbance (595 nm)"</span>,</span>
<span id="cb75-19">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard curve with QC-passing samples overlaid"</span>,</span>
<span id="cb75-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples plotted at their back-calculated concentration; error bars = ±1 SE of mean 595"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb75-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb75-22"></span>
<span id="cb75-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(samples_on_curve_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/Gen5-20260813-mgig-sormi-BSA-F07-protein_files/figure-gfm/plot-samples-on-curve-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb76" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb76-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_with_samples.png"</span>), samples_on_curve_plot,</span>
<span id="cb76-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
</section>
</section>
<section id="results-table-1" class="level1">
<h1>10 RESULTS TABLE</h1>
<div class="sourceCode" id="cb77" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb77-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb77-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb77-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample                              =</span> name,</span>
<span id="cb77-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> well_id,</span>
<span id="cb77-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean 595</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_595, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb77-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV 595 (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_595, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb77-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV concentration (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>              <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb77-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Calculated concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(calculated_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb77-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In standard curve range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_curve_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO - extrapolated"</span>)</span>
<span id="cb77-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb77-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[0-9]+$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Za-z]+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)))</span>
<span id="cb77-12"></span>
<span id="cb77-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th>Well ID</th>
<th style="text-align: right;">Mean 595</th>
<th>CV 595 (%)</th>
<th style="text-align: right;">CV concentration (%)</th>
<th style="text-align: right;">Calculated concentration (ug/mL)</th>
<th style="text-align: left;">In standard curve range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07_01_36C</td>
<td>SPL1</td>
<td style="text-align: right;">1.040</td>
<td>2.55</td>
<td style="text-align: right;">7.14</td>
<td style="text-align: right;">663.3</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_36C</td>
<td>SPL2</td>
<td style="text-align: right;">1.177</td>
<td>3.63</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">932.4</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_36C</td>
<td>SPL3</td>
<td style="text-align: right;">1.315</td>
<td>1.84</td>
<td style="text-align: right;">3.79</td>
<td style="text-align: right;">1205.5</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_36C</td>
<td>SPL4</td>
<td style="text-align: right;">1.499</td>
<td>1.05</td>
<td style="text-align: right;">1.90</td>
<td style="text-align: right;">1567.2</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_06_36C</td>
<td>SPL6</td>
<td style="text-align: right;">0.955</td>
<td>0.81</td>
<td style="text-align: right;">2.73</td>
<td style="text-align: right;">496.5</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_07_36C</td>
<td>SPL7</td>
<td style="text-align: right;">1.230</td>
<td>2.69</td>
<td style="text-align: right;">5.98</td>
<td style="text-align: right;">1038.1</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_08_36C</td>
<td>SPL8</td>
<td style="text-align: right;">0.850</td>
<td>2.67</td>
<td style="text-align: right;">12.76</td>
<td style="text-align: right;">289.8</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_ambient</td>
<td>SPL10</td>
<td style="text-align: right;">1.252</td>
<td>4.03</td>
<td style="text-align: right;">8.74</td>
<td style="text-align: right;">1080.1</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_ambient</td>
<td>SPL11</td>
<td style="text-align: right;">1.290</td>
<td>5.66</td>
<td style="text-align: right;">11.87</td>
<td style="text-align: right;">1155.6</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_05_ambient</td>
<td>SPL13</td>
<td style="text-align: right;">1.038</td>
<td>4.64</td>
<td style="text-align: right;">13.24</td>
<td style="text-align: right;">659.3</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_ambient</td>
<td>SPL15</td>
<td style="text-align: right;">1.538</td>
<td>3.92</td>
<td style="text-align: right;">6.98</td>
<td style="text-align: right;">1644.6</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_ambient</td>
<td>SPL16</td>
<td style="text-align: right;">0.988</td>
<td>2.18</td>
<td style="text-align: right;">6.91</td>
<td style="text-align: right;">560.2</td>
<td style="text-align: left;">yes</td>
</tr>
</tbody>
</table>
<p>Only samples passing <em>all</em> QC – CV ≤ 15% and within the retained standard curve’s range (i.e.&nbsp;not extrapolated) – are written to the CSV output.</p>
<div class="sourceCode" id="cb78" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb78-1">results_table_export <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In standard curve range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>)</span>
<span id="cb78-2"></span>
<span id="cb78-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- results_table_export: samples passing all QC (CV and in-range), written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb78-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(results_table_export)</span>
<span id="cb78-5"></span>
<span id="cb78-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table_export, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_protein_concentrations.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<pre><code>--- results_table_export: samples passing all QC (CV and in-range), written to CSV ---
tibble [12 × 7] (S3: tbl_df/tbl/data.frame)
 $ Sample                          : chr [1:12] "F07_01_36C" "F07_02_36C" "F07_03_36C" "F07_04_36C" ...
 $ Well ID                         : chr [1:12] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ Mean 595                        : num [1:12] 1.04 1.177 1.315 1.499 0.955 ...
 $ CV 595 (%)                      : num [1:12] 2.55 3.63 1.84 1.05 0.81 2.69 2.67 4.03 5.66 4.64 ...
 $ CV concentration (%)            : num [1:12] 7.14 8.5 3.79 1.9 2.73 ...
 $ Calculated concentration (ug/mL): num [1:12] 663 932 1206 1567 496 ...
 $ In standard curve range         : chr [1:12] "yes" "yes" "yes" "yes" ...</code></pre>
</section>
<section id="summary-1" class="level1">
<h1>11 SUMMARY</h1>
<ul>
<li>24 sample/standard triplicate groups were imported (8 BSA standards, 16 samples).</li>
<li>6 group(s) exceeded 15% technical-replicate CV(concentration), or had an undefined CV from insufficient valid replicates, and were excluded from all downstream analysis: SPL12 (F07_04_ambient), SPL14 (F07_06_ambient), SPL5 (F07_05_36C), SPL9 (F07_01_ambient), STD6 (BSA), STD7 (BSA).</li>
<li>The BSA standard curve was fit on the 6 remaining standard points: slope = 0.0005078, intercept = 0.7032, R² = 0.9217.</li>
<li>0 CV-QC-passing sample(s) fell outside the retained standard curve’s absorbance range and are flagged as extrapolated in the results table above.</li>
</ul>
<section id="samples-passing-qc-1" class="level2">
<h2 class="anchored" data-anchor-id="samples-passing-qc-1">11.1 Samples passing QC</h2>
<p>Sample names are sorted naturally (e.g.&nbsp;<code>F07_02_ambient</code> before <code>F07_10_ambient</code>, and ignoring any stray punctuation), rather than by plain lexicographic string order.</p>
<div class="sourceCode" id="cb80" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb80-1">natural_sort_key <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^A-Za-z0-9]"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, x)</span></code></pre></div>
<div class="sourceCode" id="cb81" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb81-1">passing_samples_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb81-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_name =</span> name,</span>
<span id="cb81-3">            <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">concentration(ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(calculated_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb81-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">natural_sort_key</span>(sample_name))</span>
<span id="cb81-5"></span>
<span id="cb81-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- passing_samples_table: samples passing CV QC, name + calculated concentration ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb81-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(passing_samples_table)</span>
<span id="cb81-8"></span>
<span id="cb81-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(passing_samples_table)</span></code></pre></div>
<pre><code>--- passing_samples_table: samples passing CV QC, name + calculated concentration ---
tibble [12 × 2] (S3: tbl_df/tbl/data.frame)
 $ sample_name         : chr [1:12] "F07_01_36C" "F07_02_36C" "F07_02_ambient" "F07_03_36C" ...
 $ concentration(ug/mL): num [1:12] 663 932 1080 1206 1156 ...</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">sample_name</th>
<th style="text-align: right;">concentration(ug/mL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07_01_36C</td>
<td style="text-align: right;">663.3</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_02_36C</td>
<td style="text-align: right;">932.4</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_02_ambient</td>
<td style="text-align: right;">1080.1</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_03_36C</td>
<td style="text-align: right;">1205.5</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_03_ambient</td>
<td style="text-align: right;">1155.6</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_36C</td>
<td style="text-align: right;">1567.2</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_ambient</td>
<td style="text-align: right;">659.3</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_36C</td>
<td style="text-align: right;">496.5</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_07_36C</td>
<td style="text-align: right;">1038.1</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_07_ambient</td>
<td style="text-align: right;">1644.6</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_08_36C</td>
<td style="text-align: right;">289.8</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_08_ambient</td>
<td style="text-align: right;">560.2</td>
</tr>
</tbody>
</table>
</section>
<section id="samples-recommended-for-re-assay-1" class="level2">
<h2 class="anchored" data-anchor-id="samples-recommended-for-re-assay-1">11.2 Samples recommended for re-assay</h2>
<div class="sourceCode" id="cb83" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb83-1">failed_qc_samples    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> excluded_groups <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(name)</span>
<span id="cb83-2">extrapolated_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_curve_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(name)</span>
<span id="cb83-3"></span>
<span id="cb83-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- failed_qc_samples: samples excluded from analysis on CV grounds ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb83-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(failed_qc_samples)</span>
<span id="cb83-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- extrapolated_samples: QC-passing samples outside the retained standard curve's range ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb83-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(extrapolated_samples)</span></code></pre></div>
<pre><code>--- failed_qc_samples: samples excluded from analysis on CV grounds ---
tibble [4 × 14] (S3: tbl_df/tbl/data.frame)
 $ well_id           : chr [1:4] "SPL9" "SPL12" "SPL5" "SPL14"
 $ name              : chr [1:4] "F07_01_ambient" "F07_04_ambient" "F07_05_36C" "F07_06_ambient"
 $ type              : chr [1:4] "sample" "sample" "sample" "sample"
 $ std_conc_known    : int [1:4] NA NA NA NA
 $ n_wells           : int [1:4] 3 3 3 3
 $ mean_595          : num [1:4] 0.805 1.018 0.878 1.296
 $ sd_595            : num [1:4] 0.0586 0.0835 0.0315 0.0991
 $ cv_595            : num [1:4] 7.28 8.2 3.59 7.65
 $ mean_concentration: num [1:4] 250 652 388 1178
 $ sd_concentration  : num [1:4] 110.6 157.5 59.7 187.1
 $ cv_concentration  : num [1:4] 44.3 24.2 15.4 15.9
 $ n_wells_valid_conc: int [1:4] 3 3 3 3
 $ is_zero_standard  : logi [1:4] FALSE FALSE FALSE FALSE
 $ high_cv           : logi [1:4] TRUE TRUE TRUE TRUE

--- extrapolated_samples: QC-passing samples outside the retained standard curve's range ---
tibble [0 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id                 : chr(0) 
 $ name                    : chr(0) 
 $ type                    : chr(0) 
 $ std_conc_known          : int(0) 
 $ n_wells                 : int(0) 
 $ mean_595                : num(0) 
 $ sd_595                  : num(0) 
 $ cv_595                  : num(0) 
 $ mean_concentration      : num(0) 
 $ sd_concentration        : num(0) 
 $ cv_concentration        : num(0) 
 $ n_wells_valid_conc      : int(0) 
 $ is_zero_standard        : logi(0) 
 $ high_cv                 : logi(0) 
 $ se_595                  : num(0) 
 $ calculated_concentration: num(0) 
 $ in_curve_range          : logi(0) </code></pre>
<div class="sourceCode" id="cb85" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb85-1">reassay_candidates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb85-2">  failed_qc_samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb85-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> name,</span>
<span id="cb85-4">              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rationale for re-assay</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(</span>
<span id="cb85-5">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_concentration),</span>
<span id="cb85-6">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV undefined (&lt; 2 valid replicates)"</span>,</span>
<span id="cb85-7">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV &gt; 15%"</span></span>
<span id="cb85-8">              ))),</span>
<span id="cb85-9">  extrapolated_samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb85-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> name,</span>
<span id="cb85-11">              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rationale for re-assay</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outside standard curve range"</span>)</span>
<span id="cb85-12">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb85-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">natural_sort_key</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>))</span>
<span id="cb85-14"></span>
<span id="cb85-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- reassay_candidates: all samples flagged for re-assay, with rationale ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb85-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(reassay_candidates)</span>
<span id="cb85-17"></span>
<span id="cb85-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(reassay_candidates)</span></code></pre></div>
<pre><code>--- reassay_candidates: all samples flagged for re-assay, with rationale ---
tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
 $ Sample name           : chr [1:4] "F07_01_ambient" "F07_04_ambient" "F07_05_36C" "F07_06_ambient"
 $ Rationale for re-assay: chr [1:4] "CV &gt; 15%" "CV &gt; 15%" "CV &gt; 15%" "CV &gt; 15%"</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Sample name</th>
<th style="text-align: left;">Rationale for re-assay</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: left;">CV &gt; 15%</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: left;">CV &gt; 15%</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: left;">CV &gt; 15%</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: left;">CV &gt; 15%</td>
</tr>
</tbody>
</table>
<hr>
</section>
</section>
<section id="sample-reassays" class="level1">
<h1>SAMPLE REASSAYS</h1>
</section>
<section id="background-2" class="level1">
<h1>1 BACKGROUND</h1>
<p>Protein quantification (BCA/Bradford-style, 595&nbsp;nm) of <em>Magallana gigas</em> (Pacific oyster) SoRMI re-assay plate, 9 samples plus an 8-point BSA standard curve, each measured in triplicate wells. All 9 samples are re-assays of samples previously flagged for re-assay in the <code>F05</code> and <code>F07</code> analyses (5 from <code>F05</code> – CV or standard-curve-range failures – and 4 from <code>F07</code> – CV failures), now run together on a single plate against a fresh standard curve.</p>
<p>The raw Gen5 export (<code>Gen5-20260813-mgig-BSA-F05-F07-reassay-absorbance.csv</code>) has the same per-well layout as the earlier <code>F05</code>/<code>F07</code> exports (see those documents for detail), but with one new wrinkle: sample names carry a dilution-factor suffix, <code>&lt;sample&gt;-df.&lt;N&gt;</code>, e.g.&nbsp;<code>F05_01_ambient-df.0</code> or <code>F05_03_ambient-df.2</code>. <code>df.0</code> means the well was read on <strong>undiluted</strong> material; <code>df.N</code> (N &gt; 0) means the material was diluted <strong>N-fold</strong> before reading, so the well’s back-calculated concentration must be multiplied by <code>N</code> to recover the sample’s true (pre-dilution) concentration – <code>df.0</code> is therefore treated as a multiplier of 1, not 0. This multiplication is kept as a distinct, explicit step (see “Applying the standard curve to samples” below) so the well-level (as-measured) and final (dilution-corrected) concentrations both remain visible.</p>
<p>As before, this document ignores the instrument’s pre-computed summary columns and recomputes mean, SD, and CV independently in R via <code>dplyr</code>, for both the raw absorbance (595&nbsp;nm) and the concentration.</p>
<p><strong>CV QC metric used for exclusion:</strong> the &gt;15% technical-replicate CV exclusion rule (including for standard-curve points) is applied to <strong>CV of concentration</strong> (matching what the instrument’s own <code>CV (%)</code> column already represents for this export – verified against the raw file: e.g.&nbsp;<code>SPL1</code>’s given Mean/SD/CV of 883.966/50.075/5.665 are exactly the mean/SD/CV of its three <code>[Concentration]</code> values, not of its <code>595</code> values, and this holds regardless of that sample’s dilution factor since the raw <code>[Concentration]</code> column reflects the as-measured, pre-correction well concentration).</p>
<p>Two edge cases in the raw <code>[Concentration]</code> column need explicit handling:</p>
<ul>
<li><strong>Censored reads.</strong> Wells reading outside the instrument’s own internal standard-curve range are reported as <code>&lt;0.000</code> or <code>&gt;2100.000</code> rather than a number. These are parsed to a <code>_censored</code> flag plus the boundary value, and excluded from concentration mean/SD/CV calculations (their true value is unknown, not equal to the boundary).</li>
<li><strong>The zero (blank) BSA standard</strong> (<code>STD8</code>) is <em>always</em> censored (<code>&lt;0.000</code> on all three wells), by construction – a true-zero standard’s back-calculated concentration is not a meaningful quantity to compute a CV on, and this is not a data-quality problem. <code>STD8</code> is therefore exempt from the concentration-CV exclusion rule and is retained as the curve’s origin point on the strength of its (excellent) 595 CV instead.</li>
</ul>
<p>Any other group left with fewer than 2 valid (non-censored) concentration replicates has an undefined (<code>NA</code>) concentration CV and is treated as failing QC, consistent with the source file itself being unable to compute a CV there either (<code>?????</code>). In this plate’s data, every sample well yields a numeric (non-censored) concentration, so this case only arises for the zero BSA standard (which is exempted, above).</p>
</section>
<section id="setup-2" class="level1">
<h1>2 SETUP</h1>
<section id="libraries-2" class="level2">
<h2 class="anchored" data-anchor-id="libraries-2">2.1 Libraries</h2>
<div class="sourceCode" id="cb87" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb87-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb87-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb87-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb89" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb89-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb89-2"></span>
<span id="cb89-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb89-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb89-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb89-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb89-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb89-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb89-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb89-10">)</span></code></pre></div>
</section>
<section id="set-output-directory-2" class="level2">
<h2 class="anchored" data-anchor-id="set-output-directory-2">2.2 Set output directory</h2>
<div class="sourceCode" id="cb90" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb90-1">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260813-mgig-BSA-F05-F07-reassay"</span></span>
<span id="cb90-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div>
</section>
</section>
<section id="data-import-2" class="level1">
<h1>3 DATA IMPORT</h1>
<p>The raw file is a Gen5 per-well export with non-syntactic column names (<code>[Concentration]</code>, <code>CV (%)</code>, etc.) and a UTF-8 byte-order mark on the first header cell, so columns are renamed by position immediately after import rather than referenced by their original names.</p>
<div class="sourceCode" id="cb91" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb91-1">data_path <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/Gen5-20260813-mgig-BSA-F05-F07-reassay-absorbance.csv"</span></span>
<span id="cb91-2"></span>
<span id="cb91-3">protein_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(data_path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb91-4">                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.strings =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NA"</span>))</span>
<span id="cb91-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(protein_raw) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"name"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"std_conc_known"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"abs_595"</span>,</span>
<span id="cb91-6">                           <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_concentration"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_count"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_mean"</span>,</span>
<span id="cb91-7">                           <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_sd"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gen5_cv"</span>)</span>
<span id="cb91-8"></span>
<span id="cb91-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- protein_raw: as imported from the Gen5 export ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb91-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_raw)</span></code></pre></div>
<pre><code>--- protein_raw: as imported from the Gen5 export ---
'data.frame':   51 obs. of  10 variables:
 $ well_id           : chr  "SPL1" NA NA "SPL2" ...
 $ name              : chr  "F05_01_ambient-df.0" NA NA "F05_02_ambient-df.0" ...
 $ well              : chr  "B1" "B2" "B3" "B4" ...
 $ std_conc_known    : int  NA NA NA NA NA NA NA NA NA NA ...
 $ abs_595           : num  1.14 1.18 1.19 1.22 1.28 ...
 $ gen5_concentration: chr  "827.572" "901.105" "923.221" "989.193" ...
 $ gen5_count        : int  3 NA NA 3 NA NA 3 NA NA 3 ...
 $ gen5_mean         : chr  "883.966" NA NA "1044.327" ...
 $ gen5_sd           : chr  "50.075" NA NA "56.98" ...
 $ gen5_cv           : chr  "5.665" NA NA "5.456" ...</code></pre>
</section>
<section id="reshaping-2" class="level1">
<h1>4 RESHAPING</h1>
<p><code>well_id</code> and <code>name</code> are only populated on the first row of each triplicate group in the raw export, so they are filled downward. Each row is also classified as a <code>standard</code> (<code>well_id</code> starts with <code>STD</code>) or a <code>sample</code> (<code>SPL</code>), and the instrument’s censored concentration strings (<code>&lt;0.000</code>, <code>&gt;2100.000</code>) are parsed into a numeric value plus a <code>gen5_concentration_censored</code> flag. For sample rows, the <code>-df.&lt;N&gt;</code> suffix is parsed off <code>name</code> into a clean <code>base_sample_name</code>, plus <code>dilution_code</code> (the raw <code>N</code>) and <code>dilution_multiplier</code> (1 when <code>N == 0</code>, otherwise <code>N</code>).</p>
<div class="sourceCode" id="cb93" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb93-1">protein_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb93-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, well, std_conc_known, abs_595, gen5_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb93-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fill</span>(well_id, name, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.direction =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"down"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb93-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb93-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD"</span>, well_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>),</span>
<span id="cb93-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gen5_concentration_censored =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[&lt;&gt;]"</span>, gen5_concentration),</span>
<span id="cb93-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">gen5_concentration_numeric  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[&lt;&gt;]"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, gen5_concentration)),</span>
<span id="cb93-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_sample_name =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb93-9">                                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, name),</span>
<span id="cb93-10">                                <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb93-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_code =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb93-12">                             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.([0-9]+)$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, name)),</span>
<span id="cb93-13">                             <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb93-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_multiplier =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>,</span>
<span id="cb93-15">                                   <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(dilution_code <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, dilution_code),</span>
<span id="cb93-16">                                   <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb93-17">  )</span>
<span id="cb93-18"></span>
<span id="cb93-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- protein_long: one row per well, group identifiers filled down, dilution parsed ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb93-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_long)</span></code></pre></div>
<pre><code>--- protein_long: one row per well, group identifiers filled down, dilution parsed ---
'data.frame':   51 obs. of  12 variables:
 $ well_id                    : chr  "SPL1" "SPL1" "SPL1" "SPL2" ...
 $ name                       : chr  "F05_01_ambient-df.0" "F05_01_ambient-df.0" "F05_01_ambient-df.0" "F05_02_ambient-df.0" ...
 $ well                       : chr  "B1" "B2" "B3" "B4" ...
 $ std_conc_known             : int  NA NA NA NA NA NA NA NA NA NA ...
 $ abs_595                    : num  1.14 1.18 1.19 1.22 1.28 ...
 $ gen5_concentration         : chr  "827.572" "901.105" "923.221" "989.193" ...
 $ type                       : chr  "sample" "sample" "sample" "sample" ...
 $ gen5_concentration_censored: logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ gen5_concentration_numeric : num  828 901 923 989 1103 ...
 $ base_sample_name           : chr  "F05_01_ambient" "F05_01_ambient" "F05_01_ambient" "F05_02_ambient" ...
 $ dilution_code              : num  0 0 0 0 0 0 2 2 2 2 ...
 $ dilution_multiplier        : num  1 1 1 1 1 1 2 2 2 2 ...</code></pre>
</section>
<section id="mean-values-2" class="level1">
<h1>5 MEAN VALUES</h1>
<section id="mean-595-nm-absorbance-2" class="level2">
<h2 class="anchored" data-anchor-id="mean-595-nm-absorbance-2">5.1 Mean 595 nm absorbance</h2>
<div class="sourceCode" id="cb95" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb95-1">mean_595_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb95-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known,</span>
<span id="cb95-3">           base_sample_name, dilution_code, dilution_multiplier) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb95-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb95-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_595 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(abs_595),</span>
<span id="cb95-6">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb95-7"></span>
<span id="cb95-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- mean_595_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb95-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(mean_595_by_group)</span></code></pre></div>
<pre><code>--- mean_595_by_group ---
tibble [17 × 9] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr [1:17] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ name               : chr [1:17] "F05_01_ambient-df.0" "F05_02_ambient-df.0" "F05_03_ambient-df.2" "F05_06_ambient-df.2" ...
 $ type               : chr [1:17] "sample" "sample" "sample" "sample" ...
 $ std_conc_known     : int [1:17] NA NA NA NA NA NA NA NA NA 2000 ...
 $ base_sample_name   : chr [1:17] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ dilution_code      : num [1:17] 0 0 2 2 2 0 0 0 0 NA ...
 $ dilution_multiplier: num [1:17] 1 1 2 2 2 1 1 1 1 NA ...
 $ n_wells            : int [1:17] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595           : num [1:17] 1.17 1.25 1.2 1.29 1.41 ...</code></pre>
</section>
<section id="mean-concentration-2" class="level2">
<h2 class="anchored" data-anchor-id="mean-concentration-2">5.2 Mean concentration</h2>
<p>Censored wells (reading outside the instrument’s own standard-curve range) are dropped before averaging, since their true concentration is unknown.</p>
<div class="sourceCode" id="cb97" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb97-1">mean_conc_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb97-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>gen5_concentration_censored) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb97-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known,</span>
<span id="cb97-4">           base_sample_name, dilution_code, dilution_multiplier) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb97-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_valid_conc  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb97-6">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_concentration  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(gen5_concentration_numeric),</span>
<span id="cb97-7">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb97-8"></span>
<span id="cb97-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- mean_conc_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb97-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(mean_conc_by_group)</span></code></pre></div>
<pre><code>--- mean_conc_by_group ---
tibble [16 × 9] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr [1:16] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ name               : chr [1:16] "F05_01_ambient-df.0" "F05_02_ambient-df.0" "F05_03_ambient-df.2" "F05_06_ambient-df.2" ...
 $ type               : chr [1:16] "sample" "sample" "sample" "sample" ...
 $ std_conc_known     : int [1:16] NA NA NA NA NA NA NA NA NA 2000 ...
 $ base_sample_name   : chr [1:16] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ dilution_code      : num [1:16] 0 0 2 2 2 0 0 0 0 NA ...
 $ dilution_multiplier: num [1:16] 1 1 2 2 2 1 1 1 1 NA ...
 $ n_wells_valid_conc : int [1:16] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_concentration : num [1:16] 884 1044 956 1120 1353 ...</code></pre>
</section>
</section>
<section id="standard-deviation-and-coefficient-of-variation-2" class="level1">
<h1>6 STANDARD DEVIATION AND COEFFICIENT OF VARIATION</h1>
<section id="sd-and-cv-of-595-nm-absorbance-2" class="level2">
<h2 class="anchored" data-anchor-id="sd-and-cv-of-595-nm-absorbance-2">6.1 SD and CV of 595 nm absorbance</h2>
<div class="sourceCode" id="cb99" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb99-1">sd_cv_595_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb99-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known,</span>
<span id="cb99-3">           base_sample_name, dilution_code, dilution_multiplier) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb99-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb99-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb99-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_595 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(abs_595),</span>
<span id="cb99-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_595   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(abs_595),</span>
<span id="cb99-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_595   =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> sd_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_595,</span>
<span id="cb99-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb99-10">  )</span>
<span id="cb99-11"></span>
<span id="cb99-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- sd_cv_595_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb99-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sd_cv_595_by_group)</span></code></pre></div>
<pre><code>--- sd_cv_595_by_group ---
tibble [17 × 11] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr [1:17] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ name               : chr [1:17] "F05_01_ambient-df.0" "F05_02_ambient-df.0" "F05_03_ambient-df.2" "F05_06_ambient-df.2" ...
 $ type               : chr [1:17] "sample" "sample" "sample" "sample" ...
 $ std_conc_known     : int [1:17] NA NA NA NA NA NA NA NA NA 2000 ...
 $ base_sample_name   : chr [1:17] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ dilution_code      : num [1:17] 0 0 2 2 2 0 0 0 0 NA ...
 $ dilution_multiplier: num [1:17] 1 1 2 2 2 1 1 1 1 NA ...
 $ n_wells            : int [1:17] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595           : num [1:17] 1.17 1.25 1.2 1.29 1.41 ...
 $ sd_595             : num [1:17] 0.0267 0.03 0.0259 0.0375 0.0229 ...
 $ cv_595             : num [1:17] 2.29 2.4 2.15 2.91 1.62 ...</code></pre>
</section>
<section id="sd-and-cv-of-concentration-2" class="level2">
<h2 class="anchored" data-anchor-id="sd-and-cv-of-concentration-2">6.2 SD and CV of concentration</h2>
<div class="sourceCode" id="cb101" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb101-1">sd_cv_conc_by_group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb101-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>gen5_concentration_censored) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb101-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_id, name, type, std_conc_known,</span>
<span id="cb101-4">           base_sample_name, dilution_code, dilution_multiplier) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb101-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb101-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_valid_conc  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb101-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_concentration  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(gen5_concentration_numeric),</span>
<span id="cb101-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_concentration    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(gen5_concentration_numeric),</span>
<span id="cb101-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_concentration    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> sd_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_concentration,</span>
<span id="cb101-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb101-11">  )</span>
<span id="cb101-12"></span>
<span id="cb101-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- sd_cv_conc_by_group ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb101-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sd_cv_conc_by_group)</span></code></pre></div>
<pre><code>--- sd_cv_conc_by_group ---
tibble [16 × 11] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr [1:16] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ name               : chr [1:16] "F05_01_ambient-df.0" "F05_02_ambient-df.0" "F05_03_ambient-df.2" "F05_06_ambient-df.2" ...
 $ type               : chr [1:16] "sample" "sample" "sample" "sample" ...
 $ std_conc_known     : int [1:16] NA NA NA NA NA NA NA NA NA 2000 ...
 $ base_sample_name   : chr [1:16] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ dilution_code      : num [1:16] 0 0 2 2 2 0 0 0 0 NA ...
 $ dilution_multiplier: num [1:16] 1 1 2 2 2 1 1 1 1 NA ...
 $ n_wells_valid_conc : int [1:16] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_concentration : num [1:16] 884 1044 956 1120 1353 ...
 $ sd_concentration   : num [1:16] 50.1 57 48.4 71.7 43.2 ...
 $ cv_concentration   : num [1:16] 5.66 5.46 5.06 6.4 3.19 ...</code></pre>
</section>
<section id="combined-per-group-summary-2" class="level2">
<h2 class="anchored" data-anchor-id="combined-per-group-summary-2">6.3 Combined per-group summary</h2>
<div class="sourceCode" id="cb103" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb103-1">group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sd_cv_595_by_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb103-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(</span>
<span id="cb103-3">    sd_cv_conc_by_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb103-4">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, mean_concentration, sd_concentration, cv_concentration, n_wells_valid_conc),</span>
<span id="cb103-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span></span>
<span id="cb103-6">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb103-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(type, well_id)</span>
<span id="cb103-8"></span>
<span id="cb103-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- group_stats: one row per sample/standard, 595- and concentration-level stats ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb103-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(group_stats)</span>
<span id="cb103-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(group_stats, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>--- group_stats: one row per sample/standard, 595- and concentration-level stats ---
tibble [17 × 15] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr [1:17] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ name               : chr [1:17] "F05_01_ambient-df.0" "F05_02_ambient-df.0" "F05_03_ambient-df.2" "F05_06_ambient-df.2" ...
 $ type               : chr [1:17] "sample" "sample" "sample" "sample" ...
 $ std_conc_known     : int [1:17] NA NA NA NA NA NA NA NA NA 2000 ...
 $ base_sample_name   : chr [1:17] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ dilution_code      : num [1:17] 0 0 2 2 2 0 0 0 0 NA ...
 $ dilution_multiplier: num [1:17] 1 1 2 2 2 1 1 1 1 NA ...
 $ n_wells            : int [1:17] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595           : num [1:17] 1.17 1.25 1.2 1.29 1.41 ...
 $ sd_595             : num [1:17] 0.0267 0.03 0.0259 0.0375 0.0229 ...
 $ cv_595             : num [1:17] 2.29 2.4 2.15 2.91 1.62 ...
 $ mean_concentration : num [1:17] 884 1044 956 1120 1353 ...
 $ sd_concentration   : num [1:17] 50.1 57 48.4 71.7 43.2 ...
 $ cv_concentration   : num [1:17] 5.66 5.46 5.06 6.4 3.19 ...
 $ n_wells_valid_conc : int [1:17] 3 3 3 3 3 3 3 3 3 3 ...</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
<col style="width: 6%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: left;">name</th>
<th style="text-align: left;">type</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: left;">base_sample_name</th>
<th style="text-align: right;">dilution_code</th>
<th style="text-align: right;">dilution_multiplier</th>
<th style="text-align: right;">n_wells</th>
<th style="text-align: right;">mean_595</th>
<th style="text-align: right;">sd_595</th>
<th style="text-align: right;">cv_595</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
<th style="text-align: right;">n_wells_valid_conc</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">SPL1</td>
<td style="text-align: left;">F05_01_ambient-df.0</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.166</td>
<td style="text-align: right;">0.027</td>
<td style="text-align: right;">2.287</td>
<td style="text-align: right;">883.966</td>
<td style="text-align: right;">50.075</td>
<td style="text-align: right;">5.665</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL2</td>
<td style="text-align: left;">F05_02_ambient-df.0</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.251</td>
<td style="text-align: right;">0.030</td>
<td style="text-align: right;">2.402</td>
<td style="text-align: right;">1044.327</td>
<td style="text-align: right;">56.980</td>
<td style="text-align: right;">5.456</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL3</td>
<td style="text-align: left;">F05_03_ambient-df.2</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.205</td>
<td style="text-align: right;">0.026</td>
<td style="text-align: right;">2.149</td>
<td style="text-align: right;">956.302</td>
<td style="text-align: right;">48.370</td>
<td style="text-align: right;">5.058</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL4</td>
<td style="text-align: left;">F05_06_ambient-df.2</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.291</td>
<td style="text-align: right;">0.038</td>
<td style="text-align: right;">2.907</td>
<td style="text-align: right;">1120.380</td>
<td style="text-align: right;">71.728</td>
<td style="text-align: right;">6.402</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL5</td>
<td style="text-align: left;">F05_08_ambient-df.2</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.414</td>
<td style="text-align: right;">0.023</td>
<td style="text-align: right;">1.619</td>
<td style="text-align: right;">1353.329</td>
<td style="text-align: right;">43.195</td>
<td style="text-align: right;">3.192</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL6</td>
<td style="text-align: left;">F07_05_36C-df.0</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.932</td>
<td style="text-align: right;">0.008</td>
<td style="text-align: right;">0.810</td>
<td style="text-align: right;">441.760</td>
<td style="text-align: right;">13.784</td>
<td style="text-align: right;">3.120</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL7</td>
<td style="text-align: left;">F07_01_ambient-df.0</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.846</td>
<td style="text-align: right;">0.019</td>
<td style="text-align: right;">2.280</td>
<td style="text-align: right;">278.438</td>
<td style="text-align: right;">35.812</td>
<td style="text-align: right;">12.862</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">SPL8</td>
<td style="text-align: left;">F07_04_ambient-df.0</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.001</td>
<td style="text-align: right;">0.026</td>
<td style="text-align: right;">2.551</td>
<td style="text-align: right;">571.561</td>
<td style="text-align: right;">48.935</td>
<td style="text-align: right;">8.562</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">SPL9</td>
<td style="text-align: left;">F07_06_ambient-df.0</td>
<td style="text-align: left;">sample</td>
<td style="text-align: right;">NA</td>
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.293</td>
<td style="text-align: right;">0.020</td>
<td style="text-align: right;">1.545</td>
<td style="text-align: right;">1123.972</td>
<td style="text-align: right;">37.008</td>
<td style="text-align: right;">3.293</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD1</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">2000</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.620</td>
<td style="text-align: right;">0.017</td>
<td style="text-align: right;">1.059</td>
<td style="text-align: right;">1742.543</td>
<td style="text-align: right;">32.899</td>
<td style="text-align: right;">1.888</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD2</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1500</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.543</td>
<td style="text-align: right;">0.026</td>
<td style="text-align: right;">1.654</td>
<td style="text-align: right;">1596.044</td>
<td style="text-align: right;">48.516</td>
<td style="text-align: right;">3.040</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD3</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">1000</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.374</td>
<td style="text-align: right;">0.011</td>
<td style="text-align: right;">0.772</td>
<td style="text-align: right;">1276.142</td>
<td style="text-align: right;">19.343</td>
<td style="text-align: right;">1.516</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD4</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">750</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.146</td>
<td style="text-align: right;">0.029</td>
<td style="text-align: right;">2.553</td>
<td style="text-align: right;">845.908</td>
<td style="text-align: right;">55.390</td>
<td style="text-align: right;">6.548</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD5</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">500</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1.004</td>
<td style="text-align: right;">0.024</td>
<td style="text-align: right;">2.342</td>
<td style="text-align: right;">577.674</td>
<td style="text-align: right;">44.343</td>
<td style="text-align: right;">7.676</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD6</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">250</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.811</td>
<td style="text-align: right;">0.009</td>
<td style="text-align: right;">1.054</td>
<td style="text-align: right;">212.656</td>
<td style="text-align: right;">16.562</td>
<td style="text-align: right;">7.788</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: left;">STD7</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">125</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.736</td>
<td style="text-align: right;">0.031</td>
<td style="text-align: right;">4.209</td>
<td style="text-align: right;">71.197</td>
<td style="text-align: right;">58.999</td>
<td style="text-align: right;">82.867</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: left;">STD8</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">0</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.594</td>
<td style="text-align: right;">0.014</td>
<td style="text-align: right;">2.297</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="cv-based-exclusion-2" class="level1">
<h1>7 CV-BASED EXCLUSION</h1>
<p>Groups with CV(concentration) &gt; 15% – or an undefined concentration CV due to insufficient valid (non-censored) replicates – are flagged and excluded from all downstream analysis, including standard-curve fitting. The zero BSA standard (<code>STD8</code>) is exempt from this rule (see Background) and is always retained.</p>
<div class="sourceCode" id="cb105" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb105-1">group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb105-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb105-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_zero_standard =</span> type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(std_conc_known) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> std_conc_known <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb105-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">high_cv =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_zero_standard <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> cv_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>)</span>
<span id="cb105-5">  )</span>
<span id="cb105-6"></span>
<span id="cb105-7">excluded_groups <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(high_cv)</span>
<span id="cb105-8"></span>
<span id="cb105-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- excluded_groups: CV(concentration) &gt; 15% (or undefined), dropped from further analysis ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb105-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(excluded_groups)</span>
<span id="cb105-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_groups <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb105-12">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, name, type, std_conc_known, n_wells_valid_conc,</span>
<span id="cb105-13">               mean_concentration, sd_concentration, cv_concentration),</span>
<span id="cb105-14">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb105-15"></span>
<span id="cb105-16">clean_group_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>high_cv)</span>
<span id="cb105-17"></span>
<span id="cb105-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Retained after CV exclusion:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(clean_group_stats), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(group_stats), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"groups</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb105-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(clean_group_stats)</span></code></pre></div>
<pre><code>--- excluded_groups: CV(concentration) &gt; 15% (or undefined), dropped from further analysis ---
tibble [1 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr "STD7"
 $ name               : chr "BSA"
 $ type               : chr "standard"
 $ std_conc_known     : int 125
 $ base_sample_name   : chr NA
 $ dilution_code      : num NA
 $ dilution_multiplier: num NA
 $ n_wells            : int 3
 $ mean_595           : num 0.736
 $ sd_595             : num 0.031
 $ cv_595             : num 4.21
 $ mean_concentration : num 71.2
 $ sd_concentration   : num 59
 $ cv_concentration   : num 82.9
 $ n_wells_valid_conc : int 3
 $ is_zero_standard   : logi FALSE
 $ high_cv            : logi TRUE</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: left;">name</th>
<th style="text-align: left;">type</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">n_wells_valid_conc</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">STD7</td>
<td style="text-align: left;">BSA</td>
<td style="text-align: left;">standard</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">71.197</td>
<td style="text-align: right;">58.999</td>
<td style="text-align: right;">82.867</td>
</tr>
</tbody>
</table>
<pre><code>Retained after CV exclusion: 16 of 17 groups
tibble [16 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr [1:16] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ name               : chr [1:16] "F05_01_ambient-df.0" "F05_02_ambient-df.0" "F05_03_ambient-df.2" "F05_06_ambient-df.2" ...
 $ type               : chr [1:16] "sample" "sample" "sample" "sample" ...
 $ std_conc_known     : int [1:16] NA NA NA NA NA NA NA NA NA 2000 ...
 $ base_sample_name   : chr [1:16] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ dilution_code      : num [1:16] 0 0 2 2 2 0 0 0 0 NA ...
 $ dilution_multiplier: num [1:16] 1 1 2 2 2 1 1 1 1 NA ...
 $ n_wells            : int [1:16] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_595           : num [1:16] 1.17 1.25 1.2 1.29 1.41 ...
 $ sd_595             : num [1:16] 0.0267 0.03 0.0259 0.0375 0.0229 ...
 $ cv_595             : num [1:16] 2.29 2.4 2.15 2.91 1.62 ...
 $ mean_concentration : num [1:16] 884 1044 956 1120 1353 ...
 $ sd_concentration   : num [1:16] 50.1 57 48.4 71.7 43.2 ...
 $ cv_concentration   : num [1:16] 5.66 5.46 5.06 6.4 3.19 ...
 $ n_wells_valid_conc : int [1:16] 3 3 3 3 3 3 3 3 3 3 ...
 $ is_zero_standard   : logi [1:16] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ high_cv            : logi [1:16] FALSE FALSE FALSE FALSE FALSE FALSE ...</code></pre>
</section>
<section id="standard-curve-2" class="level1">
<h1>8 STANDARD CURVE</h1>
<p>Fit using only the retained (CV ≤ 15%) standard points: known BSA concentration (<code>Conc/Dil</code>) on the x-axis, mean 595&nbsp;nm absorbance on the y-axis. Dilution correction (below) has no bearing on the curve fit itself, since standards are not diluted.</p>
<div class="sourceCode" id="cb108" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb108-1">standards_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> clean_group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>)</span>
<span id="cb108-2"></span>
<span id="cb108-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- standards_clean: standard points retained for curve fitting ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb108-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_clean)</span>
<span id="cb108-5"></span>
<span id="cb108-6">standard_curve_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean)</span>
<span id="cb108-7"></span>
<span id="cb108-8">curve_slope     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(standard_curve_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb108-9">curve_intercept <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(standard_curve_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb108-10">curve_r2        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(standard_curve_model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb108-11"></span>
<span id="cb108-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve fit: 595 ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"* concentration +"</span>,</span>
<span id="cb108-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_intercept, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb108-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(curve_r2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- standards_clean: standard points retained for curve fitting ---
tibble [7 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr [1:7] "STD1" "STD2" "STD3" "STD4" ...
 $ name               : chr [1:7] "BSA" "BSA" "BSA" "BSA" ...
 $ type               : chr [1:7] "standard" "standard" "standard" "standard" ...
 $ std_conc_known     : int [1:7] 2000 1500 1000 750 500 250 0
 $ base_sample_name   : chr [1:7] NA NA NA NA ...
 $ dilution_code      : num [1:7] NA NA NA NA NA NA NA
 $ dilution_multiplier: num [1:7] NA NA NA NA NA NA NA
 $ n_wells            : int [1:7] 3 3 3 3 3 3 3
 $ mean_595           : num [1:7] 1.62 1.54 1.37 1.15 1 ...
 $ sd_595             : num [1:7] 0.0172 0.0255 0.0106 0.0293 0.0235 ...
 $ cv_595             : num [1:7] 1.059 1.654 0.772 2.553 2.342 ...
 $ mean_concentration : num [1:7] 1743 1596 1276 846 578 ...
 $ sd_concentration   : num [1:7] 32.9 48.5 19.3 55.4 44.3 ...
 $ cv_concentration   : num [1:7] 1.89 3.04 1.52 6.55 7.68 ...
 $ n_wells_valid_conc : int [1:7] 3 3 3 3 3 3 NA
 $ is_zero_standard   : logi [1:7] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ high_cv            : logi [1:7] FALSE FALSE FALSE FALSE FALSE FALSE ...
Standard curve fit: 595 = 0.000522028 * concentration + 0.7086 
R2: 0.93363 </code></pre>
<section id="plot-standard-curve-2" class="level2">
<h2 class="anchored" data-anchor-id="plot-standard-curve-2">8.1 Plot standard curve</h2>
<div class="sourceCode" id="cb110" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb110-1">eq_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(curve_slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scientific =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x + "</span>,</span>
<span id="cb110-2">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_intercept),</span>
<span id="cb110-3">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">R² = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_r2))</span>
<span id="cb110-4"></span>
<span id="cb110-5">standard_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb110-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb110-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> sd_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> sd_595),</span>
<span id="cb110-8">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb110-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb110-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> eq_label,</span>
<span id="cb110-11">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.08</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb110-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard concentration (µg/mL)"</span>,</span>
<span id="cb110-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean absorbance (595 nm)"</span>,</span>
<span id="cb110-14">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard curve"</span>,</span>
<span id="cb110-15">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Points with technical-replicate CV(concentration) &gt; 15% excluded (see below)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb110-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb110-17"></span>
<span id="cb110-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(standard_curve_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/Gen5-20260813-mgig-sormi-BSA-F05-F07-reassay-protein_files/figure-gfm/plot-standard-curve-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb111" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb111-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_595.png"</span>), standard_curve_plot,</span>
<span id="cb111-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
<p>Standard points excluded from the curve:</p>
<div class="sourceCode" id="cb112" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb112-1">excluded_standards <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>, high_cv)</span>
<span id="cb112-2"></span>
<span id="cb112-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- excluded_standards ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb112-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(excluded_standards)</span>
<span id="cb112-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_standards <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb112-6">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, std_conc_known, mean_concentration, sd_concentration, cv_concentration),</span>
<span id="cb112-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>--- excluded_standards ---
tibble [1 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr "STD7"
 $ name               : chr "BSA"
 $ type               : chr "standard"
 $ std_conc_known     : int 125
 $ base_sample_name   : chr NA
 $ dilution_code      : num NA
 $ dilution_multiplier: num NA
 $ n_wells            : int 3
 $ mean_595           : num 0.736
 $ sd_595             : num 0.031
 $ cv_595             : num 4.21
 $ mean_concentration : num 71.2
 $ sd_concentration   : num 59
 $ cv_concentration   : num 82.9
 $ n_wells_valid_conc : int 3
 $ is_zero_standard   : logi FALSE
 $ high_cv            : logi TRUE</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 11%">
<col style="width: 19%">
<col style="width: 24%">
<col style="width: 22%">
<col style="width: 22%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">well_id</th>
<th style="text-align: right;">std_conc_known</th>
<th style="text-align: right;">mean_concentration</th>
<th style="text-align: right;">sd_concentration</th>
<th style="text-align: right;">cv_concentration</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">STD7</td>
<td style="text-align: right;">125</td>
<td style="text-align: right;">71.197</td>
<td style="text-align: right;">58.999</td>
<td style="text-align: right;">82.867</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="applying-the-standard-curve-to-samples-2" class="level1">
<h1>9 APPLYING THE STANDARD CURVE TO SAMPLES</h1>
<p>Samples that passed CV QC are back-calculated against the fitted curve to give a <strong>well-level</strong> concentration (<code>calculated_concentration_well</code>) – the concentration of whatever material was actually in the well, diluted or not. Multiplying by each sample’s <code>dilution_multiplier</code> then gives the <strong>final</strong> concentration (<code>calculated_concentration</code>) – the true concentration of the original, pre-dilution sample, which is the value reported in the results below. Samples whose mean 595 falls outside the retained standards’ absorbance range are flagged as extrapolated; this range check is done on the as-measured 595 value and is unaffected by dilution.</p>
<div class="sourceCode" id="cb114" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb114-1">samples_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> clean_group_stats <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb114-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb114-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb114-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_595                         =</span> sd_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(n_wells),</span>
<span id="cb114-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">calculated_concentration_well  =</span> (mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> curve_intercept) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> curve_slope,</span>
<span id="cb114-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">calculated_concentration       =</span> calculated_concentration_well <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> dilution_multiplier,</span>
<span id="cb114-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_curve_range                 =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(standards_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_595) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb114-8">                                       mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(standards_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_595)</span>
<span id="cb114-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb114-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(base_sample_name)</span>
<span id="cb114-11"></span>
<span id="cb114-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- samples_clean: CV-QC-passing samples, quantified against the fitted standard curve ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb114-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"    (calculated_concentration_well = as-measured; calculated_concentration = dilution-corrected)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb114-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples_clean)</span></code></pre></div>
<pre><code>--- samples_clean: CV-QC-passing samples, quantified against the fitted standard curve ---
    (calculated_concentration_well = as-measured; calculated_concentration = dilution-corrected)
tibble [9 × 21] (S3: tbl_df/tbl/data.frame)
 $ well_id                      : chr [1:9] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ name                         : chr [1:9] "F05_01_ambient-df.0" "F05_02_ambient-df.0" "F05_03_ambient-df.2" "F05_06_ambient-df.2" ...
 $ type                         : chr [1:9] "sample" "sample" "sample" "sample" ...
 $ std_conc_known               : int [1:9] NA NA NA NA NA NA NA NA NA
 $ base_sample_name             : chr [1:9] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ dilution_code                : num [1:9] 0 0 2 2 2 0 0 0 0
 $ dilution_multiplier          : num [1:9] 1 1 2 2 2 1 1 1 1
 $ n_wells                      : int [1:9] 3 3 3 3 3 3 3 3 3
 $ mean_595                     : num [1:9] 1.17 1.25 1.2 1.29 1.41 ...
 $ sd_595                       : num [1:9] 0.0267 0.03 0.0259 0.0375 0.0229 ...
 $ cv_595                       : num [1:9] 2.29 2.4 2.15 2.91 1.62 ...
 $ mean_concentration           : num [1:9] 884 1044 956 1120 1353 ...
 $ sd_concentration             : num [1:9] 50.1 57 48.4 71.7 43.2 ...
 $ cv_concentration             : num [1:9] 5.66 5.46 5.06 6.4 3.19 ...
 $ n_wells_valid_conc           : int [1:9] 3 3 3 3 3 3 3 3 3
 $ is_zero_standard             : logi [1:9] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ high_cv                      : logi [1:9] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ se_595                       : num [1:9] 0.0154 0.0173 0.0149 0.0217 0.0132 ...
 $ calculated_concentration_well: num [1:9] 876 1039 950 1116 1352 ...
 $ calculated_concentration     : num [1:9] 876 1039 1900 2232 2704 ...
 $ in_curve_range               : logi [1:9] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<div class="sourceCode" id="cb116" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb116-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with absorbance outside the retained standard curve's range (extrapolated):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb116-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_curve_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb116-3">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well_id, base_sample_name, mean_595, calculated_concentration),</span>
<span id="cb116-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span></code></pre></div>
<pre><code>Samples with absorbance outside the retained standard curve's range (extrapolated):</code></pre>
<p>well_id base_sample_name mean_595 calculated_concentration ——— —————— ———- ————————–</p>
<section id="plot-samples-on-standard-curve-2" class="level2">
<h2 class="anchored" data-anchor-id="plot-samples-on-standard-curve-2">9.1 Plot samples on standard curve</h2>
<p>Every QC-passing sample is plotted at its own mean 595 and <strong>well-level</strong> back-calculated concentration (i.e.&nbsp;before dilution correction, since that is what is directly comparable to the curve’s own x/y relationship), with vertical error bars of ±1 standard error (of mean 595, across its 2-3 retained technical replicates), overlaid on the standard curve fit line and retained standard points.</p>
<div class="sourceCode" id="cb118" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb118-1">samples_on_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb118-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595),</span>
<span id="cb118-3">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">formula =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb118-4">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb118-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_clean, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_conc_known, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595),</span>
<span id="cb118-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb118-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> samples_clean,</span>
<span id="cb118-8">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> calculated_concentration_well,</span>
<span id="cb118-9">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_595 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_595),</span>
<span id="cb118-10">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb118-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> samples_clean,</span>
<span id="cb118-12">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> calculated_concentration_well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_595, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_curve_range),</span>
<span id="cb118-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"firebrick"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb118-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb118-15">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"extrapolated"</span>),</span>
<span id="cb118-16">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample status"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb118-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well-level concentration (µg/mL, pre-dilution-correction)"</span>,</span>
<span id="cb118-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean absorbance (595 nm)"</span>,</span>
<span id="cb118-19">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BSA standard curve with QC-passing samples overlaid"</span>,</span>
<span id="cb118-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples plotted at their well-level back-calculated concentration; error bars = ±1 SE of mean 595"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb118-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb118-22"></span>
<span id="cb118-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(samples_on_curve_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/Gen5-20260813-mgig-sormi-BSA-F05-F07-reassay-protein_files/figure-gfm/plot-samples-on-curve-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb119" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb119-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_with_samples.png"</span>), samples_on_curve_plot,</span>
<span id="cb119-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
</section>
</section>
<section id="results-table-2" class="level1">
<h1>10 RESULTS TABLE</h1>
<div class="sourceCode" id="cb120" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb120-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb120-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb120-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample                                   =</span> base_sample_name,</span>
<span id="cb120-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                                <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> well_id,</span>
<span id="cb120-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dilution factor</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> dilution_multiplier,</span>
<span id="cb120-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean 595</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                               <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_595, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb120-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV 595 (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_595, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb120-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV concentration (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb120-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(calculated_concentration_well, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb120-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Calculated concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(calculated_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb120-11">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In standard curve range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_curve_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO - extrapolated"</span>)</span>
<span id="cb120-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb120-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[0-9]+$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Za-z]+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well ID</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>)))</span>
<span id="cb120-14"></span>
<span id="cb120-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Well ID</th>
<th style="text-align: right;">Dilution factor</th>
<th style="text-align: right;">Mean 595</th>
<th>CV 595 (%)</th>
<th style="text-align: right;">CV concentration (%)</th>
<th style="text-align: right;">Well concentration (ug/mL)</th>
<th style="text-align: right;">Calculated concentration (ug/mL)</th>
<th style="text-align: left;">In standard curve range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">SPL1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1.166</td>
<td>2.29</td>
<td style="text-align: right;">5.66</td>
<td style="text-align: right;">876.1</td>
<td style="text-align: right;">876.1</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">SPL2</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1.251</td>
<td>2.40</td>
<td style="text-align: right;">5.46</td>
<td style="text-align: right;">1038.9</td>
<td style="text-align: right;">1038.9</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">SPL3</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">1.205</td>
<td>2.15</td>
<td style="text-align: right;">5.06</td>
<td style="text-align: right;">950.2</td>
<td style="text-align: right;">1900.4</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">SPL4</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">1.291</td>
<td>2.91</td>
<td style="text-align: right;">6.40</td>
<td style="text-align: right;">1116.2</td>
<td style="text-align: right;">2232.4</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">SPL5</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">1.414</td>
<td>1.62</td>
<td style="text-align: right;">3.19</td>
<td style="text-align: right;">1351.8</td>
<td style="text-align: right;">2703.7</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: left;">SPL6</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.932</td>
<td>0.81</td>
<td style="text-align: right;">3.12</td>
<td style="text-align: right;">427.9</td>
<td style="text-align: right;">427.9</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: left;">SPL7</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.846</td>
<td>2.28</td>
<td style="text-align: right;">12.86</td>
<td style="text-align: right;">263.1</td>
<td style="text-align: right;">263.1</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: left;">SPL8</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1.001</td>
<td>2.55</td>
<td style="text-align: right;">8.56</td>
<td style="text-align: right;">560.0</td>
<td style="text-align: right;">560.0</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: left;">SPL9</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1.293</td>
<td>1.54</td>
<td style="text-align: right;">3.29</td>
<td style="text-align: right;">1119.4</td>
<td style="text-align: right;">1119.4</td>
<td style="text-align: left;">yes</td>
</tr>
</tbody>
</table>
<p>Only samples passing <em>all</em> QC – CV ≤ 15% and within the retained standard curve’s range (i.e.&nbsp;not extrapolated) – are written to the CSV output.</p>
<div class="sourceCode" id="cb121" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb121-1">results_table_export <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In standard curve range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>)</span>
<span id="cb121-2"></span>
<span id="cb121-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- results_table_export: samples passing all QC (CV and in-range), written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb121-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(results_table_export)</span>
<span id="cb121-5"></span>
<span id="cb121-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table_export, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_protein_concentrations.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<pre><code>--- results_table_export: samples passing all QC (CV and in-range), written to CSV ---
tibble [9 × 9] (S3: tbl_df/tbl/data.frame)
 $ Sample                          : chr [1:9] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ Well ID                         : chr [1:9] "SPL1" "SPL2" "SPL3" "SPL4" ...
 $ Dilution factor                 : num [1:9] 1 1 2 2 2 1 1 1 1
 $ Mean 595                        : num [1:9] 1.17 1.25 1.21 1.29 1.41 ...
 $ CV 595 (%)                      : num [1:9] 2.29 2.4 2.15 2.91 1.62 0.81 2.28 2.55 1.54
 $ CV concentration (%)            : num [1:9] 5.66 5.46 5.06 6.4 3.19 ...
 $ Well concentration (ug/mL)      : num [1:9] 876 1039 950 1116 1352 ...
 $ Calculated concentration (ug/mL): num [1:9] 876 1039 1900 2232 2704 ...
 $ In standard curve range         : chr [1:9] "yes" "yes" "yes" "yes" ...</code></pre>
</section>
<section id="summary-2" class="level1">
<h1>11 SUMMARY</h1>
<ul>
<li>17 sample/standard triplicate groups were imported (8 BSA standards, 9 samples).</li>
<li>1 group(s) exceeded 15% technical-replicate CV(concentration), or had an undefined CV from insufficient valid replicates, and were excluded from all downstream analysis: STD7 (BSA).</li>
<li>The BSA standard curve was fit on the 7 remaining standard points: slope = 0.000522, intercept = 0.7086, R² = 0.9336.</li>
<li>0 CV-QC-passing sample(s) fell outside the retained standard curve’s absorbance range and are flagged as extrapolated in the results table above.</li>
</ul>
<section id="samples-passing-qc-2" class="level2">
<h2 class="anchored" data-anchor-id="samples-passing-qc-2">11.1 Samples passing QC</h2>
<p>Sample names are sorted naturally (ignoring stray punctuation) rather than by plain lexicographic string order. Concentrations shown are the final, dilution-corrected values.</p>
<div class="sourceCode" id="cb123" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb123-1">natural_sort_key <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^A-Za-z0-9]"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, x)</span></code></pre></div>
<div class="sourceCode" id="cb124" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb124-1">passing_samples_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb124-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_name =</span> base_sample_name,</span>
<span id="cb124-3">            <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">concentration(ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(calculated_concentration, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb124-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">natural_sort_key</span>(sample_name))</span>
<span id="cb124-5"></span>
<span id="cb124-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- passing_samples_table: samples passing CV QC, name + calculated concentration ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb124-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(passing_samples_table)</span>
<span id="cb124-8"></span>
<span id="cb124-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(passing_samples_table)</span></code></pre></div>
<pre><code>--- passing_samples_table: samples passing CV QC, name + calculated concentration ---
tibble [9 × 2] (S3: tbl_df/tbl/data.frame)
 $ sample_name         : chr [1:9] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_06_ambient" ...
 $ concentration(ug/mL): num [1:9] 876 1039 1900 2232 2704 ...</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">sample_name</th>
<th style="text-align: right;">concentration(ug/mL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">876.1</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">1038.9</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">1900.4</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">2232.4</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">2703.7</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_01_ambient</td>
<td style="text-align: right;">263.1</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_04_ambient</td>
<td style="text-align: right;">560.0</td>
</tr>
<tr class="even">
<td style="text-align: left;">F07_05_36C</td>
<td style="text-align: right;">427.9</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F07_06_ambient</td>
<td style="text-align: right;">1119.4</td>
</tr>
</tbody>
</table>
</section>
<section id="samples-recommended-for-re-assay-2" class="level2">
<h2 class="anchored" data-anchor-id="samples-recommended-for-re-assay-2">11.2 Samples recommended for re-assay</h2>
<div class="sourceCode" id="cb126" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb126-1">failed_qc_samples    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> excluded_groups <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(base_sample_name)</span>
<span id="cb126-2">extrapolated_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_curve_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(base_sample_name)</span>
<span id="cb126-3"></span>
<span id="cb126-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- failed_qc_samples: samples excluded from analysis on CV grounds ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb126-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(failed_qc_samples)</span>
<span id="cb126-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- extrapolated_samples: QC-passing samples outside the retained standard curve's range ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb126-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(extrapolated_samples)</span></code></pre></div>
<pre><code>--- failed_qc_samples: samples excluded from analysis on CV grounds ---
tibble [0 × 17] (S3: tbl_df/tbl/data.frame)
 $ well_id            : chr(0) 
 $ name               : chr(0) 
 $ type               : chr(0) 
 $ std_conc_known     : int(0) 
 $ base_sample_name   : chr(0) 
 $ dilution_code      : num(0) 
 $ dilution_multiplier: num(0) 
 $ n_wells            : int(0) 
 $ mean_595           : num(0) 
 $ sd_595             : num(0) 
 $ cv_595             : num(0) 
 $ mean_concentration : num(0) 
 $ sd_concentration   : num(0) 
 $ cv_concentration   : num(0) 
 $ n_wells_valid_conc : int(0) 
 $ is_zero_standard   : logi(0) 
 $ high_cv            : logi(0) 

--- extrapolated_samples: QC-passing samples outside the retained standard curve's range ---
tibble [0 × 21] (S3: tbl_df/tbl/data.frame)
 $ well_id                      : chr(0) 
 $ name                         : chr(0) 
 $ type                         : chr(0) 
 $ std_conc_known               : int(0) 
 $ base_sample_name             : chr(0) 
 $ dilution_code                : num(0) 
 $ dilution_multiplier          : num(0) 
 $ n_wells                      : int(0) 
 $ mean_595                     : num(0) 
 $ sd_595                       : num(0) 
 $ cv_595                       : num(0) 
 $ mean_concentration           : num(0) 
 $ sd_concentration             : num(0) 
 $ cv_concentration             : num(0) 
 $ n_wells_valid_conc           : int(0) 
 $ is_zero_standard             : logi(0) 
 $ high_cv                      : logi(0) 
 $ se_595                       : num(0) 
 $ calculated_concentration_well: num(0) 
 $ calculated_concentration     : num(0) 
 $ in_curve_range               : logi(0) </code></pre>
<div class="sourceCode" id="cb128" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb128-1">reassay_candidates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb128-2">  failed_qc_samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb128-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> base_sample_name,</span>
<span id="cb128-4">              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rationale for re-assay</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(</span>
<span id="cb128-5">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_concentration),</span>
<span id="cb128-6">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV undefined (&lt; 2 valid replicates)"</span>,</span>
<span id="cb128-7">                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV &gt; 15%"</span></span>
<span id="cb128-8">              ))),</span>
<span id="cb128-9">  extrapolated_samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb128-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> base_sample_name,</span>
<span id="cb128-11">              <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rationale for re-assay</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outside standard curve range"</span>)</span>
<span id="cb128-12">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb128-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">natural_sort_key</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample name</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>))</span>
<span id="cb128-14"></span>
<span id="cb128-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- reassay_candidates: all samples flagged for re-assay, with rationale ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb128-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(reassay_candidates)</span>
<span id="cb128-17"></span>
<span id="cb128-18"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(reassay_candidates) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb128-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"None -- every sample on this plate passed all QC.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb128-20">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb128-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(reassay_candidates)</span>
<span id="cb128-22">}</span></code></pre></div>
<pre><code>--- reassay_candidates: all samples flagged for re-assay, with rationale ---
tibble [0 × 2] (S3: tbl_df/tbl/data.frame)
 $ Sample name           : chr(0) 
 $ Rationale for re-assay: chr(0) 
None -- every sample on this plate passed all QC.</code></pre>


</section>
</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>citrate synthase</category>
  <category>BSA</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/</guid>
  <pubDate>Thu, 13 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Citrate Synthase Assay - SORMI June 2026 M.gigas Family 5 Ambient Ctenidia</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Families 5 &amp; 7 from the June 2026 SORMI experiment were selected for citrate synthase assays (selection by Steven). This is the first citrate synthase assay run on these samples: ctenidia from the eight <em>Magallana gigas</em> (Pacific oyster) Family 5 individuals held at <strong>ambient</strong> temperature, using the Citrate Synthase Assay Kit (ABCAM; cat: ab239712). Samples had been <a href="../../../posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/index.html">previously homogenized on 20260811</a> (Notebook entry), and protein concentrations for normalization were <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">determined on 20260813</a> (Notebook entry).</p>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p><strong>This experiment needs to be repeated. This notebook entry exists primarily for posterity.</strong></p>
<p>The plate has QC failures (poor technical reps, primarily).</p>
</div>
</div>
<p>All data/code/analysis is available here:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase">https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase</a></li>
</ul>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<section id="citrate-synthase-assay" class="level2">
<h2 class="anchored" data-anchor-id="citrate-synthase-assay">Citrate Synthase Assay</h2>
<p>The Citrate Synthase Assay Kit (ABCAM; cat: ab239712) was used according to the manufacturer’s instructions (<a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf</a> (GitHub; PDF)).</p>
<p>Homogenates were thawed and 2 µL of undiluted homogenate was combined with 48 µL of Assay Buffer 7 per well, followed by 50 µL of Reaction Mix. Each sample was assayed in triplicate in a clear, flat-bottomed 96-well plate. Every sample also received a paired triplicate of background control wells, which receive Background Control Mix (no CS Substrate Mix) to correct for pre-existing free thiol in the homogenate. A six-point GSH standard curve (0, 8, 16, 24, 32, 40 nmol/well) and a CS positive control were included in triplicate on the same plate.</p>
<p>Master Mix Calcs</p>
<p>REACTION MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>43</td>
<td>50</td>
<td>2150</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>50</td>
<td>250</td>
</tr>
<tr class="odd">
<td>CS Substrate</td>
<td>2</td>
<td>50</td>
<td>100</td>
</tr>
</tbody>
</table>
<p>BACKGROUND MIX</p>
<table class="caption-top table">
<colgroup>
<col style="width: 22%">
<col style="width: 34%">
<col style="width: 15%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>REAGENT</th>
<th>SINGLE_RXN_VOLUME (uL)</th>
<th>REACTIONS</th>
<th>TOTAL_VOLUME (uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Assay Buffer 7</td>
<td>45</td>
<td>30</td>
<td>1350</td>
</tr>
<tr class="even">
<td>DTNB</td>
<td>5</td>
<td>30</td>
<td>150</td>
</tr>
</tbody>
</table>
<p>Absorbance was read at 412 nm in kinetic mode at 25°C on a Synergy HTX plate reader (Agilent), at 2-minute intervals. This plate was read for 40 minutes (21 reads).</p>
</section>
<section id="normalization" class="level2">
<h2 class="anchored" data-anchor-id="normalization">Normalization</h2>
<p>Activity was normalized to total extracted protein rather than tissue weight. Tissue was homogenized in 350 µL of Assay Buffer 7, and protein concentration in each homogenate was <a href="../../../posts/2026/2026-08-13-Protein-Quantification---June-2026-SORMI-M.gigas-Ctenidia-from-Famillies-5-and-7-for-Citrate-Synthase-Assay/index.html">quantified separately on 20260813</a> (Notebook entry) using the Bradford assay. Total protein mass per sample is that concentration multiplied by the 350 µL homogenization volume. Tissue weights are recorded in the plate layout labels for provenance only and play no role in the activity calculation.</p>
</section>
<section id="analysis" class="level2">
<h2 class="anchored" data-anchor-id="analysis">Analysis</h2>
<p>Data were analyzed in R. The Rmd file is here (GitHub):</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Citrate_synthase/code/Gen5-20260811-mgig-citrate_synthase-F05-ambient.Rmd">Gen5-20260811-mgig-citrate_synthase-F05-ambient.Rmd</a></li>
</ul>
<p>Knitted markdown is below.</p>
</section>
<section id="data-files" class="level2">
<h2 class="anchored" data-anchor-id="data-files">Data files</h2>
<section id="plate-reader-files" class="level3">
<h3 class="anchored" data-anchor-id="plate-reader-files">Plate reader files</h3>
<p>Plate reader files (<code>*.xpt</code>) are available here (require Gen5 software to open):</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/plate_reader_files</li>
</ul>
</section>
<section id="raw-absorbance-data" class="level3">
<h3 class="anchored" data-anchor-id="raw-absorbance-data">Raw absorbance data</h3>
<p>Raw absorbance data (<code>*.csv</code>), plate layouts, and Gen5 full reports are available here:</p>
<ul>
<li>https://github.com/RobertsLab/sormi-assay-development/tree/main/Citrate_synthase/data/raw_absorbance</li>
</ul>
</section>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Four of eight samples are clean on every check — <code>F05_01</code>, <code>F05_03</code>, <code>F05_07</code>, and <code>F05_08</code> — with no baseline-compromised replicates and technical CV &lt; 8%. The instructive result is how little they differ: 7.18, 7.55, 8.62, and 6.77 mA412/min background-corrected, a spread of roughly 25% against a within-sample technical CV of 5-8%. Once <code>F05_05</code> is recognized as a baseline artifact rather than a high-activity individual, no striking within-family variation remains at ambient temperature.</p>
<p>Because the standard curve failed its own QC, absolute activities carry uncertainty that the reported precision does not capture. Treat all values below as provisional.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Reps used</th>
<th style="text-align: right;">CV all reps (%)</th>
<th style="text-align: right;">CV used reps (%)</th>
<th style="text-align: right;">Corrected rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">4.9</td>
<td style="text-align: right;">4.9</td>
<td style="text-align: right;">7.18</td>
<td style="text-align: right;">73.4</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">2/3</td>
<td style="text-align: right;">30.3</td>
<td style="text-align: right;">8.9</td>
<td style="text-align: right;">8.65</td>
<td style="text-align: right;">74.6</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">5.4</td>
<td style="text-align: right;">5.4</td>
<td style="text-align: right;">7.55</td>
<td style="text-align: right;">35.6</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: left;">2/3</td>
<td style="text-align: right;">56.5</td>
<td style="text-align: right;">2.1</td>
<td style="text-align: right;">8.15</td>
<td style="text-align: right;">64.6</td>
<td style="text-align: left;">caution - some reps compromised</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: left;">2/3</td>
<td style="text-align: right;">68.8</td>
<td style="text-align: right;">15.1</td>
<td style="text-align: right;">19.10</td>
<td style="text-align: right;">240.4</td>
<td style="text-align: left;">DO NOT USE - no clean replicate</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">2/3</td>
<td style="text-align: right;">36.8</td>
<td style="text-align: right;">24.7</td>
<td style="text-align: right;">6.95</td>
<td style="text-align: right;">27.9</td>
<td style="text-align: left;">caution - some reps compromised</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">6.5</td>
<td style="text-align: right;">6.5</td>
<td style="text-align: right;">8.62</td>
<td style="text-align: right;">45.7</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: right;">7.9</td>
<td style="text-align: right;">7.9</td>
<td style="text-align: right;">6.77</td>
<td style="text-align: right;">22.4</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>Samples requiring re-assay: <code>F05_05</code> (mandatory — no clean replicate) and <code>F05_06</code> (24.7% CV on two genuinely disagreeing replicates). In practice the whole plate should be re-run, given the standard curve and background control problems.</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Citrate synthase (CS) activity in ctenidia of eight <em>Magallana gigas</em> (Pacific oyster) individuals from <strong>family F05</strong> held at <strong>ambient</strong> temperature, assayed 2026-08-11 with the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/ABCAM-Citrate-Synthase-Assay-v4a-ab239712.pdf">Abcam Citrate Synthase Assay Kit (ab239712), v4a</a>.</p>
<p>The kit is a <strong>coupled kinetic</strong> assay. CS condenses acetyl-CoA and oxaloacetate, releasing free CoA-SH; the liberated thiol reduces DTNB to TNB<sup>2-</sup>, which absorbs at 412 nm. The <strong>rate</strong> of A412 increase is proportional to CS activity, and absolute nmol of thiol are assigned from a <strong>GSH (reduced glutathione) standard curve</strong> read on the same plate.</p>
<p>Absorbance was read at 412 nm in kinetic mode, 25 °C, every 2 min for 40 min (21 reads) on a Synergy HTX.</p>
<p>This document is fully self-contained: layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are all defined directly below (see <code>## Pipeline functions</code> under SETUP) rather than sourced from a separate script, so the whole analysis can be reproduced from this one file.</p>
<section id="plate-design" class="level2">
<h2 class="anchored" data-anchor-id="plate-design">1.1 Plate design</h2>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Plate rows</th>
<th style="text-align: left;">Contents</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A, B</td>
<td style="text-align: left;">8 samples (<code>F05_01</code>–<code>F05_08</code>), technical triplicates, + Reaction Mix</td>
</tr>
<tr class="even">
<td style="text-align: left;">C, D</td>
<td style="text-align: left;">Paired <strong>background controls</strong> for the same 8 samples, + Background Control Mix (no CS Substrate Mix)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E, F1–F6</td>
<td style="text-align: left;">GSH standards: 0, 8, 16, 24, 32, 40 nmol/well, triplicates</td>
</tr>
<tr class="even">
<td style="text-align: left;">F7–F9</td>
<td style="text-align: left;">CS Positive Control, triplicate</td>
</tr>
</tbody>
</table>
<p>Background control wells receive Background Control Mix, which <strong>omits CS Substrate Mix</strong>. They therefore contain no acetyl-CoA/oxaloacetate, cannot support the CS reaction, and should read <strong>flat and low</strong> for the whole kinetic run. Their purpose (Abcam §8.4 note, §10.2) is to correct for pre-existing free thiol / CoA in the homogenate, which produces a one-time DTNB reduction at t0 rather than an ongoing rate.</p>
</section>
<section id="sample-naming" class="level2">
<h2 class="anchored" data-anchor-id="sample-naming">1.2 Sample naming</h2>
<p>Following the convention in the sibling Glycogen assay (<code>../../Glycogen/data/raw_luminescence/README.md</code>), plate layout entries are:</p>
<ul>
<li><code>&lt;sample&gt;-&lt;assay_type&gt;-&lt;tissue_weight&gt;-df.&lt;dilution_factor&gt;</code></li>
</ul>
<p>where <code>&lt;sample&gt;</code> is itself composite:</p>
<ul>
<li><code>&lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;</code>, with <code>_BG</code> appended for background control wells.</li>
</ul>
<p>E.g. <code>F05_03_ambient-citrate_synthase-22.3-df.0</code> is family F05, individual 03, ambient exposure, citrate synthase assay, 22.3 mg of ctenidia tissue, undiluted homogenate. Standards follow <code>STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</code> (e.g.&nbsp;<code>STD-citrate_synthase-24</code> = 24 nmol GSH/well); the positive control is <code>POS-citrate_synthase</code>.</p>
<p><code>df.0</code> denotes <strong>no dilution</strong> of the homogenate, i.e.&nbsp;dilution factor <em>D</em> = 1 in the Abcam activity formula. It is not a literal multiplier of zero.</p>
</section>
<section id="important-notes" class="level2">
<h2 class="anchored" data-anchor-id="important-notes">1.3 Important note(s)</h2>
<ol type="1">
<li><strong><code>absorbance-*.csv</code> is the sole data source.</strong> An earlier export of this file covered only plate columns 1–9 (54 of the 69 occupied wells); it has since been re-exported from the Gen5 software and now carries all 69 occupied wells (columns 1–12, rows A–F). The re-export was verified against <code>full_report-*.txt</code> — the two agree <strong>exactly</strong> on all 1,449 well × timepoint readings they share — and against <code>layout-*.csv</code>, which confirms the well set matches the plate layout with none missing and none extra. <code>full_report-*.txt</code> is retained only as a cross-check, not as a data source.</li>
<li><strong>Reaction volumes.</strong> 2 µL of homogenate + 48 µL Assay Buffer 7 per well, then 50 µL Reaction Mix. Sample volume <em>V</em> = 2 µL in the activity formula.</li>
<li><strong>Normalization is by total extracted protein, not tissue weight.</strong> Tissue was homogenized in <strong>350 µL</strong> of Assay Buffer 7 (<code>homogenate_volume_uL</code> below), reported by the bench operator and applied to every sample. Protein concentration in each homogenate was measured separately (BCA/Bradford-style assay, 595 nm; see <code>Protein concentration (normalization factor)</code> below) and converted to a total protein mass by multiplying by this same 350 µL. Tissue input (10.1–30.6 mg, recorded in the well label for provenance only) is not used in any activity calculation on this plate — total extracted protein is the normalizer, because it reflects what the assay actually measures against (soluble protein carried into the 2 µL aliquot), not the starting tissue mass, which can vary in extraction efficiency from sample to sample.</li>
<li><strong>Rate windows are compared over a common early interval.</strong> Every trace on this plate decelerates — substrate is being consumed — so the measured rate depends on <em>when</em> it is measured, and a rate is only comparable between wells if the wells are measured over comparable intervals. Selecting each well’s steepest window independently satisfies this here because the steepest window is the initial one (0–8 min) for 22 of 24 sample wells; the two exceptions are wells whose traces are anomalous and are excluded anyway. The R<sup>2</sup> floor for accepting a window is set to <code>rate_min_r2</code> = 0.80 rather than a stricter value for the same reason: deceleration within the window depresses R<sup>2</sup> even in clean wells (e.g.&nbsp;B10–B12 sit at 0.84–0.88 with 8% replicate CV), so a 0.95 floor would reject well-behaved replicates while retaining late, near-zero-rate windows from exhausted wells. Curvature is a property of the assay here, not a defect of the well.</li>
<li><strong>A412 at t = 0 is the master diagnostic on this plate.</strong> Clean sample wells start at A412 0.13–0.16. Every well that misbehaves — samples that decline, background wells that act like reactions — starts well above that. TNB present before the reaction begins means the well was contaminated or mis-dispensed, so its trace is not enzymology and a rate taken from it is not activity. <code>sample_baseline_od</code> = 0.35 separates the two populations cleanly (there are no sample wells between 0.23 and 0.29 except A6 at 0.29, itself anomalous). <strong>All three <code>F05_05</code> replicates</strong> start elevated (0.65–0.93), so that sample has no clean replicate at all — see the results caveat below.</li>
<li><strong>Layout label typo</strong>, carried through from the plate layout file and handled explicitly in the parsing chunk: <code>F05_05_ambient_BG</code> wells (D1–D3) are labeled <code>citrate_synthasse</code> (three s’s).</li>
</ol>
</section>
</section>
<section id="setup" class="level1">
<h1>2 SETUP</h1>
<section id="libraries-and-shared-pipeline-functions" class="level2">
<h2 class="anchored" data-anchor-id="libraries-and-shared-pipeline-functions">2.1 Libraries and shared pipeline functions</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="pipeline-functions" class="level2">
<h2 class="anchored" data-anchor-id="pipeline-functions">2.2 Pipeline functions</h2>
<p>All layout parsing, kinetic QC, standard-curve fitting, rate extraction, CV computation, protein normalization, and results assembly are defined directly in this document (rather than sourced from a separate script) so that it is fully self-contained and reproducible from this single file. The functions are grouped below by pipeline stage; each is called in the DATA / KINETIC TRACES / ANOMALY DETECTION / GSH STANDARD CURVE / RATE EXTRACTION / BACKGROUND CORRECTION / TECHNICAL REPLICATE PRECISION / CITRATE SYNTHASE ACTIVITY / QC SUMMARY sections that follow. Nothing plate-specific (typo fixes, disqualified samples, thresholds) is hardcoded in any function – it is always passed in as an argument, from the <code>assay_params</code> list defined further below or from a plate-specific fix list.</p>
<section id="data-import-and-layout-parsing" class="level3">
<h3 class="anchored" data-anchor-id="data-import-and-layout-parsing">2.2.1 Data import and layout parsing</h3>
<p>Reads the raw Gen5 exports (kinetic absorbance CSV, full-report text backup, plate-layout CSV), reconciles them against each other, and attaches well-type/sample-id/replicate metadata plus measured protein concentrations to every well.</p>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## elapsed_to_min()</span></span>
<span id="cb4-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert Gen5 "H:MM:SS" elapsed-time strings to decimal minutes.</span></span>
<span id="cb4-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : x - character vector of "H:MM:SS" strings</span></span>
<span id="cb4-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of elapsed minutes, same length as x</span></span>
<span id="cb4-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-7">elapsed_to_min <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb4-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-9">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p)</span>
<span id="cb4-10">    p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">60</span></span>
<span id="cb4-11">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb4-12">}</span>
<span id="cb4-13"></span>
<span id="cb4-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-15"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_absorbance_csv()</span></span>
<span id="cb4-16"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "absorbance-*.csv" kinetic export: wavelength</span></span>
<span id="cb4-17"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           header, a "Time," row, a temperature row, then one row per well</span></span>
<span id="cb4-18"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well ID in column 1, one OD reading per timepoint thereafter).</span></span>
<span id="cb4-19"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the absorbance-*.csv file</span></span>
<span id="cb4-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-23">read_absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-24">  ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-25">  time_i   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time,"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-26">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[time_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb4-27">  time_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> time_str[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>time_str <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time"</span>)]</span>
<span id="cb4-28">  tmin     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(time_str)</span>
<span id="cb4-29"></span>
<span id="cb4-30">  well_ln <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2},"</span>, ln)]</span>
<span id="cb4-31">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(well_ln, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb4-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> p[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-33">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(p[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(tmin) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb4-34">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-35">  }))</span>
<span id="cb4-36">}</span>
<span id="cb4-37"></span>
<span id="cb4-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## read_full_report()</span></span>
<span id="cb4-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Parse a Gen5 "full_report-*.txt" export: tab-delimited, wells</span></span>
<span id="cb4-41"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across columns, timepoints down rows. Used only as an</span></span>
<span id="cb4-42"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           independent cross-check against the absorbance CSV, never as a</span></span>
<span id="cb4-43"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           primary data source.</span></span>
<span id="cb4-44"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the full_report-*.txt file</span></span>
<span id="cb4-45"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : long-format data.frame, one row per well x timepoint:</span></span>
<span id="cb4-46"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr), time_min (dbl), od (dbl)</span></span>
<span id="cb4-47"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-48">read_full_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-49">  ln  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">iconv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">encoding =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"latin1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>)</span>
<span id="cb4-50">  hdr_i <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grep</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^Time</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.*</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">A1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb4-51">  hdr   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(ln[hdr_i], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]])</span>
<span id="cb4-52">  rows  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ln[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[0-9]:[0-9]{2}:[0-9]{2}</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, ln)]</span>
<span id="cb4-53">  m     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">do.call</span>(rbind, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">strsplit</span>(rows, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\t</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>))</span>
<span id="cb4-54">  tmin  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">elapsed_to_min</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb4-55"></span>
<span id="cb4-56">  well_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-H][0-9]{1,2}$"</span>, hdr))</span>
<span id="cb4-57">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(well_cols, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(j) {</span>
<span id="cb4-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well =</span> hdr[j], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_min =</span> tmin,</span>
<span id="cb4-59">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(m[, j]), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-60">  }))</span>
<span id="cb4-61">}</span>
<span id="cb4-62"></span>
<span id="cb4-63"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-64"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## parse_plate_layout()</span></span>
<span id="cb4-65"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Convert a raw Gen5 plate-layout CSV export into one row per</span></span>
<span id="cb4-66"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           occupied well with its descriptive label. Auto-detects two</span></span>
<span id="cb4-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           export formats seen in practice:</span></span>
<span id="cb4-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "single"  - one row per plate row (row 1 = column numbers,</span></span>
<span id="cb4-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         column 1 = row letter, last column = "Name" tag);</span></span>
<span id="cb4-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         each cell already holds the full descriptive label.</span></span>
<span id="cb4-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             "double"  - each plate row is exported as TWO rows: a</span></span>
<span id="cb4-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         "Well ID" row (SPL codes) immediately followed by</span></span>
<span id="cb4-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         a "Name" row (the descriptive label actually used</span></span>
<span id="cb4-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                         downstream).</span></span>
<span id="cb4-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           The format is detected from column 1: if a value repeats twice</span></span>
<span id="cb4-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           in a row (once for the well-ID row, once for the label row)</span></span>
<span id="cb4-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           immediately below a numeric header, it is treated as "double".</span></span>
<span id="cb4-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : path - path to the layout-*.csv file</span></span>
<span id="cb4-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per occupied well:</span></span>
<span id="cb4-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well (chr, e.g. "A1"), plate_row (chr), plate_col (int),</span></span>
<span id="cb4-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label (chr, trimmed descriptive label)</span></span>
<span id="cb4-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-83">parse_plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-84">  plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-85"></span>
<span id="cb4-86">  col1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1)</span>
<span id="cb4-87">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "double" format: row letters appear twice in a row in column 1</span></span>
<span id="cb4-88">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (once tagging the Well-ID row, once tagging the Name row), e.g.</span></span>
<span id="cb4-89">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "A", "A", "B", "B", ... Detect by checking whether non-empty,</span></span>
<span id="cb4-90">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># non-header values in col1 are each immediately followed by a repeat.</span></span>
<span id="cb4-91">  data_rows   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(col1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(col1))[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># drop header row (row 1)</span></span>
<span id="cb4-92">  is_double <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb4-93">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> col1[data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]][<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">floor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(data_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))])</span>
<span id="cb4-94"></span>
<span id="cb4-95">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (is_double) {</span>
<span id="cb4-96">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pair each row-letter row with the following label row.</span></span>
<span id="cb4-97">    row_letter_rows <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)]</span>
<span id="cb4-98">    label_rows      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data_rows[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]</span>
<span id="cb4-99">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(row_letter_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(label_rows))</span>
<span id="cb4-100"></span>
<span id="cb4-101">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pair_idx =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(row_letter_rows),</span>
<span id="cb4-102">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-103">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-104">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> col1[row_letter_rows[pair_idx]],</span>
<span id="cb4-105">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-106">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-107">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j],</span>
<span id="cb4-108">                                   label_rows[pair_idx], col_idx))</span>
<span id="cb4-109">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-110">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-111">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-112">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-113">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb4-114">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># "single" format: row 1 = column numbers, column 1 = row letters,</span></span>
<span id="cb4-115">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># last column = "Name" tag; each cell already holds the full label.</span></span>
<span id="cb4-116">    out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(plate_layout),</span>
<span id="cb4-117">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ncol</span>(plate_layout) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-118">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-119">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row =</span> plate_layout<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>V1[row_idx],</span>
<span id="cb4-120">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(plate_layout[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, col_idx]),</span>
<span id="cb4-121">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(plate_row, plate_col),</span>
<span id="cb4-122">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) plate_layout[i, j], row_idx, col_idx))</span>
<span id="cb4-123">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-124">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, plate_row, plate_col, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-126">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_row, plate_col)</span>
<span id="cb4-127">  }</span>
<span id="cb4-128"></span>
<span id="cb4-129">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(out, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(is_double, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"double"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"single"</span>)</span>
<span id="cb4-130">  out</span>
<span id="cb4-131">}</span>
<span id="cb4-132"></span>
<span id="cb4-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-134"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## reconcile_kinetic_sources()</span></span>
<span id="cb4-135"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Cross-check the absorbance CSV (primary data source) against</span></span>
<span id="cb4-136"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the full_report text export (independent instrument export)</span></span>
<span id="cb4-137"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and the plate layout (expected well set). Fails loudly</span></span>
<span id="cb4-138"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (stopifnot) if any layout well is missing from the CSV, or if</span></span>
<span id="cb4-139"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the two kinetic sources disagree on any shared reading.</span></span>
<span id="cb4-140"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : absorbance_csv - long-format data.frame from read_absorbance_csv()</span></span>
<span id="cb4-141"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           full_report    - long-format data.frame from read_full_report()</span></span>
<span id="cb4-142"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-143"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerance      - max allowed |CSV - report| absolute difference</span></span>
<span id="cb4-144"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            (default 1e-9, i.e. exact agreement)</span></span>
<span id="cb4-145"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(plate_readings, overlap_check, summary), where</span></span>
<span id="cb4-146"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_readings = absorbance_csv with a `source` column added,</span></span>
<span id="cb4-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           summary        = named list of counts for reporting</span></span>
<span id="cb4-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-149">reconcile_kinetic_sources <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(absorbance_csv, full_report, layout_wells,</span>
<span id="cb4-150">                                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tolerance =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>) {</span>
<span id="cb4-151">  wells_csv    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-152">  wells_report <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-153"></span>
<span id="cb4-154">  wells_report_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_report, wells_csv)</span>
<span id="cb4-155">  wells_layout_not_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, wells_csv)</span>
<span id="cb4-156">  wells_csv_not_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setdiff</span>(wells_csv, layout_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well)</span>
<span id="cb4-157"></span>
<span id="cb4-158">  overlap_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">inner_join</span>(absorbance_csv, full_report,</span>
<span id="cb4-159">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"time_min"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">suffix =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_csv"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_report"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-160">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_diff =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(od_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_report))</span>
<span id="cb4-161"></span>
<span id="cb4-162">  max_disagreement <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(overlap_check<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>abs_diff) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb4-163"></span>
<span id="cb4-164">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-165">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb4-166">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> tolerance</span>
<span id="cb4-167">  )</span>
<span id="cb4-168"></span>
<span id="cb4-169">  plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> absorbance_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance_csv"</span>)</span>
<span id="cb4-170"></span>
<span id="cb4-171">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-172">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_readings =</span> plate_readings,</span>
<span id="cb4-173">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">overlap_check  =</span> overlap_check,</span>
<span id="cb4-174">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">summary =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb4-175">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv),</span>
<span id="cb4-176">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report            =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report),</span>
<span id="cb4-177">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_report_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_report_not_csv),</span>
<span id="cb4-178">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_layout_not_csv    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_layout_not_csv),</span>
<span id="cb4-179">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells_csv_not_layout    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(wells_csv_not_layout),</span>
<span id="cb4-180">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_shared_readings         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(overlap_check),</span>
<span id="cb4-181">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_disagreement          =</span> max_disagreement</span>
<span id="cb4-182">    )</span>
<span id="cb4-183">  )</span>
<span id="cb4-184">}</span>
<span id="cb4-185"></span>
<span id="cb4-186"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-187"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## annotate_wells()</span></span>
<span id="cb4-188"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Join layout labels onto the kinetic readings and parse each</span></span>
<span id="cb4-189"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label into well_type, sample_id, family, individual,</span></span>
<span id="cb4-190"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           temperature, tissue weight, and standard concentration.</span></span>
<span id="cb4-191"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Expected label grammar:</span></span>
<span id="cb4-192"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             sample/background : &lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;[_BG]-&lt;assay_type&gt;-&lt;weight&gt;-df.&lt;n&gt;</span></span>
<span id="cb4-193"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             standard           : STD-&lt;assay_type&gt;-&lt;nmol_per_well&gt;</span></span>
<span id="cb4-194"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##             positive control   : POS-&lt;assay_type&gt;</span></span>
<span id="cb4-195"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Label typos (e.g. a misspelled assay_type) are corrected before</span></span>
<span id="cb4-196"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           parsing via `label_fixes`, a named character vector of</span></span>
<span id="cb4-197"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           c(pattern = replacement) pairs applied in order with gsub().</span></span>
<span id="cb4-198"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_readings - data.frame from reconcile_kinetic_sources()$plate_readings</span></span>
<span id="cb4-199"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           layout_wells   - data.frame from parse_plate_layout()</span></span>
<span id="cb4-200"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           label_fixes    - optional named character vector, e.g.</span></span>
<span id="cb4-201"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                            c("citrate_synthasse" = "citrate_synthase")</span></span>
<span id="cb4-202"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : plate_long - fully annotated long-format data.frame, one row</span></span>
<span id="cb4-203"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           per well x timepoint, with well_type, sample_id, family,</span></span>
<span id="cb4-204"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           individual, temperature, weight_mg, std_nmol columns added</span></span>
<span id="cb4-205"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-206">annotate_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_readings, layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-207">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_readings <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-208">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(layout_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-209">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-210">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_type =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb4-211">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-212">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^POS-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>,</span>
<span id="cb4-213">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_BG-"</span>,  label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>,</span>
<span id="cb4-214">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span></span>
<span id="cb4-215">      ),</span>
<span id="cb4-216">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_clean =</span> label</span>
<span id="cb4-217">    )</span>
<span id="cb4-218"></span>
<span id="cb4-219">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(label_fixes)) {</span>
<span id="cb4-220">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(label_fixes)) {</span>
<span id="cb4-221">      plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, label_fixes[[pat]], plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label_clean)</span>
<span id="cb4-222">    }</span>
<span id="cb4-223">  }</span>
<span id="cb4-224"></span>
<span id="cb4-225">  plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-226">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb4-227">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb4-228">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(_BG)?-[a-zA-Z_]+-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-229">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^(F[0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-230">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_([0-9]+)_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-231">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^F[0-9]+_[0-9]+_(.*)$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, sample_id), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>),</span>
<span id="cb4-232">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight_mg   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb4-233">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-[a-zA-Z_]+-([0-9.]+)-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">..*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean)),</span>
<span id="cb4-234">                           <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb4-235">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>,</span>
<span id="cb4-236">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-[a-zA-Z_]+-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean)), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb4-237">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-238">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well_type, sample_id, well, time_min)</span>
<span id="cb4-239"></span>
<span id="cb4-240">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fail loudly rather than silently dropping malformed labels</span></span>
<span id="cb4-241">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-242">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type)),</span>
<span id="cb4-243">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)])),</span>
<span id="cb4-244">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>]))</span>
<span id="cb4-245">  )</span>
<span id="cb4-246"></span>
<span id="cb4-247">  plate_long</span>
<span id="cb4-248">}</span>
<span id="cb4-249"></span>
<span id="cb4-250"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-251"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## load_protein_concentrations()</span></span>
<span id="cb4-252"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Load one or more BCA/Bradford-style protein-concentration CSV</span></span>
<span id="cb4-253"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exports, concatenate them, and match each plate sample to</span></span>
<span id="cb4-254"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           exactly one protein-concentration record. Fails loudly if any</span></span>
<span id="cb4-255"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate sample has zero or more than one match. Converts</span></span>
<span id="cb4-256"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration (ug/mL) to total protein mass (mg) in the full</span></span>
<span id="cb4-257"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate using the measured homogenization volume.</span></span>
<span id="cb4-258"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : protein_files        - character vector of CSV paths, each with</span></span>
<span id="cb4-259"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   columns `Sample` and</span></span>
<span id="cb4-260"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   `Calculated concentration (ug/mL)`</span></span>
<span id="cb4-261"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_sample_ids     - character vector of this plate's sample IDs</span></span>
<span id="cb4-262"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           homogenate_volume_uL - measured homogenization volume (uL),</span></span>
<span id="cb4-263"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   applied identically to every sample</span></span>
<span id="cb4-264"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_fixes      - optional named character vector of</span></span>
<span id="cb4-265"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   c(pattern = replacement) label-typo</span></span>
<span id="cb4-266"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   corrections applied to the protein</span></span>
<span id="cb4-267"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   file's Sample column before matching,</span></span>
<span id="cb4-268"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                   e.g. c("F-05_07_36C" = "F05_07_36C")</span></span>
<span id="cb4-269"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per plate sample:</span></span>
<span id="cb4-270"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id, source_file, conc_ug_mL, total_protein_mg</span></span>
<span id="cb4-271"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb4-272">load_protein_concentrations <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(protein_files, plate_sample_ids,</span>
<span id="cb4-273">                                         homogenate_volume_uL,</span>
<span id="cb4-274">                                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_fixes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb4-275">  protein_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_files <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-276">    purrr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(.x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-277">                      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">source_file =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(.x))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-278">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id_protein =</span> Sample, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc_ug_mL =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Calculated concentration (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-279">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id_protein, source_file, conc_ug_mL)</span>
<span id="cb4-280"></span>
<span id="cb4-281">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(sample_id_fixes)) {</span>
<span id="cb4-282">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (pat <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(sample_id_fixes)) {</span>
<span id="cb4-283">      protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(pat, sample_id_fixes[[pat]],</span>
<span id="cb4-284">                                             protein_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein)</span>
<span id="cb4-285">    }</span>
<span id="cb4-286">  }</span>
<span id="cb4-287"></span>
<span id="cb4-288">  protein_matches <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_id_protein <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> plate_sample_ids)</span>
<span id="cb4-289">  match_counts    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(sample_id_protein, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_matches"</span>)</span>
<span id="cb4-290"></span>
<span id="cb4-291">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(</span>
<span id="cb4-292">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(plate_sample_ids <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> protein_matches<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id_protein),</span>
<span id="cb4-293">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(match_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb4-294">  )</span>
<span id="cb4-295"></span>
<span id="cb4-296">  protein_matches <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-297">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rename</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-298">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_protein_mg =</span> conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> homogenate_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb4-299">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb4-300">}</span></code></pre></div>
</section>
<section id="well-level-kinetic-qc" class="level3">
<h3 class="anchored" data-anchor-id="well-level-kinetic-qc">2.2.2 Well-level kinetic QC</h3>
<p>Flags read glitches, non-rising (‘decreasing’) traces, elevated t0 baselines, and other well-level anomalies before any rate is trusted.</p>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## local_step_excess()</span></span>
<span id="cb5-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For a kinetic trace, measure how much each read-to-read step</span></span>
<span id="cb5-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           departs from the AVERAGE of its two immediate neighbouring</span></span>
<span id="cb5-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           steps. A large local excess flags a read glitch; comparing to</span></span>
<span id="cb5-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           local neighbours (rather than the trace's overall median step)</span></span>
<span id="cb5-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           tolerates traces that smoothly decelerate throughout.</span></span>
<span id="cb5-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : od - numeric vector of OD readings in time order</span></span>
<span id="cb5-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : numeric vector of length length(od) - 1 (one per step)</span></span>
<span id="cb5-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-11">local_step_excess <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(od) {</span>
<span id="cb5-12">  d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)</span>
<span id="cb5-13">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(d)</span>
<span id="cb5-14">  local_expect <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb5-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(d[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L, i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n))])</span>
<span id="cb5-16">  }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">numeric</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb5-17">  d <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> local_expect</span>
<span id="cb5-18">}</span>
<span id="cb5-19"></span>
<span id="cb5-20"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-21"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_diagnostics()</span></span>
<span id="cb5-22"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute four independent per-well trace-shape diagnostics from</span></span>
<span id="cb5-23"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the raw kinetic trace, before any rate fitting: direction</span></span>
<span id="cb5-24"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (net change), monotonicity (fraction of rising steps),</span></span>
<span id="cb5-25"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           over-range (any read above the photometric linearity ceiling),</span></span>
<span id="cb5-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and discontinuity (a read-to-read glitch via local_step_excess).</span></span>
<span id="cb5-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           Also flags an elevated starting absorbance for sample wells,</span></span>
<span id="cb5-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           and background wells that behave like active reactions.</span></span>
<span id="cb5-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb5-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with od_linear_max, glitch_excess_od,</span></span>
<span id="cb5-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          sample_baseline_od, bg_flat_od_max,</span></span>
<span id="cb5-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                          bg_flat_drift_max</span></span>
<span id="cb5-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_diagnostics - one row per well, with od_first, od_last,</span></span>
<span id="cb5-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           od_max, net_change, frac_rising, max_step, typical_step,</span></span>
<span id="cb5-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           step_excess, glitch_at_min, and flag_* / n_flags columns</span></span>
<span id="cb5-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-37">compute_well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb5-38">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-39">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-40">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, plate_row, plate_col, well_type, sample_id, label, std_nmol, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb5-42">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_first        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-43">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_last         =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od),</span>
<span id="cb5-44">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_max          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(od),</span>
<span id="cb5-45">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_change      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">last</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">first</span>(od),</span>
<span id="cb5-46">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">frac_rising     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb5-47">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_step        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od)))],</span>
<span id="cb5-48">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">typical_step    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(od))),</span>
<span id="cb5-49">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_excess     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od)))],</span>
<span id="cb5-50">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_at_min   =</span> time_min[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">local_step_excess</span>(od))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L],</span>
<span id="cb5-51">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb5-52">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb5-54">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step_ratio      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(max_step) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmax</span>(typical_step, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>),</span>
<span id="cb5-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_decreasing =</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb5-56">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_over_range =</span> od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb5-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_glitch     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(step_excess) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glitch_excess_od,</span>
<span id="cb5-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_high_baseline =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flag_bg_active  =</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb5-60">                        (od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_od_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span></span>
<span id="cb5-61">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(net_change) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_flat_drift_max),</span>
<span id="cb5-62">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_flags         =</span> flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_over_range <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb5-63">                        flag_bg_active <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> flag_high_baseline</span>
<span id="cb5-64">    )</span>
<span id="cb5-65">}</span>
<span id="cb5-66"></span>
<span id="cb5-67"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-68"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_baseline_diagnostics()</span></span>
<span id="cb5-69"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Classify sample/background wells by starting absorbance</span></span>
<span id="cb5-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (elevated vs. normal) and summarize, per sample, how many of</span></span>
<span id="cb5-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           its replicates are baseline-compromised. A sample with all</span></span>
<span id="cb5-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           replicates elevated has no clean replicate at all.</span></span>
<span id="cb5-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb5-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with sample_baseline_od</span></span>
<span id="cb5-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list(baseline_check, baseline_per_sample)</span></span>
<span id="cb5-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb5-77">compute_baseline_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, assay_params) {</span>
<span id="cb5-78">  baseline_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-79">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-80">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(od_first <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb5-81">                             <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-82">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(od_first))</span>
<span id="cb5-83"></span>
<span id="cb5-84">  baseline_per_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_check <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-85">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-87">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_elevated =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb5-88">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb5-89">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(n_elevated))</span>
<span id="cb5-90"></span>
<span id="cb5-91">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_check =</span> baseline_check, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">baseline_per_sample =</span> baseline_per_sample)</span>
<span id="cb5-92">}</span></code></pre></div>
</section>
<section id="standard-curve-and-rate-extraction" class="level3">
<h3 class="anchored" data-anchor-id="standard-curve-and-rate-extraction">2.2.3 Standard curve and rate extraction</h3>
<p>Fits the GSH standard curve, extracts each well’s rate via a sliding-window linear regression gated on R-squared, and summarizes the positive control.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## fit_standard_curve()</span></span>
<span id="cb6-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Extract t=0 GSH standard readings, quantify signal drift over</span></span>
<span id="cb6-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the run, compute per-concentration replicate statistics, flag</span></span>
<span id="cb6-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           outlier wells by deviation from their triplicate median, and</span></span>
<span id="cb6-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit three candidate calibration lines (all wells, per-</span></span>
<span id="cb6-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           concentration means, outlier-excluded). The outlier-excluded</span></span>
<span id="cb6-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit is the calibration used downstream.</span></span>
<span id="cb6-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long   - data.frame from annotate_wells()</span></span>
<span id="cb6-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with std_outlier_od</span></span>
<span id="cb6-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : list with standards_t0, standard_drift, standard_summary,</span></span>
<span id="cb6-12"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           standards_flagged, fit_all_wells, fit_means, fit_no_outliers,</span></span>
<span id="cb6-13"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           fit_comparison, std_slope, std_intercept, std_r2, std_nmol_max</span></span>
<span id="cb6-14"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-15">fit_standard_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, assay_params) {</span>
<span id="cb6-16">  standards_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, time_min, od, source)</span>
<span id="cb6-19"></span>
<span id="cb6-20">  standards_t0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, source) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-24"></span>
<span id="cb6-25">  standard_drift <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t0 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_t40 =</span> od[time_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(time_min)],</span>
<span id="cb6-28">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drift =</span> od_t40 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> od_t0, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol, well)</span>
<span id="cb6-30"></span>
<span id="cb6-31">  standard_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-32">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od),</span>
<span id="cb6-34">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_pct =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(od),</span>
<span id="cb6-35">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median_od =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-36">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-37">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">net_od =</span> mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean_od[std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>],</span>
<span id="cb6-38">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_per_nmol =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(std_nmol <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, net_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_nmol, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>))</span>
<span id="cb6-39"></span>
<span id="cb6-40">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-41">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-42">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">triplicate_median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od),</span>
<span id="cb6-43">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">deviation =</span> od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> triplicate_median,</span>
<span id="cb6-44">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_outlier =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(deviation)))</span>
<span id="cb6-47"></span>
<span id="cb6-48">  fit_all_wells   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged)</span>
<span id="cb6-49">  fit_means       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standard_summary)</span>
<span id="cb6-50">  fit_no_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_outlier))</span>
<span id="cb6-51"></span>
<span id="cb6-52">  fit_comparison <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb6-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all wells"</span>,          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_all_wells),</span>
<span id="cb6-54">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-55">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration means"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_means),</span>
<span id="cb6-57">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_means)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-58">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_means)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb6-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier-excluded"</span>,   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nobs</span>(fit_no_outliers),</span>
<span id="cb6-60">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb6-61">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r_squared =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared)</span>
<span id="cb6-62">  )</span>
<span id="cb6-63"></span>
<span id="cb6-64">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb6-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_all      =</span> standards_all,</span>
<span id="cb6-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_t0       =</span> standards_t0,</span>
<span id="cb6-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_drift     =</span> standard_drift,</span>
<span id="cb6-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard_summary   =</span> standard_summary,</span>
<span id="cb6-69">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standards_flagged  =</span> standards_flagged,</span>
<span id="cb6-70">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_all_wells      =</span> fit_all_wells,</span>
<span id="cb6-71">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_means          =</span> fit_means,</span>
<span id="cb6-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_no_outliers    =</span> fit_no_outliers,</span>
<span id="cb6-73">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_comparison     =</span> fit_comparison,</span>
<span id="cb6-74">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_slope          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]),</span>
<span id="cb6-75">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_intercept      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_no_outliers)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb6-76">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_r2             =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(fit_no_outliers)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared,</span>
<span id="cb6-77">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_nmol_max       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol)</span>
<span id="cb6-78">  )</span>
<span id="cb6-79">}</span>
<span id="cb6-80"></span>
<span id="cb6-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## window_slopes()</span></span>
<span id="cb6-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Fit every sliding window of `w` consecutive timepoints on one</span></span>
<span id="cb6-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           kinetic trace and return the slope (mOD/min) and R^2 of each.</span></span>
<span id="cb6-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : t - numeric vector of timepoints (min)</span></span>
<span id="cb6-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           y - numeric vector of OD readings, same length as t</span></span>
<span id="cb6-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           w - window width in number of points</span></span>
<span id="cb6-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : data.frame, one row per window: t_start, t_end,</span></span>
<span id="cb6-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2</span></span>
<span id="cb6-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-91">window_slopes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(t, y, w) {</span>
<span id="cb6-92">  n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(y)</span>
<span id="cb6-93">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb6-94">    i  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> s<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>(s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> w <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-95">    f  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(y[i] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> t[i])</span>
<span id="cb6-96">    r2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(f)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb6-97">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> t[i[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> t[i[w]],</span>
<span id="cb6-98">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(f)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb6-99">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(r2), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, r2))</span>
<span id="cb6-100">  }))</span>
<span id="cb6-101">}</span>
<span id="cb6-102"></span>
<span id="cb6-103"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-104"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_well_rates()</span></span>
<span id="cb6-105"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : For every well, scan all sliding windows of assay_params$</span></span>
<span id="cb6-106"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           rate_window_n consecutive reads and record the max-increasing</span></span>
<span id="cb6-107"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           window (used for activity) and the max-absolute window</span></span>
<span id="cb6-108"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (diagnostic only -- matches Gen5's own `Max V` convention,</span></span>
<span id="cb6-109"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           which can report large negative "rates" for degrading wells).</span></span>
<span id="cb6-110"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           A rate is `rate_usable` only if its R^2 clears the floor, the</span></span>
<span id="cb6-111"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well's net change is positive, and no read glitch falls inside</span></span>
<span id="cb6-112"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the fitted window.</span></span>
<span id="cb6-113"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : plate_long       - data.frame from annotate_wells()</span></span>
<span id="cb6-114"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_diagnostics - data.frame from compute_well_diagnostics()</span></span>
<span id="cb6-115"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with rate_window_n, rate_min_r2</span></span>
<span id="cb6-116"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : well_rates - one row per well: t_start, t_end, slope_mOD_min,</span></span>
<span id="cb6-117"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           r2, max_abs_slope_mOD_min, abs_window_is_negative,</span></span>
<span id="cb6-118"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           glitch_in_window, rate_usable (plus diagnostic columns joined in)</span></span>
<span id="cb6-119"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-120">compute_well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long, well_diagnostics, assay_params) {</span>
<span id="cb6-121">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-122">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well, time_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-123">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well, well_type, sample_id, std_nmol) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-124">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_modify</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> {</span>
<span id="cb6-125">      w   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">window_slopes</span>(.x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min, .x<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_window_n)</span>
<span id="cb6-126">      inc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min), ]</span>
<span id="cb6-127">      abs_ <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> w[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(w<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), ]</span>
<span id="cb6-128">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb6-129">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_start =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_start, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">t_end =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>t_end,</span>
<span id="cb6-130">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope_mOD_min =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> inc<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2,</span>
<span id="cb6-131">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max_abs_slope_mOD_min =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min,</span>
<span id="cb6-132">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">abs_window_is_negative =</span> abs_<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb6-133">      )</span>
<span id="cb6-134">    }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-135">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-136">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, net_change, frac_rising, od_max,</span>
<span id="cb6-137">                                          flag_decreasing, flag_over_range,</span>
<span id="cb6-138">                                          flag_glitch, glitch_at_min,</span>
<span id="cb6-139">                                          flag_bg_active, n_flags),</span>
<span id="cb6-140">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-141">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb6-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_in_window =</span> flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> t_start <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> glitch_at_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> t_end,</span>
<span id="cb6-143">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_usable      =</span> r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_min_r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>glitch_in_window</span>
<span id="cb6-144">    )</span>
<span id="cb6-145">}</span>
<span id="cb6-146"></span>
<span id="cb6-147"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-148"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_positive_control()</span></span>
<span id="cb6-149"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute the CS Positive Control's rate and activity, and check</span></span>
<span id="cb6-150"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           that its replicates rose linearly -- the plate's proof that the</span></span>
<span id="cb6-151"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reaction chemistry (DTNB, coupling, reader) worked, independent</span></span>
<span id="cb6-152"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           of any sample-specific problem.</span></span>
<span id="cb6-153"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates   - data.frame from compute_well_rates()</span></span>
<span id="cb6-154"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope    - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb6-155"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params - list with sample_volume_uL, dilution_factor</span></span>
<span id="cb6-156"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : pos_control - one row per positive-control well: t_start, t_end,</span></span>
<span id="cb6-157"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           slope_mOD_min, r2, net_change, activity_mU_uL</span></span>
<span id="cb6-158"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb6-159">compute_positive_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, std_slope, assay_params) {</span>
<span id="cb6-160">  well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-161">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"positive_control"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-162">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_uL =</span> (slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb6-163">                            assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor)</span>
<span id="cb6-164">}</span></code></pre></div>
</section>
<section id="background-correction-replicate-cv-and-activity-calculation" class="level3">
<h3 class="anchored" data-anchor-id="background-correction-replicate-cv-and-activity-calculation">2.2.4 Background correction, replicate CV, and activity calculation</h3>
<p>Estimates background rate from flat background wells, computes technical-replicate coefficients of variation, and converts corrected rates into protein-normalized CS activity.</p>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_background_correction()</span></span>
<span id="cb7-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Estimate each sample's background rate from its flat</span></span>
<span id="cb7-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (well-behaved) background-control replicates only, since</span></span>
<span id="cb7-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           anomalous background wells do not measure background.</span></span>
<span id="cb7-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates - data.frame from compute_well_rates()</span></span>
<span id="cb7-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : background_per_sample - one row per sample: n_bg_total,</span></span>
<span id="cb7-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           n_bg_flat, bg_rate_flat (NA if no flat replicate exists),</span></span>
<span id="cb7-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           bg_rate_all</span></span>
<span id="cb7-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-11">compute_background_correction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates) {</span>
<span id="cb7-12">  well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb7-16">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_total    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb7-17">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_bg_flat     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>flag_bg_active),</span>
<span id="cb7-18">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_flat  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>flag_bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb7-19">                             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>flag_bg_active]), <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>),</span>
<span id="cb7-20">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_all   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-21">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb7-22">    )</span>
<span id="cb7-23">}</span>
<span id="cb7-24"></span>
<span id="cb7-25"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-26"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## compute_replicate_cv()</span></span>
<span id="cb7-27"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute technical-replicate coefficient of variation (CV%) on</span></span>
<span id="cb7-28"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           the extracted rate, both across ALL three replicates and</span></span>
<span id="cb7-29"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           across USABLE replicates only (rate_usable == TRUE). Flags any</span></span>
<span id="cb7-30"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample whose CV exceeds assay_params$cv_threshold_pct.</span></span>
<span id="cb7-31"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates       - data.frame from compute_well_rates()</span></span>
<span id="cb7-32"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sample_id_order  - character vector giving the row order /</span></span>
<span id="cb7-33"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              complete sample-ID set to report (typically</span></span>
<span id="cb7-34"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              the plate's sample IDs, e.g. from</span></span>
<span id="cb7-35"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                              protein_by_sample$sample_id)</span></span>
<span id="cb7-36"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params     - list with cv_threshold_pct</span></span>
<span id="cb7-37"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cv_summary - one row per sample: n_all, mean_all, sd_all,</span></span>
<span id="cb7-38"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_all, n_usable, mean_usable, sd_usable, cv_usable,</span></span>
<span id="cb7-39"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           excluded_wells, fails_cv_all, fails_cv_usable</span></span>
<span id="cb7-40"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-41">compute_replicate_cv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, sample_id_order, assay_params) {</span>
<span id="cb7-42">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-43"></span>
<span id="cb7-44">  cv_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-46">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_all =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-47">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_all =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-48"></span>
<span id="cb7-49">  cv_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-50">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-51">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-53">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_usable =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-54">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_usable =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb7-55"></span>
<span id="cb7-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id =</span> sample_id_order, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-57">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_all, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-58">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-59">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-60">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">excluded_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vapply</span>(sample_id, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(s) {</span>
<span id="cb7-61">        w <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> s <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable]</span>
<span id="cb7-62">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(w) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(w, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)</span>
<span id="cb7-63">      }, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)),</span>
<span id="cb7-64">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_all    =</span> cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fails_cv_usable =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> cv_usable <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct</span>
<span id="cb7-66">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-67">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-68">}</span>
<span id="cb7-69"></span>
<span id="cb7-70"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-71"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## calculate_cs_activity()</span></span>
<span id="cb7-72"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Compute per-sample CS activity following Abcam sec 10.3, using</span></span>
<span id="cb7-73"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           only usable replicates, corrected for background rate, scaled</span></span>
<span id="cb7-74"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           through the standard curve, and normalized to total extracted</span></span>
<span id="cb7-75"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           protein (rather than tissue weight).</span></span>
<span id="cb7-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_rates            - data.frame from compute_well_rates()</span></span>
<span id="cb7-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           protein_by_sample     - data.frame from load_protein_concentrations()</span></span>
<span id="cb7-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           background_per_sample - data.frame from compute_background_correction()</span></span>
<span id="cb7-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_slope             - calibration slope (A412/nmol), from fit_standard_curve()</span></span>
<span id="cb7-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_nmol_max          - max calibrated GSH concentration, from fit_standard_curve()</span></span>
<span id="cb7-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params          - list with sample_volume_uL, dilution_factor,</span></span>
<span id="cb7-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    homogenate_volume_uL, read_duration_min</span></span>
<span id="cb7-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           plate_long            - data.frame from annotate_wells(), used to</span></span>
<span id="cb7-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##                                    attach family/individual/temperature</span></span>
<span id="cb7-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : cs_activity - one row per sample: n_reps_used, mean_rate_mOD_min,</span></span>
<span id="cb7-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           sd_rate, cv_rate, family, individual, temperature, conc_ug_mL,</span></span>
<span id="cb7-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           total_protein_mg, bg_rate_mOD_min, corrected_mOD_min,</span></span>
<span id="cb7-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_uL, total_mU_in_homogenate,</span></span>
<span id="cb7-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           activity_mU_per_mg_protein, within_std_range</span></span>
<span id="cb7-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-91">calculate_cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_rates, protein_by_sample, background_per_sample,</span>
<span id="cb7-92">                                   std_slope, std_nmol_max, assay_params, plate_long) {</span>
<span id="cb7-93">  sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb7-94"></span>
<span id="cb7-95">  sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-96">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(rate_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-97">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-98">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_reps_used =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_rate_mOD_min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min),</span>
<span id="cb7-99">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_rate =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min),</span>
<span id="cb7-100">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_rate =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(slope_mOD_min), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-101">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-102">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb7-103">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-104">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, conc_ug_mL, total_protein_mg),</span>
<span id="cb7-105">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-106">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(background_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, bg_rate_flat, n_bg_flat),</span>
<span id="cb7-107">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-108">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-109">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_rate_mOD_min       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(bg_rate_flat), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, bg_rate_flat),</span>
<span id="cb7-110">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">corrected_mOD_min     =</span> mean_rate_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> bg_rate_mOD_min,</span>
<span id="cb7-111">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_OD_min           =</span> corrected_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1000</span>,</span>
<span id="cb7-112">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_per_min          =</span> rate_OD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> std_slope,</span>
<span id="cb7-113">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_uL    =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_volume_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span></span>
<span id="cb7-114">                              assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution_factor,</span>
<span id="cb7-115">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">total_mU_in_homogenate =</span> activity_mU_per_uL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb7-116">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">activity_mU_per_mg_protein =</span> total_mU_in_homogenate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> total_protein_mg,</span>
<span id="cb7-117">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">nmol_in_window        =</span> nmol_per_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>read_duration_min),</span>
<span id="cb7-118">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">within_std_range      =</span> nmol_in_window <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> std_nmol_max</span>
<span id="cb7-119">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-120">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb7-121">}</span>
<span id="cb7-122"></span>
<span id="cb7-123"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-124"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_results_table()</span></span>
<span id="cb7-125"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Assemble the final, presentation-ready per-sample results</span></span>
<span id="cb7-126"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           table from cs_activity, cv_summary and baseline diagnostics,</span></span>
<span id="cb7-127"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           with a plain-language Interpretation column.</span></span>
<span id="cb7-128"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : cs_activity          - data.frame from calculate_cs_activity()</span></span>
<span id="cb7-129"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary           - data.frame from compute_replicate_cv()</span></span>
<span id="cb7-130"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample  - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb7-131"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params         - list with cv_threshold_pct, homogenate_volume_uL</span></span>
<span id="cb7-132"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : results_table - formatted data.frame, ready for kable()/write.csv()</span></span>
<span id="cb7-133"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb7-134">build_results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(cs_activity, cv_summary, baseline_per_sample, assay_params) {</span>
<span id="cb7-135">  cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-136">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-137">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-138">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb7-139">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample                       =</span> sample_id,</span>
<span id="cb7-140">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family                       =</span> family,</span>
<span id="cb7-141">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual                   =</span> individual,</span>
<span id="cb7-142">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature                  =</span> temperature,</span>
<span id="cb7-143">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Protein conc (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-144">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Total protein (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(total_protein_mg, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-145">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Reps used</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, n_all),</span>
<span id="cb7-146">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV all reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>            <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_all, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-147">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV used reps (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_rate, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb7-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-149">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">BG rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(bg_rate_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-150">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Corrected rate (mA412/min)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(corrected_mOD_min, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb7-151">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/uL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>           <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_uL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb7-152">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Activity (mU/mg protein)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(activity_mU_per_mg_protein, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb7-153">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV flag</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>                    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb7-154">                                            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FAIL &gt;"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pass"</span>),</span>
<span id="cb7-155">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Elevated baseline reps</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_elevated, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3"</span>),</span>
<span id="cb7-156">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Interpretation               =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb7-157">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"DO NOT USE - no clean replicate"</span>,</span>
<span id="cb7-158">        n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - some reps compromised"</span>,</span>
<span id="cb7-159">        cv_rate <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(cv_rate) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"caution - imprecise"</span>,</span>
<span id="cb7-160">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span></span>
<span id="cb7-161">      )</span>
<span id="cb7-162">    )</span>
<span id="cb7-163">}</span></code></pre></div>
</section>
<section id="qc-summary-and-narrative-generation" class="level3">
<h3 class="anchored" data-anchor-id="qc-summary-and-narrative-generation">2.2.5 QC summary and narrative generation</h3>
<p>Assembles the per-well QC summary table and auto-generates the plain-language QC findings bullets used in the QC SUMMARY section below.</p>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-2"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## build_qc_summary_table()</span></span>
<span id="cb8-3"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Consolidate every QC check performed across the pipeline into a</span></span>
<span id="cb8-4"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           single two-column (check, value) table, suitable for kable() and</span></span>
<span id="cb8-5"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           for writing to qc_summary.csv. Mirrors the individual find</span></span>
<span id="cb8-6"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           functions but as compact, at-a-glance figures rather than prose.</span></span>
<span id="cb8-7"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : layout_wells, reconcile_summary, std_curve, well_diagnostics,</span></span>
<span id="cb8-8"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates, cv_summary, baseline_per_sample, pos_control,</span></span>
<span id="cb8-9"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params</span></span>
<span id="cb8-10"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : qc_summary - data.frame with columns check, value (both chr)</span></span>
<span id="cb8-11"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-12">build_qc_summary_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(layout_wells, reconcile_summary, std_curve,</span>
<span id="cb8-13">                                    well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-14">                                    baseline_per_sample, pos_control, assay_params) {</span>
<span id="cb8-15">  standard_summary  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-16">  standards_flagged <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb8-17">  standard_drift    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb8-18">  sample_rates      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)</span>
<span id="cb8-19"></span>
<span id="cb8-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(</span>
<span id="cb8-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">check =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-22">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout"</span>,</span>
<span id="cb8-23">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from absorbance CSV"</span>,</span>
<span id="cb8-24">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max disagreement between absorbance CSV and full report"</span>,</span>
<span id="cb8-25">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard concentrations with replicate CV &gt; threshold"</span>,</span>
<span id="cb8-26">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers"</span>,</span>
<span id="cb8-27">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (outlier-excluded, replicate level)"</span>,</span>
<span id="cb8-28">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve R^2 (all wells, replicate level)"</span>,</span>
<span id="cb8-29">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells that LOST signal over the run"</span>,</span>
<span id="cb8-30">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards above photometric linearity ceiling"</span>,</span>
<span id="cb8-31">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background control wells behaving as active reactions"</span>,</span>
<span id="cb8-32">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a decreasing trace"</span>,</span>
<span id="cb8-33">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with an elevated starting A412"</span>,</span>
<span id="cb8-34">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with ALL THREE replicates baseline-compromised"</span>,</span>
<span id="cb8-35">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells with a read glitch"</span>,</span>
<span id="cb8-36">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells usable for rate extraction"</span>,</span>
<span id="cb8-37">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (all reps)"</span>,</span>
<span id="cb8-38">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with technical CV &gt; threshold (usable reps)"</span>,</span>
<span id="cb8-39">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control replicates rising and linear"</span></span>
<span id="cb8-40">    ),</span>
<span id="cb8-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb8-42">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells),</span>
<span id="cb8-43">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv,</span>
<span id="cb8-44">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.g"</span>, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement),</span>
<span id="cb8-45">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb8-46">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-47">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-48">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-49">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2),</span>
<span id="cb8-50">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared),</span>
<span id="cb8-51">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift)),</span>
<span id="cb8-52">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max],</span>
<span id="cb8-53">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb8-54">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_bg_active), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-55">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>)),</span>
<span id="cb8-56">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_decreasing <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-57">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-58">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-59">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-60">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_high_baseline], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-61">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-62">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(baseline_per_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>,</span>
<span id="cb8-63">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id[baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> baseline_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n],</span>
<span id="cb8-64">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>),</span>
<span id="cb8-65">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>flag_glitch <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>,</span>
<span id="cb8-66">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb8-67">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_rates)),</span>
<span id="cb8-68">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-69">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary)),</span>
<span id="cb8-70">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(pos_control))</span>
<span id="cb8-71">    ),</span>
<span id="cb8-72">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb8-73">  )</span>
<span id="cb8-74">}</span>
<span id="cb8-75"></span>
<span id="cb8-76"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-77"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## generate_qc_findings()</span></span>
<span id="cb8-78"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Purpose : Walk the QC/CV/anomaly objects for a plate and emit a</span></span>
<span id="cb8-79"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           consistent, generic-language markdown bullet list of findings</span></span>
<span id="cb8-80"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           (decreasing/glitched/high-baseline wells, background-control</span></span>
<span id="cb8-81"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           mix-ups, standard-curve QC failures, CV failures, disqualified</span></span>
<span id="cb8-82"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           samples). Intended to seed the SUMMARY section of a plate's</span></span>
<span id="cb8-83"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           .Rmd; a short hand-written subsection for plate-specific</span></span>
<span id="cb8-84"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           interpretation should follow it.</span></span>
<span id="cb8-85"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Inputs  : well_diagnostics    - data.frame from compute_well_diagnostics()</span></span>
<span id="cb8-86"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           well_rates          - data.frame from compute_well_rates()</span></span>
<span id="cb8-87"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           cv_summary          - data.frame from compute_replicate_cv()</span></span>
<span id="cb8-88"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           baseline_per_sample - data.frame from compute_baseline_diagnostics()</span></span>
<span id="cb8-89"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           std_curve           - list from fit_standard_curve()</span></span>
<span id="cb8-90"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           reconcile_summary   - list from reconcile_kinetic_sources()$summary</span></span>
<span id="cb8-91"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           assay_params        - list with cv_threshold_pct, od_linear_max</span></span>
<span id="cb8-92"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## Outputs : character vector, one markdown bullet per finding (empty</span></span>
<span id="cb8-93"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">##           findings are omitted, so a clean plate returns a short list)</span></span>
<span id="cb8-94"><span class="do" style="color: #5E5E5E;
background-color: null;
font-style: italic;">## -----------------------------------------------------------------------</span></span>
<span id="cb8-95">generate_qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb8-96">                                  baseline_per_sample, std_curve,</span>
<span id="cb8-97">                                  reconcile_summary, assay_params) {</span>
<span id="cb8-98">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-99"></span>
<span id="cb8-100">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Source reconciliation</span></span>
<span id="cb8-101">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span></span>
<span id="cb8-102">      (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1e-9</span>)) {</span>
<span id="cb8-103">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-104">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic source disagreement.** %d layout well(s) missing from the absorbance CSV; max disagreement between absorbance CSV and full report was %.4g A412."</span>,</span>
<span id="cb8-105">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement))</span>
<span id="cb8-106">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-107">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-108">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Kinetic sources agree.** absorbance CSV and full report agree exactly on all %d shared well x timepoint readings; all layout wells are present."</span>,</span>
<span id="cb8-109">      reconcile_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings))</span>
<span id="cb8-110">  }</span>
<span id="cb8-111"></span>
<span id="cb8-112">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Sample wells with decreasing kinetics</span></span>
<span id="cb8-113">  dec_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_decreasing)</span>
<span id="cb8-114">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-115">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-116">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Decreasing kinetics.** %d sample well(s) end lower than (or equal to) their starting A412 and are excluded from rate extraction: %s."</span>,</span>
<span id="cb8-117">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(dec_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(dec_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-118">  }</span>
<span id="cb8-119"></span>
<span id="cb8-120">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Read glitches</span></span>
<span id="cb8-121">  glitch_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_glitch)</span>
<span id="cb8-122">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-123">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-124">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Read glitches.** %d sample well(s) contain a single read-to-read step inconsistent with its neighbours: %s (only disqualifying if it falls inside the fitted rate window)."</span>,</span>
<span id="cb8-125">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(glitch_samples), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(glitch_samples<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-126">  }</span>
<span id="cb8-127"></span>
<span id="cb8-128">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Elevated baseline</span></span>
<span id="cb8-129">  high_baseline <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, flag_high_baseline)</span>
<span id="cb8-130">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-131">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-132">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Elevated starting absorbance.** %d sample well(s) start above the baseline threshold (A412 &gt; %s), indicating pre-existing thiol/contamination before the reaction began: %s."</span>,</span>
<span id="cb8-133">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_baseline), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(high_baseline<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-134">  }</span>
<span id="cb8-135"></span>
<span id="cb8-136">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Samples fully disqualified by baseline</span></span>
<span id="cb8-137">  disqualified <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n)</span>
<span id="cb8-138">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(disqualified) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-139">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-140">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Sample(s) with no clean replicate.** Every replicate of %s has an elevated starting A412; these samples have no usable measurement on this plate regardless of CV."</span>,</span>
<span id="cb8-141">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(disqualified<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-142">  }</span>
<span id="cb8-143"></span>
<span id="cb8-144">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Over-range wells</span></span>
<span id="cb8-145">  over_range <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(flag_over_range)</span>
<span id="cb8-146">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-147">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-148">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Over-range wells.** %d well(s) exceed the photometric linearity ceiling (A412 &gt; %s): %s."</span>,</span>
<span id="cb8-149">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-150">  }</span>
<span id="cb8-151"></span>
<span id="cb8-152">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Background wells behaving as active reactions</span></span>
<span id="cb8-153">  bg_active <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>, flag_bg_active)</span>
<span id="cb8-154">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-155">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-156">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Background control wells behaving as active reactions.** %d of %d background wells show a starting A412 or drift inconsistent with a flat, inactive well: %s."</span>,</span>
<span id="cb8-157">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(bg_active), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_diagnostics<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>),</span>
<span id="cb8-158">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(bg_active<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-159">  }</span>
<span id="cb8-160"></span>
<span id="cb8-161">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standard curve QC</span></span>
<span id="cb8-162">  std_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb8-163">  cv_fail_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct)</span>
<span id="cb8-164">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-165">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-166">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**GSH standard curve replicate imprecision.** %d of %d concentrations exceed %s%% CV: %s nmol/well."</span>,</span>
<span id="cb8-167">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_fail_std), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-168">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(cv_fail_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-169">  }</span>
<span id="cb8-170">  n_std_outliers <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier)</span>
<span id="cb8-171">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_std_outliers <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-172">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-173">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard outlier wells.** %d of %d standard wells deviate from their triplicate median by more than %s A412: %s."</span>,</span>
<span id="cb8-174">      n_std_outliers, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od,</span>
<span id="cb8-175">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well[std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-176">  }</span>
<span id="cb8-177">  over_range_std <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(mean_od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max)</span>
<span id="cb8-178">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(over_range_std) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-179">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-180">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standards above the photometric linear range.** %s nmol/well read above A412 %s; the calibration is trustworthy only below these concentrations."</span>,</span>
<span id="cb8-181">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(over_range_std<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max))</span>
<span id="cb8-182">  }</span>
<span id="cb8-183">  n_drift_neg <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb8-184">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n_drift_neg <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-185">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-186">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard signal decay.** %d of %d standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0."</span>,</span>
<span id="cb8-187">      n_drift_neg, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift)))</span>
<span id="cb8-188">  }</span>
<span id="cb8-189">  bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-190">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Standard curve fit (outlier-excluded):** slope = %.5f A412/nmol, R^2 = %.4f (all-wells R^2 = %.4f)."</span>,</span>
<span id="cb8-191">    std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope, std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared))</span>
<span id="cb8-192"></span>
<span id="cb8-193">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Technical replicate CV failures</span></span>
<span id="cb8-194">  fail_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all)</span>
<span id="cb8-195">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-196">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-197">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% (all replicates).** %d of %d samples: %s."</span>,</span>
<span id="cb8-198">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_all), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary),</span>
<span id="cb8-199">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%)"</span>, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-200">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb8-201">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-202">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV.** All %d samples are within %s%% CV across all three replicates."</span>,</span>
<span id="cb8-203">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct))</span>
<span id="cb8-204">  }</span>
<span id="cb8-205">  fail_usable <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable)</span>
<span id="cb8-206">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(fail_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb8-207">    bullets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(bullets, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(</span>
<span id="cb8-208">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Technical replicate CV &gt; %s%% persists after excluding flagged replicates.** %s."</span>,</span>
<span id="cb8-209">      assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb8-210">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s (%.0f%%, n=%d)"</span>, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_usable,</span>
<span id="cb8-211">                    fail_usable<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_usable), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>)))</span>
<span id="cb8-212">  }</span>
<span id="cb8-213"></span>
<span id="cb8-214">  bullets</span>
<span id="cb8-215">}</span></code></pre></div>
</section>
</section>
<section id="assay-parameters" class="level2">
<h2 class="anchored" data-anchor-id="assay-parameters">2.3 Assay parameters</h2>
<p>All assay constants and QC thresholds are collected here so nothing downstream hard-codes a number.</p>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">assay_params <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb9-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># homogenate volume per reaction well (V in Abcam formula)</span></span>
<span id="cb9-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">buffer_volume_uL      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">48</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Assay Buffer 7 added to reach 50 uL pre-Reaction Mix</span></span>
<span id="cb9-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_factor       =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># D; layout `df.0` = undiluted homogenate</span></span>
<span id="cb9-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_volume_uL  =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">350</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># MEASURED buffer volume tissue was homogenized in (see note 3)</span></span>
<span id="cb9-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_wavelength_nm    =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">412</span>,</span>
<span id="cb9-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_interval_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb9-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">read_duration_min     =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">40</span>,</span>
<span id="cb9-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_window_n         =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># points per sliding regression window (5 pts = 8 min)</span></span>
<span id="cb9-10">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">rate_min_r2           =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.80</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># min R^2 for a rate window to be trusted (see note 4)</span></span>
<span id="cb9-11">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch_excess_od      =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |step - mean of neighbouring steps| flagging a read glitch</span></span>
<span id="cb9-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_threshold_pct      =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>,    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># technical-replicate CV QC threshold</span></span>
<span id="cb9-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">od_linear_max         =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>,   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># upper A412 bound for reliable photometry</span></span>
<span id="cb9-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">std_outlier_od        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># |deviation from triplicate median| flagging a standard well</span></span>
<span id="cb9-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_baseline_od    =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># max acceptable t0 A412 for a sample well (see note 5)</span></span>
<span id="cb9-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_od_max        =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a well-behaved background well starts below this A412</span></span>
<span id="cb9-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_flat_drift_max     =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ...and drifts less than this over the whole run</span></span>
<span id="cb9-18">)</span>
<span id="cb9-19"></span>
<span id="cb9-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- assay_params: assay constants and QC thresholds ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb9-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(assay_params)</span></code></pre></div>
<pre><code>--- assay_params: assay constants and QC thresholds ---

List of 16
 $ sample_volume_uL    : num 2
 $ buffer_volume_uL    : num 48
 $ dilution_factor     : num 1
 $ homogenate_volume_uL: num 350
 $ read_wavelength_nm  : num 412
 $ read_interval_min   : num 2
 $ read_duration_min   : num 40
 $ rate_window_n       : num 5
 $ rate_min_r2         : num 0.8
 $ glitch_excess_od    : num 0.02
 $ cv_threshold_pct    : num 15
 $ od_linear_max       : num 1.5
 $ std_outlier_od      : num 0.15
 $ sample_baseline_od  : num 0.35
 $ bg_flat_od_max      : num 0.15
 $ bg_flat_drift_max   : num 0.05</code></pre>
</section>
<section id="output-directory" class="level2">
<h2 class="anchored" data-anchor-id="output-directory">2.4 Output directory</h2>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Output directory for this analysis (matches this file's name, per ../code/README.md)</span></span>
<span id="cb11-2">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../outputs/Gen5-20260811-mgig-citrate_synthase-F05-ambient"</span></span>
<span id="cb11-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb11-4"></span>
<span id="cb11-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- output_dir: destination for all figures and tables ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb11-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(output_dir)</span></code></pre></div>
<pre><code>--- output_dir: destination for all figures and tables ---
 chr "../outputs/Gen5-20260811-mgig-citrate_synthase-F05-ambient"</code></pre>
</section>
</section>
<section id="data" class="level1">
<h1>3 DATA</h1>
<p>Data are read from the local repo (<code>../data/raw_absorbance/</code>) so this document renders before/after the files are pushed to GitHub.</p>
<section id="plate-layout" class="level2">
<h2 class="anchored" data-anchor-id="plate-layout">3.1 Plate layout</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">data_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/raw_absorbance"</span></span>
<span id="cb13-2">run_stem <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Gen5-20260811-mgig-citrate_synthase-F05-ambient"</span></span>
<span id="cb13-3"></span>
<span id="cb13-4">layout_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_layout</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb13-5"></span>
<span id="cb13-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout format detected:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">attr</span>(layout_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout_format"</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Occupied wells in layout:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(layout_wells), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-8"></span>
<span id="cb13-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- layout_wells: one row per occupied well, with its descriptive label ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb13-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(layout_wells)</span></code></pre></div>
<pre><code>Layout format detected: single 
Occupied wells in layout: 69 

--- layout_wells: one row per occupied well, with its descriptive label ---

'data.frame':   69 obs. of  4 variables:
 $ well     : chr  "A1" "A2" "A3" "A4" ...
 $ plate_row: chr  "A" "A" "A" "A" ...
 $ plate_col: int  1 2 3 4 5 6 7 8 9 10 ...
 $ label    : chr  "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_02_ambient-citrate_synthase-17.5-df.0" ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "row_idx" "col_idx"
  ..$ dimnames:List of 2
  .. ..$ row_idx: chr [1:8] "row_idx=2" "row_idx=3" "row_idx=4" "row_idx=5" ...
  .. ..$ col_idx: chr [1:12] "col_idx= 2" "col_idx= 3" "col_idx= 4" "col_idx= 5" ...
 - attr(*, "layout_format")= chr "single"</code></pre>
</section>
<section id="kinetic-readers" class="level2">
<h2 class="anchored" data-anchor-id="kinetic-readers">3.2 Kinetic readers</h2>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">absorbance_csv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_absorbance_csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".csv"</span>)))</span>
<span id="cb15-2">full_report    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_full_report</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full_report-"</span>, run_stem, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".txt"</span>)))</span>
<span id="cb15-3"></span>
<span id="cb15-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"absorbance CSV : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-5">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(absorbance_csv<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"full report    : "</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" wells x "</span>,</span>
<span id="cb15-7">    dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(full_report<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_min), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" timepoints</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb15-8"></span>
<span id="cb15-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- absorbance_csv: long-format readings from absorbance-*.csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(absorbance_csv)</span>
<span id="cb15-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- full_report: long-format readings from full_report-*.txt ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb15-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(full_report)</span></code></pre></div>
<pre><code>absorbance CSV : 69 wells x 21 timepoints
full report    : 69 wells x 21 timepoints

--- absorbance_csv: long-format readings from absorbance-*.csv ---

'data.frame':   1449 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.126 0.143 0.16 0.176 0.191 0.203 0.213 0.222 0.229 0.236 ...

--- full_report: long-format readings from full_report-*.txt ---

'data.frame':   1449 obs. of  3 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.126 0.143 0.16 0.176 0.191 0.203 0.213 0.222 0.229 0.236 ...</code></pre>
</section>
<section id="cross-check-against-the-full-report" class="level2">
<h2 class="anchored" data-anchor-id="cross-check-against-the-full-report">3.3 Cross-check against the full report</h2>
<p><code>absorbance-*.csv</code> is used for every well; no gap-fill is needed now that the re-exported file covers the full plate. <code>full_report-*.txt</code> is used only to confirm the re-export is trustworthy: every well it reports should also be in the CSV, every well the layout expects should be in the CSV, and every reading the two files share should agree exactly.</p>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">recon <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reconcile_kinetic_sources</span>(absorbance_csv, full_report, layout_wells)</span>
<span id="cb17-2">plate_readings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_readings</span>
<span id="cb17-3"></span>
<span id="cb17-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in absorbance CSV          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report             :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells in full report not in CSV  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_report_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Layout wells missing from CSV    :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_layout_not_csv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CSV wells not in layout          :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells_csv_not_layout, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shared well x timepoints         :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_shared_readings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max |CSV - report| disagreement  :"</span>, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>max_disagreement, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-11"></span>
<span id="cb17-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- recon$overlap_check: per-reading comparison of the two raw files ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>overlap_check)</span>
<span id="cb17-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_readings: readings for all occupied wells, from absorbance_csv ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb17-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_readings)</span></code></pre></div>
<pre><code>Wells in absorbance CSV          : 69 
Wells in full report             : 69 
Wells in full report not in CSV  : 0 
Layout wells missing from CSV    : 0 
CSV wells not in layout          : 0 
Shared well x timepoints         : 1449 
Max |CSV - report| disagreement  : 0 

--- recon$overlap_check: per-reading comparison of the two raw files ---

'data.frame':   1449 obs. of  5 variables:
 $ well     : chr  "A1" "A1" "A1" "A1" ...
 $ time_min : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od_csv   : num  0.126 0.143 0.16 0.176 0.191 0.203 0.213 0.222 0.229 0.236 ...
 $ od_report: num  0.126 0.143 0.16 0.176 0.191 0.203 0.213 0.222 0.229 0.236 ...
 $ abs_diff : num  0 0 0 0 0 0 0 0 0 0 ...

--- plate_readings: readings for all occupied wells, from absorbance_csv ---

'data.frame':   1449 obs. of  4 variables:
 $ well    : chr  "A1" "A1" "A1" "A1" ...
 $ time_min: num  0 2 4 6 8 10 12 14 16 18 ...
 $ od      : num  0.126 0.143 0.16 0.176 0.191 0.203 0.213 0.222 0.229 0.236 ...
 $ source  : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...</code></pre>
</section>
<section id="annotate-wells-and-parse-metadata" class="level2">
<h2 class="anchored" data-anchor-id="annotate-wells-and-parse-metadata">3.4 Annotate wells and parse metadata</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Tolerate the `citrate_synthasse` typo in the D1-D3 labels (see note 6)</span></span>
<span id="cb19-2">plate_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate_wells</span>(plate_readings, layout_wells,</span>
<span id="cb19-3">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_fixes =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthasse"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase"</span>))</span>
<span id="cb19-4"></span>
<span id="cb19-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells per type:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(well, well_type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_wells"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-7">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb19-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standards (nmol/well):"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol))), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-10"></span>
<span id="cb19-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_long: fully annotated long-format plate, one row per well x timepoint ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb19-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_long)</span></code></pre></div>
<pre><code>Wells per type:
        well_type n_wells
       background      24
 positive_control       3
           sample      24
         standard      18

Samples: F05_01_ambient, F05_02_ambient, F05_03_ambient, F05_04_ambient, F05_05_ambient, F05_06_ambient, F05_07_ambient, F05_08_ambient 
Standards (nmol/well): 0, 8, 16, 24, 32, 40 

--- plate_long: fully annotated long-format plate, one row per well x timepoint ---

'data.frame':   1449 obs. of  15 variables:
 $ well       : chr  "C1" "C1" "C1" "C1" ...
 $ time_min   : num  0 2 4 6 8 10 12 14 16 18 ...
 $ od         : num  0.057 0.058 0.058 0.058 0.058 0.059 0.059 0.059 0.06 0.06 ...
 $ source     : chr  "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ plate_row  : chr  "C" "C" "C" "C" ...
 $ plate_col  : int  1 1 1 1 1 1 1 1 1 1 ...
 $ label      : chr  "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" ...
 $ well_type  : chr  "background" "background" "background" "background" ...
 $ label_clean: chr  "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" ...
 $ sample_id  : chr  "F05_01_ambient" "F05_01_ambient" "F05_01_ambient" "F05_01_ambient" ...
 $ family     : chr  "F05" "F05" "F05" "F05" ...
 $ individual : chr  "01" "01" "01" "01" ...
 $ temperature: chr  "ambient" "ambient" "ambient" "ambient" ...
 $ weight_mg  : num  10.1 10.1 10.1 10.1 10.1 10.1 10.1 10.1 10.1 10.1 ...
 $ std_nmol   : num  NA NA NA NA NA NA NA NA NA NA ...</code></pre>
</section>
<section id="protein-concentration-normalization-factor" class="level2">
<h2 class="anchored" data-anchor-id="protein-concentration-normalization-factor">3.5 Protein concentration (normalization factor)</h2>
<p>Activity is normalized to total extracted protein rather than tissue weight (note 3). Protein concentration for each sample was measured on a separate BCA/Bradford-style plate (595 nm) and supplied as two CSV exports covering different subsets of samples across families F05 and F07; only the F05 ambient samples analyzed on this plate are relevant here, so the two files are concatenated and then filtered down to this plate’s 8 sample IDs.</p>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">protein_files <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb21-2">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/sample_protein_concentrations_1.csv"</span>,</span>
<span id="cb21-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/BSA/raw_absorbance/sample_protein_concentrations_2.csv"</span></span>
<span id="cb21-4">)</span>
<span id="cb21-5"></span>
<span id="cb21-6">plate_sample_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(plate_long<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)))</span>
<span id="cb21-7"></span>
<span id="cb21-8">protein_by_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">load_protein_concentrations</span>(protein_files, plate_sample_ids,</span>
<span id="cb21-9">                                                  assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-11">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>(sample_id, family, individual, temperature),</span>
<span id="cb21-12">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb21-13"></span>
<span id="cb21-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples matched to a protein concentration record:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample),</span>
<span id="cb21-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(plate_sample_ids), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein concentration range (ug/mL):"</span>,</span>
<span id="cb21-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_ug_mL), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total protein per homogenate range (mg):"</span>,</span>
<span id="cb21-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(protein_by_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, source_file, conc_ug_mL, total_protein_mg) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-21">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb21-22"></span>
<span id="cb21-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_by_sample: matched protein concentration and total protein per homogenate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_by_sample)</span></code></pre></div>
<pre><code>Samples matched to a protein concentration record: 8 / 8 
Protein concentration range (ug/mL): 711.7 - 2703.7 
Total protein per homogenate range (mg): 0.249 - 0.946 

      sample_id                         source_file conc_ug_mL total_protein_mg
 F05_01_ambient sample_protein_concentrations_2.csv      876.1         0.306635
 F05_02_ambient sample_protein_concentrations_2.csv     1038.9         0.363615
 F05_03_ambient sample_protein_concentrations_2.csv     1900.4         0.665140
 F05_04_ambient sample_protein_concentrations_1.csv     1129.4         0.395290
 F05_05_ambient sample_protein_concentrations_1.csv      711.7         0.249095
 F05_06_ambient sample_protein_concentrations_2.csv     2232.4         0.781340
 F05_07_ambient sample_protein_concentrations_1.csv     1687.8         0.590730
 F05_08_ambient sample_protein_concentrations_2.csv     2703.7         0.946295

--- protein_by_sample: matched protein concentration and total protein per homogenate ---

'data.frame':   8 obs. of  7 variables:
 $ sample_id       : chr  "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ source_file     : chr  "sample_protein_concentrations_2.csv" "sample_protein_concentrations_2.csv" "sample_protein_concentrations_2.csv" "sample_protein_concentrations_1.csv" ...
 $ conc_ug_mL      : num  876 1039 1900 1129 712 ...
 $ total_protein_mg: num  0.307 0.364 0.665 0.395 0.249 ...
 $ family          : chr  "F05" "F05" "F05" "F05" ...
 $ individual      : chr  "01" "02" "03" "04" ...
 $ temperature     : chr  "ambient" "ambient" "ambient" "ambient" ...</code></pre>
</section>
</section>
<section id="kinetic-traces" class="level1">
<h1>4 KINETIC TRACES</h1>
<p>Every trace is plotted before any rate is extracted. In this assay the <strong>shape</strong> of the trace is the primary diagnostic: CS activity must produce a monotonically <em>rising</em> A412, and only a genuinely linear stretch may be used for a rate.</p>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">trace_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(plate_long, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> well, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> plate_row <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> plate_col, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ncol =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>,</span>
<span id="cb23-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labeller =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(d) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row, d<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>,</span>
<span id="cb23-8">                                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">standard =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">positive_control =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#6a51a3"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 kinetic traces, all occupied wells"</span>,</span>
<span id="cb23-10">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dotted line = assumed photometric linearity ceiling (A412 = "</span>,</span>
<span id="cb23-11">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb23-12">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Rising traces only are usable for rate extraction."</span>),</span>
<span id="cb23-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (min)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb23-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb23-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>),</span>
<span id="cb23-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>),</span>
<span id="cb23-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb23-19"></span>
<span id="cb23-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"kinetic_traces_all_wells.png"</span>), trace_plot,</span>
<span id="cb23-21">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb23-22"></span>
<span id="cb23-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- trace_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb23-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(trace_plot)</span>
<span id="cb23-25"></span>
<span id="cb23-26">trace_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/Gen5-20260811-mgig-citrate_synthase-F05-ambient_files/figure-gfm/plot-kinetic-traces-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- trace_plot: ggplot object structure ---

data: well, time_min, od, source, plate_row, plate_col, label,
  well_type, label_clean, sample_id, family, individual, temperature,
  weight_mg, std_nmol [1449x15]
mapping:  x = ~time_min, y = ~od, group = ~well, colour = ~well_type
scales:   colour 
faceting:  ~plate_row, ~plate_col 
-----------------------------------
geom_line: na.rm = FALSE, orientation = NA, arrow = NULL, arrow.fill = NULL, lineend = butt, linejoin = round, linemitre = 10
stat_identity: na.rm = FALSE
position_identity 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
<section id="anomaly-detection" class="level1">
<h1>5 ANOMALY DETECTION</h1>
<section id="per-well-trace-diagnostics" class="level2">
<h2 class="anchored" data-anchor-id="per-well-trace-diagnostics">5.1 Per-well trace diagnostics</h2>
<p>Four independent checks per well, all computed from the raw trace before any rate fitting:</p>
<ol type="1">
<li><strong>Direction</strong> — net A412 change from first to last read. A CS-containing well must be positive.</li>
<li><strong>Monotonicity</strong> — fraction of the 20 read-to-read intervals that rise.</li>
<li><strong>Over-range</strong> — any read above the photometric linearity ceiling.</li>
<li><strong>Discontinuity</strong> — a single read-to-read step that departs from its two <em>neighbouring</em> steps, catching read glitches rather than biology. Comparing each step against its immediate neighbours (rather than against the well’s overall median step) matters here because every trace decelerates: the first interval of a decelerating trace is legitimately the largest of the run and a median-based rule flags it spuriously.</li>
</ol>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">well_diagnostics <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_diagnostics</span>(plate_long, assay_params)</span>
<span id="cb25-2"></span>
<span id="cb25-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Flag counts across all"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_diagnostics), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-5">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">decreasing =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(flag_decreasing), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">over_range =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(flag_over_range),</span>
<span id="cb25-6">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glitch =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(flag_glitch), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">bg_active =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(flag_bg_active),</span>
<span id="cb25-7">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">high_baseline =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(flag_high_baseline),</span>
<span id="cb25-8">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">clean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb25-9"></span>
<span id="cb25-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># The starting A412 separates clean wells from compromised ones across every</span></span>
<span id="cb25-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># well type, so it is tabulated explicitly rather than only used as a flag</span></span>
<span id="cb25-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Starting A412 (t = 0) by well type:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_type) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-14">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(od_first),</span>
<span id="cb25-15">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(od_first), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-16">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb25-17"></span>
<span id="cb25-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- well_diagnostics: per-well trace shape diagnostics and anomaly flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb25-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_diagnostics)</span></code></pre></div>
<pre><code>Flag counts across all 69 wells:
 decreasing over_range glitch bg_active high_baseline clean
         28          7     11         7             5    37

Starting A412 (t = 0) by well type:
        well_type  n   min median   max
       background 24 0.050  0.061 0.817
 positive_control  3 0.216  0.229 0.236
           sample 24 0.125  0.158 0.929
         standard 18 0.095  1.285 2.189

--- well_diagnostics: per-well trace shape diagnostics and anomaly flags ---

tibble [69 × 24] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:69] "A1" "A10" "A11" "A12" ...
 $ plate_row         : chr [1:69] "A" "A" "A" "A" ...
 $ plate_col         : int [1:69] 1 10 11 12 2 3 4 5 6 7 ...
 $ well_type         : chr [1:69] "sample" "sample" "sample" "sample" ...
 $ sample_id         : chr [1:69] "F05_01_ambient" "F05_04_ambient" "F05_04_ambient" "F05_04_ambient" ...
 $ label             : chr [1:69] "F05_01_ambient-citrate_synthase-10.1-df.0" "F05_04_ambient-citrate_synthase-14.0-df.0" "F05_04_ambient-citrate_synthase-14.0-df.0" "F05_04_ambient-citrate_synthase-14.0-df.0" ...
 $ std_nmol          : num [1:69] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:69] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:69] 0.126 0.129 0.136 0.671 0.129 0.125 0.135 0.154 0.287 0.154 ...
 $ od_last           : num [1:69] 0.29 0.286 0.292 0.331 0.291 0.294 0.297 0.317 0.328 0.292 ...
 $ od_max            : num [1:69] 0.29 0.286 0.292 0.671 0.291 0.294 0.297 0.317 0.336 0.292 ...
 $ net_change        : num [1:69] 0.164 0.157 0.156 -0.34 0.162 0.169 0.162 0.163 0.041 0.138 ...
 $ frac_rising       : num [1:69] 1 1 1 0.3 1 1 1 1 0.35 1 ...
 $ max_step          : num [1:69] 0.017 0.019 0.021 -0.042 0.016 ...
 $ typical_step      : num [1:69] 0.0055 0.005 0.005 0.019 0.006 ...
 $ step_excess       : num [1:69] -0.001 0.0015 0.002 -0.036 0.001 ...
 $ glitch_at_min     : num [1:69] 38 8 2 2 24 22 18 28 30 2 ...
 $ step_ratio        : num [1:69] 3.09 3.8 4.2 2.21 2.67 ...
 $ flag_decreasing   : logi [1:69] FALSE FALSE FALSE TRUE FALSE FALSE ...
 $ flag_over_range   : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:69] FALSE FALSE FALSE TRUE FALSE FALSE ...
 $ flag_high_baseline: logi [1:69] FALSE FALSE FALSE TRUE FALSE FALSE ...
 $ flag_bg_active    : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags           : int [1:69] 0 0 0 3 0 0 0 0 1 0 ...</code></pre>
</section>
<section id="anomalous-wells" class="level2">
<h2 class="anchored" data-anchor-id="anomalous-wells">5.2 Anomalous wells</h2>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">anomalies <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_flags <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">flags =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(</span>
<span id="cb27-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(flag_decreasing, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"decreasing "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>),</span>
<span id="cb27-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(flag_over_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"over-range "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>),</span>
<span id="cb27-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(flag_glitch,        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glitch "</span>,        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>),</span>
<span id="cb27-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(flag_bg_active,     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BG-active "</span>,     <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>),</span>
<span id="cb27-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(flag_high_baseline, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"high-baseline "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb27-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>()) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(well_type, plate_row, plate_col)</span>
<span id="cb27-11"></span>
<span id="cb27-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(anomalies <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-13">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, well_type, sample_id, std_nmol, od_first, od_last,</span>
<span id="cb27-14">               net_change, frac_rising, od_max, flags),</span>
<span id="cb27-15">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb27-16">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Type"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"STD nmol"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 t0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 t40"</span>,</span>
<span id="cb27-17">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Net dA412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Frac rising"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max A412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Flags"</span>),</span>
<span id="cb27-18">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells failing one or more trace-shape checks"</span>)</span>
<span id="cb27-19"></span>
<span id="cb27-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(anomalies <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>flag_decreasing, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>flag_over_range, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>flag_glitch,</span>
<span id="cb27-21">                               <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>flag_bg_active, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>flag_high_baseline, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>n_flags),</span>
<span id="cb27-22">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"anomalous_wells.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb27-23"></span>
<span id="cb27-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- anomalies: wells failing &gt;=1 trace-shape check ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(anomalies)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Well</th>
<th style="text-align: left;">Type</th>
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">STD nmol</th>
<th>A412 t0</th>
<th style="text-align: right;">A412 t40</th>
<th style="text-align: right;">Net dA412</th>
<th style="text-align: right;">Frac rising</th>
<th style="text-align: right;">Max A412</th>
<th style="text-align: left;">Flags</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">C1</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.057</td>
<td style="text-align: right;">0.057</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.35</td>
<td style="text-align: right;">0.064</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="even">
<td style="text-align: left;">C2</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.405</td>
<td style="text-align: right;">0.691</td>
<td style="text-align: right;">0.286</td>
<td style="text-align: right;">0.95</td>
<td style="text-align: right;">0.691</td>
<td style="text-align: left;">BG-active</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C5</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.812</td>
<td style="text-align: right;">0.453</td>
<td style="text-align: right;">-0.359</td>
<td style="text-align: right;">0.05</td>
<td style="text-align: right;">0.813</td>
<td style="text-align: left;">decreasing BG-active</td>
</tr>
<tr class="even">
<td style="text-align: left;">C7</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.748</td>
<td style="text-align: right;">0.342</td>
<td style="text-align: right;">-0.406</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.748</td>
<td style="text-align: left;">decreasing BG-active</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C12</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.566</td>
<td style="text-align: right;">0.260</td>
<td style="text-align: right;">-0.306</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.566</td>
<td style="text-align: left;">decreasing BG-active</td>
</tr>
<tr class="even">
<td style="text-align: left;">D1</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.237</td>
<td style="text-align: right;">0.079</td>
<td style="text-align: right;">-0.158</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.237</td>
<td style="text-align: left;">decreasing BG-active</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D2</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.097</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">-0.037</td>
<td style="text-align: right;">0.05</td>
<td style="text-align: right;">0.097</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="even">
<td style="text-align: left;">D4</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.301</td>
<td style="text-align: right;">0.077</td>
<td style="text-align: right;">-0.224</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.301</td>
<td style="text-align: left;">decreasing glitch BG-active</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D5</td>
<td style="text-align: left;">background</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.817</td>
<td style="text-align: right;">0.409</td>
<td style="text-align: right;">-0.408</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.817</td>
<td style="text-align: left;">decreasing BG-active</td>
</tr>
<tr class="even">
<td style="text-align: left;">A6</td>
<td style="text-align: left;">sample</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.287</td>
<td style="text-align: right;">0.328</td>
<td style="text-align: right;">0.041</td>
<td style="text-align: right;">0.35</td>
<td style="text-align: right;">0.336</td>
<td style="text-align: left;">glitch</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A12</td>
<td style="text-align: left;">sample</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.671</td>
<td style="text-align: right;">0.331</td>
<td style="text-align: right;">-0.340</td>
<td style="text-align: right;">0.30</td>
<td style="text-align: right;">0.671</td>
<td style="text-align: left;">decreasing glitch high-baseline</td>
</tr>
<tr class="even">
<td style="text-align: left;">B1</td>
<td style="text-align: left;">sample</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.650</td>
<td style="text-align: right;">0.968</td>
<td style="text-align: right;">0.318</td>
<td style="text-align: right;">0.65</td>
<td style="text-align: right;">1.080</td>
<td style="text-align: left;">glitch high-baseline</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B2</td>
<td style="text-align: left;">sample</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.669</td>
<td style="text-align: right;">0.925</td>
<td style="text-align: right;">0.256</td>
<td style="text-align: right;">0.70</td>
<td style="text-align: right;">0.973</td>
<td style="text-align: left;">glitch high-baseline</td>
</tr>
<tr class="even">
<td style="text-align: left;">B3</td>
<td style="text-align: left;">sample</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.929</td>
<td style="text-align: right;">0.667</td>
<td style="text-align: right;">-0.262</td>
<td style="text-align: right;">0.15</td>
<td style="text-align: right;">0.954</td>
<td style="text-align: left;">decreasing high-baseline</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B5</td>
<td style="text-align: left;">sample</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">NA</td>
<td>0.841</td>
<td style="text-align: right;">0.696</td>
<td style="text-align: right;">-0.145</td>
<td style="text-align: right;">0.10</td>
<td style="text-align: right;">0.878</td>
<td style="text-align: left;">decreasing glitch high-baseline</td>
</tr>
<tr class="even">
<td style="text-align: left;">E1</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">0</td>
<td>0.100</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E2</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">0</td>
<td>0.871</td>
<td style="text-align: right;">0.418</td>
<td style="text-align: right;">-0.453</td>
<td style="text-align: right;">0.05</td>
<td style="text-align: right;">0.871</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="even">
<td style="text-align: left;">E4</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">8</td>
<td>0.406</td>
<td style="text-align: right;">0.372</td>
<td style="text-align: right;">-0.034</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.406</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E5</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">8</td>
<td>0.421</td>
<td style="text-align: right;">0.384</td>
<td style="text-align: right;">-0.037</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.421</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="even">
<td style="text-align: left;">E6</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">8</td>
<td>1.222</td>
<td style="text-align: right;">0.483</td>
<td style="text-align: right;">-0.739</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">1.222</td>
<td style="text-align: left;">decreasing glitch</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E7</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">16</td>
<td>1.349</td>
<td style="text-align: right;">1.099</td>
<td style="text-align: right;">-0.250</td>
<td style="text-align: right;">0.05</td>
<td style="text-align: right;">1.349</td>
<td style="text-align: left;">decreasing glitch</td>
</tr>
<tr class="even">
<td style="text-align: left;">E8</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">16</td>
<td>0.777</td>
<td style="text-align: right;">0.666</td>
<td style="text-align: right;">-0.111</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.777</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E9</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">16</td>
<td>1.167</td>
<td style="text-align: right;">0.841</td>
<td style="text-align: right;">-0.326</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">1.167</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="even">
<td style="text-align: left;">E10</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">24</td>
<td>1.791</td>
<td style="text-align: right;">1.473</td>
<td style="text-align: right;">-0.318</td>
<td style="text-align: right;">0.15</td>
<td style="text-align: right;">1.810</td>
<td style="text-align: left;">decreasing over-range glitch</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E11</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">24</td>
<td>1.425</td>
<td style="text-align: right;">1.108</td>
<td style="text-align: right;">-0.317</td>
<td style="text-align: right;">0.15</td>
<td style="text-align: right;">1.454</td>
<td style="text-align: left;">decreasing glitch</td>
</tr>
<tr class="even">
<td style="text-align: left;">E12</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">24</td>
<td>0.890</td>
<td style="text-align: right;">0.841</td>
<td style="text-align: right;">-0.049</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">0.890</td>
<td style="text-align: left;">decreasing</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F1</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">32</td>
<td>2.052</td>
<td style="text-align: right;">1.572</td>
<td style="text-align: right;">-0.480</td>
<td style="text-align: right;">0.05</td>
<td style="text-align: right;">2.052</td>
<td style="text-align: left;">decreasing over-range glitch</td>
</tr>
<tr class="even">
<td style="text-align: left;">F2</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">32</td>
<td>2.135</td>
<td style="text-align: right;">1.542</td>
<td style="text-align: right;">-0.593</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">2.135</td>
<td style="text-align: left;">decreasing over-range</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F3</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">32</td>
<td>1.695</td>
<td style="text-align: right;">1.329</td>
<td style="text-align: right;">-0.366</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">1.695</td>
<td style="text-align: left;">decreasing over-range</td>
</tr>
<tr class="even">
<td style="text-align: left;">F4</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">40</td>
<td>2.189</td>
<td style="text-align: right;">1.737</td>
<td style="text-align: right;">-0.452</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">2.189</td>
<td style="text-align: left;">decreasing over-range</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F5</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">40</td>
<td>1.929</td>
<td style="text-align: right;">1.614</td>
<td style="text-align: right;">-0.315</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">1.929</td>
<td style="text-align: left;">decreasing over-range</td>
</tr>
<tr class="even">
<td style="text-align: left;">F6</td>
<td style="text-align: left;">standard</td>
<td style="text-align: left;">NA</td>
<td style="text-align: right;">40</td>
<td>2.101</td>
<td style="text-align: right;">1.738</td>
<td style="text-align: right;">-0.363</td>
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">2.101</td>
<td style="text-align: left;">decreasing over-range</td>
</tr>
</tbody>
</table>
<p>Wells failing one or more trace-shape checks</p>
<pre><code>--- anomalies: wells failing &gt;=1 trace-shape check ---

tibble [32 × 25] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:32] "C1" "C2" "C5" "C7" ...
 $ plate_row         : chr [1:32] "C" "C" "C" "C" ...
 $ plate_col         : int [1:32] 1 2 5 7 12 1 2 4 5 6 ...
 $ well_type         : chr [1:32] "background" "background" "background" "background" ...
 $ sample_id         : chr [1:32] "F05_01_ambient" "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" ...
 $ label             : chr [1:32] "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_02_ambient_BG-citrate_synthase-17.5-df.0" "F05_03_ambient_BG-citrate_synthase-22.3-df.0" ...
 $ std_nmol          : num [1:32] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:32] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:32] 0.057 0.405 0.812 0.748 0.566 0.237 0.097 0.301 0.817 0.287 ...
 $ od_last           : num [1:32] 0.057 0.691 0.453 0.342 0.26 0.079 0.06 0.077 0.409 0.328 ...
 $ od_max            : num [1:32] 0.064 0.691 0.813 0.748 0.566 0.237 0.097 0.301 0.817 0.336 ...
 $ net_change        : num [1:32] 0 0.286 -0.359 -0.406 -0.306 -0.158 -0.037 -0.224 -0.408 0.041 ...
 $ frac_rising       : num [1:32] 0.35 0.95 0.05 0 0 0 0.05 0 0 0.35 ...
 $ max_step          : num [1:32] -0.004 0.028 -0.036 -0.043 -0.023 ...
 $ typical_step      : num [1:32] 0 0.016 0.021 0.0155 0.015 ...
 $ step_excess       : num [1:32] 0.004 -0.02 0.018 -0.005 -0.0075 ...
 $ glitch_at_min     : num [1:32] 40 4 2 14 24 6 16 2 34 30 ...
 $ step_ratio        : num [1:32] 4 1.75 1.71 2.77 1.53 ...
 $ flag_decreasing   : logi [1:32] TRUE FALSE TRUE TRUE TRUE TRUE ...
 $ flag_over_range   : logi [1:32] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:32] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:32] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:32] FALSE TRUE TRUE TRUE TRUE TRUE ...
 $ n_flags           : int [1:32] 1 1 2 2 2 2 1 3 2 1 ...
 $ flags             : chr [1:32] "decreasing" "BG-active" "decreasing BG-active" "decreasing BG-active" ...</code></pre>
</section>
<section id="background-control-wells-behaving-as-reactions" class="level2">
<h2 class="anchored" data-anchor-id="background-control-wells-behaving-as-reactions">5.3 Background control wells behaving as reactions</h2>
<p>This is the single largest anomaly on the plate and is called out separately. Background wells receive Background Control Mix, which contains <strong>no CS Substrate Mix</strong>, so they cannot sustain a CS reaction and must read flat.</p>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">bg_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_diagnostics <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">behaviour =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(flag_bg_active, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ANOMALOUS"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flat (expected)"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb29-5"></span>
<span id="cb29-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background wells by behaviour:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(behaviour) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb29-8"></span>
<span id="cb29-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Background triplicates, per sample:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-11">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-12">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_flat =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>flag_bg_active), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_anomalous =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(flag_bg_active),</span>
<span id="cb29-13">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anomalous_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(well[flag_bg_active], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb29-14">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb29-15"></span>
<span id="cb29-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(bg_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, od_first, od_last, net_change, behaviour),</span>
<span id="cb29-17">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb29-18">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 t0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 t40"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Net dA412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Behaviour"</span>),</span>
<span id="cb29-19">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background control wells: starting A412 and total drift"</span>)</span>
<span id="cb29-20"></span>
<span id="cb29-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_summary: background well behaviour classification ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_summary)</span></code></pre></div>
<pre><code>Background wells by behaviour:
       behaviour  n
       ANOMALOUS  7
 flat (expected) 17

Background triplicates, per sample:
      sample_id n_flat n_anomalous anomalous_wells
 F05_01_ambient      2           1              C2
 F05_02_ambient      2           1              C5
 F05_03_ambient      2           1              C7
 F05_04_ambient      2           1             C12
 F05_05_ambient      2           1              D1
 F05_06_ambient      1           2          D4, D5
 F05_07_ambient      3           0                
 F05_08_ambient      3           0                </code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 23%">
<col style="width: 13%">
<col style="width: 14%">
<col style="width: 15%">
<col style="width: 24%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Well</th>
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">A412 t0</th>
<th style="text-align: right;">A412 t40</th>
<th style="text-align: right;">Net dA412</th>
<th style="text-align: left;">Behaviour</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">C1</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0.057</td>
<td style="text-align: right;">0.057</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">C2</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0.405</td>
<td style="text-align: right;">0.691</td>
<td style="text-align: right;">0.286</td>
<td style="text-align: left;">ANOMALOUS</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C3</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0.051</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">0.009</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">C4</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0.055</td>
<td style="text-align: right;">0.059</td>
<td style="text-align: right;">0.004</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C5</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0.812</td>
<td style="text-align: right;">0.453</td>
<td style="text-align: right;">-0.359</td>
<td style="text-align: left;">ANOMALOUS</td>
</tr>
<tr class="even">
<td style="text-align: left;">C6</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0.051</td>
<td style="text-align: right;">0.054</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C7</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0.748</td>
<td style="text-align: right;">0.342</td>
<td style="text-align: right;">-0.406</td>
<td style="text-align: left;">ANOMALOUS</td>
</tr>
<tr class="even">
<td style="text-align: left;">C8</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0.059</td>
<td style="text-align: right;">0.065</td>
<td style="text-align: right;">0.006</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C9</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0.050</td>
<td style="text-align: right;">0.057</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">C10</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0.056</td>
<td style="text-align: right;">0.061</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C11</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0.050</td>
<td style="text-align: right;">0.057</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">C12</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0.566</td>
<td style="text-align: right;">0.260</td>
<td style="text-align: right;">-0.306</td>
<td style="text-align: left;">ANOMALOUS</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D1</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">0.237</td>
<td style="text-align: right;">0.079</td>
<td style="text-align: right;">-0.158</td>
<td style="text-align: left;">ANOMALOUS</td>
</tr>
<tr class="even">
<td style="text-align: left;">D2</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">0.097</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">-0.037</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D3</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">0.053</td>
<td style="text-align: right;">0.058</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">D4</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0.301</td>
<td style="text-align: right;">0.077</td>
<td style="text-align: right;">-0.224</td>
<td style="text-align: left;">ANOMALOUS</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D5</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0.817</td>
<td style="text-align: right;">0.409</td>
<td style="text-align: right;">-0.408</td>
<td style="text-align: left;">ANOMALOUS</td>
</tr>
<tr class="even">
<td style="text-align: left;">D6</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0.063</td>
<td style="text-align: right;">0.070</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D7</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0.070</td>
<td style="text-align: right;">0.073</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">D8</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0.061</td>
<td style="text-align: right;">0.067</td>
<td style="text-align: right;">0.006</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D9</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0.058</td>
<td style="text-align: right;">0.066</td>
<td style="text-align: right;">0.008</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">D10</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0.061</td>
<td style="text-align: right;">0.068</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D11</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0.076</td>
<td style="text-align: right;">0.081</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
<tr class="even">
<td style="text-align: left;">D12</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0.050</td>
<td style="text-align: right;">0.054</td>
<td style="text-align: right;">0.004</td>
<td style="text-align: left;">flat (expected)</td>
</tr>
</tbody>
</table>
<p>Background control wells: starting A412 and total drift</p>
<pre><code>--- bg_summary: background well behaviour classification ---

tibble [24 × 25] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:24] "C1" "C2" "C3" "C4" ...
 $ plate_row         : chr [1:24] "C" "C" "C" "C" ...
 $ plate_col         : int [1:24] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_type         : chr [1:24] "background" "background" "background" "background" ...
 $ sample_id         : chr [1:24] "F05_01_ambient" "F05_01_ambient" "F05_01_ambient" "F05_02_ambient" ...
 $ label             : chr [1:24] "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_01_ambient_BG-citrate_synthase-10.1-df.0" "F05_02_ambient_BG-citrate_synthase-17.5-df.0" ...
 $ std_nmol          : num [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:24] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:24] 0.057 0.405 0.051 0.055 0.812 0.051 0.748 0.059 0.05 0.056 ...
 $ od_last           : num [1:24] 0.057 0.691 0.06 0.059 0.453 0.054 0.342 0.065 0.057 0.061 ...
 $ od_max            : num [1:24] 0.064 0.691 0.06 0.059 0.813 0.054 0.748 0.065 0.057 0.061 ...
 $ net_change        : num [1:24] 0 0.286 0.009 0.004 -0.359 0.003 -0.406 0.006 0.007 0.005 ...
 $ frac_rising       : num [1:24] 0.35 0.95 0.25 0.3 0.05 0.15 0 0.4 0.45 0.25 ...
 $ max_step          : num [1:24] -0.004 0.028 0.005 0.001 -0.036 ...
 $ typical_step      : num [1:24] 0 0.016 0 0 0.021 ...
 $ step_excess       : num [1:24] 0.004 -0.02 0.005 -0.002 0.018 ...
 $ glitch_at_min     : num [1:24] 40 4 36 22 2 20 14 2 14 2 ...
 $ step_ratio        : num [1:24] 4 1.75 5 1 1.71 ...
 $ flag_decreasing   : logi [1:24] TRUE FALSE FALSE FALSE TRUE FALSE ...
 $ flag_over_range   : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_high_baseline: logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_bg_active    : logi [1:24] FALSE TRUE FALSE FALSE TRUE FALSE ...
 $ n_flags           : int [1:24] 1 1 0 0 2 0 2 0 0 0 ...
 $ behaviour         : chr [1:24] "flat (expected)" "ANOMALOUS" "flat (expected)" "flat (expected)" ...</code></pre>
</section>
<section id="starting-absorbance-as-the-master-diagnostic" class="level2">
<h2 class="anchored" data-anchor-id="starting-absorbance-as-the-master-diagnostic">5.4 Starting absorbance as the master diagnostic</h2>
<p>Every anomaly above — decreasing samples, active background wells, scattered standards — occurs in wells that <em>started</em> high. A412 at t = 0 reports TNB already present before the reaction began, so an elevated baseline means the well was contaminated or mis-dispensed. This matters for interpretation: a well that starts high and then declines is not measuring CS activity at all, and a rate extracted from it is an artifact of whatever is decaying.</p>
<div class="sourceCode" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1">baseline_diag       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_baseline_diagnostics</span>(well_diagnostics, assay_params)</span>
<span id="cb32-2">baseline_check      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_diag<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_check</span>
<span id="cb32-3">baseline_per_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_diag<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>baseline_per_sample</span>
<span id="cb32-4"></span>
<span id="cb32-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample and background wells by starting A412:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(baseline_check <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-7">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(well_type, baseline) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-8">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_decreasing =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(flag_decreasing), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-9">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb32-10"></span>
<span id="cb32-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Does an elevated baseline track with a declining trace?</span></span>
<span id="cb32-12">baseline_vs_direction <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> baseline_check <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb32-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">elevated_and_decreasing =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> flag_decreasing),</span>
<span id="cb32-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">elevated_total          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>),</span>
<span id="cb32-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">normal_and_decreasing   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> flag_decreasing),</span>
<span id="cb32-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">normal_total            =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"normal"</span>)</span>
<span id="cb32-18">  )</span>
<span id="cb32-19"></span>
<span id="cb32-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Elevated baseline &amp; decreasing:"</span>, baseline_vs_direction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>elevated_and_decreasing,</span>
<span id="cb32-21">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, baseline_vs_direction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>elevated_total, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normal baseline &amp; decreasing  :"</span>, baseline_vs_direction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>normal_and_decreasing,</span>
<span id="cb32-23">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, baseline_vs_direction<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>normal_total, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-24"></span>
<span id="cb32-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Sample wells with elevated baseline:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(baseline_check <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, baseline <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"elevated"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-27">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, od_first, net_change) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-28">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb32-29"></span>
<span id="cb32-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Elevated-baseline replicates per sample:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(baseline_per_sample), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb32-32"></span>
<span id="cb32-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_check: starting-A412 classification per sample/background well ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_check)</span>
<span id="cb32-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- baseline_per_sample: count of compromised replicates per sample ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(baseline_per_sample)</span></code></pre></div>
<pre><code>Sample and background wells by starting A412:
  well_type baseline  n n_decreasing
 background elevated  5            4
 background   normal 19            4
     sample elevated  5            3
     sample   normal 19            0

Elevated baseline &amp; decreasing: 7 / 10 
Normal baseline &amp; decreasing  : 4 / 38 

Sample wells with elevated baseline:
 well      sample_id od_first net_change
   B3 F05_05_ambient    0.929     -0.262
   B5 F05_06_ambient    0.841     -0.145
  A12 F05_04_ambient    0.671     -0.340
   B2 F05_05_ambient    0.669      0.256
   B1 F05_05_ambient    0.650      0.318

Elevated-baseline replicates per sample:
      sample_id n_elevated n median_baseline
 F05_05_ambient          3 3           0.669
 F05_04_ambient          1 3           0.136
 F05_06_ambient          1 3           0.322
 F05_01_ambient          0 3           0.126
 F05_02_ambient          0 3           0.154
 F05_03_ambient          0 3           0.154
 F05_07_ambient          0 3           0.149
 F05_08_ambient          0 3           0.193

--- baseline_check: starting-A412 classification per sample/background well ---

tibble [48 × 25] (S3: tbl_df/tbl/data.frame)
 $ well              : chr [1:48] "B3" "B5" "D5" "C5" ...
 $ plate_row         : chr [1:48] "B" "B" "D" "C" ...
 $ plate_col         : int [1:48] 3 5 5 5 7 12 2 1 12 2 ...
 $ well_type         : chr [1:48] "sample" "sample" "background" "background" ...
 $ sample_id         : chr [1:48] "F05_05_ambient" "F05_06_ambient" "F05_06_ambient" "F05_02_ambient" ...
 $ label             : chr [1:48] "F05_05_ambient-citrate_synthase-11.5-df.0" "F05_06_ambient-citrate_synthase-30.2-df.0" "F05_06_ambient_BG-citrate_synthase-30.2-df.0" "F05_02_ambient_BG-citrate_synthase-17.5-df.0" ...
 $ std_nmol          : num [1:48] NA NA NA NA NA NA NA NA NA NA ...
 $ source            : chr [1:48] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ od_first          : num [1:48] 0.929 0.841 0.817 0.812 0.748 0.671 0.669 0.65 0.566 0.405 ...
 $ od_last           : num [1:48] 0.667 0.696 0.409 0.453 0.342 0.331 0.925 0.968 0.26 0.691 ...
 $ od_max            : num [1:48] 0.954 0.878 0.817 0.813 0.748 0.671 0.973 1.08 0.566 0.691 ...
 $ net_change        : num [1:48] -0.262 -0.145 -0.408 -0.359 -0.406 -0.34 0.256 0.318 -0.306 0.286 ...
 $ frac_rising       : num [1:48] 0.15 0.1 0 0.05 0 0.3 0.7 0.65 0 0.95 ...
 $ max_step          : num [1:48] -0.033 0.029 -0.028 -0.036 -0.043 ...
 $ typical_step      : num [1:48] 0.0145 0.01 0.0205 0.021 0.0155 ...
 $ step_excess       : num [1:48] -0.019 0.031 0.004 0.018 -0.005 ...
 $ glitch_at_min     : num [1:48] 20 2 34 2 14 2 4 4 24 4 ...
 $ step_ratio        : num [1:48] 2.28 2.9 1.37 1.71 2.77 ...
 $ flag_decreasing   : logi [1:48] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ flag_over_range   : logi [1:48] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch       : logi [1:48] FALSE TRUE FALSE FALSE FALSE TRUE ...
 $ flag_high_baseline: logi [1:48] TRUE TRUE FALSE FALSE FALSE TRUE ...
 $ flag_bg_active    : logi [1:48] FALSE FALSE TRUE TRUE TRUE FALSE ...
 $ n_flags           : int [1:48] 2 3 2 2 2 3 2 2 2 1 ...
 $ baseline          : chr [1:48] "elevated" "elevated" "elevated" "elevated" ...

--- baseline_per_sample: count of compromised replicates per sample ---

tibble [8 × 4] (S3: tbl_df/tbl/data.frame)
 $ sample_id      : chr [1:8] "F05_05_ambient" "F05_04_ambient" "F05_06_ambient" "F05_01_ambient" ...
 $ n_elevated     : int [1:8] 3 1 1 0 0 0 0 0
 $ n              : int [1:8] 3 3 3 3 3 3 3 3
 $ median_baseline: num [1:8] 0.669 0.136 0.322 0.126 0.154 0.154 0.149 0.193</code></pre>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">baseline_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(baseline_check,</span>
<span id="cb34-2">                        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> od_first, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> net_change, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> well_type)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey50"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_vline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb34-5">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> well), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">show.legend =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">background =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#a63603"</span>),</span>
<span id="cb34-9">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well type"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Starting absorbance predicts trace direction"</span>,</span>
<span id="cb34-11">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Clean sample wells cluster tightly at low A412 with a positive net change.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb34-12">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells starting above A412 = "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_baseline_od,</span>
<span id="cb34-13">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" (dotted) scatter and mostly decline: TNB was</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb34-14">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"already present before the read began, so their traces are not enzymology."</span>),</span>
<span id="cb34-15">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 at t = 0"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Net dA412 over 40 min"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb34-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb34-19"></span>
<span id="cb34-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"baseline_vs_direction.png"</span>), baseline_plot,</span>
<span id="cb34-21">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb34-22"></span>
<span id="cb34-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- baseline_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(baseline_plot)</span>
<span id="cb34-25"></span>
<span id="cb34-26">baseline_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/Gen5-20260811-mgig-citrate_synthase-F05-ambient_files/figure-gfm/plot-baseline-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- baseline_plot: ggplot object structure ---

data: well, plate_row, plate_col, well_type, sample_id, label,
  std_nmol, source, od_first, od_last, od_max, net_change, frac_rising,
  max_step, typical_step, step_excess, glitch_at_min, step_ratio,
  flag_decreasing, flag_over_range, flag_glitch, flag_high_baseline,
  flag_bg_active, n_flags, baseline [48x25]
mapping:  x = ~od_first, y = ~net_change, colour = ~well_type
scales:   colour 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: xintercept = ~xintercept 
geom_vline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: label = ~well 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge </code></pre>
</section>
</section>
<section id="gsh-standard-curve" class="level1">
<h1>6 GSH STANDARD CURVE</h1>
<p>The GSH standard is a <strong>stoichiometric endpoint</strong>, not an enzymatic reaction: free thiol reduces DTNB immediately on mixing. The standard curve is therefore read from a single timepoint, and t = 0 is used because TNB<sup>2-</sup> degrades over the run (quantified below).</p>
<section id="fit-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="fit-the-standard-curve">6.1 Fit the standard curve</h2>
<p>Three fits are compared, so the effect of the outlier wells on the calibration is explicit rather than buried:</p>
<ul>
<li><strong>all wells</strong> — every standard replicate, no exclusions</li>
<li><strong>concentration means</strong> — the conventional fit, on per-concentration means</li>
<li><strong>outlier-excluded</strong> — replicate-level fit after dropping flagged wells</li>
</ul>
<p>The outlier-excluded fit is used for activity calculation. Standards are flagged by deviation from their own triplicate <strong>median</strong>, which is not dragged by a single contaminated well the way a mean is.</p>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">std_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit_standard_curve</span>(plate_long, assay_params)</span>
<span id="cb36-2"></span>
<span id="cb36-3">standards_t0       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_t0</span>
<span id="cb36-4">standard_drift     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_drift</span>
<span id="cb36-5">standard_summary   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standard_summary</span>
<span id="cb36-6">standards_flagged  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>standards_flagged</span>
<span id="cb36-7">fit_all_wells      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_all_wells</span>
<span id="cb36-8">fit_comparison     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_comparison</span>
<span id="cb36-9">std_slope          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_slope</span>
<span id="cb36-10">std_intercept      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_intercept</span>
<span id="cb36-11">std_r2             <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_r2</span>
<span id="cb36-12">std_nmol_max       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> std_curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol_max</span>
<span id="cb36-13"></span>
<span id="cb36-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_t0), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"at"</span>, dplyr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(standards_t0<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol),</span>
<span id="cb36-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentrations</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard drift over 40 min (dA412): median"</span>,</span>
<span id="cb36-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)),</span>
<span id="cb36-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| range"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" to "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells that DECREASED:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standard_drift<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>drift <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standard_drift), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-20"></span>
<span id="cb36-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standard_drift, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb36-22">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH (nmol)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 t0"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 t40"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Drift"</span>),</span>
<span id="cb36-23">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard wells lose signal over the kinetic run (TNB instability)"</span>)</span>
<span id="cb36-24"></span>
<span id="cb36-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standard_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(std_nmol, n, mean_od, median_od, sd_od, se_od,</span>
<span id="cb36-26">                                  cv_pct, net_od, od_per_nmol),</span>
<span id="cb36-27">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb36-28">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH (nmol)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean A412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median A412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SEM"</span>,</span>
<span id="cb36-29">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Net A412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412/nmol"</span>),</span>
<span id="cb36-30">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve summary statistics (t = 0)"</span>)</span>
<span id="cb36-31"></span>
<span id="cb36-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard concentrations exceeding the"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb36-33">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"% CV threshold:"</span>,</span>
<span id="cb36-34">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_nmol[standard_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_pct <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct],</span>
<span id="cb36-35">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-36"></span>
<span id="cb36-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(standards_flagged <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, std_nmol, od, triplicate_median,</span>
<span id="cb36-38">                                    deviation, is_outlier),</span>
<span id="cb36-39">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb36-40">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH (nmol)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Triplicate median"</span>,</span>
<span id="cb36-41">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Deviation"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Outlier"</span>),</span>
<span id="cb36-42">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells ranked by deviation from triplicate median (threshold "</span>,</span>
<span id="cb36-43">                       assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>std_outlier_od, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" A412)"</span>))</span>
<span id="cb36-44"></span>
<span id="cb36-45"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard wells flagged as outliers:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(standards_flagged<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>is_outlier),</span>
<span id="cb36-46">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(standards_flagged), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-47"></span>
<span id="cb36-48"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(fit_comparison, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb36-49">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fit"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Slope (A412/nmol)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Intercept"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R-squared"</span>),</span>
<span id="cb36-50">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve: three fitting strategies compared"</span>)</span>
<span id="cb36-51"></span>
<span id="cb36-52"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Calibration used downstream (outlier-excluded fit):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-53"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  A412 = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.5f"</span>, std_slope), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" * nmol + "</span>,</span>
<span id="cb36-54">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, std_intercept), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"   R^2 = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, std_r2), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb36-55"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  1 nmol thiol ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.5f"</span>, std_slope), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412 units</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-56"></span>
<span id="cb36-57"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standards_flagged: standard wells with median-deviation outlier flags ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-58"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_flagged)</span>
<span id="cb36-59"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- fit_comparison: side-by-side standard curve fit statistics ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-60"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(fit_comparison)</span></code></pre></div>
<pre><code>Standard wells: 18 at 6 concentrations
Standard drift over 40 min (dA412): median -0.317 | range -0.739 to 0.004 
Standard wells that DECREASED: 16 / 18 </code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Well</th>
<th style="text-align: right;">GSH (nmol)</th>
<th style="text-align: right;">A412 t0</th>
<th style="text-align: right;">A412 t40</th>
<th style="text-align: right;">Drift</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">E1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: right;">0.000</td>
</tr>
<tr class="even">
<td style="text-align: left;">E2</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.871</td>
<td style="text-align: right;">0.418</td>
<td style="text-align: right;">-0.453</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E3</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.095</td>
<td style="text-align: right;">0.099</td>
<td style="text-align: right;">0.004</td>
</tr>
<tr class="even">
<td style="text-align: left;">E4</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0.406</td>
<td style="text-align: right;">0.372</td>
<td style="text-align: right;">-0.034</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E5</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0.421</td>
<td style="text-align: right;">0.384</td>
<td style="text-align: right;">-0.037</td>
</tr>
<tr class="even">
<td style="text-align: left;">E6</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">1.222</td>
<td style="text-align: right;">0.483</td>
<td style="text-align: right;">-0.739</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E7</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">1.349</td>
<td style="text-align: right;">1.099</td>
<td style="text-align: right;">-0.250</td>
</tr>
<tr class="even">
<td style="text-align: left;">E8</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">0.777</td>
<td style="text-align: right;">0.666</td>
<td style="text-align: right;">-0.111</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E9</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">1.167</td>
<td style="text-align: right;">0.841</td>
<td style="text-align: right;">-0.326</td>
</tr>
<tr class="even">
<td style="text-align: left;">E10</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">1.791</td>
<td style="text-align: right;">1.473</td>
<td style="text-align: right;">-0.318</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E11</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">1.425</td>
<td style="text-align: right;">1.108</td>
<td style="text-align: right;">-0.317</td>
</tr>
<tr class="even">
<td style="text-align: left;">E12</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">0.890</td>
<td style="text-align: right;">0.841</td>
<td style="text-align: right;">-0.049</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F1</td>
<td style="text-align: right;">32</td>
<td style="text-align: right;">2.052</td>
<td style="text-align: right;">1.572</td>
<td style="text-align: right;">-0.480</td>
</tr>
<tr class="even">
<td style="text-align: left;">F2</td>
<td style="text-align: right;">32</td>
<td style="text-align: right;">2.135</td>
<td style="text-align: right;">1.542</td>
<td style="text-align: right;">-0.593</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F3</td>
<td style="text-align: right;">32</td>
<td style="text-align: right;">1.695</td>
<td style="text-align: right;">1.329</td>
<td style="text-align: right;">-0.366</td>
</tr>
<tr class="even">
<td style="text-align: left;">F4</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">2.189</td>
<td style="text-align: right;">1.737</td>
<td style="text-align: right;">-0.452</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F5</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">1.929</td>
<td style="text-align: right;">1.614</td>
<td style="text-align: right;">-0.315</td>
</tr>
<tr class="even">
<td style="text-align: left;">F6</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">2.101</td>
<td style="text-align: right;">1.738</td>
<td style="text-align: right;">-0.363</td>
</tr>
</tbody>
</table>
<p>GSH standard wells lose signal over the kinetic run (TNB instability)</p>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 5%">
<col style="width: 13%">
<col style="width: 15%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 9%">
<col style="width: 11%">
<col style="width: 13%">
</colgroup>
<thead>
<tr class="header">
<th>GSH (nmol)</th>
<th style="text-align: right;">n</th>
<th>Mean A412</th>
<th>Median A412</th>
<th style="text-align: right;">SD</th>
<th style="text-align: right;">SEM</th>
<th style="text-align: right;">CV (%)</th>
<th>Net A412</th>
<th style="text-align: right;">A412/nmol</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>0</td>
<td style="text-align: right;">3</td>
<td>0.355</td>
<td>0.100</td>
<td style="text-align: right;">0.447</td>
<td style="text-align: right;">0.258</td>
<td style="text-align: right;">125.7</td>
<td>0.000</td>
<td style="text-align: right;">NA</td>
</tr>
<tr class="even">
<td>8</td>
<td style="text-align: right;">3</td>
<td>0.683</td>
<td>0.421</td>
<td style="text-align: right;">0.467</td>
<td style="text-align: right;">0.270</td>
<td style="text-align: right;">68.4</td>
<td>0.328</td>
<td style="text-align: right;">0.0410</td>
</tr>
<tr class="odd">
<td>16</td>
<td style="text-align: right;">3</td>
<td>1.098</td>
<td>1.167</td>
<td style="text-align: right;">0.292</td>
<td style="text-align: right;">0.169</td>
<td style="text-align: right;">26.6</td>
<td>0.742</td>
<td style="text-align: right;">0.0464</td>
</tr>
<tr class="even">
<td>24</td>
<td style="text-align: right;">3</td>
<td>1.369</td>
<td>1.425</td>
<td style="text-align: right;">0.453</td>
<td style="text-align: right;">0.262</td>
<td style="text-align: right;">33.1</td>
<td>1.013</td>
<td style="text-align: right;">0.0422</td>
</tr>
<tr class="odd">
<td>32</td>
<td style="text-align: right;">3</td>
<td>1.961</td>
<td>2.052</td>
<td style="text-align: right;">0.234</td>
<td style="text-align: right;">0.135</td>
<td style="text-align: right;">11.9</td>
<td>1.605</td>
<td style="text-align: right;">0.0502</td>
</tr>
<tr class="even">
<td>40</td>
<td style="text-align: right;">3</td>
<td>2.073</td>
<td>2.101</td>
<td style="text-align: right;">0.132</td>
<td style="text-align: right;">0.076</td>
<td style="text-align: right;">6.4</td>
<td>1.718</td>
<td style="text-align: right;">0.0429</td>
</tr>
</tbody>
</table>
<p>GSH standard curve summary statistics (t = 0)</p>
<pre><code>Standard concentrations exceeding the 15 % CV threshold: 0, 8, 16, 24 </code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Well</th>
<th style="text-align: right;">GSH (nmol)</th>
<th style="text-align: right;">A412</th>
<th style="text-align: right;">Triplicate median</th>
<th style="text-align: right;">Deviation</th>
<th style="text-align: left;">Outlier</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">E6</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">1.222</td>
<td style="text-align: right;">0.421</td>
<td style="text-align: right;">0.801</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E2</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.871</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: right;">0.771</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E12</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">0.890</td>
<td style="text-align: right;">1.425</td>
<td style="text-align: right;">-0.535</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E8</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">0.777</td>
<td style="text-align: right;">1.167</td>
<td style="text-align: right;">-0.390</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E10</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">1.791</td>
<td style="text-align: right;">1.425</td>
<td style="text-align: right;">0.366</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F3</td>
<td style="text-align: right;">32</td>
<td style="text-align: right;">1.695</td>
<td style="text-align: right;">2.052</td>
<td style="text-align: right;">-0.357</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E7</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">1.349</td>
<td style="text-align: right;">1.167</td>
<td style="text-align: right;">0.182</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F5</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">1.929</td>
<td style="text-align: right;">2.101</td>
<td style="text-align: right;">-0.172</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F4</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">2.189</td>
<td style="text-align: right;">2.101</td>
<td style="text-align: right;">0.088</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F2</td>
<td style="text-align: right;">32</td>
<td style="text-align: right;">2.135</td>
<td style="text-align: right;">2.052</td>
<td style="text-align: right;">0.083</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E4</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0.406</td>
<td style="text-align: right;">0.421</td>
<td style="text-align: right;">-0.015</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E3</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.095</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: right;">-0.005</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: right;">0.100</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E5</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">0.421</td>
<td style="text-align: right;">0.421</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">E9</td>
<td style="text-align: right;">16</td>
<td style="text-align: right;">1.167</td>
<td style="text-align: right;">1.167</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">E11</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">1.425</td>
<td style="text-align: right;">1.425</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F1</td>
<td style="text-align: right;">32</td>
<td style="text-align: right;">2.052</td>
<td style="text-align: right;">2.052</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">F6</td>
<td style="text-align: right;">40</td>
<td style="text-align: right;">2.101</td>
<td style="text-align: right;">2.101</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">FALSE</td>
</tr>
</tbody>
</table>
<p>Standard wells ranked by deviation from triplicate median (threshold 0.15 A412)</p>
<pre><code>Standard wells flagged as outliers: 8 / 18 </code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 15%">
<col style="width: 26%">
<col style="width: 6%">
<col style="width: 24%">
<col style="width: 13%">
<col style="width: 13%">
</colgroup>
<thead>
<tr class="header">
<th></th>
<th style="text-align: left;">Fit</th>
<th style="text-align: right;">n</th>
<th>Slope (A412/nmol)</th>
<th style="text-align: right;">Intercept</th>
<th style="text-align: right;">R-squared</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>std_nmol…1</td>
<td style="text-align: left;">all wells</td>
<td style="text-align: right;">18</td>
<td>0.04533</td>
<td style="text-align: right;">0.3498</td>
<td style="text-align: right;">0.8042</td>
</tr>
<tr class="even">
<td>std_nmol…2</td>
<td style="text-align: left;">concentration means</td>
<td style="text-align: right;">6</td>
<td>0.04533</td>
<td style="text-align: right;">0.3498</td>
<td style="text-align: right;">0.9829</td>
</tr>
<tr class="odd">
<td>std_nmol…3</td>
<td style="text-align: left;">outlier-excluded</td>
<td style="text-align: right;">10</td>
<td>0.05582</td>
<td style="text-align: right;">0.0927</td>
<td style="text-align: right;">0.9678</td>
</tr>
</tbody>
</table>
<p>GSH standard curve: three fitting strategies compared</p>
<pre><code>Calibration used downstream (outlier-excluded fit):
  A412 = 0.05582 * nmol + 0.0927   R^2 = 0.9678
  1 nmol thiol = 0.05582 A412 units

--- standards_flagged: standard wells with median-deviation outlier flags ---

tibble [18 × 7] (S3: tbl_df/tbl/data.frame)
 $ well             : chr [1:18] "E6" "E2" "E12" "E8" ...
 $ std_nmol         : num [1:18] 8 0 24 16 24 32 16 40 40 32 ...
 $ od               : num [1:18] 1.222 0.871 0.89 0.777 1.791 ...
 $ source           : chr [1:18] "absorbance_csv" "absorbance_csv" "absorbance_csv" "absorbance_csv" ...
 $ triplicate_median: num [1:18] 0.421 0.1 1.425 1.167 1.425 ...
 $ deviation        : num [1:18] 0.801 0.771 -0.535 -0.39 0.366 ...
 $ is_outlier       : logi [1:18] TRUE TRUE TRUE TRUE TRUE TRUE ...

--- fit_comparison: side-by-side standard curve fit statistics ---

'data.frame':   3 obs. of  5 variables:
 $ fit      : chr  "all wells" "concentration means" "outlier-excluded"
 $ n        : int  18 6 10
 $ slope    : num  0.0453 0.0453 0.0558
 $ intercept: num  0.3498 0.3498 0.0927
 $ r_squared: num  0.804 0.983 0.968</code></pre>
</section>
<section id="plot-the-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="plot-the-standard-curve">6.2 Plot the standard curve</h2>
<div class="sourceCode" id="cb41" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1">std_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(standards_flagged, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> std_nmol, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> od)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_abline</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(fit_all_wells)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>],</span>
<span id="cb41-3">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all wells"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey55"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_abline</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> std_slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> std_intercept,</span>
<span id="cb41-5">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier-excluded"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> is_outlier, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> is_outlier), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb41-9">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"retained"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#238b45"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>),</span>
<span id="cb41-11">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"retained"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outlier"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">all wells</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier-excluded</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"solid"</span>),</span>
<span id="cb41-13">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fit"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH standard curve, A412 at t = 0"</span>,</span>
<span id="cb41-15">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dotted line = photometric linearity ceiling (A412 = "</span>,</span>
<span id="cb41-16">                         assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>od_linear_max,</span>
<span id="cb41-17">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"); the 32 and 40 nmol standards sit above it"</span>),</span>
<span id="cb41-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"GSH (nmol/well)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A412"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb41-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb41-21"></span>
<span id="cb41-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gsh_standard_curve.png"</span>), std_curve_plot,</span>
<span id="cb41-23">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb41-24"></span>
<span id="cb41-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- std_curve_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb41-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve_plot)</span>
<span id="cb41-27"></span>
<span id="cb41-28">std_curve_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/Gen5-20260811-mgig-citrate_synthase-F05-ambient_files/figure-gfm/plot-standard-curve-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- std_curve_plot: ggplot object structure ---

data: well, std_nmol, od, source, triplicate_median, deviation,
  is_outlier [18x7]
mapping:  x = ~std_nmol, y = ~od
scales:   shape, colour, linetype 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: slope = ~coef(fit_all_wells)[2], intercept = ~coef(fit_all_wells)[1], linetype = all wells 
geom_abline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: slope = ~std_slope, intercept = ~std_intercept, linetype = outlier-excluded 
geom_abline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: shape = ~is_outlier, colour = ~is_outlier 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: yintercept = ~yintercept 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
</section>
<section id="rate-extraction" class="level1">
<h1>7 RATE EXTRACTION</h1>
<section id="sliding-window-linear-fit" class="level2">
<h2 class="anchored" data-anchor-id="sliding-window-linear-fit">7.1 Sliding-window linear fit</h2>
<p>Abcam §9.3 directs the analyst to pick two timepoints “in the linear range”. That is implemented here as a sliding window of 5 consecutive reads (8 min) scanned across each trace. Two candidate windows are recorded per well:</p>
<ul>
<li><strong>max increasing</strong> — the steepest <em>positive</em> slope, which is what CS activity means. This is the rate used for activity.</li>
<li><strong>max absolute</strong> — the steepest slope of either sign. Gen5’s own <code>Max V [412]</code> column uses this convention, which is why Gen5 reports large negative “rates” for degrading wells.</li>
</ul>
<p>Recording both makes the divergence between them an explicit QC signal.</p>
<div class="sourceCode" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1">well_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_well_rates</span>(plate_long, well_diagnostics, assay_params)</span>
<span id="cb43-2"></span>
<span id="cb43-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells with a usable increasing rate:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>rate_usable),</span>
<span id="cb43-4">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(well_rates), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells where the steepest window is NEGATIVE (Gen5 would report a negative Max V):"</span>,</span>
<span id="cb43-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(well_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>abs_window_is_negative), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-7"></span>
<span id="cb43-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- well_rates: per-well max-increasing and max-absolute slope windows ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(well_rates)</span></code></pre></div>
<pre><code>Wells with a usable increasing rate: 36 / 69 
Wells where the steepest window is NEGATIVE (Gen5 would report a negative Max V): 27 

--- well_rates: per-well max-increasing and max-absolute slope windows ---

tibble [69 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:69] "A1" "A10" "A11" "A12" ...
 $ well_type             : chr [1:69] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:69] "F05_01_ambient" "F05_04_ambient" "F05_04_ambient" "F05_04_ambient" ...
 $ std_nmol              : num [1:69] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:69] 0 0 0 30 0 0 0 0 24 0 ...
 $ t_end                 : num [1:69] 8 8 8 38 8 8 8 8 32 8 ...
 $ slope_mOD_min         : num [1:69] 8.15 8.25 8.5 2.2 7.4 ...
 $ r2                    : num [1:69] 0.999 0.996 0.99 0.998 0.999 ...
 $ max_abs_slope_mOD_min : num [1:69] 8.15 8.25 8.5 -19.65 7.4 ...
 $ abs_window_is_negative: logi [1:69] FALSE FALSE FALSE TRUE FALSE FALSE ...
 $ net_change            : num [1:69] 0.164 0.157 0.156 -0.34 0.162 0.169 0.162 0.163 0.041 0.138 ...
 $ frac_rising           : num [1:69] 1 1 1 0.3 1 1 1 1 0.35 1 ...
 $ od_max                : num [1:69] 0.29 0.286 0.292 0.671 0.291 0.294 0.297 0.317 0.336 0.292 ...
 $ flag_decreasing       : logi [1:69] FALSE FALSE FALSE TRUE FALSE FALSE ...
 $ flag_over_range       : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:69] FALSE FALSE FALSE TRUE FALSE FALSE ...
 $ glitch_at_min         : num [1:69] 38 8 2 2 24 22 18 28 30 2 ...
 $ flag_bg_active        : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:69] 0 0 0 3 0 0 0 0 1 0 ...
 $ glitch_in_window      : logi [1:69] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:69] TRUE TRUE TRUE FALSE TRUE TRUE ...</code></pre>
</section>
<section id="sample-and-background-rates" class="level2">
<h2 class="anchored" data-anchor-id="sample-and-background-rates">7.2 Sample and background rates</h2>
<div class="sourceCode" id="cb45" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb45-1">sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb45-4"></span>
<span id="cb45-5">background_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, well)</span>
<span id="cb45-8"></span>
<span id="cb45-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, t_start, t_end, slope_mOD_min, r2,</span>
<span id="cb45-10">                              net_change, max_abs_slope_mOD_min,</span>
<span id="cb45-11">                              glitch_in_window, rate_usable),</span>
<span id="cb45-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb45-13">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Window start (min)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Window end (min)"</span>,</span>
<span id="cb45-14">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate (mA412/min)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R-squared"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Net dA412"</span>,</span>
<span id="cb45-15">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Max |rate|"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glitch in window"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Usable"</span>),</span>
<span id="cb45-16">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample wells: max-increasing rate window"</span>)</span>
<span id="cb45-17"></span>
<span id="cb45-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(background_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, sample_id, slope_mOD_min, r2,</span>
<span id="cb45-19">                                  net_change, flag_bg_active),</span>
<span id="cb45-20">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb45-21">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate (mA412/min)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R-squared"</span>,</span>
<span id="cb45-22">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Net dA412"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Anomalous"</span>),</span>
<span id="cb45-23">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background control wells: rates should be ~0"</span>)</span>
<span id="cb45-24"></span>
<span id="cb45-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_rates: rate windows for the sample wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb45-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_rates)</span>
<span id="cb45-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- background_rates: rate windows for the background wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb45-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(background_rates)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Well</th>
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">Window start (min)</th>
<th style="text-align: right;">Window end (min)</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">R-squared</th>
<th style="text-align: right;">Net dA412</th>
<th style="text-align: right;">Max |rate|</th>
<th style="text-align: left;">Glitch in window</th>
<th style="text-align: left;">Usable</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A1</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.15</td>
<td style="text-align: right;">0.999</td>
<td style="text-align: right;">0.164</td>
<td style="text-align: right;">8.15</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A2</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.40</td>
<td style="text-align: right;">0.999</td>
<td style="text-align: right;">0.162</td>
<td style="text-align: right;">7.40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A3</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.65</td>
<td style="text-align: right;">0.999</td>
<td style="text-align: right;">0.169</td>
<td style="text-align: right;">7.65</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A4</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.55</td>
<td style="text-align: right;">0.997</td>
<td style="text-align: right;">0.162</td>
<td style="text-align: right;">8.55</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A5</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">9.70</td>
<td style="text-align: right;">0.995</td>
<td style="text-align: right;">0.163</td>
<td style="text-align: right;">9.70</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A6</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">32</td>
<td style="text-align: right;">5.15</td>
<td style="text-align: right;">0.695</td>
<td style="text-align: right;">0.041</td>
<td style="text-align: right;">5.15</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A7</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.70</td>
<td style="text-align: right;">0.945</td>
<td style="text-align: right;">0.138</td>
<td style="text-align: right;">7.70</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A8</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">0.950</td>
<td style="text-align: right;">0.152</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A9</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.80</td>
<td style="text-align: right;">0.941</td>
<td style="text-align: right;">0.142</td>
<td style="text-align: right;">7.80</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A10</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.25</td>
<td style="text-align: right;">0.996</td>
<td style="text-align: right;">0.157</td>
<td style="text-align: right;">8.25</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A11</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: right;">0.990</td>
<td style="text-align: right;">0.156</td>
<td style="text-align: right;">8.50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">A12</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">30</td>
<td style="text-align: right;">38</td>
<td style="text-align: right;">2.20</td>
<td style="text-align: right;">0.998</td>
<td style="text-align: right;">-0.340</td>
<td style="text-align: right;">-19.65</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B1</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">21.30</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">0.318</td>
<td style="text-align: right;">21.30</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B2</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">17.20</td>
<td style="text-align: right;">0.994</td>
<td style="text-align: right;">0.256</td>
<td style="text-align: right;">17.20</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B3</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">3.10</td>
<td style="text-align: right;">0.911</td>
<td style="text-align: right;">-0.262</td>
<td style="text-align: right;">-11.50</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B4</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">6.15</td>
<td style="text-align: right;">0.824</td>
<td style="text-align: right;">0.050</td>
<td style="text-align: right;">6.15</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B5</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">4.10</td>
<td style="text-align: right;">0.725</td>
<td style="text-align: right;">-0.145</td>
<td style="text-align: right;">-10.65</td>
<td style="text-align: left;">TRUE</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B6</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.75</td>
<td style="text-align: right;">0.955</td>
<td style="text-align: right;">0.150</td>
<td style="text-align: right;">8.75</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B7</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">9.55</td>
<td style="text-align: right;">0.971</td>
<td style="text-align: right;">0.152</td>
<td style="text-align: right;">9.55</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B8</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.40</td>
<td style="text-align: right;">0.975</td>
<td style="text-align: right;">0.148</td>
<td style="text-align: right;">8.40</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B9</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">8.80</td>
<td style="text-align: right;">0.974</td>
<td style="text-align: right;">0.148</td>
<td style="text-align: right;">8.80</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B10</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">7.65</td>
<td style="text-align: right;">0.854</td>
<td style="text-align: right;">0.120</td>
<td style="text-align: right;">7.65</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">B11</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">6.80</td>
<td style="text-align: right;">0.878</td>
<td style="text-align: right;">0.123</td>
<td style="text-align: right;">6.80</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">B12</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">6.60</td>
<td style="text-align: right;">0.837</td>
<td style="text-align: right;">0.119</td>
<td style="text-align: right;">6.60</td>
<td style="text-align: left;">FALSE</td>
<td style="text-align: left;">TRUE</td>
</tr>
</tbody>
</table>
<p>Sample wells: max-increasing rate window</p>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 21%">
<col style="width: 24%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Well</th>
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">R-squared</th>
<th style="text-align: right;">Net dA412</th>
<th style="text-align: left;">Anomalous</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">C1</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.893</td>
<td style="text-align: right;">0.000</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C2</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">11.55</td>
<td style="text-align: right;">0.989</td>
<td style="text-align: right;">0.286</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C3</td>
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">0.85</td>
<td style="text-align: right;">0.830</td>
<td style="text-align: right;">0.009</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C4</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0.15</td>
<td style="text-align: right;">0.750</td>
<td style="text-align: right;">0.004</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C5</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">-3.35</td>
<td style="text-align: right;">0.885</td>
<td style="text-align: right;">-0.359</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C6</td>
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">0.80</td>
<td style="text-align: right;">0.653</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C7</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">-5.25</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">-0.406</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C8</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0.50</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">0.006</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C9</td>
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">0.40</td>
<td style="text-align: right;">0.941</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C10</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0.20</td>
<td style="text-align: right;">0.800</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">C11</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.893</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">C12</td>
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">-5.15</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">-0.306</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D1</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">-1.45</td>
<td style="text-align: right;">0.987</td>
<td style="text-align: right;">-0.158</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D2</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">0.05</td>
<td style="text-align: right;">0.083</td>
<td style="text-align: right;">-0.037</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D3</td>
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.893</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D4</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">-1.10</td>
<td style="text-align: right;">0.992</td>
<td style="text-align: right;">-0.224</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D5</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">-7.75</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">-0.408</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D6</td>
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">0.50</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D7</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0.15</td>
<td style="text-align: right;">0.750</td>
<td style="text-align: right;">0.003</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D8</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.893</td>
<td style="text-align: right;">0.006</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D9</td>
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">0.50</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">0.008</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D10</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.893</td>
<td style="text-align: right;">0.007</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">D11</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.893</td>
<td style="text-align: right;">0.005</td>
<td style="text-align: left;">FALSE</td>
</tr>
<tr class="even">
<td style="text-align: left;">D12</td>
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">0.25</td>
<td style="text-align: right;">0.893</td>
<td style="text-align: right;">0.004</td>
<td style="text-align: left;">FALSE</td>
</tr>
</tbody>
</table>
<p>Background control wells: rates should be ~0</p>
<pre><code>--- sample_rates: rate windows for the sample wells ---

tibble [24 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:24] "A1" "A2" "A3" "A4" ...
 $ well_type             : chr [1:24] "sample" "sample" "sample" "sample" ...
 $ sample_id             : chr [1:24] "F05_01_ambient" "F05_01_ambient" "F05_01_ambient" "F05_02_ambient" ...
 $ std_nmol              : num [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:24] 0 0 0 0 0 24 0 0 0 0 ...
 $ t_end                 : num [1:24] 8 8 8 8 8 32 8 8 8 8 ...
 $ slope_mOD_min         : num [1:24] 8.15 7.4 7.65 8.55 9.7 ...
 $ r2                    : num [1:24] 0.999 0.999 0.999 0.997 0.995 ...
 $ max_abs_slope_mOD_min : num [1:24] 8.15 7.4 7.65 8.55 9.7 ...
 $ abs_window_is_negative: logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ net_change            : num [1:24] 0.164 0.162 0.169 0.162 0.163 0.041 0.138 0.152 0.142 0.157 ...
 $ frac_rising           : num [1:24] 1 1 1 1 1 0.35 1 1 1 1 ...
 $ od_max                : num [1:24] 0.29 0.291 0.294 0.297 0.317 0.336 0.292 0.307 0.296 0.286 ...
 $ flag_decreasing       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_over_range       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:24] FALSE FALSE FALSE FALSE FALSE TRUE ...
 $ glitch_at_min         : num [1:24] 38 24 22 18 28 30 2 2 2 8 ...
 $ flag_bg_active        : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_flags               : int [1:24] 0 0 0 0 0 1 0 0 0 0 ...
 $ glitch_in_window      : logi [1:24] FALSE FALSE FALSE FALSE FALSE TRUE ...
 $ rate_usable           : logi [1:24] TRUE TRUE TRUE TRUE TRUE FALSE ...

--- background_rates: rate windows for the background wells ---

tibble [24 × 21] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:24] "C1" "C2" "C3" "C4" ...
 $ well_type             : chr [1:24] "background" "background" "background" "background" ...
 $ sample_id             : chr [1:24] "F05_01_ambient" "F05_01_ambient" "F05_01_ambient" "F05_02_ambient" ...
 $ std_nmol              : num [1:24] NA NA NA NA NA NA NA NA NA NA ...
 $ t_start               : num [1:24] 16 24 30 0 0 16 32 10 24 10 ...
 $ t_end                 : num [1:24] 24 32 38 8 8 24 40 18 32 18 ...
 $ slope_mOD_min         : num [1:24] 0.25 11.55 0.85 0.15 -3.35 ...
 $ r2                    : num [1:24] 0.893 0.989 0.83 0.75 0.885 ...
 $ max_abs_slope_mOD_min : num [1:24] -0.95 11.55 0.85 0.15 -13.5 ...
 $ abs_window_is_negative: logi [1:24] TRUE FALSE FALSE FALSE TRUE FALSE ...
 $ net_change            : num [1:24] 0 0.286 0.009 0.004 -0.359 0.003 -0.406 0.006 0.007 0.005 ...
 $ frac_rising           : num [1:24] 0.35 0.95 0.25 0.3 0.05 0.15 0 0.4 0.45 0.25 ...
 $ od_max                : num [1:24] 0.064 0.691 0.06 0.059 0.813 0.054 0.748 0.065 0.057 0.061 ...
 $ flag_decreasing       : logi [1:24] TRUE FALSE FALSE FALSE TRUE FALSE ...
 $ flag_over_range       : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ flag_glitch           : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ glitch_at_min         : num [1:24] 40 4 36 22 2 20 14 2 14 2 ...
 $ flag_bg_active        : logi [1:24] FALSE TRUE FALSE FALSE TRUE FALSE ...
 $ n_flags               : int [1:24] 1 1 0 0 2 0 2 0 0 0 ...
 $ glitch_in_window      : logi [1:24] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ rate_usable           : logi [1:24] FALSE TRUE TRUE FALSE FALSE FALSE ...</code></pre>
</section>
<section id="positive-control" class="level2">
<h2 class="anchored" data-anchor-id="positive-control">7.3 Positive control</h2>
<div class="sourceCode" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">pos_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_positive_control</span>(well_rates, std_slope, assay_params)</span>
<span id="cb47-2"></span>
<span id="cb47-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(pos_control <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(well, t_start, t_end, slope_mOD_min, r2, net_change),</span>
<span id="cb47-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb47-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Window start (min)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Window end (min)"</span>,</span>
<span id="cb47-6">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate (mA412/min)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R-squared"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Net dA412"</span>),</span>
<span id="cb47-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS Positive Control: the plate's proof that the reaction chemistry worked"</span>)</span>
<span id="cb47-8"></span>
<span id="cb47-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Positive control rate: mean"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)),</span>
<span id="cb47-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min | CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb47-11">                                     <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"All three replicates rising and linear:"</span>,</span>
<span id="cb47-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all</span>(pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>net_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> pos_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.99</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-14"></span>
<span id="cb47-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- pos_control: positive control rate and R^2 per replicate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(pos_control)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 7%">
<col style="width: 23%">
<col style="width: 21%">
<col style="width: 21%">
<col style="width: 13%">
<col style="width: 13%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Well</th>
<th style="text-align: right;">Window start (min)</th>
<th style="text-align: right;">Window end (min)</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">R-squared</th>
<th>Net dA412</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F7</td>
<td style="text-align: right;">28</td>
<td style="text-align: right;">36</td>
<td style="text-align: right;">2.85</td>
<td style="text-align: right;">0.9991</td>
<td>0.093</td>
</tr>
<tr class="even">
<td style="text-align: left;">F8</td>
<td style="text-align: right;">26</td>
<td style="text-align: right;">34</td>
<td style="text-align: right;">2.85</td>
<td style="text-align: right;">0.9991</td>
<td>0.099</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F9</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">18</td>
<td style="text-align: right;">2.75</td>
<td style="text-align: right;">0.9990</td>
<td>0.104</td>
</tr>
</tbody>
</table>
<p>CS Positive Control: the plate’s proof that the reaction chemistry worked</p>
<pre><code>Positive control rate: mean 2.82 mA412/min | CV 2.0 %
All three replicates rising and linear: TRUE 

--- pos_control: positive control rate and R^2 per replicate ---

tibble [3 × 22] (S3: tbl_df/tbl/data.frame)
 $ well                  : chr [1:3] "F7" "F8" "F9"
 $ well_type             : chr [1:3] "positive_control" "positive_control" "positive_control"
 $ sample_id             : chr [1:3] NA NA NA
 $ std_nmol              : num [1:3] NA NA NA
 $ t_start               : num [1:3] 28 26 10
 $ t_end                 : num [1:3] 36 34 18
 $ slope_mOD_min         : num [1:3] 2.85 2.85 2.75
 $ r2                    : num [1:3] 0.999 0.999 0.999
 $ max_abs_slope_mOD_min : num [1:3] 2.85 2.85 2.75
 $ abs_window_is_negative: logi [1:3] FALSE FALSE FALSE
 $ net_change            : num [1:3] 0.093 0.099 0.104
 $ frac_rising           : num [1:3] 1 1 1
 $ od_max                : num [1:3] 0.322 0.335 0.32
 $ flag_decreasing       : logi [1:3] FALSE FALSE FALSE
 $ flag_over_range       : logi [1:3] FALSE FALSE FALSE
 $ flag_glitch           : logi [1:3] FALSE FALSE FALSE
 $ glitch_at_min         : num [1:3] 20 10 10
 $ flag_bg_active        : logi [1:3] FALSE FALSE FALSE
 $ n_flags               : int [1:3] 0 0 0
 $ glitch_in_window      : logi [1:3] FALSE FALSE FALSE
 $ rate_usable           : logi [1:3] TRUE TRUE TRUE
 $ activity_mU_uL        : num [1:3] 0.0255 0.0255 0.0246</code></pre>
</section>
</section>
<section id="background-correction" class="level1">
<h1>8 BACKGROUND CORRECTION</h1>
<p>Abcam §10.2 subtracts the background reading only “if sample background control reading is significant”. Here the background <em>rate</em> is the relevant quantity, and only the well-behaved (flat) background replicates are used to estimate it, since the anomalous ones do not measure background.</p>
<div class="sourceCode" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1">background_per_sample <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_background_correction</span>(well_rates)</span>
<span id="cb49-2"></span>
<span id="cb49-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background rate from flat wells only (mA412/min):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(background_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb49-5"></span>
<span id="cb49-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Median flat-background rate:"</span>,</span>
<span id="cb49-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(background_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)),</span>
<span id="cb49-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Median sample rate:"</span>,</span>
<span id="cb49-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background as % of sample signal:"</span>,</span>
<span id="cb49-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(background_per_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>bg_rate_flat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb49-13">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(sample_rates<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope_mOD_min)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-14"></span>
<span id="cb49-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- background_per_sample: per-sample background rate estimates ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(background_per_sample)</span></code></pre></div>
<pre><code>Background rate from flat wells only (mA412/min):
      sample_id n_bg_total n_bg_flat bg_rate_flat bg_rate_all
 F05_01_ambient          3         2        0.550       4.217
 F05_02_ambient          3         2        0.475      -0.800
 F05_03_ambient          3         2        0.450      -1.450
 F05_04_ambient          3         2        0.225      -1.567
 F05_05_ambient          3         2        0.150      -0.383
 F05_06_ambient          3         1        0.500      -2.783
 F05_07_ambient          3         3        0.300       0.300
 F05_08_ambient          3         3        0.250       0.250

Median flat-background rate: 0.375 mA412/min
Median sample rate: 7.98 mA412/min
Background as % of sample signal: 4.7 %

--- background_per_sample: per-sample background rate estimates ---

tibble [8 × 5] (S3: tbl_df/tbl/data.frame)
 $ sample_id   : chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ n_bg_total  : int [1:8] 3 3 3 3 3 3 3 3
 $ n_bg_flat   : int [1:8] 2 2 2 2 2 1 3 3
 $ bg_rate_flat: num [1:8] 0.55 0.475 0.45 0.225 0.15 ...
 $ bg_rate_all : num [1:8] 4.217 -0.8 -1.45 -1.567 -0.383 ...</code></pre>
<section id="background-significance-test" class="level2">
<h2 class="anchored" data-anchor-id="background-significance-test">8.1 Background significance test</h2>
<p>Cattau et al.&nbsp;(2023; legacy version of this assay, <code>Cattau_v1_master.Rmd</code>) validated background subtraction once with an ANOVA and then applied that conclusion to every subsequent plate. The same formal test is run here – a Welch two-sample t-test of well-level rate (background vs.&nbsp;sample), plus an ANOVA on the OD trajectory over time – so the flat/active threshold classification used above is backed by an explicit significance test rather than the threshold alone.</p>
<div class="sourceCode" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1">bg_sample_rates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb51-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))</span>
<span id="cb51-3"></span>
<span id="cb51-4">bg_significance_test <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">t.test</span>(slope_mOD_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> bg_sample_rates)</span>
<span id="cb51-5"></span>
<span id="cb51-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- Welch two-sample t-test: well-level rate (background vs. sample) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_significance_test)</span>
<span id="cb51-8"></span>
<span id="cb51-9">bg_trend_anova <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(od <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> time_min,</span>
<span id="cb51-10">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(well_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"background"</span>))))</span>
<span id="cb51-11"></span>
<span id="cb51-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(bg_trend_anova)</span>
<span id="cb51-14"></span>
<span id="cb51-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation: mean background-well rate is"</span>,</span>
<span id="cb51-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group background"</span>])),</span>
<span id="cb51-17">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min vs."</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.2f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mean in group sample"</span>])),</span>
<span id="cb51-18">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mA412/min for sample wells (p ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format.pval</span>(bg_significance_test<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb51-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"). Background wells are statistically distinct from, and far slower</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb51-20">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"than, reaction wells on this plate -- consistent with the per-well</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb51-21">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flat/active classification above and with the qualitative conclusion</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb51-22">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"reached by Cattau et al. (2023) on the legacy assay version.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-23"></span>
<span id="cb51-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_significance_test: Welch t-test result object ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_significance_test)</span>
<span id="cb51-26"></span>
<span id="cb51-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb51-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(bg_trend_anova)</span></code></pre></div>
<pre><code>--- Welch two-sample t-test: well-level rate (background vs. sample) ---


    Welch Two Sample t-test

data:  slope_mOD_min by well_type
t = -8.0493, df = 44.983, p-value = 2.931e-10
alternative hypothesis: true difference in means between group background and group sample is not equal to 0
95 percent confidence interval:
 -10.658164  -6.391836
sample estimates:
mean in group background     mean in group sample 
              -0.2770833                8.2479167 


--- ANOVA: OD trajectory by well_type x time_min (background vs sample wells) ---

Analysis of Variance Table

Response: od
                     Df Sum Sq Mean Sq  F value    Pr(&gt;F)    
well_type             1  9.908  9.9081 205.3025 &lt; 2.2e-16 ***
time_min              1  0.012  0.0117   0.2424  0.622564    
well_type:time_min    1  0.512  0.5118  10.6053  0.001165 ** 
Residuals          1004 48.454  0.0483                       
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Interpretation: mean background-well rate is -0.28 mA412/min vs. 8.25 mA412/min for sample wells (p = 2.93e-10 ). Background wells are statistically distinct from, and far slower
 than, reaction wells on this plate -- consistent with the per-well
 flat/active classification above and with the qualitative conclusion
 reached by Cattau et al. (2023) on the legacy assay version.

--- bg_significance_test: Welch t-test result object ---

List of 10
 $ statistic  : Named num -8.05
  ..- attr(*, "names")= chr "t"
 $ parameter  : Named num 45
  ..- attr(*, "names")= chr "df"
 $ p.value    : num 2.93e-10
 $ conf.int   : num [1:2] -10.66 -6.39
  ..- attr(*, "conf.level")= num 0.95
 $ estimate   : Named num [1:2] -0.277 8.248
  ..- attr(*, "names")= chr [1:2] "mean in group background" "mean in group sample"
 $ null.value : Named num 0
  ..- attr(*, "names")= chr "difference in means between group background and group sample"
 $ stderr     : num 1.06
 $ alternative: chr "two.sided"
 $ method     : chr "Welch Two Sample t-test"
 $ data.name  : chr "slope_mOD_min by well_type"
 - attr(*, "class")= chr "htest"

--- bg_trend_anova: ANOVA table for OD ~ well_type * time_min ---

Classes 'anova' and 'data.frame':   4 obs. of  5 variables:
 $ Df     : int  1 1 1 1004
 $ Sum Sq : num  9.9081 0.0117 0.5118 48.4542
 $ Mean Sq: num  9.9081 0.0117 0.5118 0.0483
 $ F value: num  205.302 0.242 10.605 NA
 $ Pr(&gt;F) : num  1.67e-42 6.23e-01 1.17e-03 NA
 - attr(*, "heading")= chr [1:2] "Analysis of Variance Table\n" "Response: od"</code></pre>
</section>
</section>
<section id="technical-replicate-precision" class="level1">
<h1>9 TECHNICAL REPLICATE PRECISION</h1>
<p>Coefficient of variation across the three technical replicates of each sample, computed on the extracted rate. Two versions are reported: <strong>all</strong> three replicates, and <strong>usable replicates only</strong> (rate window with R<sup>2</sup> &gt;= 0.8, rising trace, no read glitch). The comparison localizes the imprecision to specific wells. Any sample whose CV exceeds 15% on either basis is flagged below.</p>
<div class="sourceCode" id="cb53" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb53-1">cv_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_replicate_cv</span>(well_rates, protein_by_sample<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id, assay_params)</span>
<span id="cb53-2"></span>
<span id="cb53-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all,</span>
<span id="cb53-4">                            n_usable, mean_usable, sd_usable, cv_usable,</span>
<span id="cb53-5">                            excluded_wells),</span>
<span id="cb53-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb53-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>,</span>
<span id="cb53-8">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean rate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Excluded wells"</span>),</span>
<span id="cb53-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate CV of the extracted rate (mA412/min), "</span>,</span>
<span id="cb53-10">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all replicates vs. usable replicates only"</span>))</span>
<span id="cb53-11"></span>
<span id="cb53-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb53-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on ALL replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cv_summary), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb53-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb53-15">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_all, mean_all, sd_all, cv_all) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb53-16">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb53-17"></span>
<span id="cb53-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding CV"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb53-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"on USABLE replicates:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_usable), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb53-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(fails_cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb53-21">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_usable, mean_usable, sd_usable, cv_usable) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb53-22">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb53-23"></span>
<span id="cb53-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb53-25"></span>
<span id="cb53-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cv_summary: per-sample technical replicate CV, both variants ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb53-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cv_summary)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th>CV (%)</th>
<th>n usable</th>
<th style="text-align: right;">Mean rate</th>
<th style="text-align: right;">SD</th>
<th>CV (%)</th>
<th style="text-align: left;">Excluded wells</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.73</td>
<td style="text-align: right;">0.38</td>
<td>4.9</td>
<td>3</td>
<td style="text-align: right;">7.73</td>
<td style="text-align: right;">0.38</td>
<td>4.9</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.80</td>
<td style="text-align: right;">2.37</td>
<td>30.3</td>
<td>2</td>
<td style="text-align: right;">9.13</td>
<td style="text-align: right;">0.81</td>
<td>8.9</td>
<td style="text-align: left;">A6</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">8.00</td>
<td style="text-align: right;">0.44</td>
<td>5.4</td>
<td>3</td>
<td style="text-align: right;">8.00</td>
<td style="text-align: right;">0.44</td>
<td>5.4</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">6.32</td>
<td style="text-align: right;">3.57</td>
<td>56.5</td>
<td>2</td>
<td style="text-align: right;">8.38</td>
<td style="text-align: right;">0.18</td>
<td>2.1</td>
<td style="text-align: left;">A12</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">13.87</td>
<td style="text-align: right;">9.55</td>
<td>68.8</td>
<td>2</td>
<td style="text-align: right;">19.25</td>
<td style="text-align: right;">2.90</td>
<td>15.1</td>
<td style="text-align: left;">B3</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">6.33</td>
<td style="text-align: right;">2.33</td>
<td>36.8</td>
<td>2</td>
<td style="text-align: right;">7.45</td>
<td style="text-align: right;">1.84</td>
<td>24.7</td>
<td style="text-align: left;">B5</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">8.92</td>
<td style="text-align: right;">0.58</td>
<td>6.5</td>
<td>3</td>
<td style="text-align: right;">8.92</td>
<td style="text-align: right;">0.58</td>
<td>6.5</td>
<td style="text-align: left;">-</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">7.02</td>
<td style="text-align: right;">0.56</td>
<td>7.9</td>
<td>3</td>
<td style="text-align: right;">7.02</td>
<td style="text-align: right;">0.56</td>
<td>7.9</td>
<td style="text-align: left;">-</td>
</tr>
</tbody>
</table>
<p>Technical replicate CV of the extracted rate (mA412/min), all replicates vs.&nbsp;usable replicates only</p>
<pre><code>Samples exceeding CV 15% on ALL replicates: 4 / 8 
      sample_id n_all mean_all sd_all cv_all
 F05_02_ambient     3    7.800  2.366  30.33
 F05_04_ambient     3    6.317  3.567  56.47
 F05_05_ambient     3   13.867  9.547  68.85
 F05_06_ambient     3    6.333  2.330  36.80

Samples exceeding CV 15% on USABLE replicates: 2 
      sample_id n_usable mean_usable sd_usable cv_usable
 F05_05_ambient        2       19.25     2.899     15.06
 F05_06_ambient        2        7.45     1.838     24.68

--- cv_summary: per-sample technical replicate CV, both variants ---

'data.frame':   8 obs. of  12 variables:
 $ sample_id      : chr  "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ n_all          : int  3 3 3 3 3 3 3 3
 $ mean_all       : num  7.73 7.8 8 6.32 13.87 ...
 $ sd_all         : num  0.382 2.366 0.436 3.567 9.547 ...
 $ cv_all         : num  4.94 30.33 5.45 56.47 68.85 ...
 $ n_usable       : int  3 2 3 2 2 2 3 3
 $ mean_usable    : num  7.73 9.13 8 8.38 19.25 ...
 $ sd_usable      : num  0.382 0.813 0.436 0.177 2.899 ...
 $ cv_usable      : num  4.94 8.91 5.45 2.11 15.06 ...
 $ excluded_wells : Named chr  "-" "A6" "-" "A12" ...
  ..- attr(*, "names")= chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ fails_cv_all   : logi  FALSE TRUE FALSE TRUE TRUE TRUE ...
 $ fails_cv_usable: logi  FALSE FALSE FALSE FALSE TRUE TRUE ...</code></pre>
<section id="plot-replicate-spread" class="level2">
<h2 class="anchored" data-anchor-id="plot-replicate-spread">9.1 Plot replicate spread</h2>
<div class="sourceCode" id="cb55" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb55-1">cv_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_rates <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb55-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>)</span>
<span id="cb55-3"></span>
<span id="cb55-4">cv_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(cv_plot_data, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> slope_mOD_min)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> rate_usable, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> rate_usable),</span>
<span id="cb55-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat_summary</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fun =</span> mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">geom =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"crossbar"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>,</span>
<span id="cb55-8">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> cv_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb55-10">                                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV %.0f%%"</span>, cv_all)),</span>
<span id="cb55-11">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>,</span>
<span id="cb55-12">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(cv_summary<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fails_cv_all, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey30"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>),</span>
<span id="cb55-14">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb55-16">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"usable"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"flagged"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicate"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Technical replicate spread in extracted rate"</span>,</span>
<span id="cb55-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Crossbar = mean of all three replicates; CV computed on all three. "</span>,</span>
<span id="cb55-19">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Threshold "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%."</span>),</span>
<span id="cb55-20">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rate (mA412/min)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb55-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb55-23">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">30</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb55-24"></span>
<span id="cb55-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"technical_replicate_cv.png"</span>), cv_plot,</span>
<span id="cb55-26">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb55-27"></span>
<span id="cb55-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- cv_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb55-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(cv_plot)</span>
<span id="cb55-30"></span>
<span id="cb55-31">cv_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/Gen5-20260811-mgig-citrate_synthase-F05-ambient_files/figure-gfm/plot-replicate-cv-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- cv_plot: ggplot object structure ---

data: well, well_type, sample_id, std_nmol, t_start, t_end,
  slope_mOD_min, r2, max_abs_slope_mOD_min, abs_window_is_negative,
  net_change, frac_rising, od_max, flag_decreasing, flag_over_range,
  flag_glitch, glitch_at_min, flag_bg_active, n_flags,
  glitch_in_window, rate_usable, cv_all [24x22]
mapping:  x = ~sample_id, y = ~slope_mOD_min
scales:   colour, shape 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: colour = ~rate_usable, shape = ~rate_usable 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_jitter 

geom_crossbar: na.rm = FALSE, orientation = NA, width = 0.5
stat_summary: fun.data = NULL, fun = function (x, ...) 
UseMethod("mean"), fun.max = NULL, fun.min = NULL, fun.args = list(), na.rm = FALSE, orientation = NA
position_identity 

mapping: x = ~sample_id, y = Inf, label = ~sprintf("CV %.0f%%", cv_all) 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge </code></pre>
</section>
</section>
<section id="citrate-synthase-activity" class="level1">
<h1>10 CITRATE SYNTHASE ACTIVITY</h1>
<section id="calculation" class="level2">
<h2 class="anchored" data-anchor-id="calculation">10.1 Calculation</h2>
<p>Following Abcam §10.3:</p>
<p><code>Sample CS activity = B / (dT x V) x D</code> nmol/min/µL (= mU/µL)</p>
<p>Rearranged for a kinetic slope, where the standard curve converts A412 into nmol of thiol:</p>
<ol type="1">
<li><strong>Rate</strong> (A412/min) = max-increasing sliding-window slope / 1000</li>
<li><strong>Background-corrected rate</strong> = sample rate - mean flat background rate</li>
<li><strong>B/dT</strong> (nmol/min) = background-corrected rate / standard curve slope (0.05582 A412 per nmol, from the outlier-excluded fit)</li>
<li><strong>Activity</strong> (mU/µL) = (B/dT) / <em>V</em> x <em>D</em>, with <em>V</em> = 2 µL and <em>D</em> = 1</li>
<li><strong>Protein-normalized</strong> (mU/mg protein) = activity x <code>homogenate_volume_uL</code> (350 µL, measured) / total protein (mg) — recovers total enzyme units in the homogenate, then divides by the total protein extracted from that homogenate (note 3), rather than by tissue input mass</li>
</ol>
<div class="sourceCode" id="cb57" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb57-1">cs_activity <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calculate_cs_activity</span>(well_rates, protein_by_sample, background_per_sample,</span>
<span id="cb57-2">                                      std_slope, std_nmol_max, assay_params, plate_long)</span>
<span id="cb57-3"></span>
<span id="cb57-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with a computed activity:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(cs_activity), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(protein_by_sample), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb57-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/uL):"</span>,</span>
<span id="cb57-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb57-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Activity range (mU/mg protein):"</span>,</span>
<span id="cb57-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.3f"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(cs_activity<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb57-9"></span>
<span id="cb57-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- cs_activity: per-sample citrate synthase activity ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb57-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(cs_activity)</span></code></pre></div>
<pre><code>Samples with a computed activity: 8 / 8 
Activity range (mU/uL): 0.061 - 0.171 
Activity range (mU/mg protein): 22.418 - 240.387 

--- cs_activity: per-sample citrate synthase activity ---

tibble [8 × 21] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ n_reps_used               : int [1:8] 3 2 3 2 2 2 3 3
 $ mean_rate_mOD_min         : num [1:8] 7.73 9.13 8 8.38 19.25 ...
 $ sd_rate                   : num [1:8] 0.382 0.813 0.436 0.177 2.899 ...
 $ cv_rate                   : num [1:8] 4.94 8.91 5.45 2.11 15.06 ...
 $ family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ individual                : chr [1:8] "01" "02" "03" "04" ...
 $ temperature               : chr [1:8] "ambient" "ambient" "ambient" "ambient" ...
 $ conc_ug_mL                : num [1:8] 876 1039 1900 1129 712 ...
 $ total_protein_mg          : num [1:8] 0.307 0.364 0.665 0.395 0.249 ...
 $ bg_rate_flat              : num [1:8] 0.55 0.475 0.45 0.225 0.15 ...
 $ n_bg_flat                 : int [1:8] 2 2 2 2 2 1 3 3
 $ bg_rate_mOD_min           : num [1:8] 0.55 0.475 0.45 0.225 0.15 ...
 $ corrected_mOD_min         : num [1:8] 7.18 8.65 7.55 8.15 19.1 ...
 $ rate_OD_min               : num [1:8] 0.00718 0.00865 0.00755 0.00815 0.0191 ...
 $ nmol_per_min              : num [1:8] 0.129 0.155 0.135 0.146 0.342 ...
 $ activity_mU_per_uL        : num [1:8] 0.0643 0.0775 0.0676 0.073 0.1711 ...
 $ total_mU_in_homogenate    : num [1:8] 22.5 27.1 23.7 25.6 59.9 ...
 $ activity_mU_per_mg_protein: num [1:8] 73.4 74.6 35.6 64.6 240.4 ...
 $ nmol_in_window            : num [1:8] 5.15 6.2 5.41 5.84 13.69 ...
 $ within_std_range          : logi [1:8] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
</section>
<section id="results-table" class="level2">
<h2 class="anchored" data-anchor-id="results-table">10.2 Results table</h2>
<div class="sourceCode" id="cb59" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb59-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_results_table</span>(cs_activity, cv_summary, baseline_per_sample, assay_params)</span>
<span id="cb59-2"></span>
<span id="cb59-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table,</span>
<span id="cb59-4">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, family F05 ambient (mU/mg protein uses "</span>,</span>
<span id="cb59-5">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"measured protein concentration x the "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb59-6">                       <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume)"</span>))</span>
<span id="cb59-7"></span>
<span id="cb59-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Interpretation summary:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb59-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(results_table <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">count</span>(Interpretation, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n_samples"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb59-10">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb59-11"></span>
<span id="cb59-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_results.csv"</span>),</span>
<span id="cb59-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb59-14"></span>
<span id="cb59-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- results_table: formatted per-sample results written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb59-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(results_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
<col style="width: 5%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">Protein conc (ug/mL)</th>
<th style="text-align: right;">Total protein (mg)</th>
<th style="text-align: left;">Reps used</th>
<th>CV all reps (%)</th>
<th style="text-align: right;">CV used reps (%)</th>
<th style="text-align: right;">Rate (mA412/min)</th>
<th style="text-align: right;">BG rate (mA412/min)</th>
<th style="text-align: right;">Corrected rate (mA412/min)</th>
<th style="text-align: right;">Activity (mU/uL)</th>
<th style="text-align: right;">Activity (mU/mg protein)</th>
<th>CV flag</th>
<th style="text-align: left;">Elevated baseline reps</th>
<th style="text-align: left;">Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">F05_01_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">01</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">876.1</td>
<td style="text-align: right;">0.307</td>
<td style="text-align: left;">3/3</td>
<td>4.9</td>
<td style="text-align: right;">4.9</td>
<td style="text-align: right;">7.73</td>
<td style="text-align: right;">0.550</td>
<td style="text-align: right;">7.18</td>
<td style="text-align: right;">0.0643</td>
<td style="text-align: right;">73.442</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_02_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">02</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1038.9</td>
<td style="text-align: right;">0.364</td>
<td style="text-align: left;">2/3</td>
<td>30.3</td>
<td style="text-align: right;">8.9</td>
<td style="text-align: right;">9.13</td>
<td style="text-align: right;">0.475</td>
<td style="text-align: right;">8.65</td>
<td style="text-align: right;">0.0775</td>
<td style="text-align: right;">74.579</td>
<td>FAIL &gt;15%</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_03_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">03</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1900.4</td>
<td style="text-align: right;">0.665</td>
<td style="text-align: left;">3/3</td>
<td>5.4</td>
<td style="text-align: right;">5.4</td>
<td style="text-align: right;">8.00</td>
<td style="text-align: right;">0.450</td>
<td style="text-align: right;">7.55</td>
<td style="text-align: right;">0.0676</td>
<td style="text-align: right;">35.586</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_04_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">04</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1129.4</td>
<td style="text-align: right;">0.395</td>
<td style="text-align: left;">2/3</td>
<td>56.5</td>
<td style="text-align: right;">2.1</td>
<td style="text-align: right;">8.38</td>
<td style="text-align: right;">0.225</td>
<td style="text-align: right;">8.15</td>
<td style="text-align: right;">0.0730</td>
<td style="text-align: right;">64.638</td>
<td>FAIL &gt;15%</td>
<td style="text-align: left;">1/3</td>
<td style="text-align: left;">caution - some reps compromised</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_05_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">05</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">711.7</td>
<td style="text-align: right;">0.249</td>
<td style="text-align: left;">2/3</td>
<td>68.8</td>
<td style="text-align: right;">15.1</td>
<td style="text-align: right;">19.25</td>
<td style="text-align: right;">0.150</td>
<td style="text-align: right;">19.10</td>
<td style="text-align: right;">0.1711</td>
<td style="text-align: right;">240.387</td>
<td>FAIL &gt;15%</td>
<td style="text-align: left;">3/3</td>
<td style="text-align: left;">DO NOT USE - no clean replicate</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_06_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">06</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">2232.4</td>
<td style="text-align: right;">0.781</td>
<td style="text-align: left;">2/3</td>
<td>36.8</td>
<td style="text-align: right;">24.7</td>
<td style="text-align: right;">7.45</td>
<td style="text-align: right;">0.500</td>
<td style="text-align: right;">6.95</td>
<td style="text-align: right;">0.0623</td>
<td style="text-align: right;">27.886</td>
<td>FAIL &gt;15%</td>
<td style="text-align: left;">1/3</td>
<td style="text-align: left;">caution - some reps compromised</td>
</tr>
<tr class="odd">
<td style="text-align: left;">F05_07_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">07</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">1687.8</td>
<td style="text-align: right;">0.591</td>
<td style="text-align: left;">3/3</td>
<td>6.5</td>
<td style="text-align: right;">6.5</td>
<td style="text-align: right;">8.92</td>
<td style="text-align: right;">0.300</td>
<td style="text-align: right;">8.62</td>
<td style="text-align: right;">0.0772</td>
<td style="text-align: right;">45.729</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
<tr class="even">
<td style="text-align: left;">F05_08_ambient</td>
<td style="text-align: left;">F05</td>
<td style="text-align: left;">08</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">2703.7</td>
<td style="text-align: right;">0.946</td>
<td style="text-align: left;">3/3</td>
<td>7.9</td>
<td style="text-align: right;">7.9</td>
<td style="text-align: right;">7.02</td>
<td style="text-align: right;">0.250</td>
<td style="text-align: right;">6.77</td>
<td style="text-align: right;">0.0606</td>
<td style="text-align: right;">22.418</td>
<td>pass</td>
<td style="text-align: left;">0/3</td>
<td style="text-align: left;">usable</td>
</tr>
</tbody>
</table>
<p>Citrate synthase activity, family F05 ambient (mU/mg protein uses measured protein concentration x the 350 uL homogenization volume)</p>
<pre><code>Interpretation summary:
                  Interpretation n_samples
 DO NOT USE - no clean replicate         1
 caution - some reps compromised         2
                          usable         5

--- results_table: formatted per-sample results written to CSV ---

tibble [8 × 17] (S3: tbl_df/tbl/data.frame)
 $ Sample                    : chr [1:8] "F05_01_ambient" "F05_02_ambient" "F05_03_ambient" "F05_04_ambient" ...
 $ Family                    : chr [1:8] "F05" "F05" "F05" "F05" ...
 $ Individual                : chr [1:8] "01" "02" "03" "04" ...
 $ Temperature               : chr [1:8] "ambient" "ambient" "ambient" "ambient" ...
 $ Protein conc (ug/mL)      : num [1:8] 876 1039 1900 1129 712 ...
 $ Total protein (mg)        : num [1:8] 0.307 0.364 0.665 0.395 0.249 0.781 0.591 0.946
 $ Reps used                 : chr [1:8] "3/3" "2/3" "3/3" "2/3" ...
 $ CV all reps (%)           : num [1:8] 4.9 30.3 5.4 56.5 68.8 36.8 6.5 7.9
 $ CV used reps (%)          : num [1:8] 4.9 8.9 5.4 2.1 15.1 24.7 6.5 7.9
 $ Rate (mA412/min)          : num [1:8] 7.73 9.13 8 8.38 19.25 ...
 $ BG rate (mA412/min)       : num [1:8] 0.55 0.475 0.45 0.225 0.15 0.5 0.3 0.25
 $ Corrected rate (mA412/min): num [1:8] 7.18 8.65 7.55 8.15 19.1 6.95 8.62 6.77
 $ Activity (mU/uL)          : num [1:8] 0.0643 0.0775 0.0676 0.073 0.1711 ...
 $ Activity (mU/mg protein)  : num [1:8] 73.4 74.6 35.6 64.6 240.4 ...
 $ CV flag                   : chr [1:8] "pass" "FAIL &gt;15%" "pass" "FAIL &gt;15%" ...
 $ Elevated baseline reps    : chr [1:8] "0/3" "0/3" "0/3" "1/3" ...
 $ Interpretation            : chr [1:8] "usable" "usable" "usable" "caution - some reps compromised" ...</code></pre>
</section>
<section id="plot-activity" class="level2">
<h2 class="anchored" data-anchor-id="plot-activity">10.3 Plot activity</h2>
<div class="sourceCode" id="cb61" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb61-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Three-level quality status: a sample whose every replicate has an elevated</span></span>
<span id="cb61-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># baseline cannot be rescued by replicate exclusion, so it outranks CV as a</span></span>
<span id="cb61-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># disqualifier and is drawn separately (see note 6).</span></span>
<span id="cb61-4">qual_levels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clean"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV &gt; "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%"</span>),</span>
<span id="cb61-5">                 <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"all reps baseline-compromised"</span>)</span>
<span id="cb61-6">qual_cols   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#08519c"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#cb181d"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey60"</span>), qual_levels)</span>
<span id="cb61-7"></span>
<span id="cb61-8">activity_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> cs_activity <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb61-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(cv_summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, cv_all), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb61-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(baseline_per_sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, n_elevated, n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb61-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_flag =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb61-12">                            n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n                              <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>],</span>
<span id="cb61-13">                            cv_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct       <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>],</span>
<span id="cb61-14">                            <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>                                        <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb61-15">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> qual_levels),</span>
<span id="cb61-16">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(n_reps_used, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/3 reps"</span>,</span>
<span id="cb61-17">                          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(n_elevated <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> n, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - DISQUALIFIED"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)))</span>
<span id="cb61-18"></span>
<span id="cb61-19">activity_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb61-20">                        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">reorder</span>(sample_id, activity_mU_per_uL),</span>
<span id="cb61-21">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_uL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> cv_flag)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_col</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.65</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> label_n), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coord_flip</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">clip =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"off"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand_limits</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.25</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Citrate synthase activity, M. gigas ctenidia, family F05 ambient"</span>,</span>
<span id="cb61-28">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background-corrected, mean of usable technical replicates.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-29">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Red = replicate CV above "</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_threshold_pct,</span>
<span id="cb61-30">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%. Grey = every replicate had an elevated starting A412,</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb61-31">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"so the apparent high activity is a baseline artifact, not enzyme."</span>),</span>
<span id="cb61-32">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/uL homogenate)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb61-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb61-35">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb61-36"></span>
<span id="cb61-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity.png"</span>), activity_plot,</span>
<span id="cb61-38">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb61-39"></span>
<span id="cb61-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- activity_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb61-41"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(activity_plot)</span>
<span id="cb61-42"></span>
<span id="cb61-43">activity_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/Gen5-20260811-mgig-citrate_synthase-F05-ambient_files/figure-gfm/plot-activity-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- activity_plot: ggplot object structure ---

data: sample_id, n_reps_used, mean_rate_mOD_min, sd_rate, cv_rate,
  family, individual, temperature, conc_ug_mL, total_protein_mg,
  bg_rate_flat, n_bg_flat, bg_rate_mOD_min, corrected_mOD_min,
  rate_OD_min, nmol_per_min, activity_mU_per_uL,
  total_mU_in_homogenate, activity_mU_per_mg_protein, nmol_in_window,
  within_std_range, cv_all, n_elevated, n, cv_flag, label_n [8x26]
mapping:  x = ~reorder(sample_id, activity_mU_per_uL), y = ~activity_mU_per_uL, fill = ~cv_flag
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_col: na.rm = FALSE, just = 0.5, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_stack 

mapping: label = ~label_n 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge 

mapping: y = ~y 
geom_blank: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
<section id="protein-normalized-activity" class="level2">
<h2 class="anchored" data-anchor-id="protein-normalized-activity">10.4 Protein-normalized activity</h2>
<div class="sourceCode" id="cb63" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb63-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Clean samples only: the trend test must not be driven by wells whose rate is</span></span>
<span id="cb63-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># a baseline artifact, so the fit is restricted to samples clean on every check.</span></span>
<span id="cb63-3">norm_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> activity_plot_data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_flag <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> qual_levels[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>])</span>
<span id="cb63-4"></span>
<span id="cb63-5">norm_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(activity_plot_data,</span>
<span id="cb63-6">                    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> total_protein_mg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> activity_mU_per_mg_protein)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb63-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> norm_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb63-8">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey35"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey85"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb63-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> cv_flag), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb63-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> individual), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey25"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb63-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> qual_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">drop =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well quality"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb63-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Protein-normalized CS activity vs. total extracted protein"</span>,</span>
<span id="cb63-13">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Point labels = individual ID. Total protein = measured protein "</span>,</span>
<span id="cb63-14">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"concentration x the same</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, assay_params<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_volume_uL,</span>
<span id="cb63-15">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" uL homogenization volume used for every sample. Grey line = fit to "</span>,</span>
<span id="cb63-16">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clean</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">samples only; a negative slope would indicate the normalization "</span>,</span>
<span id="cb63-17">                         <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"is not protein-independent."</span>),</span>
<span id="cb63-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Total extracted protein (mg)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CS activity (mU/mg protein)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb63-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb63-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb63-21">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb63-22"></span>
<span id="cb63-23">protein_trend <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, activity_plot_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb63-24">protein_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)</span>
<span id="cb63-25">uL_trend_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>total_protein_mg, norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)</span>
<span id="cb63-26"></span>
<span id="cb63-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"citrate_synthase_activity_normalized.png"</span>), norm_plot,</span>
<span id="cb63-28">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb63-29"></span>
<span id="cb63-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Correlation of mU/mg protein with total extracted protein</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb63-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  all %d samples      : r = %+.3f, p = %.4f</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb63-32">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(activity_plot_data), protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value))</span>
<span id="cb63-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean samples only  : r = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb63-34">            protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, protein_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb63-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/mg protein range: %.3f to %.3f (%.1f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb63-36">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein),</span>
<span id="cb63-37">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_mg_protein)))</span>
<span id="cb63-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  clean-sample mU/uL range: %.4f to %.4f (%.1f-fold)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb63-39">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL),</span>
<span id="cb63-40">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>activity_mU_per_uL)))</span>
<span id="cb63-41"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Artifact check: r(total protein, mU/uL raw rate) = %+.3f, p = %.4f  (n = %d)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb63-42">            uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>estimate, uL_trend_clean<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(norm_clean)))</span>
<span id="cb63-43"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"If mU/uL itself trends with total protein while mU/mg protein trends oppositely,</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb63-44">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>,</span>
<span id="cb63-45">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rather than a biological difference in specific activity.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb63-46"></span>
<span id="cb63-47"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- protein_trend_clean: correlation test on clean samples ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb63-48"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(protein_trend_clean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb63-49"></span>
<span id="cb63-50"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- norm_clean: clean samples used for the trend fit ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb63-51"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(norm_clean)</span>
<span id="cb63-52"></span>
<span id="cb63-53">norm_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/Gen5-20260811-mgig-citrate_synthase-F05-ambient_files/figure-gfm/plot-activity-normalized-1.png" class="img-fluid"><!-- --></p>
<pre><code>Correlation of mU/mg protein with total extracted protein
  all 8 samples      : r = -0.695, p = 0.0555
  clean samples only  : r = -0.978, p = 0.0215  (n = 4)
  clean-sample mU/mg protein range: 22.418 to 73.442 (3.3-fold)
  clean-sample mU/uL range: 0.0606 to 0.0772 (1.3-fold)

Artifact check: r(total protein, mU/uL raw rate) = -0.274, p = 0.7259  (n = 4)
If mU/uL itself trends with total protein while mU/mg protein trends oppositely,
the mU/mg protein trend is partly/wholly the arithmetic of dividing by a covariate
rather than a biological difference in specific activity.

--- protein_trend_clean: correlation test on clean samples ---

List of 9
 $ statistic  : Named num -6.7
 $ parameter  : Named int 2
 $ p.value    : num 0.0215
 $ estimate   : Named num -0.978
 $ null.value : Named num 0
 $ alternative: chr "two.sided"
 $ method     : chr "Pearson's product-moment correlation"
 $ data.name  : chr "norm_clean$total_protein_mg and norm_clean$activity_mU_per_mg_protein"
 $ conf.int   : num [1:2] -1 -0.291

--- norm_clean: clean samples used for the trend fit ---

tibble [4 × 26] (S3: tbl_df/tbl/data.frame)
 $ sample_id                 : chr [1:4] "F05_01_ambient" "F05_03_ambient" "F05_07_ambient" "F05_08_ambient"
 $ n_reps_used               : int [1:4] 3 3 3 3
 $ mean_rate_mOD_min         : num [1:4] 7.73 8 8.92 7.02
 $ sd_rate                   : num [1:4] 0.382 0.436 0.584 0.558
 $ cv_rate                   : num [1:4] 4.94 5.45 6.55 7.95
 $ family                    : chr [1:4] "F05" "F05" "F05" "F05"
 $ individual                : chr [1:4] "01" "03" "07" "08"
 $ temperature               : chr [1:4] "ambient" "ambient" "ambient" "ambient"
 $ conc_ug_mL                : num [1:4] 876 1900 1688 2704
 $ total_protein_mg          : num [1:4] 0.307 0.665 0.591 0.946
 $ bg_rate_flat              : num [1:4] 0.55 0.45 0.3 0.25
 $ n_bg_flat                 : int [1:4] 2 2 3 3
 $ bg_rate_mOD_min           : num [1:4] 0.55 0.45 0.3 0.25
 $ corrected_mOD_min         : num [1:4] 7.18 7.55 8.62 6.77
 $ rate_OD_min               : num [1:4] 0.00718 0.00755 0.00862 0.00677
 $ nmol_per_min              : num [1:4] 0.129 0.135 0.154 0.121
 $ activity_mU_per_uL        : num [1:4] 0.0643 0.0676 0.0772 0.0606
 $ total_mU_in_homogenate    : num [1:4] 22.5 23.7 27 21.2
 $ activity_mU_per_mg_protein: num [1:4] 73.4 35.6 45.7 22.4
 $ nmol_in_window            : num [1:4] 5.15 5.41 6.17 4.85
 $ within_std_range          : logi [1:4] TRUE TRUE TRUE TRUE
 $ cv_all                    : num [1:4] 4.94 5.45 6.55 7.95
 $ n_elevated                : int [1:4] 0 0 0 0
 $ n                         : int [1:4] 3 3 3 3
 $ cv_flag                   : Factor w/ 3 levels "clean","CV &gt; 15%",..: 1 1 1 1
 $ label_n                   : chr [1:4] "3/3 reps" "3/3 reps" "3/3 reps" "3/3 reps"</code></pre>
<p>The clean-sample correlation of mU/mg protein with total extracted protein is r = -0.978 (p = 0.0215, n = 4) — as strongly negative as the tissue-weight version of this check was. The difference is in the artifact check: raw mU/µL correlates with total protein at r = -0.274 (p = 0.726), a real (if not clean) inverse trend rather than the flat line seen against tissue weight. That means the mU/mg protein trend is <strong>not purely a division artifact</strong> the way mU/mg tissue was — part of it reflects that samples with more extracted protein measured a <em>lower</em> raw rate, which a fixed-volume, decelerating-kinetics assay (notes 3–4) cannot distinguish from a genuine difference in specific activity without a dilution series. Both possibilities remain open on this plate; the number should be treated as provisional pending that follow-up, but it is not dismissible as pure arithmetic the way the tissue-weight version was.</p>
</section>
</section>
<section id="qc-summary" class="level1">
<h1>11 QC SUMMARY</h1>
<div class="sourceCode" id="cb65" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb65-1">qc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_qc_summary_table</span>(layout_wells, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary, std_curve,</span>
<span id="cb65-2">                                      well_diagnostics, well_rates, cv_summary,</span>
<span id="cb65-3">                                      baseline_per_sample, pos_control, assay_params)</span>
<span id="cb65-4"></span>
<span id="cb65-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(qc_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"QC check"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Result"</span>),</span>
<span id="cb65-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quality control summary for this plate"</span>)</span>
<span id="cb65-7"></span>
<span id="cb65-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(qc_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"qc_summary.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb65-9"></span>
<span id="cb65-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- qc_summary: consolidated QC checks for the run ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb65-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(qc_summary)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">QC check</th>
<th style="text-align: left;">Result</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Occupied wells in layout</td>
<td style="text-align: left;">69</td>
</tr>
<tr class="even">
<td style="text-align: left;">Layout wells missing from absorbance CSV</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Max disagreement between absorbance CSV and full report</td>
<td style="text-align: left;">0</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard concentrations with replicate CV &gt; threshold</td>
<td style="text-align: left;">0, 8, 16, 24</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard wells flagged as outliers</td>
<td style="text-align: left;">8/18 (E6, E2, E12, E8, E10, F3, E7, F5)</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard curve R^2 (outlier-excluded, replicate level)</td>
<td style="text-align: left;">0.9678</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standard curve R^2 (all wells, replicate level)</td>
<td style="text-align: left;">0.8042</td>
</tr>
<tr class="even">
<td style="text-align: left;">Standard wells that LOST signal over the run</td>
<td style="text-align: left;">16/18</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Standards above photometric linearity ceiling</td>
<td style="text-align: left;">32, 40</td>
</tr>
<tr class="even">
<td style="text-align: left;">Background control wells behaving as active reactions</td>
<td style="text-align: left;">7/24</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells with a decreasing trace</td>
<td style="text-align: left;">3/24</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with an elevated starting A412</td>
<td style="text-align: left;">5/24 (A12, B1, B2, B3, B5)</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with ALL THREE replicates baseline-compromised</td>
<td style="text-align: left;">1/8 (F05_05_ambient)</td>
</tr>
<tr class="even">
<td style="text-align: left;">Sample wells with a read glitch</td>
<td style="text-align: left;">5/24</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Sample wells usable for rate extraction</td>
<td style="text-align: left;">20/24</td>
</tr>
<tr class="even">
<td style="text-align: left;">Samples with technical CV &gt; threshold (all reps)</td>
<td style="text-align: left;">4/8</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Samples with technical CV &gt; threshold (usable reps)</td>
<td style="text-align: left;">2/8</td>
</tr>
<tr class="even">
<td style="text-align: left;">Positive control replicates rising and linear</td>
<td style="text-align: left;">3/3</td>
</tr>
</tbody>
</table>
<p>Quality control summary for this plate</p>
<pre><code>--- qc_summary: consolidated QC checks for the run ---

'data.frame':   18 obs. of  2 variables:
 $ check: chr  "Occupied wells in layout" "Layout wells missing from absorbance CSV" "Max disagreement between absorbance CSV and full report" "Standard concentrations with replicate CV &gt; threshold" ...
 $ value: chr  "69" "0" "0" "0, 8, 16, 24" ...</code></pre>
<section id="auto-generated-findings" class="level2">
<h2 class="anchored" data-anchor-id="auto-generated-findings">11.1 Auto-generated findings</h2>
<p>The bullets below are generated programmatically from the QC/CV/anomaly objects above by <code>generate_qc_findings()</code>, so the same logic that flags a problem here is guaranteed to be the logic that flagged it upstream.</p>
<div class="sourceCode" id="cb67" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb67-1">qc_findings <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">generate_qc_findings</span>(well_diagnostics, well_rates, cv_summary,</span>
<span id="cb67-2">                                     baseline_per_sample, std_curve, recon<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary,</span>
<span id="cb67-3">                                     assay_params)</span>
<span id="cb67-4"></span>
<span id="cb67-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"- "</span>, qc_findings, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>- **Kinetic sources agree.** absorbance CSV and full report agree exactly on all 1449 shared well x timepoint readings; all layout wells are present.

- **Decreasing kinetics.** 3 sample well(s) end lower than (or equal to) their starting A412 and are excluded from rate extraction: A12, B3, B5.

- **Read glitches.** 5 sample well(s) contain a single read-to-read step inconsistent with its neighbours: A12, A6, B1, B2, B5 (only disqualifying if it falls inside the fitted rate window).

- **Elevated starting absorbance.** 5 sample well(s) start above the baseline threshold (A412 &gt; 0.35), indicating pre-existing thiol/contamination before the reaction began: A12, B1, B2, B3, B5.

- **Sample(s) with no clean replicate.** Every replicate of F05_05_ambient has an elevated starting A412; these samples have no usable measurement on this plate regardless of CV.

- **Over-range wells.** 7 well(s) exceed the photometric linearity ceiling (A412 &gt; 1.5): E10, F1, F2, F3, F4, F5, F6.

- **Background control wells behaving as active reactions.** 7 of 24 background wells show a starting A412 or drift inconsistent with a flat, inactive well: C12, C2, C5, C7, D1, D4, D5.

- **GSH standard curve replicate imprecision.** 4 of 6 concentrations exceed 15% CV: 0, 8, 16, 24 nmol/well.

- **Standard outlier wells.** 8 of 18 standard wells deviate from their triplicate median by more than 0.15 A412: E6, E2, E12, E8, E10, F3, E7, F5.

- **Standards above the photometric linear range.** 32, 40 nmol/well read above A412 1.5; the calibration is trustworthy only below these concentrations.

- **Standard signal decay.** 16 of 18 standard wells lost signal over the run (TNB instability); the standard curve is read at t = 0.

- **Standard curve fit (outlier-excluded):** slope = 0.05582 A412/nmol, R^2 = 0.9678 (all-wells R^2 = 0.8042).

- **Technical replicate CV &gt; 15% (all replicates).** 4 of 8 samples: F05_02_ambient (30%), F05_04_ambient (56%), F05_05_ambient (69%), F05_06_ambient (37%).

- **Technical replicate CV &gt; 15% persists after excluding flagged replicates.** F05_05_ambient (15%, n=2), F05_06_ambient (25%, n=2).</code></pre>
</section>
</section>
<section id="summary" class="level1">
<h1>12 SUMMARY</h1>
<section id="anomalies-found" class="level2">
<h2 class="anchored" data-anchor-id="anomalies-found">12.1 Anomalies found</h2>
<ol type="1">
<li><p><strong><code>absorbance-*.csv</code> originally omitted plate columns 10–12 — now resolved.</strong> An earlier export of this file covered only 54 of the 69 occupied wells (missing <code>F05_04</code>, <code>F05_08</code>, their background controls, and the whole 24 nmol GSH standard). The file has been re-exported from Gen5 and now covers all 69 wells; the <code>reconcile-sources</code> chunk confirms every layout well is present and that the re-export agrees exactly with <code>full_report-*.txt</code> on all 1,449 shared readings. No wells were recovered from the full report in this version of the analysis.</p></li>
<li><p><strong>Background control wells are not behaving as background controls.</strong> Of 24 background wells, roughly a third start at high A412 (0.24–0.82 vs.&nbsp;~0.05 for well-behaved wells) and then <em>decrease</em> steeply — up to -19 mA412/min. Background Control Mix contains no CS Substrate Mix, so these wells cannot support a CS reaction and must read flat. Six of the eight background triplicates contain at least one such well, and they appear in a near-regular pattern across the plate. One well (C2) instead <em>increases</em> at 11.6 mA412/min, i.e.&nbsp;it behaves like a full reaction well. The most consistent explanation is that Reaction Mix was dispensed into some background wells instead of Background Control Mix. Because of this, background correction here uses only the flat replicates, and the flat-well background rate is ~0.3 mA412/min — about 3% of the median sample signal, so background correction is a minor term regardless.</p></li>
<li><p><strong>The GSH standard curve failed QC.</strong> Replicate CVs run from 6% to 126%, and five of six concentrations exceed the 15% threshold. The replicate-level R<sup>2</sup> is only 0.80. Two wells are grossly discrepant from their triplicate medians (E6 at the 8 nmol point, +0.80 A412; E2 at the 0 nmol point, +0.77 A412) — E2 reads 0.871 while its siblings E1 and E3 read 0.100 and 0.095. This is the dominant source of uncertainty in every reported activity value, since the standard curve slope scales all of them.</p></li>
<li><p><strong>The top two standards are above the photometric linear range.</strong> The 32 and 40 nmol standards read A412 1.7–2.2. Response per nmol is essentially flat between them (net A412 1.61 vs.&nbsp;1.72 for a 25% concentration increase), i.e.&nbsp;the curve is saturating. The calibration is trustworthy only over roughly 0–24 nmol.</p></li>
<li><p><strong>Every standard well lost signal over the run</strong> (18/18 wells, drift -0.001 to -0.74 A412). GSH + DTNB is a stoichiometric endpoint, so standards should be stable; this indicates TNB<sup>2-</sup> instability under the run conditions. The standard curve is therefore read at t = 0, before appreciable decay.</p></li>
<li><p><strong>Decreasing kinetics in sample wells.</strong> Wells A12, B3 and B5 end lower than they started, and A6 rises by only 0.041 A412 total against ~0.16 for its siblings. These wells are excluded from rate extraction. Note that Gen5’s own <code>Max V [412]</code> column reports large <em>negative</em> rates for these wells (e.g.&nbsp;-19.7 for A12, -11.5 for B3) because Gen5 selects the window of maximum <em>absolute</em> slope; those numbers are not activities and must not be used as such.</p></li>
<li><p><strong>Read glitches.</strong> Eleven wells contain a single read-to-read step that disagrees with the steps on either side of it by more than 0.02 A412 — among sample wells: A6 (+0.040 at 30 min, after the trace had gone flat), A12 (-0.036 at 2 min), B1 (-0.035 at 4 min), B2 (-0.041 at 4 min) and B5 (+0.031 at 2 min); also D4, E6, E7, E10, E11 and F1. These are instrument artifacts rather than kinetics. A glitch only disqualifies a well’s rate when it falls <em>inside</em> the fitted window, which is why B1 and B2 retain usable rates (their glitch at 4 min precedes their 10–18 min window) while A6 and B5 do not.</p></li>
<li><p><strong>Elevated starting absorbance is the pattern underlying most of the above.</strong> Five sample wells (A12, B1, B2, B3, B5) and seven background wells start far above the clean-well baseline of A412 0.13–0.16, and these are precisely the wells that decline or misbehave. TNB present at t = 0 means the reaction had already run, or the well was contaminated, before the first read. The affected wells cluster in the right-hand columns of rows A–B and scattered positions in C–D, which points to a dispensing or timing problem rather than random error. Most consequentially, <strong>all three <code>F05_05</code> replicates are affected</strong>, which disqualifies that sample entirely.</p></li>
<li><p><strong>Layout label problem.</strong> <code>F05_05_ambient_BG</code> (D1–D3) is spelled <code>citrate_synthasse</code>. Handled in code, but the layout file should be corrected.</p></li>
</ol>
</section>
<section id="technical-replicate-precision-1" class="level2">
<h2 class="anchored" data-anchor-id="technical-replicate-precision-1">12.2 Technical replicate precision</h2>
<p>Across all three replicates, <strong>four of eight samples exceed the 15% CV threshold</strong>: <code>F05_05</code> (69%), <code>F05_04</code> (56%), <code>F05_06</code> (37%) and <code>F05_02</code> (30%). The other four — <code>F05_01</code>, <code>F05_03</code>, <code>F05_07</code>, <code>F05_08</code> — sit at 4.9%, 5.4%, 6.5% and 7.9% respectively.</p>
<p>In every failing case the CV is driven by <strong>a single bad well</strong>, not by uniform imprecision. Excluding that one flagged replicate drops <code>F05_02</code> to 8.9% (excluding A6), <code>F05_04</code> to 2.1% (A12) and <code>F05_05</code> to 15.1% (B3). <code>F05_06</code> is the exception: excluding B5 still leaves 24.7%, because its remaining two replicates (B4 at 6.15 and B6 at 8.75 mA412/min) genuinely disagree. Every sample retains at least two usable replicates.</p>
<p>So <strong>two samples remain above threshold after QC exclusion</strong>: <code>F05_06</code> (24.7%, n = 2) and <code>F05_05</code> (15.1%, n = 2, marginal).</p>
<p><strong><code>F05_05</code> should not be used at all, and its CV is not the reason.</strong> It reports 19.3 mA412/min — 2.2x the next-highest sample — but <strong>all three of its replicates start at elevated A412</strong> (0.65, 0.67, 0.93 versus 0.13–0.16 for clean wells). Its two “usable” wells (B1, B2) are the two steepest traces on the plate and both rise from an already-contaminated baseline before turning over, and B3 declines outright. A well that begins with TNB already present is not measuring citrate synthase from zero, so the apparent high activity is an artifact of the starting condition, not enzymology. Excluding one replicate on CV grounds cannot repair a sample in which no replicate is clean.</p>
</section>
<section id="assay-validity" class="level2">
<h2 class="anchored" data-anchor-id="assay-validity">12.3 Assay validity</h2>
<p>The <strong>positive control worked</strong>: all three replicates rise linearly (R<sup>2</sup> &gt; 0.999) at ~2.8 mA412/min with 2% CV. The core reaction chemistry and the reader were functioning. The problems on this plate are in the standards and background wells, not in the CS reaction itself.</p>
<p>Sample rates in clean wells are also well-behaved and mutually consistent (~7–9 mA412/min for most individuals, R<sup>2</sup> &gt; 0.99 over the first 8 min), which is why per-sample activity estimates are reported despite the standard curve problems.</p>
</section>
<section id="recommendation" class="level2">
<h2 class="anchored" data-anchor-id="recommendation">12.4 Recommendation</h2>
<p>Treat the activity values here as <strong>provisional</strong>. The rate measurements are sound for the wells that passed QC, but they are calibrated through a standard curve that failed its own QC, so absolute activities carry an uncertainty that the reported precision does not capture. Before these numbers are used downstream:</p>
<ol type="1">
<li><strong>Run a dilution series on one homogenate — the highest priority item.</strong> Assay a single sample neat, 1:2, 1:5 and 1:10 and plot rate against dilution. Measured mU/µL correlates with total extracted protein at r = -0.27 (p = 0.73) across a 3-fold range of protein input on this plate — a real but noisy inverse trend, not the flat line seen against tissue weight. A dilution series is the only way to tell whether that reflects the assay running outside its linear range (aliquot volume, substrate depletion) or a genuine difference in specific activity between individuals; nothing on this list should be treated as settled until it is run.</li>
<li><strong>Re-run the GSH standard curve</strong>, keeping the top standard at or below 24 nmol/well so all points stay within photometric linearity, and read it immediately.</li>
<li><strong>Resolve the background control mix-up</strong> — confirm which wells received Background Control Mix vs.&nbsp;Reaction Mix before the next plate.</li>
<li><strong>Re-assay <code>F05_05</code> — mandatory, not optional.</strong> All three replicates are baseline-compromised, so this sample has no usable measurement on this plate regardless of what the CV column says. Do not carry its 240 mU/mg protein into any downstream comparison. Re-assay <code>F05_06</code> as well (24.7% CV on two genuinely disagreeing replicates).</li>
<li><strong>Check the dispensing/plating step for the elevated-baseline wells</strong> (A12, B1, B2, B3, B5 — all in the bottom-right region of rows A–B, plus background wells C2, C5, C7, C12, D1, D4, D5). The spatial clustering suggests a systematic cause — carryover on a multichannel tip, DTNB added before the plate reached the reader, or a delay between reagent addition and the first read — rather than random pipetting error.</li>
<li><strong>Protein normalization controls for extraction differences, but not for whatever is driving the mU/uL-vs-protein trend.</strong> Normalizing to total extracted protein (rather than tissue weight) already removes sample-to-sample variation in how much soluble material a given tissue input yielded. It does not, by itself, explain why raw mU/µL trends downward with more extracted protein (recommendation 1) — that requires the dilution series, not a change in normalization basis.</li>
<li><del>Re-export the absorbance CSV covering all 12 plate columns.</del> <strong>Done</strong> — <code>absorbance-*.csv</code> now covers the full plate; see anomaly
<ol type="1">
<li></li>
</ol></li>
</ol>
</section>
<section id="what-can-be-used-from-this-plate" class="level2">
<h2 class="anchored" data-anchor-id="what-can-be-used-from-this-plate">12.5 What can be used from this plate</h2>
<p>Four samples are clean on every check — <code>F05_01</code>, <code>F05_03</code>, <code>F05_07</code> and <code>F05_08</code>, all with no baseline-compromised replicates and CV &lt; 8%. Their relative <em>ranking</em> is more robust than their absolute values, since all four share the same calibration.</p>
<p>The instructive result is how <em>little</em> they differ: 6.8, 7.6, 8.6 and 6.8 mA412/min background-corrected — a spread of roughly 25%, against a technical CV of 5–8% within samples. Once the plate’s one apparent outlier (<code>F05_05</code>) is recognized as a baseline artifact rather than a high-activity individual, no striking within-family variation remains at ambient temperature. Two implications for the wider design:</p>
<ul>
<li><strong>The mU/mg protein values should be treated as provisional, not discarded outright.</strong> The standard curve QC failure (three of six concentrations with CV &gt; 15%, 8/18 wells flagged) is one source of uncertainty affecting every reported value equally. Separately, mU/mg protein correlates strongly negatively with total extracted protein (r = -0.98, clean samples), but — unlike the tissue-weight version of this plate — the underlying raw rate (mU/µL) also correlates with extracted protein (r = -0.27), so the mU/mg protein trend is not pure division artifact. Whether it reflects real specific-activity differences between individuals or an assay linear-range effect is unresolved without the dilution series.</li>
<li><strong>The assay needs a linear-range check before more plates are run.</strong> The dilution series is cheap — one homogenate, four dilutions — and it determines whether the deceleration seen in every trace, and its apparent relationship to protein content, is substrate depletion, aliquot overload, or extraction saturation rather than biology. Running more families before that is answered risks generating plates with an uninterpretable normalization.</li>
</ul>


</section>
</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>citrate synthase</category>
  <category>ABCAM</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Citrate-Synthase-Assay---SORMI-June-2026-M.gigas-Family-5-Ambient-Ctenidia/</guid>
  <pubDate>Tue, 11 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Homogenization - SORMI June 2026 M.gigas Ctenidia from Families 5 and 7 for Citrate Synthase Assay</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Families 5 &amp; 7 from the <a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/sampling-event-metadata/june-2026">June 2026 SORMI experiment</a> (GitHub repo) were selected for citrate synthase assay (selection by Steven). Ctenidia samples from these families were homogenized in preparation for the Citrate Synthase Assay Kit (ABCAM; cat: ab239712).</p>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<p>Eight ctenidia samples (1-8) from each treatment (ambient and 36°C) in Families 5 and 7 were selected. Samples were stored on dried ice until homogenization. Pieces of ctenidia were broken off and weighed to the nearest 0.1 mg. Tissue was transferred to 1.5mL Safe-Lock tubes (Eppendorf) containing 350 µL of Assay Buffer 7 and ~100µL of 0.5mm glass beads (Research Products International). Samples were homogenized in a pre-/cooled (dry ice) Bullet Blender 5E Gold+ using the 1.5mL adapters. Homogenization was performed for 10 minutes at Speed 12. After homogenization, samples were stored at -80°C until further processing.</p>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>A homogenization volume of 350 µL (instead of the manufacturer’s recommended 100 µL) was used based off of prior work in our lab with this kit, <a href="https://doi.org/10.1111/gcb.16880">performed by Matt George</a> (link to the paper - requires institutional access).</p>
</div>
</div>
<p>Below is a list of the samples and the weights of ctenidia used for homogenization:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>Sample</th>
<th>Weight(mg)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>F05_01_ambient</td>
<td>10.1</td>
</tr>
<tr class="even">
<td>F05_02_ambient</td>
<td>17.5</td>
</tr>
<tr class="odd">
<td>F05_03_ambient</td>
<td>22.3</td>
</tr>
<tr class="even">
<td>F05_04_ambient</td>
<td>14</td>
</tr>
<tr class="odd">
<td>F05_05_ambient</td>
<td>11.5</td>
</tr>
<tr class="even">
<td>F05_06_ambient</td>
<td>30.2</td>
</tr>
<tr class="odd">
<td>F05_07_ambient</td>
<td>25.8</td>
</tr>
<tr class="even">
<td>F05_08_ambient</td>
<td>30.6</td>
</tr>
<tr class="odd">
<td>F05_01_36C</td>
<td>12.8</td>
</tr>
<tr class="even">
<td>F05_02_36C</td>
<td>6.2</td>
</tr>
<tr class="odd">
<td>F05_03_36C</td>
<td>10.3</td>
</tr>
<tr class="even">
<td>F05_04_36C</td>
<td>12.8</td>
</tr>
<tr class="odd">
<td>F05_05_36C</td>
<td>22.7</td>
</tr>
<tr class="even">
<td>F05_06_36C</td>
<td>18.4</td>
</tr>
<tr class="odd">
<td>F05_07_36C</td>
<td>11.3</td>
</tr>
<tr class="even">
<td>F05_08_36C</td>
<td>13.8</td>
</tr>
<tr class="odd">
<td>F07_01_ambient</td>
<td>7.3</td>
</tr>
<tr class="even">
<td>F07_02_ambient</td>
<td>19.4</td>
</tr>
<tr class="odd">
<td>F07_03_ambient</td>
<td>19.7</td>
</tr>
<tr class="even">
<td>F07_04_ambient</td>
<td>10.7</td>
</tr>
<tr class="odd">
<td>F07_05_ambient</td>
<td>8.3</td>
</tr>
<tr class="even">
<td>F07_06_ambient</td>
<td>12.8</td>
</tr>
<tr class="odd">
<td>F07_07_ambient</td>
<td>20.6</td>
</tr>
<tr class="even">
<td>F07_08_ambient</td>
<td>10.9</td>
</tr>
<tr class="odd">
<td>F07_01_36C</td>
<td>9</td>
</tr>
<tr class="even">
<td>F07_02_36C</td>
<td>9.5</td>
</tr>
<tr class="odd">
<td>F07_03_36C</td>
<td>18.3</td>
</tr>
<tr class="even">
<td>F07_04_36C</td>
<td>16.9</td>
</tr>
<tr class="odd">
<td>F07_05_36C</td>
<td>10.5</td>
</tr>
<tr class="even">
<td>F07_06_36C</td>
<td>9.7</td>
</tr>
<tr class="odd">
<td>F07_07_36C</td>
<td>12.5</td>
</tr>
<tr class="even">
<td>F07_08_36C</td>
<td>9.1</td>
</tr>
</tbody>
</table>
<ul>
<li><a href="https://docs.google.com/spreadsheets/d/1klABW56Tm_VoGIiwarxhgLH82f3gh_SGf8PDxynTArM/edit?usp=sharing">20240811-mgig-Fams5_and_7-citrate_synthase-tissue-weights</a> (Google Sheet)</li>
</ul>


</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>citrate synthase</category>
  <category>homogenization</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-11-Homogenization---SORMI-June-2026-M.gigas-Ctenidia-from-Families-5-and-7-for-Citrate-Synthase-Assay/</guid>
  <pubDate>Tue, 11 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Trimming - Andy Dittman RNA-seq Data Using fastp FastQC MultiQC on Hyak</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-10-Trimming---Andy-Dittman-RNA-seq-Data-Using-fastp-FastQC-MultiQC-on-Hyak/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>After <a href="../../../posts/2026/2026-08-06-FastQC-MultiQC---Andy-Dittman-Remaining-RNA-seq-Data-on-Hyak/index.html">running an initial FastQC on the raw reads on 20260806</a> (notebook entry), I thought it would be prudent to run the reads through some adapter and quality trimming. I ran <a href="https://github.com/OpenGene/fastp">fastp</a> to trim the reads (removed adapters and low-quality bases, 15bp from 5’ end of each read, removed poly-G and poly-A tails), and then ran FastQC and MultiQC on the trimmed reads to assess the quality of the trimmed data. See CODE section below for specifics.</p>
<p>The trimming and quality assessment was run on Hyak using our Apptainer image: <code>srlab-R4.4-bioinformatics-container-c3d3116.sif</code>.</p>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Output directory:</p>
<ul>
<li><a href="https://gannet.fish.washington.edu/v1_web/Atumefaciens/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq/">https://gannet.fish.washington.edu/v1_web/Atumefaciens/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq/</a></li>
</ul>
<p>MultiQC report (HTML):</p>
<ul>
<li><a href="https://gannet.fish.washington.edu/v1_web/Atumefaciens/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq/multiqc_report.html">https://gannet.fish.washington.edu/v1_web/Atumefaciens/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq/multiqc_report.html</a></li>
</ul>
</section>
<section id="discussion" class="level1">
<h1>DISCUSSION</h1>
<p>Trimming with <a href="https://github.com/OpenGene/fastp"><code>fastp</code></a> went quickly and smoothly, and the resulting trimmed FastQs were of good quality, as assessed by FastQC and MultiQC. After trimming, the per base sequence content is much more consistent across the read length.</p>
<p>Will let Andy know.</p>
<p>Code is below.</p>
<hr>
</section>
<section id="setup" class="level1">
<h1>1 SETUP</h1>
<section id="libraries" class="level2">
<h2 class="anchored" data-anchor-id="libraries">1.1 Libraries</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"></span>
<span id="cb1-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb1-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb1-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb1-10">)</span></code></pre></div>
</section>
</section>
<section id="variables" class="level1">
<h1>2 VARIABLES</h1>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># DIRECTORIES</span></span>
<span id="cb2-2">raw_reads_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1/"</span></span>
<span id="cb2-3">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/mmfs1/gscratch/scrubbed/samwhite/outputs/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq"</span></span>
<span id="cb2-4"></span>
<span id="cb2-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># FILES</span></span>
<span id="cb2-6">fastq_pattern<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*.fastq.gz"</span></span>
<span id="cb2-7">R1_fastq_pattern<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*_R1_*.fastq.gz"</span></span>
<span id="cb2-8">R2_fastq_pattern<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*_R2_*.fastq.gz"</span></span>
<span id="cb2-9">trimmed_fastq_pattern<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*fastp-trim.fq.gz"</span></span>
<span id="cb2-10"></span>
<span id="cb2-11"></span>
<span id="cb2-12"></span>
<span id="cb2-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># SETTINGS</span></span>
<span id="cb2-14">threads <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"50"</span></span>
<span id="cb2-15"></span>
<span id="cb2-16"></span>
<span id="cb2-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Export these as environment variables for bash chunks.</span></span>
<span id="cb2-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.setenv</span>(</span>
<span id="cb2-19">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fastq_pattern =</span> fastq_pattern,</span>
<span id="cb2-20">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">raw_reads_dir =</span> raw_reads_dir,</span>
<span id="cb2-21">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">R1_fastq_pattern =</span> R1_fastq_pattern,</span>
<span id="cb2-22">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">R2_fastq_pattern =</span> R2_fastq_pattern,</span>
<span id="cb2-23">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trimmed_fastq_pattern =</span> trimmed_fastq_pattern,</span>
<span id="cb2-24">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">output_dir =</span> output_dir,</span>
<span id="cb2-25">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threads =</span> threads</span>
<span id="cb2-26">)</span></code></pre></div>
</section>
<section id="fastp-trimming" class="level1">
<h1>3 Fastp Trimming</h1>
<p><a href="https://github.com/OpenGene/fastp">fastp</a> [<span class="citation" data-cites="chen2023">@chen2023</span>] is set to auto-detect Illumina adapters, as well as trim the first 15bp from each read, as past experience shows these first 15bp are more inconsistent than the remainder of the read length.</p>
<p>Expects filenames like: <code>lib_212412_sample_1703783_S120_L002_R2_001.fastq.gz</code></p>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Make output directories, if it doesn't exist</span></span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mkdir</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--parents</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb3-3"></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Change to raw reads directory</span></span>
<span id="cb3-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_reads_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create arrays of fastq R1 files and sample names</span></span>
<span id="cb3-8"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> fastq <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R1_fastq_pattern}</span></span>
<span id="cb3-9"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb3-10">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">fastq_array_R1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-11">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">R1_names_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">awk</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-F</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-v</span> OFS=<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'{print $1, $2, $3, $4, $5, $6}'</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-12"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span>
<span id="cb3-13"></span>
<span id="cb3-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create array of fastq R2 files</span></span>
<span id="cb3-15"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> fastq <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R2_fastq_pattern}</span></span>
<span id="cb3-16"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb3-17">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">fastq_array_R2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-18">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">R2_names_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">(</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">awk</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-F</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-v</span> OFS=<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'{print $1, $2, $3, $4, $5, $6}'</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-19"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span>
<span id="cb3-20"></span>
<span id="cb3-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create list of fastq files used in analysis</span></span>
<span id="cb3-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create MD5 checksum for reference</span></span>
<span id="cb3-23"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">[</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">!</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">-f</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>/raw-fastq-checksums.md5 <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">]</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">;</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">then</span></span>
<span id="cb3-24"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> fastq <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>.gz</span>
<span id="cb3-25">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb3-26">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">md5sum</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq}</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>/raw-fastq-checksums.md5</span>
<span id="cb3-27">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span>
<span id="cb3-28"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">fi</span></span>
<span id="cb3-29"></span>
<span id="cb3-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Run fastp on files</span></span>
<span id="cb3-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Adds JSON report output for downstream usage by MultiQC</span></span>
<span id="cb3-32"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> index <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">fastq_array_R1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[@]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb3-33"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">do</span></span>
<span id="cb3-34">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">R1_sample_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R1_names_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-35">  <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">R2_sample_name</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R2_names_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-36">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">fastp</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-37">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--in1</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq_array_R1</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-38">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--in2</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq_array_R2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[</span>index<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-39">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--detect_adapter_for_pe</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-40">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--trim_poly_g</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-41">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--trim_poly_x</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-42">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--trim_front1</span> 15 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-43">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--trim_front2</span> 15 <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-44">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--thread</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${threads}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-45">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--html</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>/<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R1_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>.fastp-trim.report.html <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-46">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--json</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>/<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R1_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>.fastp-trim.report.json <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-47">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--out1</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>/<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R1_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>_R1_001.fastp-trim.fq.gz <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-48">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--out2</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>/<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R2_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>_R2_001.fastp-trim.fq.gz <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-49">  <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>/fastp.stderr</span>
<span id="cb3-50"></span>
<span id="cb3-51">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Generate md5 checksums for newly trimmed files</span></span>
<span id="cb3-52">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb3-53">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">md5sum</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R1_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>_R1_001.fastp-trim.fq.gz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R1_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>_R1_001.fastp-trim.fq.gz.md5</span>
<span id="cb3-54">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">md5sum</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R2_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>_R2_001.fastp-trim.fq.gz <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${R2_sample_name}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>_R2_001.fastp-trim.fq.gz.md5</span>
<span id="cb3-55">  <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-</span></span>
<span id="cb3-56"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">done</span></span></code></pre></div>
<pre><code>/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1</code></pre>
</section>
<section id="fastqcmultiqc" class="level1">
<h1>4 FASTQC/MULTIQC</h1>
<p>Uses <code>--cl-config "sp: { fastp: { fn: '*report.json' } }"</code> to update the MultiQC search pattern for the fastp module.</p>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Make output directory if it doesn't exist</span></span>
<span id="cb5-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mkdir</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--parents</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb5-3"></span>
<span id="cb5-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ RUN FASTQC ############</span></span>
<span id="cb5-5"></span>
<span id="cb5-6"></span>
<span id="cb5-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create array of trimmed FastQs</span></span>
<span id="cb5-8"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">trimmed_fastqs_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">(${output_dir}</span>/<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${trimmed_fastq_pattern})</span></span>
<span id="cb5-9"></span>
<span id="cb5-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pass array contents to new variable as space-delimited list</span></span>
<span id="cb5-11"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">trimmed_fastqc_list</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${trimmed_fastqs_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[*]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb5-12"></span>
<span id="cb5-13"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Beginning FastQC on trimmed reads..."</span></span>
<span id="cb5-14"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb5-15"></span>
<span id="cb5-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Run FastQC</span></span>
<span id="cb5-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">### </span><span class="al" style="color: #AD0000;
background-color: null;
font-style: inherit;">NOTE</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">: Do NOT quote trimmed_fastqc_list</span></span>
<span id="cb5-18"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">fastqc</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb5-19">--threads <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${threads}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb5-20">--outdir <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb5-21">--quiet <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb5-22"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${trimmed_fastqc_list}</span></span>
<span id="cb5-23"></span>
<span id="cb5-24"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FastQC on trimmed reads complete!"</span></span>
<span id="cb5-25"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb5-26"></span>
<span id="cb5-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ </span><span class="re">END</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> FASTQC ############</span></span>
<span id="cb5-28"></span>
<span id="cb5-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ RUN MULTIQC ############</span></span>
<span id="cb5-30"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Beginning MultiQC on trimmed FastQC..."</span></span>
<span id="cb5-31"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb5-32"></span>
<span id="cb5-33"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">multiqc</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb5-34">--cl-config <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sp: { fastp: { fn: '*report.json' } }"</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb5-35">--interactive <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb5-36">-o <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span></span>
<span id="cb5-37"></span>
<span id="cb5-38"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb5-39"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MultiQC on trimmed FastQs complete."</span></span>
<span id="cb5-40"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb5-41"></span>
<span id="cb5-42"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ </span><span class="re">END</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> MULTIQC ############</span></span>
<span id="cb5-43"></span>
<span id="cb5-44"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Removing FastQC zip files."</span></span>
<span id="cb5-45"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb5-46"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rm</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${output_dir}</span>/<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>.zip</span>
<span id="cb5-47"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FastQC zip files removed."</span></span>
<span id="cb5-48"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span></code></pre></div>
<pre><code>Beginning FastQC on trimmed reads...

application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
FastQC on trimmed reads complete!

Beginning MultiQC on trimmed FastQC...


/// MultiQC 🔍 v1.24.1

     version_check | MultiQC Version v1.35 now available!
       file_search | Search path: /mmfs1/gscratch/scrubbed/samwhite/outputs/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq
             fastp | Found 96 reports
            fastqc | Found 192 reports
     write_results | Data        : /mmfs1/gscratch/scrubbed/samwhite/outputs/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq/multiqc_data
     write_results | Report      : /mmfs1/gscratch/scrubbed/samwhite/outputs/20260806-Fastp-FastQC-MultiQC-dittman-grc-rnaseq/multiqc_report.html
           multiqc | MultiQC complete

MultiQC on trimmed FastQs complete.

Removing FastQC zip files.

FastQC zip files removed.</code></pre>


</section>

 ]]></description>
  <category>2026</category>
  <category>fastp</category>
  <category>fastqc</category>
  <category>multiqc</category>
  <category>hyak</category>
  <category>RNA-seq</category>
  <category>trimming</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-10-Trimming---Andy-Dittman-RNA-seq-Data-Using-fastp-FastQC-MultiQC-on-Hyak/</guid>
  <pubDate>Mon, 10 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>FastQC MultiQC - Andy Dittman Remaining RNA-seq Data on Hyak</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-FastQC-MultiQC---Andy-Dittman-Remaining-RNA-seq-Data-on-Hyak/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>The remainder of RNA-seq data for Andy Dittman at NOAA came in on <a href="../../../posts/2026/2026-07-15-Data-Received---Full-RNA-seq-Data-for-Andy-Dittman-and-NOAA/index.html">20260715</a> (Notebook entry). The data is the remainder of the RNA-seq data, after an initial run of a subset of samples to see how the data looked and to make sure it was of good quality. The initial <a href="https://github.com/RobertsLab/resources/issues/2397">GitHub Issue</a> indicated that the RNA Integrity Number (RIN) for these samples was not ideal, however, the <a href="../../../posts/2026/2026-05-19-FastQC-MultiQC---Andy-Dittman-Preliminary-RNA-seq-Data-on-Hyak/index.html">initial FastQC/MultiQC</a> (notebook entry) and <a href="../../../posts/2026/2026-05-20-Trimming---Andy-Dittman-Preliminary-RNA-seq-Data-Using-Fastp-FastQC-MultiQC-on-Hyak/index.html">subsequent trimming</a> (notebook entry) showed the data was good. I ran FastQC and MultiQC on these new raw reads to assess their quality.</p>
<p>Analysis was run on Hyak using the following Roberts Lab Apptainer image:</p>
<ul>
<li><code>srlab-R4.4-bioinformatics-container-c3d3116.sif</code> (built on 20260410)</li>
</ul>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Output directory:</p>
<ul>
<li><a href="https://owl.fish.washington.edu/nightingales/dittman_grc_rnaseq_1/">https://owl.fish.washington.edu/nightingales/dittman_grc_rnaseq_1/</a></li>
</ul>
<p>MultiQC Report (HTML):</p>
<ul>
<li><a href="https://owl.fish.washington.edu/nightingales/dittman_grc_rnaseq_1/multiqc_report.html">https://owl.fish.washington.edu/nightingales/dittman_grc_rnaseq_1/multiqc_report.html</a></li>
</ul>
<p>Overall, the FastQC and MultiQC reports indicate that the raw reads are of good quality, with quality being consistent for what we usually see with RNA-seq data. Will proceed with quality trimming and adapter removal using FastP, and then re-run FastQC and MultiQC on the trimmed reads.</p>
<p>Code is below.</p>
<hr>
</section>
<section id="setup" class="level1">
<h1>1 SETUP</h1>
<section id="libraries" class="level2">
<h2 class="anchored" data-anchor-id="libraries">1.1 Libraries</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"></span>
<span id="cb1-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb1-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb1-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb1-10">)</span></code></pre></div>
</section>
</section>
<section id="variables" class="level1">
<h1>2 VARIABLES</h1>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># DIRECTORIES</span></span>
<span id="cb2-2">raw_reads_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1"</span></span>
<span id="cb2-3">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"/mmfs1/gscratch/scrubbed/samwhite/outputs/20260806-FastQC-MultiQC-dittman-grc-rnaseq/"</span></span>
<span id="cb2-4"></span>
<span id="cb2-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># FILES</span></span>
<span id="cb2-6">fastq_pattern<span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*.fastq.gz"</span></span>
<span id="cb2-7"></span>
<span id="cb2-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># SETTINGS</span></span>
<span id="cb2-9">threads <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"50"</span></span>
<span id="cb2-10"></span>
<span id="cb2-11"></span>
<span id="cb2-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Export these as environment variables for bash chunks.</span></span>
<span id="cb2-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.setenv</span>(</span>
<span id="cb2-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fastq_pattern =</span> fastq_pattern,</span>
<span id="cb2-15">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">raw_reads_dir =</span> raw_reads_dir,</span>
<span id="cb2-16">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">output_dir =</span> output_dir,</span>
<span id="cb2-17">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">threads =</span> threads</span>
<span id="cb2-18">)</span></code></pre></div>
</section>
<section id="fastqcmultiqc" class="level1">
<h1>3 FASTQC/MULTIQC</h1>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Make output directory if it doesn't exist</span></span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mkdir</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--parents</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_reads_dir}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span></span>
<span id="cb3-3"></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ RUN FASTQC ############</span></span>
<span id="cb3-5"></span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Create array of trimmed FastQs</span></span>
<span id="cb3-8"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">raw_fastqs_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">(${raw_reads_dir}</span>/<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${fastq_pattern})</span></span>
<span id="cb3-9"></span>
<span id="cb3-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pass array contents to new variable as space-delimited list</span></span>
<span id="cb3-11"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">raw_fastqc_list</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$(</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_fastqs_array</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">[*]</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">}</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">)</span></span>
<span id="cb3-12"></span>
<span id="cb3-13"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Beginning FastQC on raw reads..."</span></span>
<span id="cb3-14"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb3-15"></span>
<span id="cb3-16"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Run FastQC</span></span>
<span id="cb3-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">### </span><span class="al" style="color: #AD0000;
background-color: null;
font-style: inherit;">NOTE</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">: Do NOT quote raw_fastqc_list</span></span>
<span id="cb3-18"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">fastqc</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-19">--threads <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${threads}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-20">--outdir <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_reads_dir}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-21">--quiet <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-22"><span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_fastqc_list}</span></span>
<span id="cb3-23"></span>
<span id="cb3-24"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FastQC on raw reads complete!"</span></span>
<span id="cb3-25"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb3-26"></span>
<span id="cb3-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ </span><span class="re">END</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> FASTQC ############</span></span>
<span id="cb3-28"></span>
<span id="cb3-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ RUN MULTIQC ############</span></span>
<span id="cb3-30"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Beginning MultiQC on raw FastQC..."</span></span>
<span id="cb3-31"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb3-32"></span>
<span id="cb3-33"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">multiqc</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_reads_dir}</span> <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-34">--interactive <span class="dt" style="color: #AD0000;
background-color: null;
font-style: inherit;">\</span></span>
<span id="cb3-35">-o <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_reads_dir}</span></span>
<span id="cb3-36"></span>
<span id="cb3-37"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb3-38"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MultiQC on raw FastQs complete."</span></span>
<span id="cb3-39"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb3-40"></span>
<span id="cb3-41"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">############ </span><span class="re">END</span><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"> MULTIQC ############</span></span>
<span id="cb3-42"></span>
<span id="cb3-43"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Removing FastQC zip files."</span></span>
<span id="cb3-44"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb3-45"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rm</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">${raw_reads_dir}</span>/<span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">*</span>.zip</span>
<span id="cb3-46"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FastQC zip files removed."</span></span>
<span id="cb3-47"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span></code></pre></div>
<pre><code>Beginning FastQC on raw reads...

application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
application/gzip
FastQC on raw reads complete!

Beginning MultiQC on raw FastQC...


/// MultiQC 🔍 v1.24.1

     version_check | MultiQC Version v1.35 now available!
       file_search | Search path: /mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1
            fastqc | Found 155 reports
     write_results | Data        : /mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1/multiqc_data
     write_results | Report      : /mmfs1/gscratch/scrubbed/samwhite/data/dittman_grc_rnaseq_1/multiqc_report.html
           multiqc | MultiQC complete

MultiQC on raw FastQs complete.

Removing FastQC zip files.

FastQC zip files removed.</code></pre>


</section>

 ]]></description>
  <category>2026</category>
  <category>FastQC</category>
  <category>MultiQC</category>
  <category>RNA-seq</category>
  <category>hyak</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-FastQC-MultiQC---Andy-Dittman-Remaining-RNA-seq-Data-on-Hyak/</guid>
  <pubDate>Thu, 06 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Glycogen Analysis - SORMI June 2026 M.gigas Family 1 vs Family 9</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-Glycogen-Analysis---SORMI-June-2026-M.gigas-Family-1-vs-Family-9/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>This notebook analyzed glycogen content in <em>Magallana gigas</em> (Pacific oyster) ctenidia samples from USDA families 1 and 9, comparing ambient vs.&nbsp;36°C temperature exposure, results from two assay dates (<a href="../../../posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/index.html">20260730</a> and <a href="../../../posts/2026/2026-08-03-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Sample-Re-runs/index.html">20260803</a> (Notebook entries)).</p>
<p>See the <code>BACKGROUND</code> section below for details on the re-assay rationale, the standard-curve QC checks, and the outlier/replicate-exclusion analysis for <code>1_04_36C</code>.</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>This section was knitted from <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Glycogen/code/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined.Rmd">https://github.com/RobertsLab/sormi-assay-development/blob/main/Glycogen/code/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined.Rmd</a> (GitHub).</p>
</div>
</div>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Combined glycogen analysis of <em>Magallana gigas</em> (Pacific oyster) ctenidia samples from USDA families 1 and 9, comparing ambient vs.&nbsp;36°C temperature exposure, using the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/Promega_Glycogen_Glo_Assay.pdf">Glycogen-Glo Assay (Promega)</a> (GitHub; PDF).</p>
<p>This document merges results from two assay dates:</p>
<ul>
<li><p><strong>2026-07-30</strong> (<a href="Gen5-20260730-mgig-fams1_9-glycogen-glo.md"><code>Gen5-20260730-mgig-fams1_9-glycogen-glo</code></a>): the full 32-sample experiment (all family × temperature combinations), samples run at 1:25 dilution on one plate, standard curve + negative control run on a separate plate.</p></li>
<li><p><strong>2026-08-03</strong> (<a href="Gen5-20260803-mgig-fams1_9-glycogen-glo.md"><code>Gen5-20260803-mgig-fams1_9-glycogen-glo</code></a>): a targeted re-assay of 5 samples at 1:200 dilution (~8× higher), run alongside a fresh, same-plate standard curve. Four of these five (<code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>) had read above the top standard (20 µg/mL) in the original run and required extrapolation; the fifth (<code>1_04_36C</code>) was in range originally but had an elevated technical-replicate CV (30.1%).</p></li>
</ul>
<p><strong>Reconciliation rule applied here:</strong> for each of the 32 samples, this document selects <strong>whichever available measurement falls within its own run’s standard-curve range</strong> (interpolated rather than extrapolated), preferring the more recent run as a tiebreaker if more than one candidate qualifies. In practice this means:</p>
<ul>
<li><code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>: the <strong>2026-08-03 (1:200)</strong> value is used, since it is in-range and the 2026-07-30 value was extrapolated.</li>
<li><code>1_04_36C</code>: the <strong>2026-07-30 (1:25)</strong> value is used per instruction – its 2026-08-03 (1:200) re-assay read below the standard curve’s floor (negative back-calculated concentration, unusable), so the original in-range-but-high-CV value is retained here rather than the unusable re-assay value.</li>
<li>All other 28 samples: only the 2026-07-30 value exists and is used as-is.</li>
</ul>
<p>Full detail on the re-assay rationale, the standard-curve QC checks, and the outlier/replicate-exclusion analysis for <code>1_04_36C</code> (a Grubbs test found no statistical basis for dropping a replicate, and a general “exclude any replicate outside 1 SD of the triplicate mean” rule was tested and rejected as a mathematical inevitability for n=3, not a data-quality signal) are documented in the two source analyses linked above and are not repeated here.</p>
<section id="sample-naming" class="level2">
<h2 class="anchored" data-anchor-id="sample-naming">1.1 Sample naming</h2>
<p>Per <a href="../data/raw_luminescence/README.md"><code>../data/raw_luminescence/README.md</code></a>, plate layout entries follow <code>&lt;sample&gt;-&lt;assay_type&gt;-&lt;tissue_weight&gt;-df.&lt;dilution_factor&gt;</code>, with sample tokens formatted as <code>&lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;</code>, e.g. <code>1_06_ambient-glyc-11.0-df.25</code>. Standards are labeled <code>STD-glyc-&lt;concentration&gt;</code> and the negative (buffer-only) control <code>NEG-glyc</code>.</p>
</section>
</section>
<section id="setup" class="level1">
<h1>2 SETUP</h1>
<section id="libraries" class="level2">
<h2 class="anchored" data-anchor-id="libraries">2.1 Libraries</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="set-output-directory" class="level2">
<h2 class="anchored" data-anchor-id="set-output-directory">2.2 Set output directory</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../output/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined"</span></span>
<span id="cb4-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span></code></pre></div>
</section>
</section>
<section id="data-import" class="level1">
<h1>3 DATA IMPORT</h1>
<p>Raw plate-reader exports (comma-separated, no header, one row per plate row <code>A</code>-<code>H</code> and one column per plate column <code>1</code>-<code>12</code>) are read separately for each plate, for both assay dates.</p>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1">data_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/raw_luminescence"</span></span>
<span id="cb5-2"></span>
<span id="cb5-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 2026-07-30: plate-01 (32 samples, triplicate wells), plate-02 (standard curve + neg. control)</span></span>
<span id="cb5-4">layout_0730_plate01 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-Gen5-20260730-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb5-5">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb5-6">raw_0730_plate01    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_lum-Gen5-20260730-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb5-7">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb5-8">layout_0730_plate02 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-Gen5-20260730-mgig-fams1_9-plate-02.csv"</span>),</span>
<span id="cb5-9">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb5-10">raw_0730_plate02    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_lum-Gen5-20260730-mgig-fams1_9-plate-02.csv"</span>),</span>
<span id="cb5-11">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb5-12"></span>
<span id="cb5-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 2026-08-03: single plate (5 re-assayed samples + fresh standard curve + neg. control)</span></span>
<span id="cb5-14">layout_0803_plate01 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-Gen5-20260803-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb5-15">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb5-16">raw_0803_plate01    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_lum-Gen5-20260803-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb5-17">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb5-18"></span>
<span id="cb5-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30 plate-01 dims:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(layout_0730_plate01), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb5-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30 plate-02 dims:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(layout_0730_plate02), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb5-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03 plate-01 dims:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(layout_0803_plate01), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>2026-07-30 plate-01 dims: 8 12 
2026-07-30 plate-02 dims: 8 12 
2026-08-03 plate-01 dims: 8 12 </code></pre>
</section>
<section id="plate-reshaping" class="level1">
<h1>4 PLATE RESHAPING</h1>
<p>Converts each plate’s row/column layout into long format (one row per well), dropping any well without a sample/standard label (empty wells).</p>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">plate_to_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(layout, luminescence, plate_label) {</span>
<span id="cb7-2">  n_row <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb7-3">  n_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span></span>
<span id="cb7-4">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_row, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_col)</span>
<span id="cb7-5">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_label</span>
<span id="cb7-6">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> LETTERS[out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx]</span>
<span id="cb7-7">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well         <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s%02d"</span>, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col)</span>
<span id="cb7-8">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) layout[i, j],</span>
<span id="cb7-9">                                                  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col)))</span>
<span id="cb7-10">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) luminescence[i, j],</span>
<span id="cb7-11">                                        out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col))</span>
<span id="cb7-12">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> out[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col), ]</span>
<span id="cb7-13">  out[out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label), ]</span>
<span id="cb7-14">}</span></code></pre></div>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1">plate_0730_01_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plate_to_long</span>(layout_0730_plate01, raw_0730_plate01, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0730-plate-01"</span>)</span>
<span id="cb8-2">plate_0730_02_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plate_to_long</span>(layout_0730_plate02, raw_0730_plate02, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0730-plate-02"</span>)</span>
<span id="cb8-3">plate_0803_01_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plate_to_long</span>(layout_0803_plate01, raw_0803_plate01, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"0803-plate-01"</span>)</span>
<span id="cb8-4"></span>
<span id="cb8-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- plate_0730_01_long ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_0730_01_long)</span>
<span id="cb8-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_0730_02_long ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_0730_02_long)</span>
<span id="cb8-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate_0803_01_long ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_0803_01_long)</span></code></pre></div>
<pre><code>--- plate_0730_01_long ---
'data.frame':   96 obs. of  7 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "0730-plate-01" "0730-plate-01" "0730-plate-01" "0730-plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_02_ambient-glyc-4.7-df.25" ...
 $ luminescence : num  11367 10284 10754 14834 14603 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

--- plate_0730_02_long ---
'data.frame':   18 obs. of  7 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "0730-plate-02" "0730-plate-02" "0730-plate-02" "0730-plate-02" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "STD-glyc-20" "STD-glyc-20" "STD-glyc-20" "STD-glyc-2" ...
 $ luminescence : num  53166 68390 63329 6947 6432 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

--- plate_0803_01_long ---
'data.frame':   36 obs. of  7 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "0803-plate-01" "0803-plate-01" "0803-plate-01" "0803-plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "1_06_ambient-glyc-11.0-df.200" ...
 $ luminescence : num  6528 6498 6599 9137 9214 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...</code></pre>
</section>
<section id="standard-curves" class="level1">
<h1>5 STANDARD CURVES</h1>
<p>Each assay date has its own standard curve (glycogen standards run alongside the samples), fit independently – samples are always back-calculated against the curve from <em>their own</em> assay date/plate, never a curve from a different run.</p>
<div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">standards_0730 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_0730_02_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_concentration =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label)),</span>
<span id="cb10-4">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30"</span>)</span>
<span id="cb10-5"></span>
<span id="cb10-6">negative_0730 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_0730_02_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^NEG-glyc"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30"</span>)</span>
<span id="cb10-9"></span>
<span id="cb10-10">standards_0803 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_0803_01_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_concentration =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label)),</span>
<span id="cb10-13">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03"</span>)</span>
<span id="cb10-14"></span>
<span id="cb10-15">negative_0803 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_0803_01_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^NEG-glyc"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03"</span>)</span>
<span id="cb10-18"></span>
<span id="cb10-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- standards_0730 ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_0730)</span>
<span id="cb10-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standards_0803 ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards_0803)</span>
<span id="cb10-23"></span>
<span id="cb10-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Negative control, 2026-07-30 (n ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(negative_0730), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"): mean luminescence ="</span>,</span>
<span id="cb10-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(negative_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Negative control, 2026-08-03 (n ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(negative_0803), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"): mean luminescence ="</span>,</span>
<span id="cb10-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(negative_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- standards_0730 ---
'data.frame':   15 obs. of  9 variables:
 $ plate_row_idx     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col         : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate             : chr  "0730-plate-02" "0730-plate-02" "0730-plate-02" "0730-plate-02" ...
 $ plate_row         : chr  "A" "A" "A" "A" ...
 $ well              : chr  "A01" "A02" "A03" "A04" ...
 $ label             : chr  "STD-glyc-20" "STD-glyc-20" "STD-glyc-20" "STD-glyc-2" ...
 $ luminescence      : num  53166 68390 63329 6947 6432 ...
 $ glyc_concentration: num  20 20 20 2 2 2 0.2 0.2 0.2 0.02 ...
 $ run               : chr  "2026-07-30" "2026-07-30" "2026-07-30" "2026-07-30" ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

--- standards_0803 ---
'data.frame':   18 obs. of  9 variables:
 $ plate_row_idx     : int  3 3 3 3 3 3 3 3 3 3 ...
 $ plate_col         : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate             : chr  "0803-plate-01" "0803-plate-01" "0803-plate-01" "0803-plate-01" ...
 $ plate_row         : chr  "C" "C" "C" "C" ...
 $ well              : chr  "C01" "C02" "C03" "C04" ...
 $ label             : chr  "STD-glyc-20" "STD-glyc-20" "STD-glyc-20" "STD-glyc-10" ...
 $ luminescence      : num  61432 62800 60190 28374 27652 ...
 $ glyc_concentration: num  20 20 20 10 10 10 2 2 2 0.2 ...
 $ run               : chr  "2026-08-03" "2026-08-03" "2026-08-03" "2026-08-03" ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

Negative control, 2026-07-30 (n = 3 ): mean luminescence = 913 
Negative control, 2026-08-03 (n = 3 ): mean luminescence = 583.3 </code></pre>
<div class="sourceCode" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">fit_curve <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(standards) {</span>
<span id="cb12-2">  summ <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(glyc_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb12-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_mean_luminescence =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb12-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_sd                =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence),</span>
<span id="cb12-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_se                =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()),</span>
<span id="cb12-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_cv                =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb12-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_n                 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb12-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb12-11">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(glyc_concentration)</span>
<span id="cb12-13"></span>
<span id="cb12-14">  lm_model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> summ)</span>
<span id="cb12-15"></span>
<span id="cb12-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb12-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">summary   =</span> summ,</span>
<span id="cb12-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model     =</span> lm_model,</span>
<span id="cb12-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(lm_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]),</span>
<span id="cb12-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unname</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(lm_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]),</span>
<span id="cb12-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(lm_model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared,</span>
<span id="cb12-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc_min  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(summ<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration[summ<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]),</span>
<span id="cb12-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conc_max  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(summ<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration),</span>
<span id="cb12-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_min   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(summ<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration),</span>
<span id="cb12-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_max   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(summ<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration)</span>
<span id="cb12-26">  )</span>
<span id="cb12-27">}</span>
<span id="cb12-28"></span>
<span id="cb12-29">curve_0730 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit_curve</span>(standards_0730)</span>
<span id="cb12-30">curve_0803 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fit_curve</span>(standards_0803)</span>
<span id="cb12-31"></span>
<span id="cb12-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- 2026-07-30 standard curve ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary)</span>
<span id="cb12-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"slope:"</span>, curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" intercept:"</span>, curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept,</span>
<span id="cb12-35">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" R2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"quantifiable range:"</span>, curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_min, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>, curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_max, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ug/mL</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-37"></span>
<span id="cb12-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- 2026-08-03 standard curve ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary)</span>
<span id="cb12-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"slope:"</span>, curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" intercept:"</span>, curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept,</span>
<span id="cb12-41">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" R2:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"quantifiable range:"</span>, curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_min, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>, curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_max, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ug/mL</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- 2026-07-30 standard curve ---
tibble [5 × 6] (S3: tbl_df/tbl/data.frame)
 $ glyc_concentration    : num [1:5] 0 0.02 0.2 2 20
 $ glyc_mean_luminescence: num [1:5] 910 1087 1410 6512 61628
 $ glyc_sd               : num [1:5] 13.5 107.2 30.4 401.5 7753.2
 $ glyc_se               : num [1:5] 7.81 61.89 17.52 231.79 4476.3
 $ glyc_cv               : num [1:5] 1.49 9.86 2.15 6.17 12.58
 $ glyc_n                : int [1:5] 3 3 3 3 3
slope: 3039.495  intercept: 801.7511  R2: 0.99993 
quantifiable range: 0.02 - 20 ug/mL

--- 2026-08-03 standard curve ---
tibble [6 × 6] (S3: tbl_df/tbl/data.frame)
 $ glyc_concentration    : num [1:6] 0 0.02 0.2 2 10 20
 $ glyc_mean_luminescence: num [1:6] 313 681 2220 12126 28236 ...
 $ glyc_sd               : num [1:6] 256 107 1100 338 529 ...
 $ glyc_se               : num [1:6] 147.7 61.9 635.4 194.9 305.5 ...
 $ glyc_cv               : num [1:6] 81.82 15.73 49.57 2.78 1.87 ...
 $ glyc_n                : int [1:6] 3 3 3 3 3 3
slope: 2937.696  intercept: 1732.959  R2: 0.98861 
quantifiable range: 0.02 - 20 ug/mL</code></pre>
<section id="plot-standard-curves" class="level2">
<h2 class="anchored" data-anchor-id="plot-standard-curves">5.1 Plot standard curves</h2>
<div class="sourceCode" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">curve_plot_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb14-2">  curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30"</span>),</span>
<span id="cb14-3">  curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03"</span>)</span>
<span id="cb14-4">)</span>
<span id="cb14-5">curve_fit_lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb14-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept,</span>
<span id="cb14-7">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_min =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_max =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_max, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2),</span>
<span id="cb14-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">slope =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">intercept =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept,</span>
<span id="cb14-9">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_min =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fit_max =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_max, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2 =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2)</span>
<span id="cb14-10">) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb14-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y_start   =</span> intercept <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> fit_min,</span>
<span id="cb14-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y_end     =</span> intercept <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> fit_max,</span>
<span id="cb14-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">r2_label  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R\u00b2 = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, r2))</span>
<span id="cb14-15">  )</span>
<span id="cb14-16"></span>
<span id="cb14-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- curve_fit_lines: trend-line endpoints + R2 per run ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(curve_fit_lines)</span>
<span id="cb14-19"></span>
<span id="cb14-20">standard_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(curve_plot_data, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> glyc_mean_luminescence)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> curve_fit_lines,</span>
<span id="cb14-22">               <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> fit_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> fit_max, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_start, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> y_end),</span>
<span id="cb14-23">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> glyc_se, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> glyc_se),</span>
<span id="cb14-25">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> curve_fit_lines, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> r2_label),</span>
<span id="cb14-28">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> run, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scales =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"free_y"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard concentration (\u00b5g/mL)"</span>,</span>
<span id="cb14-31">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean luminescence (RLU)"</span>,</span>
<span id="cb14-32">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curves by assay date"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb14-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb14-35"></span>
<span id="cb14-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(standard_curve_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-Glycogen-Analysis---SORMI-June-2026-M.gigas-Family-1-vs-Family-9/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined_files/figure-gfm/plot-standard-curves-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curves_both_runs.png"</span>), standard_curve_plot,</span>
<span id="cb15-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
<pre><code>--- curve_fit_lines: trend-line endpoints + R2 per run ---
'data.frame':   2 obs. of  9 variables:
 $ run      : chr  "2026-07-30" "2026-08-03"
 $ slope    : num  3039 2938
 $ intercept: num  802 1733
 $ fit_min  : num  0 0
 $ fit_max  : num  20 20
 $ r2       : num  1 0.989
 $ y_start  : num  802 1733
 $ y_end    : num  61592 60487
 $ r2_label : chr  "R² = 0.9999" "R² = 0.9886"</code></pre>
</section>
</section>
<section id="sample-label-parsing" class="level1">
<h1>6 SAMPLE LABEL PARSING</h1>
<p>Sample labels are parsed into family, individual, temperature, tissue weight, and dilution factor. Both runs’ sample wells (excluding standards and the negative control) use the same label grammar.</p>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">parse_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(plate_long) {</span>
<span id="cb17-2">  plate_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-|^NEG-glyc"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_clean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([19])[-_]([0-9]{2})[-_](ambient|36C)-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1_</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2_</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">3-"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb17-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-glyc-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean),</span>
<span id="cb17-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([19])_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb17-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[19]_([0-9]{2})_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb17-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[19]_[0-9]{2}_([^-]+)-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb17-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight_mg   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-glyc-([0-9.]+)-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">..*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean)),</span>
<span id="cb17-11">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">."</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean))</span>
<span id="cb17-12">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb17-14">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span>)),</span>
<span id="cb17-15">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span>))</span>
<span id="cb17-16">    )</span>
<span id="cb17-17">}</span></code></pre></div>
<div class="sourceCode" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">samples_0730 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_samples</span>(plate_0730_01_long)</span>
<span id="cb18-2">samples_0803 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_samples</span>(plate_0803_01_long)</span>
<span id="cb18-3"></span>
<span id="cb18-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- samples_0730 ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb18-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples_0730)</span>
<span id="cb18-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- samples_0803 ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb18-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples_0803)</span>
<span id="cb18-8"></span>
<span id="cb18-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2026-07-30: "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(samples_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"unique samples,"</span>,</span>
<span id="cb18-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(samples_0730), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells (triplicate).</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb18-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03: "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(samples_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"unique samples,"</span>,</span>
<span id="cb18-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(samples_0803), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells (triplicate).</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- samples_0730 ---
'data.frame':   96 obs. of  14 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "0730-plate-01" "0730-plate-01" "0730-plate-01" "0730-plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_02_ambient-glyc-4.7-df.25" ...
 $ luminescence : num  11367 10284 10754 14834 14603 ...
 $ label_clean  : chr  "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_02_ambient-glyc-4.7-df.25" ...
 $ sample_id    : chr  "1_01_ambient" "1_01_ambient" "1_01_ambient" "1_02_ambient" ...
 $ family       : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual   : chr  "01" "01" "01" "02" ...
 $ temperature  : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 1 1 ...
 $ weight_mg    : num  7 7 7 4.7 4.7 4.7 2.5 2.5 2.5 10.7 ...
 $ dilution     : num  25 25 25 25 25 25 25 25 25 25 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

--- samples_0803 ---
'data.frame':   15 obs. of  14 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "0803-plate-01" "0803-plate-01" "0803-plate-01" "0803-plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "1_06_ambient-glyc-11.0-df.200" ...
 $ luminescence : num  6528 6498 6599 9137 9214 ...
 $ label_clean  : chr  "9_05_ambient-glyc-9.2-df.200" "9_05_ambient-glyc-9.2-df.200" "9_05_ambient-glyc-9.2-df.200" "1_06_ambient-glyc-11.0-df.200" ...
 $ sample_id    : chr  "9_05_ambient" "9_05_ambient" "9_05_ambient" "1_06_ambient" ...
 $ family       : Factor w/ 2 levels "Family 1","Family 9": 2 2 2 1 1 1 1 1 1 1 ...
 $ individual   : chr  "05" "05" "05" "06" ...
 $ temperature  : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 1 2 ...
 $ weight_mg    : num  9.2 9.2 9.2 11 11 11 24.8 24.8 24.8 12.4 ...
 $ dilution     : num  200 200 200 200 200 200 200 200 200 200 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

2026-07-30:  32 unique samples, 96 wells (triplicate).
2026-08-03:  5 unique samples, 15 wells (triplicate).</code></pre>
</section>
<section id="per-sample-glycogen-quantification" class="level1">
<h1>7 PER-SAMPLE GLYCOGEN QUANTIFICATION</h1>
<p>For each sample, technical-replicate wells are averaged, back-calculated against that assay date’s own standard curve, corrected for dilution factor and tissue weight, and flagged for whether the well-level luminescence falls within the quantifiable range of that date’s standard curve.</p>
<div class="sourceCode" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">calc_glycogen <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(samples_wells, curve, run_label) {</span>
<span id="cb20-2">  samples_wells <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id, family, individual, temperature, weight_mg, dilution) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb20-5">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_reps   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb20-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_lum =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb20-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_lum   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence),</span>
<span id="cb20-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_lum   =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb20-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb20-10">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb20-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run                   =</span> run_label,</span>
<span id="cb20-13">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_conc_ug_mL       =</span> (mean_lum <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope,</span>
<span id="cb20-14">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_conc_ug_mL =</span> well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> dilution,</span>
<span id="cb20-15">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen         =</span> homogenate_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> weight_mg,</span>
<span id="cb20-16">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_std_range          =</span> well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_min <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> curve<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_max</span>
<span id="cb20-17">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(family, temperature, individual)</span>
<span id="cb20-19">}</span></code></pre></div>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1">glycogen_0730 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calc_glycogen</span>(samples_0730, curve_0730, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30"</span>)</span>
<span id="cb21-2">glycogen_0803 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">calc_glycogen</span>(samples_0803, curve_0803, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03"</span>)</span>
<span id="cb21-3"></span>
<span id="cb21-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- glycogen_0730 ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(glycogen_0730)</span>
<span id="cb21-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- glycogen_0803 ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb21-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(glycogen_0803)</span></code></pre></div>
<pre><code>--- glycogen_0730 ---
tibble [32 × 15] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:32] "1_01_ambient" "1_02_ambient" "1_03_ambient" "1_04_ambient" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual           : chr [1:32] "01" "02" "03" "04" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 2 2 ...
 $ weight_mg            : num [1:32] 7 4.7 2.5 10.7 7.9 11 6.1 24.8 9.6 9.2 ...
 $ dilution             : num [1:32] 25 25 25 25 25 25 25 25 25 25 ...
 $ n_reps               : int [1:32] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_lum             : num [1:32] 10802 14632 7373 39486 22099 ...
 $ sd_lum               : num [1:32] 543 189 278 2525 603 ...
 $ cv_lum               : num [1:32] 5.03 1.29 3.77 6.4 2.73 ...
 $ run                  : chr [1:32] "2026-07-30" "2026-07-30" "2026-07-30" "2026-07-30" ...
 $ well_conc_ug_mL      : num [1:32] 3.29 4.55 2.16 12.73 7.01 ...
 $ homogenate_conc_ug_mL: num [1:32] 82.2 113.8 54 318.2 175.2 ...
 $ norm_glycogen        : num [1:32] 11.7 24.2 21.6 29.7 22.2 ...
 $ in_std_range         : logi [1:32] TRUE TRUE TRUE TRUE TRUE FALSE ...

--- glycogen_0803 ---
tibble [5 × 15] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:5] "1_06_ambient" "1_08_ambient" "1_04_36C" "1_05_36C" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 2
 $ individual           : chr [1:5] "06" "08" "04" "05" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 2 2 1
 $ weight_mg            : num [1:5] 11 24.8 12.4 25.7 9.2
 $ dilution             : num [1:5] 200 200 200 200 200
 $ n_reps               : int [1:5] 3 3 3 3 3
 $ mean_lum             : num [1:5] 9218 30767 823 8742 6542
 $ sd_lum               : num [1:5] 83.6 278 42.9 236.4 51.9
 $ cv_lum               : num [1:5] 0.907 0.903 5.211 2.704 0.793
 $ run                  : chr [1:5] "2026-08-03" "2026-08-03" "2026-08-03" "2026-08-03" ...
 $ well_conc_ug_mL      : num [1:5] 2.55 9.88 -0.31 2.39 1.64
 $ homogenate_conc_ug_mL: num [1:5] 510 1977 -62 477 327
 $ norm_glycogen        : num [1:5] 46.3 79.7 -5 18.6 35.6
 $ in_std_range         : logi [1:5] TRUE TRUE FALSE TRUE TRUE</code></pre>
</section>
<section id="coefficient-of-variation-cv-check" class="level1">
<h1>8 COEFFICIENT OF VARIATION (CV) CHECK</h1>
<p>Technical-replicate CV is computed for every sample in both runs. Samples exceeding 15% CV are <strong>flagged, not excluded</strong> – per the analysis requirements, high CV is a data-quality note carried alongside the result, not a reason to drop a sample.</p>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1">all_glycogen_by_run <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(glycogen_0730, glycogen_0803) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">high_cv =</span> cv_lum <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>)</span>
<span id="cb23-3"></span>
<span id="cb23-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- all_glycogen_by_run: every measurement from both runs, CV-flagged ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb23-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(all_glycogen_by_run)</span>
<span id="cb23-6"></span>
<span id="cb23-7">high_cv_samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> all_glycogen_by_run <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(high_cv) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, run, n_reps, mean_lum, cv_lum, norm_glycogen, in_std_range)</span>
<span id="cb23-10"></span>
<span id="cb23-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples exceeding 15% technical-replicate CV (flagged, not excluded):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb23-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(high_cv_samples, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span></code></pre></div>
<pre><code>--- all_glycogen_by_run: every measurement from both runs, CV-flagged ---
tibble [37 × 16] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:37] "1_01_ambient" "1_02_ambient" "1_03_ambient" "1_04_ambient" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual           : chr [1:37] "01" "02" "03" "04" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 2 2 ...
 $ weight_mg            : num [1:37] 7 4.7 2.5 10.7 7.9 11 6.1 24.8 9.6 9.2 ...
 $ dilution             : num [1:37] 25 25 25 25 25 25 25 25 25 25 ...
 $ n_reps               : int [1:37] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_lum             : num [1:37] 10802 14632 7373 39486 22099 ...
 $ sd_lum               : num [1:37] 543 189 278 2525 603 ...
 $ cv_lum               : num [1:37] 5.03 1.29 3.77 6.4 2.73 ...
 $ run                  : chr [1:37] "2026-07-30" "2026-07-30" "2026-07-30" "2026-07-30" ...
 $ well_conc_ug_mL      : num [1:37] 3.29 4.55 2.16 12.73 7.01 ...
 $ homogenate_conc_ug_mL: num [1:37] 82.2 113.8 54 318.2 175.2 ...
 $ norm_glycogen        : num [1:37] 11.7 24.2 21.6 29.7 22.2 ...
 $ in_std_range         : logi [1:37] TRUE TRUE TRUE TRUE TRUE FALSE ...
 $ high_cv              : logi [1:37] FALSE FALSE FALSE FALSE FALSE FALSE ...

Samples exceeding 15% technical-replicate CV (flagged, not excluded):</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 15%">
<col style="width: 10%">
<col style="width: 12%">
<col style="width: 10%">
<col style="width: 19%">
<col style="width: 17%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">sample_id</th>
<th style="text-align: left;">run</th>
<th style="text-align: right;">n_reps</th>
<th style="text-align: right;">mean_lum</th>
<th style="text-align: right;">cv_lum</th>
<th style="text-align: right;">norm_glycogen</th>
<th style="text-align: left;">in_std_range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">1_04_36C</td>
<td style="text-align: left;">2026-07-30</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">5075.33</td>
<td style="text-align: right;">30.07</td>
<td style="text-align: right;">2.83</td>
<td style="text-align: left;">TRUE</td>
</tr>
</tbody>
</table>
</section>
<section id="standard-curves-with-samples-overlaid" class="level1">
<h1>9 STANDARD CURVES WITH SAMPLES OVERLAID</h1>
<p>Each run’s samples are plotted against that run’s own standard curve, on the well-concentration scale, so it’s visually clear which samples fall inside vs.&nbsp;outside the curve’s quantifiable range.</p>
<section id="plot-20260730-standard-curves-with-samples" class="level2">
<h2 class="anchored" data-anchor-id="plot-20260730-standard-curves-with-samples">9.1 Plot 20260730 Standard Curves with Samples</h2>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">r2_label_0730 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R\u00b2 = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2))</span>
<span id="cb25-2"></span>
<span id="cb25-3">std_samples_0730 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_min, curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_max)),</span>
<span id="cb25-5">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey85"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>,</span>
<span id="cb25-6">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_max,</span>
<span id="cb25-8">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_min,</span>
<span id="cb25-9">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_max),</span>
<span id="cb25-10">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> curve_0730<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> glyc_mean_luminescence),</span>
<span id="cb25-12">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> glycogen_0730, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> well_conc_ug_mL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_lum, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_std_range),</span>
<span id="cb25-14">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"firebrick"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb25-16">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"out of range"</span>),</span>
<span id="cb25-17">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample status"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> r2_label_0730,</span>
<span id="cb25-19">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen concentration (\u00b5g/mL, well-level)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Luminescence (RLU)"</span>,</span>
<span id="cb25-21">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30: standard curve with samples overlaid"</span>,</span>
<span id="cb25-22">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shaded band = quantifiable range of the standard curve"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb25-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb25-24"></span>
<span id="cb25-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(std_samples_0730)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-Glycogen-Analysis---SORMI-June-2026-M.gigas-Family-1-vs-Family-9/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined_files/figure-gfm/plot-standards-with-samples-0730-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_with_samples_20260730.png"</span>), std_samples_0730,</span>
<span id="cb26-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
</section>
<section id="plot-20260803-standard-curves-with-samples" class="level2">
<h2 class="anchored" data-anchor-id="plot-20260803-standard-curves-with-samples">9.2 Plot 20260803 Standard Curves with Samples</h2>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">r2_label_0803 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"R\u00b2 = "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r2))</span>
<span id="cb27-2"></span>
<span id="cb27-3">std_samples_0803 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_min, curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>conc_max)),</span>
<span id="cb27-5">              <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey85"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>,</span>
<span id="cb27-6">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_min, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_max,</span>
<span id="cb27-8">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_min,</span>
<span id="cb27-9">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>intercept <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>slope <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>fit_max),</span>
<span id="cb27-10">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> curve_0803<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> glyc_mean_luminescence),</span>
<span id="cb27-12">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> glycogen_0803, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> well_conc_ug_mL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_lum, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_std_range),</span>
<span id="cb27-14">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"firebrick"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb27-16">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"out of range"</span>),</span>
<span id="cb27-17">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample status"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> r2_label_0803,</span>
<span id="cb27-19">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen concentration (\u00b5g/mL, well-level)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Luminescence (RLU)"</span>,</span>
<span id="cb27-21">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03: standard curve with re-assayed samples overlaid"</span>,</span>
<span id="cb27-22">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shaded band = quantifiable range of the standard curve"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>)</span>
<span id="cb27-24"></span>
<span id="cb27-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(std_samples_0803)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-Glycogen-Analysis---SORMI-June-2026-M.gigas-Family-1-vs-Family-9/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined_files/figure-gfm/plot-standards-with-samples-0803-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_with_samples_20260803.png"</span>), std_samples_0803,</span>
<span id="cb28-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
</section>
</section>
<section id="merging-runs-into-a-single-final-dataset" class="level1">
<h1>10 MERGING RUNS INTO A SINGLE FINAL DATASET</h1>
<p>For the 5 samples with a measurement from both dates, the value used going forward is the one that falls within its own run’s standard-curve range (interpolated), with the more recent run used as a tiebreaker if both qualify. All other 27 samples have only a single (2026-07-30) measurement and pass through unchanged. This yields the reconciliation described in Background: the 4 originally-extrapolated samples take their 2026-08-03 (1:200) value, while <code>1_04_36C</code> takes its 2026-07-30 (1:25) value, since its 2026-08-03 re-assay fell below the standard curve’s floor (negative back-calculated concentration).</p>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">combined_measurements <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(glycogen_0730, glycogen_0803) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">high_cv =</span> cv_lum <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id, run)</span>
<span id="cb29-4"></span>
<span id="cb29-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- combined_measurements: every available measurement, both runs, before reconciliation ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(combined_measurements)</span>
<span id="cb29-7"></span>
<span id="cb29-8">final_glycogen <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> combined_measurements <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(in_std_range), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(run), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.by_group =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_runs_available =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">slice</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(family, temperature, individual)</span>
<span id="cb29-15"></span>
<span id="cb29-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- final_glycogen: one reconciled measurement per sample ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(final_glycogen)</span>
<span id="cb29-18"></span>
<span id="cb29-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples for which the 2026-08-03 re-assay superseded the 2026-07-30 value:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(final_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_runs_available <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, run <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-08-03"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, run, in_std_range, cv_lum, norm_glycogen)))</span>
<span id="cb29-23"></span>
<span id="cb29-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples for which the 2026-07-30 value was retained despite a 2026-08-03 re-assay existing:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(final_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_runs_available <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, run <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"2026-07-30"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, run, in_std_range, cv_lum, norm_glycogen)))</span>
<span id="cb29-28"></span>
<span id="cb29-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Total samples in final dataset:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(final_glycogen), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples still out-of-range after reconciliation:"</span>,</span>
<span id="cb29-31">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>final_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>in_std_range), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- combined_measurements: every available measurement, both runs, before reconciliation ---
tibble [37 × 16] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:37] "1_01_36C" "1_01_ambient" "1_02_36C" "1_02_ambient" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual           : chr [1:37] "01" "01" "02" "02" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 2 1 2 1 2 1 2 2 1 2 ...
 $ weight_mg            : num [1:37] 9.6 7 9.2 4.7 3.1 2.5 12.4 12.4 10.7 25.7 ...
 $ dilution             : num [1:37] 25 25 25 25 25 25 25 200 25 25 ...
 $ n_reps               : int [1:37] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_lum             : num [1:37] 31844 10802 5679 14632 4832 ...
 $ sd_lum               : num [1:37] 1604 543 377 189 479 ...
 $ cv_lum               : num [1:37] 5.04 5.03 6.63 1.29 9.92 ...
 $ run                  : chr [1:37] "2026-07-30" "2026-07-30" "2026-07-30" "2026-07-30" ...
 $ well_conc_ug_mL      : num [1:37] 10.21 3.29 1.6 4.55 1.33 ...
 $ homogenate_conc_ug_mL: num [1:37] 255.3 82.2 40.1 113.8 33.1 ...
 $ norm_glycogen        : num [1:37] 26.6 11.75 4.36 24.2 10.69 ...
 $ in_std_range         : logi [1:37] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ high_cv              : logi [1:37] FALSE FALSE FALSE FALSE FALSE FALSE ...

--- final_glycogen: one reconciled measurement per sample ---
tibble [32 × 17] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:32] "1_01_ambient" "1_02_ambient" "1_03_ambient" "1_04_ambient" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual           : chr [1:32] "01" "02" "03" "04" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 2 2 ...
 $ weight_mg            : num [1:32] 7 4.7 2.5 10.7 7.9 11 6.1 24.8 9.6 9.2 ...
 $ dilution             : num [1:32] 25 25 25 25 25 200 25 200 25 25 ...
 $ n_reps               : int [1:32] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_lum             : num [1:32] 10802 14632 7373 39486 22099 ...
 $ sd_lum               : num [1:32] 543 189 278 2525 603 ...
 $ cv_lum               : num [1:32] 5.03 1.29 3.77 6.4 2.73 ...
 $ run                  : chr [1:32] "2026-07-30" "2026-07-30" "2026-07-30" "2026-07-30" ...
 $ well_conc_ug_mL      : num [1:32] 3.29 4.55 2.16 12.73 7.01 ...
 $ homogenate_conc_ug_mL: num [1:32] 82.2 113.8 54 318.2 175.2 ...
 $ norm_glycogen        : num [1:32] 11.7 24.2 21.6 29.7 22.2 ...
 $ in_std_range         : logi [1:32] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ high_cv              : logi [1:32] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_runs_available     : int [1:32] 1 1 1 1 1 2 1 2 1 1 ...

Samples for which the 2026-08-03 re-assay superseded the 2026-07-30 value:
     sample_id        run in_std_range    cv_lum norm_glycogen
1 1_06_ambient 2026-08-03         TRUE 0.9067180      46.32804
2 1_08_ambient 2026-08-03         TRUE 0.9034992      79.70469
3     1_05_36C 2026-08-03         TRUE 2.7043812      18.56729
4 9_05_ambient 2026-08-03         TRUE 0.7928931      35.58473

Samples for which the 2026-07-30 value was retained despite a 2026-08-03 re-assay existing:
  sample_id        run in_std_range  cv_lum norm_glycogen
1  1_04_36C 2026-07-30         TRUE 30.0656      2.834712

Total samples in final dataset: 32 
Samples still out-of-range after reconciliation: 0 </code></pre>
<section id="excluding-out-of-range-samples-from-statistical-comparisons" class="level2">
<h2 class="anchored" data-anchor-id="excluding-out-of-range-samples-from-statistical-comparisons">10.1 Excluding out-of-range samples from statistical comparisons</h2>
<p>Per the analysis requirements, any sample still falling outside its standard curve’s quantifiable range after reconciliation is <strong>excluded from the statistical comparisons</strong> below (family/temperature ANOVA and pairwise tests), though it remains visible in the full results table and raw distribution plots.</p>
<div class="sourceCode" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1">stats_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> final_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(in_std_range)</span>
<span id="cb31-2"></span>
<span id="cb31-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples excluded from statistical comparisons (out of range after reconciliation):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb31-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(final_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_std_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb31-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, run, in_std_range, norm_glycogen)))</span>
<span id="cb31-6"></span>
<span id="cb31-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">n samples entering statistical comparisons:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(stats_data), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(final_glycogen), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb31-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(stats_data)</span></code></pre></div>
<pre><code>Samples excluded from statistical comparisons (out of range after reconciliation):
[1] sample_id     run           in_std_range  norm_glycogen
&lt;0 rows&gt; (or 0-length row.names)

n samples entering statistical comparisons: 32 of 32 
tibble [32 × 17] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:32] "1_01_ambient" "1_02_ambient" "1_03_ambient" "1_04_ambient" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual           : chr [1:32] "01" "02" "03" "04" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 2 2 ...
 $ weight_mg            : num [1:32] 7 4.7 2.5 10.7 7.9 11 6.1 24.8 9.6 9.2 ...
 $ dilution             : num [1:32] 25 25 25 25 25 200 25 200 25 25 ...
 $ n_reps               : int [1:32] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_lum             : num [1:32] 10802 14632 7373 39486 22099 ...
 $ sd_lum               : num [1:32] 543 189 278 2525 603 ...
 $ cv_lum               : num [1:32] 5.03 1.29 3.77 6.4 2.73 ...
 $ run                  : chr [1:32] "2026-07-30" "2026-07-30" "2026-07-30" "2026-07-30" ...
 $ well_conc_ug_mL      : num [1:32] 3.29 4.55 2.16 12.73 7.01 ...
 $ homogenate_conc_ug_mL: num [1:32] 82.2 113.8 54 318.2 175.2 ...
 $ norm_glycogen        : num [1:32] 11.7 24.2 21.6 29.7 22.2 ...
 $ in_std_range         : logi [1:32] TRUE TRUE TRUE TRUE TRUE TRUE ...
 $ high_cv              : logi [1:32] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ n_runs_available     : int [1:32] 1 1 1 1 1 2 1 2 1 1 ...</code></pre>
</section>
</section>
<section id="results-table" class="level1">
<h1>11 RESULTS TABLE</h1>
<div class="sourceCode" id="cb33" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb33-1">results_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> final_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb33-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb33-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample =</span> sample_id,</span>
<span id="cb33-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family,</span>
<span id="cb33-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature =</span> temperature,</span>
<span id="cb33-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual =</span> individual,</span>
<span id="cb33-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Tissue (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> weight_mg,</span>
<span id="cb33-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dilution =</span> dilution,</span>
<span id="cb33-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Run used</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> run,</span>
<span id="cb33-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean lum.</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb33-11">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb33-12">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">High CV (&gt;15%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(high_cv, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"no"</span>),</span>
<span id="cb33-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well glycogen (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(well_conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb33-14">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Normalized glycogen (ug/mL/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(norm_glycogen, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb33-15">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In std range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_std_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO - excluded from stats"</span>)</span>
<span id="cb33-16">  )</span>
<span id="cb33-17"></span>
<span id="cb33-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(results_table)</span>
<span id="cb33-19"></span>
<span id="cb33-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(results_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_glycogen_results_combined.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
<col style="width: 7%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: right;">Tissue (mg)</th>
<th style="text-align: right;">Dilution</th>
<th style="text-align: left;">Run used</th>
<th>Mean lum.</th>
<th>CV (%)</th>
<th style="text-align: left;">High CV (&gt;15%)</th>
<th style="text-align: right;">Well glycogen (ug/mL)</th>
<th style="text-align: right;">Normalized glycogen (ug/mL/mg)</th>
<th style="text-align: left;">In std range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">1_01_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">7.0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>10801.7</td>
<td>5.0</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">3.290</td>
<td style="text-align: right;">11.75</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_02_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">4.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>14632.3</td>
<td>1.3</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">4.550</td>
<td style="text-align: right;">24.20</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_03_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">2.5</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>7372.7</td>
<td>3.8</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">2.162</td>
<td style="text-align: right;">21.62</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_04_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">10.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>39485.7</td>
<td>6.4</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">12.727</td>
<td style="text-align: right;">29.74</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_05_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">7.9</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>22099.3</td>
<td>2.7</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">7.007</td>
<td style="text-align: right;">22.17</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_06_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">11.0</td>
<td style="text-align: right;">200</td>
<td style="text-align: left;">2026-08-03</td>
<td>9218.3</td>
<td>0.9</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">2.548</td>
<td style="text-align: right;">46.33</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_07_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">6.1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>5075.7</td>
<td>5.4</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">1.406</td>
<td style="text-align: right;">5.76</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_08_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">24.8</td>
<td style="text-align: right;">200</td>
<td style="text-align: left;">2026-08-03</td>
<td>30767.3</td>
<td>0.9</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">9.883</td>
<td style="text-align: right;">79.70</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_01_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">9.6</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>31844.0</td>
<td>5.0</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">10.213</td>
<td style="text-align: right;">26.60</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_02_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>5679.0</td>
<td>6.6</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">1.605</td>
<td style="text-align: right;">4.36</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_03_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">3.1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>4831.7</td>
<td>9.9</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">1.326</td>
<td style="text-align: right;">10.69</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_04_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">12.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>5075.3</td>
<td>30.1</td>
<td style="text-align: left;">yes</td>
<td style="text-align: right;">1.406</td>
<td style="text-align: right;">2.83</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_05_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">25.7</td>
<td style="text-align: right;">200</td>
<td style="text-align: left;">2026-08-03</td>
<td>8742.0</td>
<td>2.7</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">2.386</td>
<td style="text-align: right;">18.57</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_06_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">13.0</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>56800.0</td>
<td>1.9</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">18.424</td>
<td style="text-align: right;">35.43</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_07_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">6.1</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>21659.7</td>
<td>4.1</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">6.862</td>
<td style="text-align: right;">28.12</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_08_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">8.8</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>46235.0</td>
<td>3.5</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">14.948</td>
<td style="text-align: right;">42.46</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_01_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">7.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>7336.3</td>
<td>3.3</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">2.150</td>
<td style="text-align: right;">7.36</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_02_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">4.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>4990.7</td>
<td>4.7</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">1.378</td>
<td style="text-align: right;">7.83</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_03_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>11467.0</td>
<td>5.1</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">3.509</td>
<td style="text-align: right;">20.40</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_04_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>5652.7</td>
<td>6.4</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">1.596</td>
<td style="text-align: right;">22.17</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_05_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">200</td>
<td style="text-align: left;">2026-08-03</td>
<td>6541.7</td>
<td>0.8</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">1.637</td>
<td style="text-align: right;">35.58</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_06_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>3648.7</td>
<td>6.5</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">0.937</td>
<td style="text-align: right;">5.45</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_07_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>9969.0</td>
<td>4.9</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">3.016</td>
<td style="text-align: right;">31.42</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_08_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">7.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>2677.7</td>
<td>5.3</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">0.617</td>
<td style="text-align: right;">2.09</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_01_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">7.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>14412.7</td>
<td>5.9</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">4.478</td>
<td style="text-align: right;">14.54</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_02_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">15.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>12523.3</td>
<td>4.4</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">3.856</td>
<td style="text-align: right;">6.14</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_03_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">10.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>43856.7</td>
<td>3.2</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">14.165</td>
<td style="text-align: right;">34.05</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_04_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">11.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>23983.3</td>
<td>2.2</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">7.627</td>
<td style="text-align: right;">16.87</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_05_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>49780.7</td>
<td>4.3</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">16.114</td>
<td style="text-align: right;">43.79</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_06_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>14106.0</td>
<td>3.2</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">4.377</td>
<td style="text-align: right;">25.45</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_07_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>2408.0</td>
<td>11.0</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">0.528</td>
<td style="text-align: right;">5.50</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_08_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">4.9</td>
<td style="text-align: right;">25</td>
<td style="text-align: left;">2026-07-30</td>
<td>18651.0</td>
<td>6.6</td>
<td style="text-align: left;">no</td>
<td style="text-align: right;">5.872</td>
<td style="text-align: right;">29.96</td>
<td style="text-align: left;">yes</td>
</tr>
</tbody>
</table>
</section>
<section id="group-summary-statistics" class="level1">
<h1>12 GROUP SUMMARY STATISTICS</h1>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">group_summary_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats_data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature =</span> temperature) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb34-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb34-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(norm_glycogen),</span>
<span id="cb34-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(norm_glycogen),</span>
<span id="cb34-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()),</span>
<span id="cb34-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(norm_glycogen),</span>
<span id="cb34-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb34-10">  )</span>
<span id="cb34-11"></span>
<span id="cb34-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- group_summary_stats ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(group_summary_stats)</span>
<span id="cb34-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(group_summary_stats, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb34-15"></span>
<span id="cb34-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(group_summary_stats, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"group_summary_stats_combined.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<pre><code>--- group_summary_stats ---
tibble [4 × 7] (S3: tbl_df/tbl/data.frame)
 $ Family     : Factor w/ 2 levels "Family 1","Family 9": 1 1 2 2
 $ Temperature: Factor w/ 2 levels "ambient","36C": 1 2 1 2
 $ n          : int [1:4] 8 8 8 8
 $ mean       : num [1:4] 30.2 21.1 16.5 22
 $ sd         : num [1:4] 23.4 14.5 12.7 13.6
 $ se         : num [1:4] 8.26 5.12 4.48 4.82
 $ median     : num [1:4] 23.2 22.6 14.1 21.2</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">mean</th>
<th style="text-align: right;">sd</th>
<th style="text-align: right;">se</th>
<th style="text-align: right;">median</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">30.16</td>
<td style="text-align: right;">23.37</td>
<td style="text-align: right;">8.26</td>
<td style="text-align: right;">23.19</td>
</tr>
<tr class="even">
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">21.13</td>
<td style="text-align: right;">14.49</td>
<td style="text-align: right;">5.12</td>
<td style="text-align: right;">22.58</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">16.54</td>
<td style="text-align: right;">12.66</td>
<td style="text-align: right;">4.48</td>
<td style="text-align: right;">14.12</td>
</tr>
<tr class="even">
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">22.04</td>
<td style="text-align: right;">13.63</td>
<td style="text-align: right;">4.82</td>
<td style="text-align: right;">21.16</td>
</tr>
</tbody>
</table>
</section>
<section id="statistical-analysis" class="level1">
<h1>13 STATISTICAL ANALYSIS</h1>
<p>Statistical analysis is performed <strong>before</strong> the box plot and interaction plot below, so that the plots can be annotated with the significance calls made here. Normalized glycogen values span roughly an order of magnitude and are right-skewed, so the primary test uses a <strong>log10 transform</strong> to better meet ANOVA’s normality/homoscedasticity assumptions; the raw-scale ANOVA and a non-parametric (Wilcoxon rank-sum) alternative are reported alongside it as robustness checks. Out-of-range samples (if any remain after reconciliation) are excluded from all tests below (<code>stats_data</code>, 32 samples).</p>
<section id="two-way-anova-family-x-temperature" class="level2">
<h2 class="anchored" data-anchor-id="two-way-anova-family-x-temperature">13.1 Two-way ANOVA (family x temperature)</h2>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">aov_log <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aov</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log10</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> stats_data)</span>
<span id="cb36-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- Two-way ANOVA, log10(normalized glycogen) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(aov_log))</span></code></pre></div>
<pre><code>--- Two-way ANOVA, log10(normalized glycogen) ---
                   Df Sum Sq Mean Sq F value Pr(&gt;F)
family              1  0.111 0.11078   0.730  0.400
temperature         1  0.000 0.00005   0.000  0.986
family:temperature  1  0.272 0.27183   1.791  0.192
Residuals          28  4.249 0.15176               </code></pre>
<div class="sourceCode" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1">aov_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aov</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> stats_data)</span>
<span id="cb38-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- Two-way ANOVA, raw-scale normalized glycogen (robustness check) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb38-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(aov_raw))</span></code></pre></div>
<pre><code>--- Two-way ANOVA, raw-scale normalized glycogen (robustness check) ---
                   Df Sum Sq Mean Sq F value Pr(&gt;F)
family              1    324   323.5   1.174  0.288
temperature         1     25    24.8   0.090  0.766
family:temperature  1    422   422.1   1.532  0.226
Residuals          28   7716   275.6               </code></pre>
</section>
<section id="overall-family-and-temperature-comparisons-wilcoxon-rank-sum" class="level2">
<h2 class="anchored" data-anchor-id="overall-family-and-temperature-comparisons-wilcoxon-rank-sum">13.2 Overall family and temperature comparisons (Wilcoxon rank-sum)</h2>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">wilcox_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> stats_data)</span>
<span id="cb40-2">wilcox_temp   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> stats_data)</span>
<span id="cb40-3"></span>
<span id="cb40-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1 vs. Family 9 (pooled across temperature):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(wilcox_family)</span>
<span id="cb40-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Ambient vs. 36C (pooled across family):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(wilcox_temp)</span></code></pre></div>
<pre><code>Family 1 vs. Family 9 (pooled across temperature):

    Wilcoxon rank sum exact test

data:  norm_glycogen by family
W = 148, p-value = 0.4677
alternative hypothesis: true location shift is not equal to 0


Ambient vs. 36C (pooled across family):

    Wilcoxon rank sum exact test

data:  norm_glycogen by temperature
W = 127, p-value = 0.9852
alternative hypothesis: true location shift is not equal to 0</code></pre>
</section>
<section id="reusable-significance-annotation-helpers" class="level2">
<h2 class="anchored" data-anchor-id="reusable-significance-annotation-helpers">13.3 Reusable significance-annotation helpers</h2>
<p>These three helpers are plot-agnostic: they take a <code>family</code>/<code>temperature</code>-style pairwise-comparison table (built in the next section) and a data frame, and compute/draw asterisk-annotated brackets. They generalize directly to other analyses (different family counts, additional temperature levels, or different grouping factors) as long as the same long-format comparison table shape (<code>comparison_type</code>, <code>fixed_level</code>, <code>group1</code>, <code>group2</code>, <code>p_value</code>) is provided. Defined here, ahead of the comparisons themselves, since the comparison-building chunk below calls <code>sig_stars()</code> directly.</p>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># sig_stars(): map p-values to conventional significance stars.</span></span>
<span id="cb42-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Returns NA (i.e. "no annotation") for non-significant results, so callers</span></span>
<span id="cb42-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># can filter on !is.na(sig) to find only what needs to be drawn.</span></span>
<span id="cb42-4">sig_stars <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">thresholds =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">symbols =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"***"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*"</span>)) {</span>
<span id="cb42-5">  ord <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(thresholds)</span>
<span id="cb42-6">  thresholds <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> thresholds[ord]; symbols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> symbols[ord]</span>
<span id="cb42-7">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(p))</span>
<span id="cb42-8">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_along</span>(thresholds)) out[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(out) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> thresholds[i]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> symbols[i]</span>
<span id="cb42-9">  out</span>
<span id="cb42-10">}</span>
<span id="cb42-11"></span>
<span id="cb42-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># dodge_offset(): x-axis offset of the k-th level of an n-level dodged group,</span></span>
<span id="cb42-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># matching ggplot2's position_dodge(width)/position_jitterdodge(dodge.width = width).</span></span>
<span id="cb42-14">dodge_offset <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(group_index, n_groups, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>) {</span>
<span id="cb42-15">  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>width <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> width <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> n_groups <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (group_index <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb42-16">}</span>
<span id="cb42-17"></span>
<span id="cb42-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># build_sig_brackets(): compute bracket endpoints + stacked heights for every</span></span>
<span id="cb42-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># significant (non-NA sig) row of `comparisons`, for a two-factor plot with</span></span>
<span id="cb42-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># `x_var` on the x-axis and `dodge_var` as the fill/color/dodge factor.</span></span>
<span id="cb42-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   - comparison_type == "across_x"     : fixed dodge_var level, compare two</span></span>
<span id="cb42-22"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                                         x_var levels (horizontal bracket</span></span>
<span id="cb42-23"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                                         spanning x positions).</span></span>
<span id="cb42-24"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   - comparison_type == "across_dodge" : fixed x_var level, compare two</span></span>
<span id="cb42-25"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                                         dodge_var levels (horizontal bracket</span></span>
<span id="cb42-26"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                                         spanning dodge offsets within one</span></span>
<span id="cb42-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                                         x position; dodge_width = 0 collapses</span></span>
<span id="cb42-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                                         this to a zero-width case, so only</span></span>
<span id="cb42-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                                         use "across_dodge" when dodge_width &gt; 0).</span></span>
<span id="cb42-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Returns list(brackets, tip) where brackets is empty (0 rows) when nothing</span></span>
<span id="cb42-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># is significant -- callers should add zero layers in that case, which</span></span>
<span id="cb42-32"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># geom_sig_brackets() does automatically.</span></span>
<span id="cb42-33">build_sig_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(data, y_var, x_var, dodge_var, comparisons,</span>
<span id="cb42-34">                                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodge_width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">step =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tip =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) {</span>
<span id="cb42-35">  y_vals  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> data[[y_var]]</span>
<span id="cb42-36">  y_range <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(y_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb42-37">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(step)) step <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.09</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> y_range</span>
<span id="cb42-38">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(tip))  tip  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.02</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> y_range</span>
<span id="cb42-39"></span>
<span id="cb42-40">  x_levels     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(data[[x_var]])</span>
<span id="cb42-41">  dodge_levels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(data[[dodge_var]])</span>
<span id="cb42-42">  n_dodge      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(dodge_levels)</span>
<span id="cb42-43"></span>
<span id="cb42-44">  offset_for <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(lvl) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dodge_offset</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(lvl, dodge_levels), n_dodge, dodge_width)</span>
<span id="cb42-45">  xnum_for   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(lvl) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(lvl, x_levels)</span>
<span id="cb42-46"></span>
<span id="cb42-47">  sig_rows <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> comparisons <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sig))</span>
<span id="cb42-48">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_rows) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">brackets =</span> sig_rows, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tip =</span> tip))</span>
<span id="cb42-49"></span>
<span id="cb42-50">  base_y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(y_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> step</span>
<span id="cb42-51"></span>
<span id="cb42-52">  brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sig_rows <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rowwise</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-54">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb42-55">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x1 =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (comparison_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"across_x"</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xnum_for</span>(group1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">offset_for</span>(fixed_level)</span>
<span id="cb42-56">           <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>                               <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xnum_for</span>(fixed_level) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">offset_for</span>(group1),</span>
<span id="cb42-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x2 =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (comparison_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"across_x"</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xnum_for</span>(group2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">offset_for</span>(fixed_level)</span>
<span id="cb42-58">           <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>                               <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">xnum_for</span>(fixed_level) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">offset_for</span>(group2)</span>
<span id="cb42-59">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-60">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ungroup</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-61">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(x1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> x2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span>   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># degenerate (zero-width) brackets are not drawable</span></span>
<span id="cb42-62">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmin</span>(x1, x2), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(x2 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> x1)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb42-63">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> base_y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">row_number</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> step, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x_mid =</span> (x1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> x2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb42-64"></span>
<span id="cb42-65">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">brackets =</span> brackets, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">tip =</span> tip)</span>
<span id="cb42-66">}</span>
<span id="cb42-67"></span>
<span id="cb42-68"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># geom_sig_brackets(): ggplot layer list drawing a horizontal bracket + star</span></span>
<span id="cb42-69"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># for every row of a build_sig_brackets() result. Adds nothing when there are</span></span>
<span id="cb42-70"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># no significant comparisons, so it is always safe to add to a plot.</span></span>
<span id="cb42-71">geom_sig_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(bracket_result) {</span>
<span id="cb42-72">  b <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bracket_result<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>brackets</span>
<span id="cb42-73">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(b) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>())</span>
<span id="cb42-74">  tip <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> bracket_result<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>tip</span>
<span id="cb42-75">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb42-76">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> b, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> y),</span>
<span id="cb42-77">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb42-78">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> b, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> tip),</span>
<span id="cb42-79">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb42-80">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_segment</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> b, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> tip),</span>
<span id="cb42-81">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>),</span>
<span id="cb42-82">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> b, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x_mid, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> sig),</span>
<span id="cb42-83">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vjust =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>)</span>
<span id="cb42-84">  )</span>
<span id="cb42-85">}</span>
<span id="cb42-86"></span>
<span id="cb42-87"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Defined: sig_stars(), dodge_offset(), build_sig_brackets(), geom_sig_brackets()</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>Defined: sig_stars(), dodge_offset(), build_sig_brackets(), geom_sig_brackets()</code></pre>
</section>
<section id="within-family-temperature-comparisons-and-within-temperature-family-comparisons" class="level2">
<h2 class="anchored" data-anchor-id="within-family-temperature-comparisons-and-within-temperature-family-comparisons">13.4 Within-family temperature comparisons, and within-temperature family comparisons</h2>
<p>Four stratified pairwise comparisons, each via Wilcoxon rank-sum, with Holm correction applied across the family of four tests. This is written generically over the levels of <code>family</code> and <code>temperature</code> present in <code>stats_data</code>, so it extends unchanged to analyses with additional families or temperature levels: every same-family pair across temperature levels, and every same-temperature pair across families, is tested and Holm-corrected as one family of comparisons.</p>
<div class="sourceCode" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1">family_levels <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(stats_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family)</span>
<span id="cb44-2">temp_levels   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(stats_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>temperature)</span>
<span id="cb44-3"></span>
<span id="cb44-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Every pairwise comparison within a fixed family, across temperature levels.</span></span>
<span id="cb44-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># comparison_type = "across_x" -- generic tag consumed by build_sig_brackets()</span></span>
<span id="cb44-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># below: it means "x_var (temperature) varies, dodge_var (family) is fixed".</span></span>
<span id="cb44-7">across_temp_tests <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(family_levels, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(fam) {</span>
<span id="cb44-8">  d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(stats_data, family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> fam)</span>
<span id="cb44-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">combn</span>(temp_levels, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplify =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb44-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(pair) {</span>
<span id="cb44-11">      p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> temperature,</span>
<span id="cb44-12">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(d, temperature <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> pair))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value</span>
<span id="cb44-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison_type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"across_x"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fixed_level =</span> fam,</span>
<span id="cb44-14">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group1 =</span> pair[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group2 =</span> pair[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p_value =</span> p,</span>
<span id="cb44-15">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_prefix =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"within-family"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb44-16">    }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>()</span>
<span id="cb44-17">}))</span>
<span id="cb44-18"></span>
<span id="cb44-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Every pairwise comparison within a fixed temperature, across family levels.</span></span>
<span id="cb44-20"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># comparison_type = "across_dodge" -- "dodge_var (family) varies, x_var</span></span>
<span id="cb44-21"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># (temperature) is fixed".</span></span>
<span id="cb44-22">across_family_tests <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(temp_levels, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(tp) {</span>
<span id="cb44-23">  d <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(stats_data, temperature <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> tp)</span>
<span id="cb44-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">combn</span>(family_levels, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplify =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb44-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(pair) {</span>
<span id="cb44-26">      p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family,</span>
<span id="cb44-27">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(d, family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> pair))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value</span>
<span id="cb44-28">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison_type =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"across_dodge"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fixed_level =</span> tp,</span>
<span id="cb44-29">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group1 =</span> pair[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group2 =</span> pair[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p_value =</span> p,</span>
<span id="cb44-30">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_prefix =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"within-temperature"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb44-31">    }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>()</span>
<span id="cb44-32">}))</span>
<span id="cb44-33"></span>
<span id="cb44-34">stratified_tests <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(across_temp_tests, across_family_tests) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb44-35">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb44-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p_holm =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">p.adjust</span>(p_value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"holm"</span>),</span>
<span id="cb44-37">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sig    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sig_stars</span>(p_holm),</span>
<span id="cb44-38">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(label_prefix, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ("</span>, fixed_level, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"): "</span>, group1, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" vs. "</span>, group2)</span>
<span id="cb44-39">  )</span>
<span id="cb44-40"></span>
<span id="cb44-41"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- stratified_tests ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(stratified_tests)</span>
<span id="cb44-43"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(stratified_tests <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(label, comparison_type, p_value, p_holm, sig), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb44-44"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Significant (Holm-corrected) stratified comparisons in this dataset:"</span>,</span>
<span id="cb44-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(stratified_tests<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sig)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(stratified_tests), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>--- stratified_tests ---
'data.frame':   4 obs. of  9 variables:
 $ comparison_type: chr  "across_x" "across_x" "across_dodge" "across_dodge"
 $ fixed_level    : chr  "Family 1" "Family 9" "ambient" "36C"
 $ group1         : chr  "ambient" "ambient" "Family 1" "Family 1"
 $ group2         : chr  "36C" "36C" "Family 9" "Family 9"
 $ p_value        : num  0.505 0.505 0.195 0.878
 $ label_prefix   : chr  "within-family" "within-family" "within-temperature" "within-temperature"
 $ p_holm         : num  1 1 0.779 1
 $ sig            : chr  NA NA NA NA
 $ label          : chr  "within-family (Family 1): ambient vs. 36C" "within-family (Family 9): ambient vs. 36C" "within-temperature (ambient): Family 1 vs. Family 9" "within-temperature (36C): Family 1 vs. Family 9"</code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">label</th>
<th style="text-align: left;">comparison_type</th>
<th style="text-align: right;">p_value</th>
<th style="text-align: right;">p_holm</th>
<th style="text-align: left;">sig</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">within-family (Family 1): ambient vs.&nbsp;36C</td>
<td style="text-align: left;">across_x</td>
<td style="text-align: right;">0.5054</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">NA</td>
</tr>
<tr class="even">
<td style="text-align: left;">within-family (Family 9): ambient vs.&nbsp;36C</td>
<td style="text-align: left;">across_x</td>
<td style="text-align: right;">0.5054</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">NA</td>
</tr>
<tr class="odd">
<td style="text-align: left;">within-temperature (ambient): Family 1 vs.&nbsp;Family 9</td>
<td style="text-align: left;">across_dodge</td>
<td style="text-align: right;">0.1949</td>
<td style="text-align: right;">0.7795</td>
<td style="text-align: left;">NA</td>
</tr>
<tr class="even">
<td style="text-align: left;">within-temperature (36C): Family 1 vs.&nbsp;Family 9</td>
<td style="text-align: left;">across_dodge</td>
<td style="text-align: right;">0.8785</td>
<td style="text-align: right;">1.0000</td>
<td style="text-align: left;">NA</td>
</tr>
</tbody>
</table>
<pre><code>Significant (Holm-corrected) stratified comparisons in this dataset: 0 of 4 </code></pre>
</section>
</section>
<section id="exploratory-distribution-plot" class="level1">
<h1>14 EXPLORATORY DISTRIBUTION PLOT</h1>
<p>The box plot is annotated with brackets for every statistically significant (Holm-corrected p &lt; 0.05) pairwise comparison from <code>stratified_tests</code> above, via the reusable <code>build_sig_brackets()</code>/<code>geom_sig_brackets()</code> helpers. With the current dataset none of the four stratified comparisons are significant, so no brackets are drawn – the annotation layer is present but empty. If a future re-analysis (e.g.&nbsp;additional families, or a stronger temperature effect) produces a significant pairwise result, a bracket and asterisk(s) will appear automatically without any code changes.</p>
<div class="sourceCode" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">box_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_sig_brackets</span>(stats_data, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y_var =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"norm_glycogen"</span>,</span>
<span id="cb47-2">                                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x_var =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"temperature"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodge_var =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family"</span>,</span>
<span id="cb47-3">                                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparisons =</span> stratified_tests, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodge_width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>)</span>
<span id="cb47-4"></span>
<span id="cb47-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- box_brackets$brackets (significant comparisons drawn on the box plot) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(box_brackets<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>brackets)</span>
<span id="cb47-7"></span>
<span id="cb47-8">group_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(stats_data, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> norm_glycogen, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitterdodge</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">jitter.width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodge.width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>),</span>
<span id="cb47-11">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_sig_brackets</span>(box_brackets) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature exposure"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen (\u00b5g/mL/mg tissue)"</span>,</span>
<span id="cb47-15">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen content by family and temperature"</span>,</span>
<span id="cb47-16">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Combined dataset (2026-07-30 + 2026-08-03 reconciled); boxplot + individual points"</span>,</span>
<span id="cb47-17">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1b9e77"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d95f02"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb47-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb47-21">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb47-22"></span>
<span id="cb47-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(group_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-Glycogen-Analysis---SORMI-June-2026-M.gigas-Family-1-vs-Family-9/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined_files/figure-gfm/plot-family-temp-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb48" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glycogen_by_family_temperature_combined.png"</span>), group_plot,</span>
<span id="cb48-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
<pre><code>--- box_brackets$brackets (significant comparisons drawn on the box plot) ---
'data.frame':   0 obs. of  9 variables:
 $ comparison_type: chr 
 $ fixed_level    : chr 
 $ group1         : chr 
 $ group2         : chr 
 $ p_value        : num 
 $ label_prefix   : chr 
 $ p_holm         : num 
 $ sig            : chr 
 $ label          : chr </code></pre>
</section>
<section id="family-x-temperature-interaction" class="level1">
<h1>15 FAMILY x TEMPERATURE INTERACTION</h1>
<p>The interaction plot is annotated using the same <code>build_sig_brackets()</code> helper, restricted to the <code>"across_temperature"</code> (within-family) comparisons and drawn with <code>dodge_width = 0</code> since family is encoded by line color here rather than by horizontal dodging. Within-temperature family-vs-family comparisons are already shown as brackets on the box plot above rather than duplicated here, since family is not spatially separated at a given temperature in this plot.</p>
<div class="sourceCode" id="cb50" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1">interaction_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats_data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family, temperature) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb50-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_glycogen =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(norm_glycogen),</span>
<span id="cb50-4">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_glycogen   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()),</span>
<span id="cb50-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb50-6"></span>
<span id="cb50-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- interaction_data ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(interaction_data)</span>
<span id="cb50-9"></span>
<span id="cb50-10">interaction_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">build_sig_brackets</span>(</span>
<span id="cb50-11">  interaction_data <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen =</span> mean_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_glycogen),</span>
<span id="cb50-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y_var =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"norm_glycogen"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x_var =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"temperature"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodge_var =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family"</span>,</span>
<span id="cb50-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparisons =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(stratified_tests, comparison_type <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"across_x"</span>),</span>
<span id="cb50-14">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodge_width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb50-15">)</span>
<span id="cb50-16"></span>
<span id="cb50-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- interaction_brackets$brackets (significant within-family comparisons drawn) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb50-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(interaction_brackets<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>brackets)</span>
<span id="cb50-19"></span>
<span id="cb50-20">interaction_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(interaction_data, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_glycogen,</span>
<span id="cb50-21">                                                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> family)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_glycogen, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_glycogen),</span>
<span id="cb50-25">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_sig_brackets</span>(interaction_brackets) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_continuous</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">expand =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expansion</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mult =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span>))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1b9e77"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d95f02"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature exposure"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean normalized glycogen (\u00b5g/mL/mg, \u00b1 SE)"</span>,</span>
<span id="cb50-30">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family x temperature interaction"</span>,</span>
<span id="cb50-31">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Combined dataset (2026-07-30 + 2026-08-03 reconciled); group means \u00b1 SE"</span>,</span>
<span id="cb50-32">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb50-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb50-35">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span>)</span>
<span id="cb50-36"></span>
<span id="cb50-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(interaction_plot)</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-Glycogen-Analysis---SORMI-June-2026-M.gigas-Family-1-vs-Family-9/Gen5-20260804-mgig-fams1_9-glycogen-glo-combined_files/figure-gfm/plot-interaction-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb51" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb51-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glycogen_family_temperature_interaction_combined.png"</span>), interaction_plot,</span>
<span id="cb51-2">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span></code></pre></div>
<pre><code>--- interaction_data ---
tibble [4 × 4] (S3: tbl_df/tbl/data.frame)
 $ family       : Factor w/ 2 levels "Family 1","Family 9": 1 1 2 2
 $ temperature  : Factor w/ 2 levels "ambient","36C": 1 2 1 2
 $ mean_glycogen: num [1:4] 30.2 21.1 16.5 22
 $ se_glycogen  : num [1:4] 8.26 5.12 4.48 4.82
--- interaction_brackets$brackets (significant within-family comparisons drawn) ---
'data.frame':   0 obs. of  9 variables:
 $ comparison_type: chr 
 $ fixed_level    : chr 
 $ group1         : chr 
 $ group2         : chr 
 $ p_value        : num 
 $ label_prefix   : chr 
 $ p_holm         : num 
 $ sig            : chr 
 $ label          : chr </code></pre>
</section>
<section id="summary" class="level1">
<h1>16 SUMMARY</h1>
<ul>
<li><p><strong>Combined dataset:</strong> 32 samples (families 1 and 9, ambient and 36°C), reconciling 2026-07-30 and 2026-08-03 measurements per the rule in Background. 5 samples had a measurement from both dates; for 4 of these (<code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>) the 2026-08-03 (1:200) in-range value superseded the original extrapolated value, while <code>1_04_36C</code> retained its 2026-07-30 (1:25) value since its 2026-08-03 re-assay fell below the standard curve’s floor.</p></li>
<li><p><strong>Out-of-range samples:</strong> 0 sample(s) remain outside their standard curve’s quantifiable range after reconciliation and were excluded from all statistical comparisons above (see “Excluding out-of-range samples” for detail).</p></li>
<li><p><strong>High-CV samples:</strong> samples exceeding 15% technical-replicate CV were flagged (see “Coefficient of Variation (CV) Check”) but retained in all analyses, per the analysis requirements.</p></li>
<li><p><strong>Family effect:</strong> no statistically significant difference between Family 1 and Family 9 in normalized glycogen content, either pooled across temperature (two-way ANOVA <code>family</code> term, and the overall Wilcoxon test) or within either temperature stratum (Holm-corrected pairwise comparisons).</p></li>
<li><p><strong>Temperature effect:</strong> no statistically significant difference between ambient and 36°C exposure, either pooled across family or within either family stratum.</p></li>
<li><p><strong>Family x temperature interaction:</strong> no statistically significant interaction term in the two-way ANOVA. The interaction plot shows Family 1’s mean glycogen trending down from ambient to 36°C while Family 9’s trends up, but neither the interaction term nor the stratified within-family comparisons reach significance at this sample size – this pattern should be interpreted as a visual trend, not a confirmed effect.</p></li>
</ul>


</section>

 ]]></description>
  <category>2026</category>
  <category>glycogen</category>
  <category>Glycogen-Glo</category>
  <category>SORMI</category>
  <category>Pacific oyster</category>
  <category>Magallana gigas</category>
  <category>Crassostrea gigas</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-06-Glycogen-Analysis---SORMI-June-2026-M.gigas-Family-1-vs-Family-9/</guid>
  <pubDate>Thu, 06 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Glycogen Assay - SORMI June 2026 M.gigas USDA Families 1 and 9 Sample Re-runs</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-03-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Sample-Re-runs/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>As part of the June 2026 SORMI project, I conducted a glycogen assay on <em>Magallana gigas</em> (Pacific oyster) ctenidia samples (ambient and 36°C temperatures) from USDA Families 1 and 9 (chosen by Steven). The purpose of this study was to compare the glycogen content between these two families using the Glycogen Glo Kit. Samples had been <a href="../../../posts/2026/2026-07-22-Homogenization---June-2026-SORMI-M.gigas-Ctenidia-from-Families-1-and-9-for-Glycogen-Glo-Assay/index.html">previously homogenized on 20260722</a> (Notebook entry) as well as <a href="../../../posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/index.html">assayed for glycogen on 20260730</a> (Notebook entry). However, four samples were outside of the standard curve and one had poor coefficient of variation (CV) between replicates, so a re-run of those samples was necessary.</p>
<ul>
<li><p><code>1_06_ambient</code></p></li>
<li><p><code>1_08_ambient</code></p></li>
<li><p><code>1_04_36C</code></p></li>
<li><p><code>1_05_36C</code></p></li>
<li><p><code>9_05_ambient</code></p></li>
</ul>
<div class="callout callout-style-default callout-important callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p>Sample <code>1_04_36C</code> was re-run due to poor CV between replicates in the previous assay attempt. It should have been processed with the previous 1:25 dilution, but was accidentally processed with a 1:200 dilution which resulted in a low signal.</p>
</div>
</div>
<p>All data/code/analysis is available here:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Glycogen">https://github.com/RobertsLab/sormi-assay-development/tree/main/Glycogen</a></li>
</ul>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<p>Homogenized ctenidia samples were thawed, vortexed, and spun at 16,000g for 1min to pellet debris. Based on <a href="../../../posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/index.html">the previous attempt at assaying these samples on 20260730</a> (Notebook) the following was decided upon:</p>
<ul>
<li><p>dilution of 1:200 should be appropriate for samples to fall within standard curve range</p></li>
<li><p>glucose analysis is unnecessary for <em>M.gigas</em> ctenidia samples, as glucose has been shown to be negligible</p></li>
</ul>
<section id="dilutions" class="level2">
<h2 class="anchored" data-anchor-id="dilutions">Dilutions</h2>
<p>All samples were diluted 1:200 in dilution buffer (2:1:1 ratio of PBS:0.3N HCl:TRIS). E.g. 1uL of sample + 199uL of dilution buffer. The diluted samples were then used for the glycogen assay.</p>
</section>
<section id="glycogen-assay" class="level2">
<h2 class="anchored" data-anchor-id="glycogen-assay">Glycogen Assay</h2>
<p>A standard curve of glycogen (20ug, 10ug, 2ug, 0.2ug, 0.02ug, 0ug) in PBS was prepared. The assay was performed in triplicate for each sample in a separate 96-well, white Costar plate, and luminescence readings were taken using a HTX Synergy plate reader (Agilent). A negative control (dilution buffer only), in triplicate, was included in the assay to account for background luminescence.</p>
<p>The assay was performed in triplicate for each sample in a 96-well, white Costar plate, and luminescence readings were taken using a HTX Synergy plate reader (Agilent).</p>
<p>The Glycogen Glo Kit protocol was followed according to the manufacturer’s instructions, with appropriate incubation times and reagent additions.</p>
<section id="master-mix-calcs" class="level3">
<h3 class="anchored" data-anchor-id="master-mix-calcs">Master Mix Calcs</h3>
<section id="digestion-master-mix" class="level4">
<h4 class="anchored" data-anchor-id="digestion-master-mix">Digestion Master Mix</h4>
<table class="caption-top table">
<thead>
<tr class="header">
<th>COMPONENT</th>
<th>vol.per.rxn(uL)</th>
<th>no.rxns</th>
<th>total(uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>glucoamylase buffer</td>
<td>25</td>
<td>36</td>
<td>900</td>
</tr>
<tr class="even">
<td>glucoamylase</td>
<td>0.125</td>
<td>36</td>
<td>4.5</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td>TOTAL</td>
<td>904.5</td>
</tr>
</tbody>
</table>
</section>
<section id="detection-master-mix" class="level4">
<h4 class="anchored" data-anchor-id="detection-master-mix">Detection Master Mix</h4>
<table class="caption-top table">
<thead>
<tr class="header">
<th>COMPONENT</th>
<th>vol.per.rxn(uL)</th>
<th>no.rxns</th>
<th>total(uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>luciferin detection solution</td>
<td>50</td>
<td>36</td>
<td>1800</td>
</tr>
<tr class="even">
<td>reductase substrate</td>
<td>0.25</td>
<td>36</td>
<td>9</td>
</tr>
<tr class="odd">
<td>reductase</td>
<td>0.25</td>
<td>36</td>
<td>9</td>
</tr>
<tr class="even">
<td>NAD</td>
<td>0.25</td>
<td>36</td>
<td>9</td>
</tr>
<tr class="odd">
<td>glucose dehydrogenase</td>
<td>2</td>
<td>36</td>
<td>72</td>
</tr>
<tr class="even">
<td></td>
<td></td>
<td>TOTAL</td>
<td>1899</td>
</tr>
</tbody>
</table>
</section>
</section>
</section>
<section id="data-analysis" class="level2">
<h2 class="anchored" data-anchor-id="data-analysis">Data Analysis</h2>
<p>Data was analyzed in the following R Markdown file:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Glycogen/code/Gen5-20260803-mgig-fams1_9-glycogen-glo.Rmd">Gen5-20260803-mgig-fams1_9-glycogen-glo.Rmd</a> (GitHub)</li>
</ul>
<p>Analysis assessed the success of the new dilution factor (1:200).</p>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>A dilution factor of 1:200 was successful in bringing all samples within the standard curve range. Since I spaced out and also diluted the <code>1_04_36C</code> sample (which should have been kept at the original 1:25 dilution), the signal was low and the sample was below the standard curve. However, the other four samples were all within the standard curve range and had good CVs between replicates. I should re-assay <code>1_04_36C</code> <em>again</em>…</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>This section was knitted from <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Glycogen/code/Gen5-20260803-mgig-fams1_9-glycogen-glo.Rmd">Gen5-20260803-mgig-fams1_9-glycogen-glo.Rmd</a> (GitHub).</p>
</div>
</div>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Targeted re-assay of five <em>Magallana gigas</em> (Pacific oyster) ctenidia samples from the 2026-07-30 glycogen run (<a href="../code/Gen5-20260730-mgig-fams1_9-glycogen-glo.md"><code>Gen5-20260730-mgig-fams1_9-glycogen-glo</code></a>) using the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/Promega_Glycogen_Glo_Assay.pdf">Glycogen-Glo Assay (Promega)</a> (GitHub; PDF), read on 2026-08-03.</p>
<p>Four of these five samples read above the top standard (20 µg/mL) in the original run and required extrapolation: <code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>. The fifth, <code>1_04_36C</code>, was within range but had a technical-triplicate CV of 30.1%, above the 15% QC threshold used in the original analysis. All five were re-assayed here at a <strong>1:200 dilution</strong> (vs.&nbsp;1:25 originally, ~8× higher), using the same homogenate as the original run (tissue weights match exactly between runs).</p>
<p>This is a small, targeted follow-up analysis, not a full re-run of the 32-sample experiment. Results here are intended to supersede the corresponding five rows of the original run’s results table where the values differ meaningfully; see the Summary for a direct comparison and recommendation.</p>
<section id="sample-naming" class="level2">
<h2 class="anchored" data-anchor-id="sample-naming">1.1 Sample naming</h2>
<p>Per <a href="../data/raw_luminescence/README.md"><code>../data/raw_luminescence/README.md</code></a>, plate layout entries follow:</p>
<ul>
<li><code>&lt;sample&gt;-&lt;assay_type&gt;-&lt;tissue_weight&gt;-df.&lt;dilution_factor&gt;</code></li>
</ul>
<p>Here <code>&lt;sample&gt;</code> itself is composite:</p>
<ul>
<li><code>&lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;</code></li>
</ul>
<p>E.g. <code>1_06_ambient-glyc-11.0-df.200</code> is family 1, individual 06, ambient exposure, glycogen assay, 11.0 mg of ctenidia tissue, diluted 1:200.</p>
<p>Standards follow <code>STD-&lt;assay_type&gt;-&lt;concentration&gt;</code>, e.g.&nbsp;<code>STD-glyc-20</code> (20 µg/mL glycogen); the buffer-only well is <code>NEG-glyc</code>.</p>
</section>
<section id="important-notes" class="level2">
<h2 class="anchored" data-anchor-id="important-notes">1.2 Important note(s)</h2>
<ol type="1">
<li><strong>Tissue weights</strong> are taken from the plate layout labels rather than a separate weights CSV, and match the corresponding weights in the original 2026-07-30 run exactly, confirming these are re-assays of the same homogenates rather than newly prepared samples.</li>
</ol>
</section>
</section>
<section id="setup" class="level1">
<h1>2 SETUP</h1>
<section id="libraries" class="level2">
<h2 class="anchored" data-anchor-id="libraries">2.1 Libraries</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="output-directory" class="level2">
<h2 class="anchored" data-anchor-id="output-directory">2.2 Output directory</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Output directory for this analysis (matches this file's name, per ../code/README.md)</span></span>
<span id="cb4-2">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../output/Gen5-20260803-mgig-fams1_9-glycogen-glo"</span></span>
<span id="cb4-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb4-4"></span>
<span id="cb4-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- output_dir: destination for all figures and tables ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb4-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(output_dir)</span></code></pre></div>
<pre><code>--- output_dir: destination for all figures and tables ---
 chr "../output/Gen5-20260803-mgig-fams1_9-glycogen-glo"</code></pre>
</section>
</section>
<section id="data" class="level1">
<h1>3 DATA</h1>
<p>Data are read from the local repo (<code>../data/raw_luminescence/</code>) so this document renders before/after the files are pushed to GitHub. A single plate holds both the five re-assayed samples and the fresh standard curve/negative control.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">data_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/raw_luminescence"</span></span>
<span id="cb6-2"></span>
<span id="cb6-3">plate_layout <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-Gen5-20260803-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb6-4">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb6-5">raw_luminescence <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_lum-Gen5-20260803-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb6-6">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb6-7"></span>
<span id="cb6-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate layout:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_layout)</span>
<span id="cb6-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Raw luminescence:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(raw_luminescence)</span></code></pre></div>
<pre><code>Plate layout:

'data.frame':   8 obs. of  12 variables:
 $ V1 : chr  "9_05-ambient-glyc-9.2-df.200" "1_05_36C-glyc-25.7-df.200" "STD-glyc-20" "STD-glyc-0.02" ...
 $ V2 : chr  "9_05-ambient-glyc-9.2-df.200" "1_05_36C-glyc-25.7-df.200" "STD-glyc-20" "STD-glyc-0.02" ...
 $ V3 : chr  "9_05-ambient-glyc-9.2-df.200" "1_05_36C-glyc-25.7-df.200" "STD-glyc-20" "STD-glyc-0.02" ...
 $ V4 : chr  "1_06_ambient-glyc-11.0-df.200" "" "STD-glyc-10" "STD-glyc-0" ...
 $ V5 : chr  "1_06_ambient-glyc-11.0-df.200" "" "STD-glyc-10" "STD-glyc-0" ...
 $ V6 : chr  "1_06_ambient-glyc-11.0-df.200" "" "STD-glyc-10" "STD-glyc-0" ...
 $ V7 : chr  "1_08_ambient-glyc-24.8-df.200" "" "STD-glyc-2" "" ...
 $ V8 : chr  "1_08_ambient-glyc-24.8-df.200" "" "STD-glyc-2" "" ...
 $ V9 : chr  "1_08_ambient-glyc-24.8-df.200" "" "STD-glyc-2" "" ...
 $ V10: chr  "1_04_36C-glyc-12.4-df.200" "" "STD-glyc-0.2" "" ...
 $ V11: chr  "1_04_36C-glyc-12.4-df.200" "" "STD-glyc-0.2" "" ...
 $ V12: chr  "1_04_36C-glyc-12.4-df.200" "" "STD-glyc-0.2" "" ...

Raw luminescence:

'data.frame':   8 obs. of  12 variables:
 $ V1 : int  6528 8906 61432 804 570 7 8 3
 $ V2 : int  6498 8471 62800 631 576 5 8 6
 $ V3 : int  6599 8849 60190 608 604 7 4 5
 $ V4 : int  9137 29 28374 499 9 9 5 4
 $ V5 : int  9214 19 27652 418 4 5 3 4
 $ V6 : int  9304 16 28683 21 7 4 7 4
 $ V7 : int  31079 30 11790 10 7 4 7 5
 $ V8 : int  30545 27 12124 10 6 8 5 2
 $ V9 : int  30678 21 12465 11 9 5 4 2
 $ V10: int  833 12 3474 8 5 4 6 8
 $ V11: int  776 5 1771 6 6 4 3 4
 $ V12: int  860 6 1415 5 5 4 5 4</code></pre>
<section id="reshape-plate-to-long-format" class="level2">
<h2 class="anchored" data-anchor-id="reshape-plate-to-long-format">3.1 Reshape plate to long format</h2>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Convert a paired layout/luminescence plate into one row per well</span></span>
<span id="cb8-2">plate_to_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(layout, luminescence, plate_label) {</span>
<span id="cb8-3">  n_row <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb8-4">  n_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span></span>
<span id="cb8-5">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_row, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_col)</span>
<span id="cb8-6">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_label</span>
<span id="cb8-7">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> LETTERS[out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx]</span>
<span id="cb8-8">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s%02d"</span>, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col)</span>
<span id="cb8-9">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) layout[i, j],</span>
<span id="cb8-10">                                                out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col)))</span>
<span id="cb8-11">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) luminescence[i, j],</span>
<span id="cb8-12">                                        out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col))</span>
<span id="cb8-13">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> out[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col), ]</span>
<span id="cb8-14">  out[out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label), ]</span>
<span id="cb8-15">}</span>
<span id="cb8-16"></span>
<span id="cb8-17">plate1_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plate_to_long</span>(plate_layout, raw_luminescence, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate-01"</span>)</span>
<span id="cb8-18"></span>
<span id="cb8-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- plate_to_long(): layout + luminescence -&gt; one row per well ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">args</span>(plate_to_long))</span>
<span id="cb8-21"></span>
<span id="cb8-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate1_long: one row per occupied well ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate1_long)</span></code></pre></div>
<pre><code>--- plate_to_long(): layout + luminescence -&gt; one row per well ---

function (layout, luminescence, plate_label)  

--- plate1_long: one row per occupied well ---

'data.frame':   36 obs. of  7 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "plate-01" "plate-01" "plate-01" "plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "1_06_ambient-glyc-11.0-df.200" ...
 $ luminescence : num  6528 6498 6599 9137 9214 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...</code></pre>
</section>
</section>
<section id="standard-curve" class="level1">
<h1>4 STANDARD CURVE</h1>
<section id="extract-luminescence-data" class="level2">
<h2 class="anchored" data-anchor-id="extract-luminescence-data">4.1 Extract luminescence data</h2>
<p>Row C holds the 20, 10, 2, and 0.2 µg/mL standards; row D holds the 0.02 and 0 µg/mL standards; row E columns 1-3 hold the <code>NEG-glyc</code> buffer-only negative control – all in triplicate, on the same plate as the re-assayed samples.</p>
<div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">standards <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate1_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_concentration =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label)))</span>
<span id="cb10-4"></span>
<span id="cb10-5">negative_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate1_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^NEG-glyc"</span>, label))</span>
<span id="cb10-6"></span>
<span id="cb10-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard concentrations (ug/mL):"</span>,</span>
<span id="cb10-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicates per standard:"</span>,</span>
<span id="cb10-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-11"></span>
<span id="cb10-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Negative control (buffer only) luminescence:"</span>,</span>
<span id="cb10-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(negative_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb10-14">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| mean ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(negative_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Zero glycogen standard luminescence:  mean ="</span>,</span>
<span id="cb10-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence[standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-17"></span>
<span id="cb10-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standards: standard curve wells with parsed concentration ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards)</span>
<span id="cb10-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- negative_control: buffer-only wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(negative_control)</span></code></pre></div>
<pre><code>Standard concentrations (ug/mL): 0, 0.02, 0.2, 2, 10, 20 
Replicates per standard: 3 

Negative control (buffer only) luminescence: 570, 576, 604 | mean = 583.3 
Zero glycogen standard luminescence:  mean = 312.7 

--- standards: standard curve wells with parsed concentration ---
'data.frame':   18 obs. of  8 variables:
 $ plate_row_idx     : int  3 3 3 3 3 3 3 3 3 3 ...
 $ plate_col         : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate             : chr  "plate-01" "plate-01" "plate-01" "plate-01" ...
 $ plate_row         : chr  "C" "C" "C" "C" ...
 $ well              : chr  "C01" "C02" "C03" "C04" ...
 $ label             : chr  "STD-glyc-20" "STD-glyc-20" "STD-glyc-20" "STD-glyc-10" ...
 $ luminescence      : num  61432 62800 60190 28374 27652 ...
 $ glyc_concentration: num  20 20 20 10 10 10 2 2 2 0.2 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

--- negative_control: buffer-only wells ---
'data.frame':   3 obs. of  7 variables:
 $ plate_row_idx: int  5 5 5
 $ plate_col    : int  1 2 3
 $ plate        : chr  "plate-01" "plate-01" "plate-01"
 $ plate_row    : chr  "E" "E" "E"
 $ well         : chr  "E01" "E02" "E03"
 $ label        : chr  "NEG-glyc" "NEG-glyc" "NEG-glyc"
 $ luminescence : num  570 576 604
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...</code></pre>
<p>The buffer-only negative control and the zero-glycogen standard are again in close agreement (913 vs.&nbsp;910 RLU in the original run; see below), as expected.</p>
</section>
<section id="glycogen-standard-curve-summary-statistics-and-linear-regression" class="level2">
<h2 class="anchored" data-anchor-id="glycogen-standard-curve-summary-statistics-and-linear-regression">4.2 Glycogen standard curve summary statistics and linear regression</h2>
<div class="sourceCode" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">glycogen_summary_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(glyc_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb12-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_mean_luminescence =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb12-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_sd                =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence),</span>
<span id="cb12-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_se                =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()),</span>
<span id="cb12-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_cv                =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb12-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_n                 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb12-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb12-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(glyc_concentration)</span>
<span id="cb12-12"></span>
<span id="cb12-13">lm_model      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> glycogen_summary_data)</span>
<span id="cb12-14">glyc_slope     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(lm_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb12-15">glyc_intercept <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(lm_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb12-16">glyc_r_squared <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(lm_model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb12-17"></span>
<span id="cb12-18">lm_model_reps    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards)</span>
<span id="cb12-19">glyc_r2_reps     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(lm_model_reps)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb12-20"></span>
<span id="cb12-21">glyc_conc_min_nonzero <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(glycogen_summary_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration[</span>
<span id="cb12-22">  glycogen_summary_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])</span>
<span id="cb12-23">glyc_conc_max <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(glycogen_summary_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration)</span>
<span id="cb12-24"></span>
<span id="cb12-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(glycogen_summary_data,</span>
<span id="cb12-26">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb12-27">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen (ug/mL)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean luminescence"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SEM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>),</span>
<span id="cb12-28">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard curve summary statistics (this plate)"</span>)</span>
<span id="cb12-29"></span>
<span id="cb12-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Fit to concentration means:      y ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, glyc_slope), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x +"</span>,</span>
<span id="cb12-31">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, glyc_intercept), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" R^2 ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, glyc_r_squared), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fit to individual replicates:    R^2 ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, glyc_r2_reps), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quantifiable range (standards):"</span>, glyc_conc_min_nonzero, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>, glyc_conc_max, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ug/mL</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-34"></span>
<span id="cb12-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- glycogen_summary_data: per-concentration summary statistics ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(glycogen_summary_data)</span>
<span id="cb12-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- lm_model: regression on per-concentration means ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(lm_model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: right;">Glycogen (ug/mL)</th>
<th style="text-align: right;">Mean luminescence</th>
<th style="text-align: right;">SD</th>
<th style="text-align: right;">SEM</th>
<th style="text-align: right;">CV (%)</th>
<th style="text-align: right;">n</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">312.7</td>
<td style="text-align: right;">255.8</td>
<td style="text-align: right;">147.7</td>
<td style="text-align: right;">81.82</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: right;">0.02</td>
<td style="text-align: right;">681.0</td>
<td style="text-align: right;">107.1</td>
<td style="text-align: right;">61.9</td>
<td style="text-align: right;">15.73</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">0.20</td>
<td style="text-align: right;">2220.0</td>
<td style="text-align: right;">1100.5</td>
<td style="text-align: right;">635.4</td>
<td style="text-align: right;">49.57</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: right;">2.00</td>
<td style="text-align: right;">12126.3</td>
<td style="text-align: right;">337.5</td>
<td style="text-align: right;">194.9</td>
<td style="text-align: right;">2.78</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">10.00</td>
<td style="text-align: right;">28236.3</td>
<td style="text-align: right;">529.1</td>
<td style="text-align: right;">305.5</td>
<td style="text-align: right;">1.87</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: right;">20.00</td>
<td style="text-align: right;">61474.0</td>
<td style="text-align: right;">1305.5</td>
<td style="text-align: right;">753.7</td>
<td style="text-align: right;">2.12</td>
<td style="text-align: right;">3</td>
</tr>
</tbody>
</table>
<p>Glycogen standard curve summary statistics (this plate)</p>
<pre><code>Fit to concentration means:      y = 2937.7 x + 1733.0  R^2 = 0.9886 
Fit to individual replicates:    R^2 = 0.9878 
Quantifiable range (standards): 0.02 - 20 ug/mL

--- glycogen_summary_data: per-concentration summary statistics ---
tibble [6 × 6] (S3: tbl_df/tbl/data.frame)
 $ glyc_concentration    : num [1:6] 0 0.02 0.2 2 10 20
 $ glyc_mean_luminescence: num [1:6] 313 681 2220 12126 28236 ...
 $ glyc_sd               : num [1:6] 256 107 1100 338 529 ...
 $ glyc_se               : num [1:6] 147.7 61.9 635.4 194.9 305.5 ...
 $ glyc_cv               : num [1:6] 81.82 15.73 49.57 2.78 1.87 ...
 $ glyc_n                : int [1:6] 3 3 3 3 3 3

--- lm_model: regression on per-concentration means ---
List of 12
 $ coefficients : Named num [1:2] 1733 2938
 $ residuals    : Named num [1:6] -1420 -1111 -100 4518 -2874 ...
 $ effects      : Named num [1:6] -42887 53448 426 4987 -2659 ...
 $ rank         : int 2
 $ fitted.values: Named num [1:6] 1733 1792 2320 7608 31110 ...
 $ assign       : int [1:2] 0 1
 $ qr           :List of 5
 $ df.residual  : int 4
 $ xlevels      : Named list()
 $ call         : language lm(formula = glyc_mean_luminescence ~ glyc_concentration, data = glycogen_summary_data)
 $ terms        :Classes 'terms', 'formula'  language glyc_mean_luminescence ~ glyc_concentration
 $ model        :'data.frame':  6 obs. of  2 variables:</code></pre>
<p><strong>Standard curve QC note.</strong> The 0 and 0.2 µg/mL standards show high triplicate CV (81.8% and 49.6% respectively) – both are low-signal wells where a small absolute RLU difference translates to a large percentage swing, and one 0 µg/mL well (21 RLU) reads well below its two replicates (499, 418 RLU). Excluding that single well changes the fitted slope/intercept by &lt;2%, and has a negligible effect on back-calculated concentrations for the samples below (e.g.&nbsp;<code>1_04_36C</code>’s well concentration shifts from -0.310 to -0.323 µg/mL) – this variability at the assay’s low end does not materially affect the regression, but it is consistent with <code>1_04_36C</code> reading close enough to background that its sign is not reliable (see Out-of-range / floor-effect check below). The curve overall fits tightly (R^2 = 0.9886, individual-replicate R^2 = 0.9878), consistent with the original run’s standard curve quality.</p>
</section>
<section id="extract-sample-data-and-calculate-glycogen-levels" class="level2">
<h2 class="anchored" data-anchor-id="extract-sample-data-and-calculate-glycogen-levels">4.3 Extract sample data and calculate glycogen levels</h2>
<div class="sourceCode" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">samples_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate1_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, label) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^NEG-glyc"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-3">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalize `-` to `_` in the &lt;family&gt;-&lt;individual&gt;-&lt;temperature&gt; prefix</span></span>
<span id="cb14-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_clean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([19])[-_]([0-9]{2})[-_](ambient|36C)-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1_</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2_</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">3-"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb14-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-glyc-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean),</span>
<span id="cb14-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([19])_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb14-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[19]_([0-9]{2})_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb14-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[19]_[0-9]{2}_([^-]+)-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb14-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight_mg  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-glyc-([0-9.]+)-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">..*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean)),</span>
<span id="cb14-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">."</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean))</span>
<span id="cb14-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb14-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span>)),</span>
<span id="cb14-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span>))</span>
<span id="cb14-16">  )</span>
<span id="cb14-17"></span>
<span id="cb14-18"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fail loudly rather than silently dropping malformed labels</span></span>
<span id="cb14-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg)),</span>
<span id="cb14-20">          <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution)),</span>
<span id="cb14-21">          <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>temperature)))</span>
<span id="cb14-22"></span>
<span id="cb14-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells parsed:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(samples_wells),</span>
<span id="cb14-24">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| unique samples:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dilution factor(s) used:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples re-assayed:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tissue weight range (mg):"</span>,</span>
<span id="cb14-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-29"></span>
<span id="cb14-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- samples_wells: one row per sample well, metadata parsed from label ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples_wells)</span></code></pre></div>
<pre><code>Wells parsed: 15 | unique samples: 5 
Dilution factor(s) used: 200 

Samples re-assayed: 1_04_36C, 1_05_36C, 1_06_ambient, 1_08_ambient, 9_05_ambient 
Tissue weight range (mg): 9.2 - 25.7 

--- samples_wells: one row per sample well, metadata parsed from label ---
'data.frame':   15 obs. of  14 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "plate-01" "plate-01" "plate-01" "plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "9_05-ambient-glyc-9.2-df.200" "1_06_ambient-glyc-11.0-df.200" ...
 $ luminescence : num  6528 6498 6599 9137 9214 ...
 $ label_clean  : chr  "9_05_ambient-glyc-9.2-df.200" "9_05_ambient-glyc-9.2-df.200" "9_05_ambient-glyc-9.2-df.200" "1_06_ambient-glyc-11.0-df.200" ...
 $ sample_id    : chr  "9_05_ambient" "9_05_ambient" "9_05_ambient" "1_06_ambient" ...
 $ family       : Factor w/ 2 levels "Family 1","Family 9": 2 2 2 1 1 1 1 1 1 1 ...
 $ individual   : chr  "05" "05" "05" "06" ...
 $ temperature  : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 1 2 ...
 $ weight_mg    : num  9.2 9.2 9.2 11 11 11 24.8 24.8 24.8 12.4 ...
 $ dilution     : num  200 200 200 200 200 200 200 200 200 200 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...</code></pre>
<p>Per-sample values are computed identically to the original analysis: mean of the technical triplicate, back-calculated through this plate’s own standard curve.</p>
<ol type="1">
<li><strong>Well concentration</strong> = <code>(mean luminescence - intercept) / slope</code> → µg/mL in the assayed (diluted) well.</li>
<li><strong>Homogenate concentration</strong> = well concentration × dilution factor (200) → µg/mL in the undiluted homogenate.</li>
<li><strong>Normalized glycogen</strong> = homogenate concentration / tissue weight → µg/mL per mg tissue.</li>
</ol>
<div class="sourceCode" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">sample_glycogen <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_wells <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id, family, individual, temperature, weight_mg, dilution) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb16-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_reps        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb16-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_lum      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb16-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_lum        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence),</span>
<span id="cb16-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_lum        =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb16-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb16-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb16-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_conc_ug_mL       =</span> (mean_lum <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> glyc_intercept) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> glyc_slope,</span>
<span id="cb16-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_conc_ug_mL =</span> well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> dilution,</span>
<span id="cb16-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen         =</span> homogenate_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> weight_mg,</span>
<span id="cb16-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_std_range          =</span> well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> glyc_conc_min_nonzero <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb16-15">                            well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> glyc_conc_max</span>
<span id="cb16-16">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(family, temperature, individual)</span>
<span id="cb16-18"></span>
<span id="cb16-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples quantified:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_glycogen), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb16-20"></span>
<span id="cb16-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_glycogen: one row per individual, triplicate averaged and back-calculated ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb16-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_glycogen)</span></code></pre></div>
<pre><code>Samples quantified: 5 

--- sample_glycogen: one row per individual, triplicate averaged and back-calculated ---
tibble [5 × 14] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:5] "1_06_ambient" "1_08_ambient" "1_04_36C" "1_05_36C" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 2
 $ individual           : chr [1:5] "06" "08" "04" "05" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 2 2 1
 $ weight_mg            : num [1:5] 11 24.8 12.4 25.7 9.2
 $ dilution             : num [1:5] 200 200 200 200 200
 $ n_reps               : int [1:5] 3 3 3 3 3
 $ mean_lum             : num [1:5] 9218 30767 823 8742 6542
 $ sd_lum               : num [1:5] 83.6 278 42.9 236.4 51.9
 $ cv_lum               : num [1:5] 0.907 0.903 5.211 2.704 0.793
 $ well_conc_ug_mL      : num [1:5] 2.55 9.88 -0.31 2.39 1.64
 $ homogenate_conc_ug_mL: num [1:5] 510 1977 -62 477 327
 $ norm_glycogen        : num [1:5] 46.3 79.7 -5 18.6 35.6
 $ in_std_range         : logi [1:5] TRUE TRUE FALSE TRUE TRUE</code></pre>
</section>
<section id="plot-standard-curve-with-re-assayed-sample-points" class="level2">
<h2 class="anchored" data-anchor-id="plot-standard-curve-with-re-assayed-sample-points">4.4 Plot standard curve with re-assayed sample points</h2>
<div class="sourceCode" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">std_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(glycogen_summary_data,</span>
<span id="cb18-2">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> glyc_mean_luminescence)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey60"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> glyc_se,</span>
<span id="cb18-5">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> glyc_se), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#3182bd"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sample_glycogen,</span>
<span id="cb18-8">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> well_conc_ug_mL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_lum, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_std_range),</span>
<span id="cb18-9">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#d94801"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">inherit.aes =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb18-11">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">TRUE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">FALSE</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"out of range / floor"</span>),</span>
<span id="cb18-12">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Re-assayed sample"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard curve (this plate) with re-assayed sample points"</span>,</span>
<span id="cb18-14">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen (ug/mL)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean luminescence (RLU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb18-17"></span>
<span id="cb18-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- std_curve_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb18-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve_plot)</span>
<span id="cb18-20"></span>
<span id="cb18-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glycogen_standard_curve_rerun.png"</span>), std_curve_plot,</span>
<span id="cb18-22">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb18-23"></span>
<span id="cb18-24">std_curve_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-03-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Sample-Re-runs/Gen5-20260803-mgig-fams1_9-glycogen-glo_files/figure-gfm/plot-glycogen-standard-curve-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- std_curve_plot: ggplot object structure ---

data: glyc_concentration, glyc_mean_luminescence, glyc_sd, glyc_se,
  glyc_cv, glyc_n [6x6]
mapping:  x = ~glyc_concentration, y = ~glyc_mean_luminescence
scales:   shape 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_smooth: na.rm = FALSE, orientation = NA, se = FALSE
stat_smooth: na.rm = FALSE, orientation = NA, se = FALSE, method = lm
position_identity 

mapping: ymin = ~glyc_mean_luminescence - glyc_se, ymax = ~glyc_mean_luminescence + glyc_se 
geom_errorbar: na.rm = FALSE, orientation = NA, lineend = butt, width = 0.3
stat_identity: na.rm = FALSE
position_identity 

geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: x = ~well_conc_ug_mL, y = ~mean_lum, shape = ~in_std_range 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
</section>
<section id="quality-control" class="level1">
<h1>5 QUALITY CONTROL</h1>
<section id="technical-replicate-variability" class="level2">
<h2 class="anchored" data-anchor-id="technical-replicate-variability">5.1 Technical replicate variability</h2>
<div class="sourceCode" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Coefficient of variation across technical triplicates (%):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(sample_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb20-3"></span>
<span id="cb20-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples with CV &gt; 15%:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-5">high_cv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_lum <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, mean_lum, sd_lum, cv_lum)</span>
<span id="cb20-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_cv) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb20-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  none</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-9">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb20-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(high_cv), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb20-11">}</span>
<span id="cb20-12"></span>
<span id="cb20-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- high_cv: samples exceeding the 15% triplicate CV threshold ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(high_cv)</span></code></pre></div>
<pre><code>Coefficient of variation across technical triplicates (%):
[1] 0.91 0.90 5.21 2.70 0.79

Samples with CV &gt; 15%:
  none

--- high_cv: samples exceeding the 15% triplicate CV threshold ---

tibble [0 × 4] (S3: tbl_df/tbl/data.frame)
 $ sample_id: chr(0) 
 $ mean_lum : num(0) 
 $ sd_lum   : num(0) 
 $ cv_lum   : num(0) </code></pre>
<p><code>1_04_36C</code> – re-assayed specifically because of a 30.1% CV in the original run – now has a CV of 5.2%, well below threshold: the higher dilution resolved the reproducibility problem it was re-run for. See below for why this improvement in precision did not translate into a usable concentration estimate.</p>
</section>
<section id="out-of-range-floor-effect-check" class="level2">
<h2 class="anchored" data-anchor-id="out-of-range-floor-effect-check">5.2 Out-of-range / floor-effect check</h2>
<div class="sourceCode" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1">oor <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb22-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, family, temperature, mean_lum, well_conc_ug_mL,</span>
<span id="cb22-3">         weight_mg, norm_glycogen, in_std_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb22-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(well_conc_ug_mL))</span>
<span id="cb22-5"></span>
<span id="cb22-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(oor, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb22-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temp"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean lum."</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well conc. (ug/mL)"</span>,</span>
<span id="cb22-8">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tissue (mg)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"In std range"</span>),</span>
<span id="cb22-9">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Re-assayed samples: back-calculated concentrations at 1:200 dilution"</span>)</span>
<span id="cb22-10"></span>
<span id="cb22-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- Full re-assay results, all 5 samples ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb22-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(oor)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temp</th>
<th style="text-align: right;">Mean lum.</th>
<th style="text-align: right;">Well conc. (ug/mL)</th>
<th style="text-align: right;">Tissue (mg)</th>
<th style="text-align: right;">Normalized glycogen</th>
<th style="text-align: left;">In std range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">1_08_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">30767</td>
<td style="text-align: right;">9.883</td>
<td style="text-align: right;">24.8</td>
<td style="text-align: right;">79.70</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_06_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">9218</td>
<td style="text-align: right;">2.548</td>
<td style="text-align: right;">11.0</td>
<td style="text-align: right;">46.33</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_05_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8742</td>
<td style="text-align: right;">2.386</td>
<td style="text-align: right;">25.7</td>
<td style="text-align: right;">18.57</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_05_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">6542</td>
<td style="text-align: right;">1.637</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">35.58</td>
<td style="text-align: left;">TRUE</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_04_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">823</td>
<td style="text-align: right;">-0.310</td>
<td style="text-align: right;">12.4</td>
<td style="text-align: right;">-5.00</td>
<td style="text-align: left;">FALSE</td>
</tr>
</tbody>
</table>
<p>Re-assayed samples: back-calculated concentrations at 1:200 dilution</p>
<pre><code>--- Full re-assay results, all 5 samples ---

tibble [5 × 8] (S3: tbl_df/tbl/data.frame)
 $ sample_id      : chr [1:5] "1_08_ambient" "1_06_ambient" "1_05_36C" "9_05_ambient" ...
 $ family         : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 2 1
 $ temperature    : Factor w/ 2 levels "ambient","36C": 1 1 2 1 2
 $ mean_lum       : num [1:5] 30767 9218 8742 6542 823
 $ well_conc_ug_mL: num [1:5] 9.88 2.55 2.39 1.64 -0.31
 $ weight_mg      : num [1:5] 24.8 11 25.7 9.2 12.4
 $ norm_glycogen  : num [1:5] 79.7 46.3 18.6 35.6 -5
 $ in_std_range   : logi [1:5] TRUE TRUE TRUE TRUE FALSE</code></pre>
<p>Four of the five samples (<code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>) now fall comfortably within the standard curve’s quantifiable range (0.02-20 µg/mL) at 1:200 – the 8× dilution increase successfully resolved the original extrapolation problem for all four.</p>
<p>The fifth, <code>1_04_36C</code>, was <strong>not</strong> originally out-of-range (it was re-assayed for high CV, not for reading above the curve); at 1:200 its mean luminescence (823 RLU) falls below the fitted intercept, producing a <strong>negative</strong> back-calculated well concentration. It was accidentally diluted at 1:200 for this re-assay, when it should have been re-assayed with its original dilution of 1:25.</p>
</section>
</section>
<section id="comparison-to-original-run" class="level1">
<h1>6 COMPARISON TO ORIGINAL RUN</h1>
<div class="sourceCode" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1">original_path <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../output/Gen5-20260730-mgig-fams1_9-glycogen-glo/sample_glycogen_results.csv"</span></span>
<span id="cb24-2">original <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(original_path)</span>
<span id="cb24-3"></span>
<span id="cb24-4">original_sub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> original <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(Sample <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> sample_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb24-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id             =</span> Sample,</span>
<span id="cb24-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_orig         =</span> Dilution,</span>
<span id="cb24-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_lum_orig         =</span> Mean.lum.,</span>
<span id="cb24-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_orig               =</span> CV....,</span>
<span id="cb24-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen_orig    =</span> Normalized.glycogen..ug.mL.mg.,</span>
<span id="cb24-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_range_orig         =</span> In.std.range</span>
<span id="cb24-13">  )</span>
<span id="cb24-14"></span>
<span id="cb24-15">rerun_sub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb24-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id          =</span> sample_id,</span>
<span id="cb24-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution_rerun     =</span> dilution,</span>
<span id="cb24-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_lum_rerun     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb24-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_rerun           =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb24-21">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen_rerun =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(norm_glycogen, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb24-22">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_range_rerun     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_std_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO - extrapolated"</span>)</span>
<span id="cb24-23">  )</span>
<span id="cb24-24"></span>
<span id="cb24-25">comparison <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">inner_join</span>(original_sub, rerun_sub, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_id"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(sample_id)</span>
<span id="cb24-27"></span>
<span id="cb24-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(comparison,</span>
<span id="cb24-29">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dilution (orig)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean lum. (orig)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV % (orig)"</span>,</span>
<span id="cb24-30">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Norm. glycogen (orig)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"In range (orig)"</span>,</span>
<span id="cb24-31">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dilution (re-run)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean lum. (re-run)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV % (re-run)"</span>,</span>
<span id="cb24-32">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Norm. glycogen (re-run)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"In range (re-run)"</span>),</span>
<span id="cb24-33">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Original run (2026-07-30, 1:25) vs. targeted re-assay (2026-08-03, 1:200)"</span>)</span>
<span id="cb24-34"></span>
<span id="cb24-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- comparison: original vs. re-assay results, side by side ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb24-36"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(comparison)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
<col style="width: 9%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">Dilution (orig)</th>
<th style="text-align: right;">Mean lum. (orig)</th>
<th style="text-align: right;">CV % (orig)</th>
<th style="text-align: right;">Norm. glycogen (orig)</th>
<th style="text-align: left;">In range (orig)</th>
<th style="text-align: right;">Dilution (re-run)</th>
<th style="text-align: right;">Mean lum. (re-run)</th>
<th style="text-align: right;">CV % (re-run)</th>
<th style="text-align: right;">Norm. glycogen (re-run)</th>
<th style="text-align: left;">In range (re-run)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">1_04_36C</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">5075</td>
<td style="text-align: right;">30.1</td>
<td style="text-align: right;">2.83</td>
<td style="text-align: left;">yes</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">823</td>
<td style="text-align: right;">5.2</td>
<td style="text-align: right;">-5.00</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_05_36C</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">94104</td>
<td style="text-align: right;">4.9</td>
<td style="text-align: right;">29.86</td>
<td style="text-align: left;">NO - extrapolated</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">8742</td>
<td style="text-align: right;">2.7</td>
<td style="text-align: right;">18.57</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_06_ambient</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">97291</td>
<td style="text-align: right;">6.0</td>
<td style="text-align: right;">72.15</td>
<td style="text-align: left;">NO - extrapolated</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">9218</td>
<td style="text-align: right;">0.9</td>
<td style="text-align: right;">46.33</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_08_ambient</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">200961</td>
<td style="text-align: right;">0.2</td>
<td style="text-align: right;">66.38</td>
<td style="text-align: left;">NO - extrapolated</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">30767</td>
<td style="text-align: right;">0.9</td>
<td style="text-align: right;">79.70</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_05_ambient</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">70209</td>
<td style="text-align: right;">1.1</td>
<td style="text-align: right;">62.05</td>
<td style="text-align: left;">NO - extrapolated</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">6542</td>
<td style="text-align: right;">0.8</td>
<td style="text-align: right;">35.58</td>
<td style="text-align: left;">yes</td>
</tr>
</tbody>
</table>
<p>Original run (2026-07-30, 1:25) vs.&nbsp;targeted re-assay (2026-08-03, 1:200)</p>
<pre><code>--- comparison: original vs. re-assay results, side by side ---

'data.frame':   5 obs. of  11 variables:
 $ sample_id          : chr  "1_04_36C" "1_05_36C" "1_06_ambient" "1_08_ambient" ...
 $ dilution_orig      : int  25 25 25 25 25
 $ mean_lum_orig      : int  5075 94104 97291 200961 70209
 $ cv_orig            : num  30.1 4.9 6 0.2 1.1
 $ norm_glycogen_orig : num  2.83 29.86 72.15 66.38 62.05
 $ in_range_orig      : chr  "yes" "NO - extrapolated" "NO - extrapolated" "NO - extrapolated" ...
 $ dilution_rerun     : num  200 200 200 200 200
 $ mean_lum_rerun     : num  823 8742 9218 30767 6542
 $ cv_rerun           : num  5.2 2.7 0.9 0.9 0.8
 $ norm_glycogen_rerun: num  -5 18.6 46.3 79.7 35.6
 $ in_range_rerun     : chr  "NO - extrapolated" "yes" "yes" "yes" ...</code></pre>
<section id="plot-original-vs.-re-assayed-normalized-glycogen" class="level2">
<h2 class="anchored" data-anchor-id="plot-original-vs.-re-assayed-normalized-glycogen">6.1 Plot: original vs.&nbsp;re-assayed normalized glycogen</h2>
<div class="sourceCode" id="cb26" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1">comparison_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> comparison <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb26-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, in_range_orig, in_range_rerun,</span>
<span id="cb26-3">         norm_glycogen_orig, norm_glycogen_rerun) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb26-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_longer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(norm_glycogen_orig, norm_glycogen_rerun),</span>
<span id="cb26-5">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"run"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"norm_glycogen"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb26-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb26-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">recode</span>(run, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen_orig =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Original (1:25)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen_rerun =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Re-assay (1:200)"</span>),</span>
<span id="cb26-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">run =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(run, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Original (1:25)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Re-assay (1:200)"</span>)),</span>
<span id="cb26-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_range =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(run <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Original (1:25)"</span>, in_range_orig, in_range_rerun),</span>
<span id="cb26-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_range =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_range <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"out of range / floor"</span>)</span>
<span id="cb26-11">  )</span>
<span id="cb26-12"></span>
<span id="cb26-13">comparison_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(comparison_long, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> run, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> norm_glycogen, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> sample_id)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb26-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey60"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb26-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> sample_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_range), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb26-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"in range"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"out of range / floor"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb26-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen: original run vs. targeted re-assay"</span>,</span>
<span id="cb26-18">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Points connected by sample; 'x' marks values flagged out-of-range or below the detection floor"</span>,</span>
<span id="cb26-19">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen (ug/mL/mg tissue)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Status"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb26-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb26-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb26-22">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"right"</span>)</span>
<span id="cb26-23"></span>
<span id="cb26-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- comparison_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb26-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(comparison_plot)</span>
<span id="cb26-26"></span>
<span id="cb26-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"original_vs_rerun_comparison.png"</span>), comparison_plot,</span>
<span id="cb26-28">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb26-29"></span>
<span id="cb26-30">comparison_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-08-03-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Sample-Re-runs/Gen5-20260803-mgig-fams1_9-glycogen-glo_files/figure-gfm/plot-comparison-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- comparison_plot: ggplot object structure ---

data: sample_id, in_range_orig, in_range_rerun, run, norm_glycogen,
  in_range [10x6]
mapping:  x = ~run, y = ~norm_glycogen, group = ~sample_id
scales:   shape 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_line: na.rm = FALSE, orientation = NA, arrow = NULL, arrow.fill = NULL, lineend = butt, linejoin = round, linemitre = 10
stat_identity: na.rm = FALSE
position_identity 

mapping: colour = ~sample_id, shape = ~in_range 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
</section>
<section id="sample-glycogen-table" class="level1">
<h1>7 SAMPLE GLYCOGEN TABLE</h1>
<div class="sourceCode" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1">sample_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb28-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb28-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample        =</span> sample_id,</span>
<span id="cb28-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family        =</span> family,</span>
<span id="cb28-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature   =</span> temperature,</span>
<span id="cb28-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual    =</span> individual,</span>
<span id="cb28-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Tissue (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> weight_mg,</span>
<span id="cb28-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dilution</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> dilution,</span>
<span id="cb28-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean lum.</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb28-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb28-11">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well glycogen (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(well_conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb28-12">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Homogenate glycogen (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(homogenate_conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb28-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Normalized glycogen (ug/mL/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(norm_glycogen, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb28-14">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In std range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_std_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO - extrapolated"</span>)</span>
<span id="cb28-15">  )</span>
<span id="cb28-16"></span>
<span id="cb28-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(sample_table, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per-sample glycogen quantification, targeted re-assay (mean of technical triplicate)"</span>)</span>
<span id="cb28-18"></span>
<span id="cb28-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(sample_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_glycogen_results.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb28-20"></span>
<span id="cb28-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_table: formatted per-sample results written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb28-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: right;">Tissue (mg)</th>
<th style="text-align: right;">Dilution</th>
<th style="text-align: right;">Mean lum.</th>
<th style="text-align: right;">CV (%)</th>
<th style="text-align: right;">Well glycogen (ug/mL)</th>
<th style="text-align: right;">Homogenate glycogen (ug/mL)</th>
<th style="text-align: right;">Normalized glycogen (ug/mL/mg)</th>
<th style="text-align: left;">In std range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">1_06_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">11.0</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">9218</td>
<td style="text-align: right;">0.9</td>
<td style="text-align: right;">2.548</td>
<td style="text-align: right;">509.61</td>
<td style="text-align: right;">46.33</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_08_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">24.8</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">30767</td>
<td style="text-align: right;">0.9</td>
<td style="text-align: right;">9.883</td>
<td style="text-align: right;">1976.68</td>
<td style="text-align: right;">79.70</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_04_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">12.4</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">823</td>
<td style="text-align: right;">5.2</td>
<td style="text-align: right;">-0.310</td>
<td style="text-align: right;">-61.95</td>
<td style="text-align: right;">-5.00</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_05_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">25.7</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">8742</td>
<td style="text-align: right;">2.7</td>
<td style="text-align: right;">2.386</td>
<td style="text-align: right;">477.18</td>
<td style="text-align: right;">18.57</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_05_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">200</td>
<td style="text-align: right;">6542</td>
<td style="text-align: right;">0.8</td>
<td style="text-align: right;">1.637</td>
<td style="text-align: right;">327.38</td>
<td style="text-align: right;">35.58</td>
<td style="text-align: left;">yes</td>
</tr>
</tbody>
</table>
<p>Per-sample glycogen quantification, targeted re-assay (mean of technical triplicate)</p>
<pre><code>--- sample_table: formatted per-sample results written to CSV ---

tibble [5 × 12] (S3: tbl_df/tbl/data.frame)
 $ Sample                        : chr [1:5] "1_06_ambient" "1_08_ambient" "1_04_36C" "1_05_36C" ...
 $ Family                        : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 2
 $ Temperature                   : Factor w/ 2 levels "ambient","36C": 1 1 2 2 1
 $ Individual                    : chr [1:5] "06" "08" "04" "05" ...
 $ Tissue (mg)                   : num [1:5] 11 24.8 12.4 25.7 9.2
 $ Dilution                      : num [1:5] 200 200 200 200 200
 $ Mean lum.                     : num [1:5] 9218 30767 823 8742 6542
 $ CV (%)                        : num [1:5] 0.9 0.9 5.2 2.7 0.8
 $ Well glycogen (ug/mL)         : num [1:5] 2.55 9.88 -0.31 2.39 1.64
 $ Homogenate glycogen (ug/mL)   : num [1:5] 510 1977 -62 477 327
 $ Normalized glycogen (ug/mL/mg): num [1:5] 46.3 79.7 -5 18.6 35.6
 $ In std range                  : chr [1:5] "yes" "yes" "NO - extrapolated" "yes" ...</code></pre>
</section>
<section id="summary" class="level1">
<h1>8 SUMMARY</h1>
<p><strong>What this re-assay was for.</strong> Five samples from the 2026-07-30 run were re-assayed at a higher dilution (1:200 vs.&nbsp;1:25): four that read above the standard curve’s top standard (<code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>) and one with a high technical-replicate CV (<code>1_04_36C</code>, 30.1% originally).</p>
<p><strong>Standard curve.</strong> This plate’s standard curve fit well (y = 2937.7 x + 1733.0, R^2 = 0.9886), comparable in quality to the original run’s curve.</p>
<p><strong>Dilution outcome: 4 of 5 successful.</strong> The 8× dilution increase worked as intended for all four samples that were originally out-of-range – all four now fall within the standard curve’s quantifiable range, with comfortable margin below the top standard (well concentrations 1.6-9.9 µg/mL vs.&nbsp;the 0.02-20 µg/mL curve). Their re-assayed normalized glycogen values are lower than the original (extrapolated) estimates in every case, consistent with extrapolation beyond a standard curve’s top point tending to overestimate concentration:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 21%">
<col style="width: 41%">
<col style="width: 37%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">Original (1:25, extrapolated)</th>
<th style="text-align: right;">Re-assay (1:200, in range)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>1_08_ambient</code></td>
<td style="text-align: right;">66.4</td>
<td style="text-align: right;">79.7</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>1_06_ambient</code></td>
<td style="text-align: right;">72.2</td>
<td style="text-align: right;">46.3</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>1_05_36C</code></td>
<td style="text-align: right;">29.9</td>
<td style="text-align: right;">18.6</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>9_05_ambient</code></td>
<td style="text-align: right;">62.1</td>
<td style="text-align: right;">35.6</td>
</tr>
</tbody>
</table>
<p>(Note <code>1_08_ambient</code> is the exception – its re-assayed value is <em>higher</em> than the original extrapolated estimate, underscoring that extrapolation error is not predictably one-directional and is exactly why re-assay within range matters rather than trusting the extrapolated numbers.)</p>
<p>Sample <code>1_04_36C</code> should <em>NOT</em> have been diluted, as it previously failed QC due to a high CV. This should be re-assayed.</p>
<p><strong>Using these results going forward.</strong> For <code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, and <code>9_05_ambient</code>, the values in this document’s <code>sample_glycogen_results.csv</code> should replace the corresponding rows from the 2026-07-30 run in any downstream analysis (e.g.&nbsp;the family/temperature ANOVA), since they are now interpolated rather than extrapolated and were measured with a same-plate standard curve.</p>


</section>

 ]]></description>
  <category>2026</category>
  <category>glycogen</category>
  <category>Glycogen-Glo</category>
  <category>SORMI</category>
  <category>Pacific oyster</category>
  <category>Magallana gigas</category>
  <category>Crassostrea gigas</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-08-03-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Sample-Re-runs/</guid>
  <pubDate>Mon, 03 Aug 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Glycogen Assay - SORMI June 2026 M.gigas USDA Families 1 and 9 Comparisons Using Glycogen Glo Kit</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>As part of the June 2026 SORMI project, I conducted a glycogen assay on <em>Magallana gigas</em> (Pacific oyster) ctenidia samples (ambient and 36°C temperatures) from USDA Families 1 and 9 (chosen by Steven). The purpose of this study was to compare the glycogen content between these two families using the Glycogen Glo Kit. Samples had been <a href="../../../posts/2026/2026-07-22-Homogenization---June-2026-SORMI-M.gigas-Ctenidia-from-Families-1-and-9-for-Glycogen-Glo-Assay/index.html">previously homogenized on 20260722</a> (Notebook entry).</p>
<p>All data/code/analysis is available here:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/Glycogen">https://github.com/RobertsLab/sormi-assay-development/tree/main/Glycogen</a></li>
</ul>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<p>Homogenized ctenidia samples were thawed, vortexed, and spun at 16,000g for 1min to pellet debris. Based on <a href="https://genefish.wordpress.com/author/hnote22/">prior work by Hazel</a> (Notebook) the following was decided upon:</p>
<ul>
<li><p>dilution of 1:25 should be appropriate for samples to fall within standard curve range</p></li>
<li><p>glucose analysis is unnecessary for <em>M.gigas</em> ctenidia samples, as glucose has been shown to be negligible</p></li>
</ul>
<section id="dilutions" class="level2">
<h2 class="anchored" data-anchor-id="dilutions">Dilutions</h2>
<p>All samples were diluted 1:25 in dilution buffer (2:1:1 ratio of PBS:0.3N HCl:TRIS). E.g. 4uL of sample + 96uL of dilution buffer. The diluted samples were then used for the glycogen assay.</p>
</section>
<section id="glycogen-assay" class="level2">
<h2 class="anchored" data-anchor-id="glycogen-assay">Glycogen Assay</h2>
<p>A standard curve of glycogen (20ug, 2ug, 0.2ug, 0.02ug, 0ug) in PBS was prepared. The assay was performed in triplicate for each sample in a separate 96-well, white Costar plate, and luminescence readings were taken using a HTX Synergy plate reader (Agilent). A negative control (dilution buffer only), in triplicate, was included in the assay to account for background luminescence.</p>
<p>The assay was performed in triplicate for each sample in a 96-well, white Costar plates, and luminescence readings were taken using a HTX Synergy plate reader (Agilent).</p>
<p>The Glycogen Glo Kit protocol was followed according to the manufacturer’s instructions, with appropriate incubation times and reagent additions.</p>
<section id="master-mix-calcs" class="level3">
<h3 class="anchored" data-anchor-id="master-mix-calcs">Master Mix Calcs</h3>
<section id="digestion-master-mix" class="level4">
<h4 class="anchored" data-anchor-id="digestion-master-mix">Digestion Master Mix</h4>
<table class="caption-top table">
<thead>
<tr class="header">
<th>COMPONENT</th>
<th>vol.per.rxn(uL)</th>
<th>no.rxns</th>
<th>total(uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>glucoamylase buffer</td>
<td>25</td>
<td>125</td>
<td>3125</td>
</tr>
<tr class="even">
<td>glucoamylase</td>
<td>0.125</td>
<td>125</td>
<td>15.625</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td>TOTAL</td>
<td>3140.625</td>
</tr>
</tbody>
</table>
</section>
<section id="detection-master-mix" class="level4">
<h4 class="anchored" data-anchor-id="detection-master-mix">Detection Master Mix</h4>
<table class="caption-top table">
<thead>
<tr class="header">
<th>COMPONENT</th>
<th>vol.per.rxn(uL)</th>
<th>no.rxns</th>
<th>total(uL)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>luciferin detection solution</td>
<td>50</td>
<td>125</td>
<td>6250</td>
</tr>
<tr class="even">
<td>reductase substrate</td>
<td>0.25</td>
<td>125</td>
<td>31.25</td>
</tr>
<tr class="odd">
<td>reductase</td>
<td>0.25</td>
<td>125</td>
<td>31.25</td>
</tr>
<tr class="even">
<td>NAD</td>
<td>0.25</td>
<td>125</td>
<td>31.25</td>
</tr>
<tr class="odd">
<td>glucose dehydrogenase</td>
<td>2</td>
<td>125</td>
<td>250</td>
</tr>
<tr class="even">
<td></td>
<td></td>
<td>TOTAL</td>
<td>6593.75</td>
</tr>
</tbody>
</table>
</section>
</section>
</section>
<section id="data-analysis" class="level2">
<h2 class="anchored" data-anchor-id="data-analysis">Data Analysis</h2>
<p>Data was analyzed in the following R Markdown file:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Glycogen/code/Gen5-20260730-mgig-fams1_9-glycogen-glo.Rmd">Gen5-20260730-mgig-fams1_9-glycogen-glo.Rmd</a> (GitHub)</li>
</ul>
<p>See the BACKGROUND section below for code/details on the data analysis workflow.</p>
</section>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>None of the family, temperature, or family × temperature effects are statistically significant at n = 8 per group – excluding the four extrapolated samples changes this picture only slightly (log-scale ANOVA family p = 0.652, temperature p = 0.467, interaction p = 0.292, n = 28), so the qualitative conclusion (no detectable family or temperature effect) is robust to that exclusion.</p>
<p>I need to re-run the assay for the four extrapolated samples with higher dilutions to ensure they are within the standard curve range and then re-analyze the data. The current analysis is based on extrapolated values for those four samples, which may not be reliable.</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note
</div>
</div>
<div class="callout-body-container callout-body">
<p>This section was knitted from <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Glycogen/code/Gen5-20260730-mgig-fams1_9-glycogen-glo.Rmd">Gen5-20260730-mgig-fams1_9-glycogen-glo.Rmd</a> (GitHub)</p>
</div>
</div>
</section>
<section id="background" class="level1">
<h1>1 BACKGROUND</h1>
<p>Glycogen quantification of <em>Magallana gigas</em> (Pacific oyster) ctenidia homogenates using the <a href="https://github.com/RobertsLab/resources/blob/master/protocols/Commercial_Protocols/Promega_Glycogen_Glo_Assay.pdf">Glycogen-Glo Assay (Promega)</a> (GitHub; PDF), read on 2026-07-30.</p>
<p>The experiment compares two USDA oyster families (<strong>family 1</strong> and <strong>family 9</strong>) across two temperature exposures (<strong>ambient</strong> and <strong>36°C</strong>), with <strong>8 individuals per family per temperature</strong> (32 samples total). Each sample was run in <strong>technical triplicate</strong> at a <strong>1:25 dilution</strong>.</p>
<p>Two plates were read on the same instrument/protocol:</p>
<ul>
<li><strong>Plate 01</strong>: all 32 samples, triplicate, filling all 96 wells (no standards).</li>
<li><strong>Plate 02</strong>: glycogen standard curve (20, 2, 0.2, 0.02, 0 µg/mL) plus a buffer-only negative control, all in triplicate.</li>
</ul>
<p>Because the standards live on a separate plate from the samples, a single standard curve from plate 02 is applied to all samples on plate 01. Both plates were read with the same protocol (<code>luminesence-96wells-1.0s-glycogen_glo.prt</code>, gain 135, 1.00 s integration, extended dynamic range) back-to-back, so this is reasonable, but it does mean plate-to-plate signal drift is not controlled for. This is flagged in the interpretation.</p>
<section id="sample-naming" class="level2">
<h2 class="anchored" data-anchor-id="sample-naming">1.1 Sample naming</h2>
<p>Per <a href="../data/raw_luminescence/README.md"><code>../data/raw_luminescence/README.md</code></a>, plate layout entries follow:</p>
<ul>
<li><code>&lt;sample&gt;-&lt;assay_type&gt;-&lt;tissue_weight&gt;-df.&lt;dilution_factor&gt;</code></li>
</ul>
<p>Here <code>&lt;sample&gt;</code> itself is composite:</p>
<ul>
<li><code>&lt;family&gt;_&lt;individual&gt;_&lt;temperature&gt;</code></li>
</ul>
<p>E.g. <code>1_05_36C-glyc-25.7-df.25</code> is family 1, individual 05, 36°C exposure, glycogen assay, 25.7 mg of ctenidia tissue, diluted 1:25.</p>
<p>Standards follow <code>STD-&lt;assay_type&gt;-&lt;concentration&gt;</code>, e.g.&nbsp;<code>STD-glyc-20</code> (20 µg/mL glycogen); the buffer-only well is <code>NEG-glyc</code>.</p>
</section>
<section id="important-notes" class="level2">
<h2 class="anchored" data-anchor-id="important-notes">1.2 Important note(s)</h2>
<ol type="1">
<li><p><strong>Units.</strong> Promega’s glycogen standards and linear range are specified in <strong>µg/mL</strong> (linear to 20 µg/mL), and the layout labels (<code>STD-glyc-20</code>) are on that scale. Earlier scripts in this repo labeled the same quantity “µg/µL”; that label is incorrect by a factor of 1000 and is corrected here.</p></li>
<li><p><strong>Tissue weights</strong> are taken from the plate layout labels rather than a separate weights CSV, since they are already encoded there for this experiment.</p></li>
</ol>
</section>
</section>
<section id="setup" class="level1">
<h1>2 SETUP</h1>
<section id="libraries" class="level2">
<h2 class="anchored" data-anchor-id="libraries">2.1 Libraries</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(knitr)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(ggplot2)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(dplyr)</span></code></pre></div>
<pre><code>## 
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':
## 
##     filter, lag

## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union</code></pre>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyr)</span>
<span id="cb3-2"></span>
<span id="cb3-3">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb3-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb3-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb3-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb3-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb3-8">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb3-9">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb3-10">)</span></code></pre></div>
</section>
<section id="output-directory" class="level2">
<h2 class="anchored" data-anchor-id="output-directory">2.2 Output directory</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Output directory for this analysis (matches this file's name, per ../code/README.md)</span></span>
<span id="cb4-2">output_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../output/Gen5-20260730-mgig-fams1_9-glycogen-glo"</span></span>
<span id="cb4-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(output_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb4-4"></span>
<span id="cb4-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- output_dir: destination for all figures and tables ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb4-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(output_dir)</span></code></pre></div>
<pre><code>--- output_dir: destination for all figures and tables ---
 chr "../output/Gen5-20260730-mgig-fams1_9-glycogen-glo"</code></pre>
</section>
</section>
<section id="data" class="level1">
<h1>3 DATA</h1>
<p>Data are read from the local repo (<code>../data/raw_luminescence/</code>) so this document renders before/after the files are pushed to GitHub. The commented-out URLs are the remote equivalents.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">data_dir <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"../data/raw_luminescence"</span></span>
<span id="cb6-2"></span>
<span id="cb6-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plate 1 - all 32 samples, triplicate, 1:25 dilution</span></span>
<span id="cb6-4"></span>
<span id="cb6-5">plate_layout1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-Gen5-20260730-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb6-6">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb6-7">raw_luminescence1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_lum-Gen5-20260730-mgig-fams1_9-plate-01.csv"</span>),</span>
<span id="cb6-8">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb6-9"></span>
<span id="cb6-10"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># plate 2 - glycogen standard curve + negative control, triplicates</span></span>
<span id="cb6-11">plate_layout2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout-Gen5-20260730-mgig-fams1_9-plate-02.csv"</span>),</span>
<span id="cb6-12">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stringsAsFactors =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb6-13">raw_luminescence2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read.csv</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_lum-Gen5-20260730-mgig-fams1_9-plate-02.csv"</span>),</span>
<span id="cb6-14">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">header =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb6-15"></span>
<span id="cb6-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate layout 1 (samples):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_layout1)</span>
<span id="cb6-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Raw luminescence 1 (samples):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(raw_luminescence1)</span>
<span id="cb6-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Plate layout 2 (standards):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_layout2)</span>
<span id="cb6-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Raw luminescence 2 (standards):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(raw_luminescence2)</span></code></pre></div>
<pre><code>Plate layout 1 (samples):

'data.frame':   8 obs. of  12 variables:
 $ V1 : chr  "1_01_ambient-glyc-7.0-df.25" "1_05_ambient-glyc-7.9-df.25" "1_01_36C-glyc-9.6-df.25" "1_05_36C-glyc-25.7-df.25" ...
 $ V2 : chr  "1_01_ambient-glyc-7.0-df.25" "1_05_ambient-glyc-7.9-df.25" "1_01_36C-glyc-9.6-df.25" "1_05_36C-glyc-25.7-df.25" ...
 $ V3 : chr  "1_01_ambient-glyc-7.0-df.25" "1_05_ambient-glyc-7.9-df.25" "1_01_36C-glyc-9.6-df.25" "1_05_36C-glyc-25.7-df.25" ...
 $ V4 : chr  "1_02_ambient-glyc-4.7-df.25" "1_06_ambient-glyc-11.0-df.25" "1_02_36C-glyc-9.2-df.25" "1_06_36C-glyc-13.0-df.25" ...
 $ V5 : chr  "1_02_ambient-glyc-4.7-df.25" "1_06_ambient-glyc-11.0-df.25" "1_02_36C-glyc-9.2-df.25" "1_06_36C-glyc-13.0-df.25" ...
 $ V6 : chr  "1_02_ambient-glyc-4.7-df.25" "1_06_ambient-glyc-11.0-df.25" "1_02_36C-glyc-9.2-df.25" "1_06_36C-glyc-13.0-df.25" ...
 $ V7 : chr  "1_03_ambient-glyc-2.5-df.25" "1_07_ambient-glyc-6.1-df.25" "1_03_36C-glyc-3.1-df.25" "1_07_36C-glyc-6.1-df.25" ...
 $ V8 : chr  "1_03_ambient-glyc-2.5-df.25" "1_07_ambient-glyc-6.1-df.25" "1_03_36C-glyc-3.1-df.25" "1_07_36C-glyc-6.1-df.25" ...
 $ V9 : chr  "1_03_ambient-glyc-2.5-df.25" "1_07_ambient-glyc-6.1-df.25" "1_03_36C-glyc-3.1-df.25" "1_07_36C-glyc-6.1-df.25" ...
 $ V10: chr  "1_04_ambient-glyc-10.7-df.25" "1_08_ambient-glyc-24.8-df.25" "1_04_36C-glyc-12.4-df.25" "1_08_36C-glyc-8.8-df.25" ...
 $ V11: chr  "1_04_ambient-glyc-10.7-df.25" "1_08_ambient-glyc-24.8-df.25" "1_04_36C-glyc-12.4-df.25" "1_08_36C-glyc-8.8-df.25" ...
 $ V12: chr  "1_04_ambient-glyc-10.7-df.25" "1_08_ambient-glyc-24.8-df.25" "1_04_36C-glyc-12.4-df.25" "1_08_36C-glyc-8.8-df.25" ...

Raw luminescence 1 (samples):

'data.frame':   8 obs. of  12 variables:
 $ V1 : int  11367 21917 32434 99029 7587 70560 15396 47510
 $ V2 : int  10284 22772 33069 89772 7324 70742 13953 51778
 $ V3 : int  10754 21609 30029 93511 7098 69326 13889 50054
 $ V4 : int  14834 99291 5244 56801 4924 3792 11887 13583
 $ V5 : int  14603 101901 5895 55712 4796 3376 12805 14333
 $ V6 : int  14460 90681 5898 57887 5252 3778 12878 14402
 $ V7 : int  7584 5141 4542 22179 10788 10100 44070 2685
 $ V8 : int  7058 4776 5385 20629 11788 9429 45147 2382
 $ V9 : int  7476 5310 4568 22171 11825 10378 42353 2157
 $ V10: int  39832 200695 6309 46456 5276 2669 23819 19314
 $ V11: int  36805 200780 3369 47737 5688 2825 23562 17222
 $ V12: int  41820 201408 5548 44512 5994 2539 24569 19417

Plate layout 2 (standards):

'data.frame':   8 obs. of  12 variables:
 $ V1 : chr  "STD-glyc-20" "STD-glyc-0" "NEG-glyc" "" ...
 $ V2 : chr  "STD-glyc-20" "STD-glyc-0" "NEG-glyc" "" ...
 $ V3 : chr  "STD-glyc-20" "STD-glyc-0" "NEG-glyc" "" ...
 $ V4 : chr  "STD-glyc-2" "" "" "" ...
 $ V5 : chr  "STD-glyc-2" "" "" "" ...
 $ V6 : chr  "STD-glyc-2" "" "" "" ...
 $ V7 : chr  "STD-glyc-0.2" "" "" "" ...
 $ V8 : chr  "STD-glyc-0.2" "" "" "" ...
 $ V9 : chr  "STD-glyc-0.2" "" "" "" ...
 $ V10: chr  "STD-glyc-0.02" "" "" "" ...
 $ V11: chr  "STD-glyc-0.02" "" "" "" ...
 $ V12: chr  "STD-glyc-0.02" "" "" "" ...

Raw luminescence 2 (standards):

'data.frame':   8 obs. of  12 variables:
 $ V1 : int  53166 924 932 NA NA NA NA NA
 $ V2 : int  68390 909 840 NA NA NA NA NA
 $ V3 : int  63329 897 967 NA NA NA NA NA
 $ V4 : int  6947 NA NA NA NA NA NA NA
 $ V5 : int  6432 NA NA NA NA NA NA NA
 $ V6 : int  6156 NA NA NA NA NA NA NA
 $ V7 : int  1437 NA NA NA NA NA NA NA
 $ V8 : int  1415 NA NA NA NA NA NA NA
 $ V9 : int  1377 NA NA NA NA NA NA NA
 $ V10: int  1144 NA NA NA NA NA NA NA
 $ V11: int  1153 NA NA NA NA NA NA NA
 $ V12: int  963 NA NA NA NA NA NA NA</code></pre>
<section id="reshape-plates-to-long-format" class="level2">
<h2 class="anchored" data-anchor-id="reshape-plates-to-long-format">3.1 Reshape plates to long format</h2>
<p>Rather than defining one variable per sample, both plates are melted to a tidy well-level data frame and the sample metadata is parsed out of the layout labels. This keeps the code independent of how many samples are on the plate.</p>
<div class="sourceCode" id="cb8" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Convert a paired layout/luminescence plate into one row per well</span></span>
<span id="cb8-2">plate_to_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(layout, luminescence, plate_label) {</span>
<span id="cb8-3">  n_row <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span></span>
<span id="cb8-4">  n_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span></span>
<span id="cb8-5">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">expand.grid</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_row_idx =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_row, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_col =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>n_col)</span>
<span id="cb8-6">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_label</span>
<span id="cb8-7">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> LETTERS[out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx]</span>
<span id="cb8-8">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>well        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%s%02d"</span>, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col)</span>
<span id="cb8-9">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) layout[i, j],</span>
<span id="cb8-10">                                                out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col)))</span>
<span id="cb8-11">  out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mapply</span>(<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i, j) luminescence[i, j],</span>
<span id="cb8-12">                                        out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col))</span>
<span id="cb8-13">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> out[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_row_idx, out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_col), ]</span>
<span id="cb8-14">  out[out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(out<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label), ]</span>
<span id="cb8-15">}</span>
<span id="cb8-16"></span>
<span id="cb8-17">plate1_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plate_to_long</span>(plate_layout1, raw_luminescence1, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate-01"</span>)</span>
<span id="cb8-18">plate2_long <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plate_to_long</span>(plate_layout2, raw_luminescence2, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate-02"</span>)</span>
<span id="cb8-19"></span>
<span id="cb8-20"></span>
<span id="cb8-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- plate_to_long(): layout + luminescence -&gt; one row per well ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">args</span>(plate_to_long))</span>
<span id="cb8-23"></span>
<span id="cb8-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate1_long: one row per occupied well, sample plate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate1_long)</span>
<span id="cb8-26"></span>
<span id="cb8-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- plate2_long: one row per occupied well, standards plate ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb8-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate2_long)</span></code></pre></div>
<pre><code>--- plate_to_long(): layout + luminescence -&gt; one row per well ---

function (layout, luminescence, plate_label)  

--- plate1_long: one row per occupied well, sample plate ---

'data.frame':   96 obs. of  7 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "plate-01" "plate-01" "plate-01" "plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_02_ambient-glyc-4.7-df.25" ...
 $ luminescence : num  11367 10284 10754 14834 14603 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

--- plate2_long: one row per occupied well, standards plate ---

'data.frame':   18 obs. of  7 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "plate-02" "plate-02" "plate-02" "plate-02" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "STD-glyc-20" "STD-glyc-20" "STD-glyc-20" "STD-glyc-2" ...
 $ luminescence : num  53166 68390 63329 6947 6432 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...</code></pre>
</section>
</section>
<section id="standard-curves" class="level1">
<h1>4 STANDARD CURVES</h1>
<section id="glycogen-standard-curve" class="level2">
<h2 class="anchored" data-anchor-id="glycogen-standard-curve">4.1 Glycogen Standard Curve</h2>
<section id="extract-luminescence-data" class="level3">
<h3 class="anchored" data-anchor-id="extract-luminescence-data">4.1.1 Extract luminescence data</h3>
<p>Plate 02, row A holds the four non-zero glycogen standards (20, 2, 0.2, 0.02 µg/mL) in triplicate; row B columns 1-3 hold the <code>STD-glyc-0</code> (zero-glycogen) standard and row C columns 1-3 hold the <code>NEG-glyc</code> buffer-only negative control.</p>
<div class="sourceCode" id="cb10" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1">standards <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate2_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb10-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_concentration =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^STD-glyc-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label)))</span>
<span id="cb10-4"></span>
<span id="cb10-5">negative_control <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate2_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^NEG-glyc"</span>, label))</span>
<span id="cb10-6"></span>
<span id="cb10-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard concentrations (ug/mL):"</span>,</span>
<span id="cb10-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Replicates per standard:"</span>,</span>
<span id="cb10-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-11"></span>
<span id="cb10-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Negative control (buffer only) luminescence:"</span>,</span>
<span id="cb10-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(negative_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>),</span>
<span id="cb10-14">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| mean ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(negative_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Zero glycogen standard luminescence:  mean ="</span>,</span>
<span id="cb10-16">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence[standards<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>]), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-17"></span>
<span id="cb10-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- standards: standard curve wells with parsed concentration ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(standards)</span>
<span id="cb10-20"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- negative_control: buffer-only wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb10-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(negative_control)</span></code></pre></div>
<pre><code>Standard concentrations (ug/mL): 0, 0.02, 0.2, 2, 20 
Replicates per standard: 3 

Negative control (buffer only) luminescence: 932, 840, 967 | mean = 913 
Zero glycogen standard luminescence:  mean = 910 

--- standards: standard curve wells with parsed concentration ---
'data.frame':   15 obs. of  8 variables:
 $ plate_row_idx     : int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col         : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate             : chr  "plate-02" "plate-02" "plate-02" "plate-02" ...
 $ plate_row         : chr  "A" "A" "A" "A" ...
 $ well              : chr  "A01" "A02" "A03" "A04" ...
 $ label             : chr  "STD-glyc-20" "STD-glyc-20" "STD-glyc-20" "STD-glyc-2" ...
 $ luminescence      : num  53166 68390 63329 6947 6432 ...
 $ glyc_concentration: num  20 20 20 2 2 2 0.2 0.2 0.2 0.02 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...

--- negative_control: buffer-only wells ---
'data.frame':   3 obs. of  7 variables:
 $ plate_row_idx: int  3 3 3
 $ plate_col    : int  1 2 3
 $ plate        : chr  "plate-02" "plate-02" "plate-02"
 $ plate_row    : chr  "C" "C" "C"
 $ well         : chr  "C01" "C02" "C03"
 $ label        : chr  "NEG-glyc" "NEG-glyc" "NEG-glyc"
 $ luminescence : num  932 840 967
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...</code></pre>
<p>The buffer-only negative control and the zero-glycogen standard are indistinguishable, as expected – both report the reagent/instrument background.</p>
</section>
<section id="glycogen-standard-curve-summary-statistics-and-linear-regression" class="level3">
<h3 class="anchored" data-anchor-id="glycogen-standard-curve-summary-statistics-and-linear-regression">4.1.2 Glycogen standard curve summary statistics and linear regression</h3>
<p>Following the convention used in previous analyses in this repo, the regression is fit to the <strong>mean</strong> luminescence at each standard concentration. The fit to all individual replicate wells is also reported, since it is the more honest estimate of the curve’s uncertainty.</p>
<div class="sourceCode" id="cb12" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1">glycogen_summary_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> standards <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(glyc_concentration) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb12-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_mean_luminescence =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb12-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_sd                =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence),</span>
<span id="cb12-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_se                =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()),</span>
<span id="cb12-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_cv                =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb12-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">glyc_n                 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb12-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb12-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb12-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(glyc_concentration)</span>
<span id="cb12-12"></span>
<span id="cb12-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Regression on the per-concentration means (repo convention)</span></span>
<span id="cb12-14">lm_model      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> glycogen_summary_data)</span>
<span id="cb12-15">glyc_slope     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(lm_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb12-16">glyc_intercept <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coef</span>(lm_model)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb12-17">glyc_r_squared <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(lm_model)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb12-18"></span>
<span id="cb12-19"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Regression on all individual replicate wells (for comparison)</span></span>
<span id="cb12-20">lm_model_reps    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> standards)</span>
<span id="cb12-21">glyc_r2_reps     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(lm_model_reps)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>r.squared</span>
<span id="cb12-22"></span>
<span id="cb12-23">glyc_conc_min_nonzero <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(glycogen_summary_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration[</span>
<span id="cb12-24">  glycogen_summary_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])</span>
<span id="cb12-25">glyc_conc_max <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(glycogen_summary_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_concentration)</span>
<span id="cb12-26"></span>
<span id="cb12-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(glycogen_summary_data,</span>
<span id="cb12-28">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb12-29">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen (ug/mL)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean luminescence"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SD"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"SEM"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"CV (%)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n"</span>),</span>
<span id="cb12-30">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard curve summary statistics"</span>)</span>
<span id="cb12-31"></span>
<span id="cb12-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Fit to concentration means:      y ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, glyc_slope), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x +"</span>,</span>
<span id="cb12-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.1f"</span>, glyc_intercept), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" R^2 ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, glyc_r_squared), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-34"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Fit to individual replicates:    R^2 ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"%.4f"</span>, glyc_r2_reps), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-35"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Quantifiable range (standards):"</span>, glyc_conc_min_nonzero, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>, glyc_conc_max, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ug/mL</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-36"></span>
<span id="cb12-37"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- glycogen_summary_data: per-concentration summary statistics ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-38"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(glycogen_summary_data)</span>
<span id="cb12-39"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- lm_model: regression on per-concentration means ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-40"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(lm_model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb12-41"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- lm_model_reps: regression on all individual replicate wells ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb12-42"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(lm_model_reps, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 27%">
<col style="width: 28%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 12%">
<col style="width: 7%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">Glycogen (ug/mL)</th>
<th style="text-align: right;">Mean luminescence</th>
<th style="text-align: right;">SD</th>
<th style="text-align: right;">SEM</th>
<th style="text-align: right;">CV (%)</th>
<th style="text-align: right;">n</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0.00</td>
<td style="text-align: right;">910.0</td>
<td style="text-align: right;">13.5</td>
<td style="text-align: right;">7.8</td>
<td style="text-align: right;">1.49</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: right;">0.02</td>
<td style="text-align: right;">1086.7</td>
<td style="text-align: right;">107.2</td>
<td style="text-align: right;">61.9</td>
<td style="text-align: right;">9.86</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">0.20</td>
<td style="text-align: right;">1409.7</td>
<td style="text-align: right;">30.4</td>
<td style="text-align: right;">17.5</td>
<td style="text-align: right;">2.15</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="even">
<td style="text-align: right;">2.00</td>
<td style="text-align: right;">6511.7</td>
<td style="text-align: right;">401.5</td>
<td style="text-align: right;">231.8</td>
<td style="text-align: right;">6.17</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">20.00</td>
<td style="text-align: right;">61628.3</td>
<td style="text-align: right;">7753.2</td>
<td style="text-align: right;">4476.3</td>
<td style="text-align: right;">12.58</td>
<td style="text-align: right;">3</td>
</tr>
</tbody>
</table>
<p>Glycogen standard curve summary statistics</p>
<pre><code>Fit to concentration means:      y = 3039.5 x + 801.8  R^2 = 0.9999 
Fit to individual replicates:    R^2 = 0.9859 
Quantifiable range (standards): 0.02 - 20 ug/mL

--- glycogen_summary_data: per-concentration summary statistics ---
tibble [5 × 6] (S3: tbl_df/tbl/data.frame)
 $ glyc_concentration    : num [1:5] 0 0.02 0.2 2 20
 $ glyc_mean_luminescence: num [1:5] 910 1087 1410 6512 61628
 $ glyc_sd               : num [1:5] 13.5 107.2 30.4 401.5 7753.2
 $ glyc_se               : num [1:5] 7.81 61.89 17.52 231.79 4476.3
 $ glyc_cv               : num [1:5] 1.49 9.86 2.15 6.17 12.58
 $ glyc_n                : int [1:5] 3 3 3 3 3

--- lm_model: regression on per-concentration means ---
List of 12
 $ coefficients : Named num [1:2] 802 3039
 $ residuals    : Named num [1:5] 108.2489 224.1257 0.0166 -369.0743 36.6831
 $ effects      : Named num [1:5] -31996.5 53108.1 -60.1 -412.5 160.5
 $ rank         : int 2
 $ fitted.values: Named num [1:5] 802 863 1410 6881 61592
 $ assign       : int [1:2] 0 1
 $ qr           :List of 5
 $ df.residual  : int 3
 $ xlevels      : Named list()
 $ call         : language lm(formula = glyc_mean_luminescence ~ glyc_concentration, data = glycogen_summary_data)
 $ terms        :Classes 'terms', 'formula'  language glyc_mean_luminescence ~ glyc_concentration
 $ model        :'data.frame':  5 obs. of  2 variables:

--- lm_model_reps: regression on all individual replicate wells ---
List of 12
 $ coefficients : Named num [1:2] 802 3039
 $ residuals    : Named num [1:15] -8425.7 6798.3 1737.3 66.3 -448.7 ...
 $ effects      : Named num [1:15] -55420 -91986 993 2923 2408 ...
 $ rank         : int 2
 $ fitted.values: Named num [1:15] 61592 61592 61592 6881 6881 ...
 $ assign       : int [1:2] 0 1
 $ qr           :List of 5
 $ df.residual  : int 13
 $ xlevels      : Named list()
 $ call         : language lm(formula = luminescence ~ glyc_concentration, data = standards)
 $ terms        :Classes 'terms', 'formula'  language luminescence ~ glyc_concentration
 $ model        :'data.frame':  15 obs. of  2 variables:</code></pre>
</section>
<section id="extract-sample-data-and-calculate-glycogen-levels" class="level3">
<h3 class="anchored" data-anchor-id="extract-sample-data-and-calculate-glycogen-levels">4.1.3 Extract sample data and calculate glycogen levels</h3>
<p>Sample labels are parsed into family, individual, temperature, tissue weight, and dilution factor. The delimiter inconsistencies noted above (<code>1_02-36C</code>, <code>9-07-36C</code>, <code>9-08-36C</code>) are normalized here.</p>
<div class="sourceCode" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1">samples_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate1_long <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-2">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalize `-` to `_` in the &lt;family&gt;-&lt;individual&gt;-&lt;temperature&gt; prefix</span></span>
<span id="cb14-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label_clean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([19])[-_]([0-9]{2})[-_](ambient|36C)-"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1_</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2_</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">3-"</span>, label)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb14-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-glyc-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean),</span>
<span id="cb14-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([19])_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb14-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[19]_([0-9]{2})_.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb14-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[19]_[0-9]{2}_([^-]+)-.*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean),</span>
<span id="cb14-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">weight_mg  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-glyc-([0-9.]+)-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">..*$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, label_clean)),</span>
<span id="cb14-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dilution   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^.*-df</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">."</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, label_clean))</span>
<span id="cb14-11">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb14-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb14-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span>)),</span>
<span id="cb14-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">temperature =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span>))</span>
<span id="cb14-15">  )</span>
<span id="cb14-16"></span>
<span id="cb14-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fail loudly rather than silently dropping malformed labels</span></span>
<span id="cb14-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stopifnot</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg)),</span>
<span id="cb14-19">          <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution)),</span>
<span id="cb14-20">          <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>temperature)))</span>
<span id="cb14-21"></span>
<span id="cb14-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells parsed:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(samples_wells),</span>
<span id="cb14-23">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"| unique samples:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>sample_id)), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dilution factor(s) used:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>dilution), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Design (wells per group):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family, samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>temperature))</span>
<span id="cb14-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Tissue weight range (mg):"</span>,</span>
<span id="cb14-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(samples_wells<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-29"></span>
<span id="cb14-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- samples_wells: one row per sample well, metadata parsed from label ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb14-31"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples_wells)</span></code></pre></div>
<pre><code>Wells parsed: 96 | unique samples: 32 
Dilution factor(s) used: 25 

Design (wells per group):
          
           ambient 36C
  Family 1      24  24
  Family 9      24  24

Tissue weight range (mg): 1.8 - 25.7 

--- samples_wells: one row per sample well, metadata parsed from label ---
'data.frame':   96 obs. of  14 variables:
 $ plate_row_idx: int  1 1 1 1 1 1 1 1 1 1 ...
 $ plate_col    : int  1 2 3 4 5 6 7 8 9 10 ...
 $ plate        : chr  "plate-01" "plate-01" "plate-01" "plate-01" ...
 $ plate_row    : chr  "A" "A" "A" "A" ...
 $ well         : chr  "A01" "A02" "A03" "A04" ...
 $ label        : chr  "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_02_ambient-glyc-4.7-df.25" ...
 $ luminescence : num  11367 10284 10754 14834 14603 ...
 $ label_clean  : chr  "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_01_ambient-glyc-7.0-df.25" "1_02_ambient-glyc-4.7-df.25" ...
 $ sample_id    : chr  "1_01_ambient" "1_01_ambient" "1_01_ambient" "1_02_ambient" ...
 $ family       : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual   : chr  "01" "01" "01" "02" ...
 $ temperature  : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 1 1 ...
 $ weight_mg    : num  7 7 7 4.7 4.7 4.7 2.5 2.5 2.5 10.7 ...
 $ dilution     : num  25 25 25 25 25 25 25 25 25 25 ...
 - attr(*, "out.attrs")=List of 2
  ..$ dim     : Named int [1:2] 8 12
  .. ..- attr(*, "names")= chr [1:2] "plate_row_idx" "plate_col"
  ..$ dimnames:List of 2
  .. ..$ plate_row_idx: chr [1:8] "plate_row_idx=1" "plate_row_idx=2" "plate_row_idx=3" "plate_row_idx=4" ...
  .. ..$ plate_col    : chr [1:12] "plate_col= 1" "plate_col= 2" "plate_col= 3" "plate_col= 4" ...</code></pre>
<p>Per-sample values are then computed by averaging the technical triplicate and back-calculating through the standard curve:</p>
<ol type="1">
<li><strong>Well concentration</strong> = <code>(mean luminescence - intercept) / slope</code> → µg/mL in the assayed (diluted) well.</li>
<li><strong>Homogenate concentration</strong> = well concentration × dilution factor (25) → µg/mL in the undiluted homogenate.</li>
<li><strong>Normalized glycogen</strong> = homogenate concentration / tissue weight → µg/mL per mg tissue.</li>
</ol>
<p>Note on step 3: because homogenization volume is not recorded in these data files, normalized values are reported as µg glycogen per mL homogenate per mg tissue. If the standard 1.0 mL homogenization volume was used (750 µL PBS/0.3N HCl + 250 µL Tris, per <a href="../glycogen-promega-notes.md"><code>../glycogen-promega-notes.md</code></a>), these values are numerically equal to <strong>µg glycogen / mg tissue</strong>. All comparisons below are unaffected as long as the volume was constant across samples.</p>
<div class="sourceCode" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1">sample_glycogen <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples_wells <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_id, family, individual, temperature, weight_mg, dilution) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb16-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_reps        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb16-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_lum      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb16-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd_lum        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence),</span>
<span id="cb16-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">cv_lum        =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(luminescence),</span>
<span id="cb16-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb16-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb16-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_conc_ug_mL       =</span> (mean_lum <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> glyc_intercept) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> glyc_slope,</span>
<span id="cb16-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_conc_ug_mL =</span> well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> dilution,</span>
<span id="cb16-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen         =</span> homogenate_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> weight_mg,</span>
<span id="cb16-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">in_std_range          =</span> well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> glyc_conc_min_nonzero <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb16-15">                            well_conc_ug_mL <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> glyc_conc_max</span>
<span id="cb16-16">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb16-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(family, temperature, individual)</span>
<span id="cb16-18"></span>
<span id="cb16-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples quantified:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_glycogen), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb16-20"></span>
<span id="cb16-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_glycogen: one row per individual, triplicate averaged and back-calculated ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb16-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_glycogen)</span></code></pre></div>
<pre><code>Samples quantified: 32 

--- sample_glycogen: one row per individual, triplicate averaged and back-calculated ---
tibble [32 × 14] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:32] "1_01_ambient" "1_02_ambient" "1_03_ambient" "1_04_ambient" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual           : chr [1:32] "01" "02" "03" "04" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 2 2 ...
 $ weight_mg            : num [1:32] 7 4.7 2.5 10.7 7.9 11 6.1 24.8 9.6 9.2 ...
 $ dilution             : num [1:32] 25 25 25 25 25 25 25 25 25 25 ...
 $ n_reps               : int [1:32] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_lum             : num [1:32] 10802 14632 7373 39486 22099 ...
 $ sd_lum               : num [1:32] 543 189 278 2525 603 ...
 $ cv_lum               : num [1:32] 5.03 1.29 3.77 6.4 2.73 ...
 $ well_conc_ug_mL      : num [1:32] 3.29 4.55 2.16 12.73 7.01 ...
 $ homogenate_conc_ug_mL: num [1:32] 82.2 113.8 54 318.2 175.2 ...
 $ norm_glycogen        : num [1:32] 11.7 24.2 21.6 29.7 22.2 ...
 $ in_std_range         : logi [1:32] TRUE TRUE TRUE TRUE TRUE FALSE ...</code></pre>
</section>
<section id="plot-glycogen-standard-curve-with-sample-points" class="level3">
<h3 class="anchored" data-anchor-id="plot-glycogen-standard-curve-with-sample-points">4.1.4 Plot glycogen standard curve with sample points</h3>
<div class="sourceCode" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1">std_curve_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(glycogen_summary_data,</span>
<span id="cb18-2">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> glyc_mean_luminescence)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Std curve best fit line"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,</span>
<span id="cb18-4">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"coral"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> glyc_se,</span>
<span id="cb18-6">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> glyc_se),</span>
<span id="cb18-7">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sample_glycogen,</span>
<span id="cb18-10">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> well_conc_ug_mL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_lum, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> family),</span>
<span id="cb18-11">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.85</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_glycogen, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_std_range),</span>
<span id="cb18-13">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> well_conc_ug_mL, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_lum, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Extrapolated"</span>),</span>
<span id="cb18-14">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">stroke =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"rect"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xmin =</span> glyc_conc_max, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xmax =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">Inf</span>,</span>
<span id="cb18-16">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"red"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.06</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb18-18">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span>),</span>
<span id="cb18-19">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>,</span>
<span id="cb18-20">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span>          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1b7837"</span>,</span>
<span id="cb18-21">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span>          <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#762a83"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Extrapolated"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">21</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Std curve best fit line"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">guides</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">guide_legend</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">override.aes =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb18-25">                              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">order =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb18-26">         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">guide_legend</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">order =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">guide_legend</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">order =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"label"</span>,</span>
<span id="cb18-28">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> glyc_conc_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.45</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(glycogen_summary_data<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>glyc_mean_luminescence) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.95</span>,</span>
<span id="cb18-29">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"y = %.1fx + %.1f</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">R2 = %.4f"</span>, glyc_slope, glyc_intercept, glyc_r_squared),</span>
<span id="cb18-30">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fontface =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"coral"</span>,</span>
<span id="cb18-31">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label.padding =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unit</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lines"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb18-33">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard curve with sample well concentrations"</span>,</span>
<span id="cb18-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shaded region is above the top standard (20 ug/mL): samples there are extrapolated"</span>,</span>
<span id="cb18-35">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen concentration (ug/mL)"</span>,</span>
<span id="cb18-36">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Luminescence"</span>,</span>
<span id="cb18-37">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Standard curve error bars are SEM of triplicate wells (n = 3)"</span></span>
<span id="cb18-38">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-39">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb18-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb18-41">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb18-42">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb18-43">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid.minor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey70"</span>)</span>
<span id="cb18-44">  )</span>
<span id="cb18-45"></span>
<span id="cb18-46"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- std_curve_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb18-47"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve_plot)</span>
<span id="cb18-48"></span>
<span id="cb18-49"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glycogen_standard_curve.png"</span>), std_curve_plot,</span>
<span id="cb18-50">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb18-51"></span>
<span id="cb18-52">std_curve_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/Gen5-20260730-mgig-fams1_9-glycogen-glo_files/figure-gfm/plot-glycogen-standard-curve-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- std_curve_plot: ggplot object structure ---
data: glyc_concentration, glyc_mean_luminescence, glyc_sd, glyc_se,
  glyc_cv, glyc_n [5x6]
mapping:  x = ~glyc_concentration, y = ~glyc_mean_luminescence
scales:   colour, shape, linetype 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: linetype = Std curve best fit line 
geom_smooth: na.rm = FALSE, orientation = NA, se = FALSE
stat_smooth: na.rm = FALSE, orientation = NA, se = FALSE, method = lm
position_identity 

mapping: ymin = ~glyc_mean_luminescence - glyc_se, ymax = ~glyc_mean_luminescence + glyc_se 
geom_errorbar: na.rm = FALSE, orientation = NA, lineend = butt, width = 0.3
stat_identity: na.rm = FALSE
position_identity 

mapping: colour = Glycogen standard 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: x = ~well_conc_ug_mL, y = ~mean_lum, colour = ~family 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: x = ~well_conc_ug_mL, y = ~mean_lum, shape = Extrapolated 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: xmin = ~xmin, xmax = ~xmax, ymin = ~ymin, ymax = ~ymax 
geom_rect: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

mapping: x = ~x, y = ~y 
geom_label: na.rm = FALSE, label.padding = 0.3
stat_identity: na.rm = FALSE
position_identity </code></pre>
<p>The linear fit is anchored almost entirely by the 20 µg/mL standard. On a log-log scale it is clear that the three lowest standards (0.02, 0.2, 2 µg/mL) sit essentially on the baseline of this linear model, i.e.&nbsp;the curve has little resolving power at the bottom of the range:</p>
<div class="sourceCode" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">std_curve_log_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(glycogen_summary_data, glyc_concentration <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb20-2">                             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> glyc_concentration, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> glyc_mean_luminescence)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_hline</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yintercept =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(negative_control<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>luminescence),</span>
<span id="cb20-4">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background (buffer only)"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey40"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.8</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> glyc_se,</span>
<span id="cb20-7">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> glyc_mean_luminescence <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> glyc_se),</span>
<span id="cb20-8">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.08</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"darkblue"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"steelblue"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_x_log10</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_log10</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Background (buffer only)"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb20-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen standard curve (log-log)"</span>,</span>
<span id="cb20-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Glycogen concentration (ug/mL, log scale)"</span>,</span>
<span id="cb20-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Luminescence (log scale)"</span></span>
<span id="cb20-17">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb20-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb20-20">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb20-21"></span>
<span id="cb20-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- std_curve_log_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(std_curve_log_plot)</span>
<span id="cb20-24"></span>
<span id="cb20-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glycogen_standard_curve_loglog.png"</span>), std_curve_log_plot,</span>
<span id="cb20-26">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb20-27"></span>
<span id="cb20-28">std_curve_log_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/Gen5-20260730-mgig-fams1_9-glycogen-glo_files/figure-gfm/plot-glycogen-standard-curve-log-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- std_curve_log_plot: ggplot object structure ---
data: glyc_concentration, glyc_mean_luminescence, glyc_sd, glyc_se,
  glyc_cv, glyc_n [4x6]
mapping:  x = ~glyc_concentration, y = ~glyc_mean_luminescence
scales:   x, xmin, xmax, xend, xintercept, xmin_final, xmax_final, xlower, xmiddle, xupper, x0, y, ymin, ymax, yend, yintercept, ymin_final, ymax_final, lower, middle, upper, y0, linetype 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: yintercept = ~mean(negative_control$luminescence), linetype = Background (buffer only) 
geom_hline: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

geom_line: na.rm = FALSE, orientation = NA, arrow = NULL, arrow.fill = NULL, lineend = butt, linejoin = round, linemitre = 10
stat_identity: na.rm = FALSE
position_identity 

mapping: ymin = ~glyc_mean_luminescence - glyc_se, ymax = ~glyc_mean_luminescence + glyc_se 
geom_errorbar: na.rm = FALSE, orientation = NA, lineend = butt, width = 0.08
stat_identity: na.rm = FALSE
position_identity 

geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
</section>
</section>
<section id="quality-control" class="level1">
<h1>5 QUALITY CONTROL</h1>
<section id="technical-replicate-variability" class="level2">
<h2 class="anchored" data-anchor-id="technical-replicate-variability">5.1 Technical replicate variability</h2>
<div class="sourceCode" id="cb22" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Coefficient of variation across technical triplicates (%):</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb22-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(sample_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>cv_lum), <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>))</span>
<span id="cb22-3"></span>
<span id="cb22-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Samples with CV &gt; 15%:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb22-5">high_cv <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(cv_lum <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">15</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb22-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, mean_lum, sd_lum, cv_lum)</span>
<span id="cb22-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(high_cv) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb22-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  none</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb22-9">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb22-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(high_cv), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb22-11">}</span>
<span id="cb22-12"></span>
<span id="cb22-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- high_cv: samples exceeding the 15% triplicate CV threshold ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb22-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(high_cv)</span></code></pre></div>
<pre><code>Coefficient of variation across technical triplicates (%):
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.19    3.31    4.92    5.48    6.12   30.07 

Samples with CV &gt; 15%:
 sample_id mean_lum sd_lum cv_lum
  1_04_36C     5075   1526  30.07

--- high_cv: samples exceeding the 15% triplicate CV threshold ---

tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
 $ sample_id: chr "1_04_36C"
 $ mean_lum : num 5075
 $ sd_lum   : num 1526
 $ cv_lum   : num 30.1</code></pre>
</section>
<section id="samples-outside-the-standard-curve-range" class="level2">
<h2 class="anchored" data-anchor-id="samples-outside-the-standard-curve-range">5.2 Samples outside the standard curve range</h2>
<div class="sourceCode" id="cb24" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1">oor <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>in_std_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, family, temperature, mean_lum, well_conc_ug_mL,</span>
<span id="cb24-4">         weight_mg, norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb24-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">desc</span>(well_conc_ug_mL))</span>
<span id="cb24-6"></span>
<span id="cb24-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples with well concentrations outside"</span>, glyc_conc_min_nonzero, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-"</span>,</span>
<span id="cb24-8">    glyc_conc_max, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ug/mL:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(oor), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_glycogen), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb24-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(oor, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb24-10">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temp"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean lum."</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well conc. (ug/mL)"</span>,</span>
<span id="cb24-11">                    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Tissue (mg)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen"</span>),</span>
<span id="cb24-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Samples requiring extrapolation beyond the top standard"</span>)</span>
<span id="cb24-13"></span>
<span id="cb24-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- Samples outside the standard curve range ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb24-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(oor)</span></code></pre></div>
<pre><code>Samples with well concentrations outside 0.02 - 20 ug/mL: 4 of 32 </code></pre>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
<col style="width: 14%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temp</th>
<th style="text-align: right;">Mean lum.</th>
<th style="text-align: right;">Well conc. (ug/mL)</th>
<th style="text-align: right;">Tissue (mg)</th>
<th style="text-align: right;">Normalized glycogen</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">1_08_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">200961</td>
<td style="text-align: right;">65.85</td>
<td style="text-align: right;">24.8</td>
<td style="text-align: right;">66.38</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_06_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">97291</td>
<td style="text-align: right;">31.75</td>
<td style="text-align: right;">11.0</td>
<td style="text-align: right;">72.15</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_05_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">94104</td>
<td style="text-align: right;">30.70</td>
<td style="text-align: right;">25.7</td>
<td style="text-align: right;">29.86</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_05_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">70209</td>
<td style="text-align: right;">22.84</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">62.05</td>
</tr>
</tbody>
</table>
<p>Samples requiring extrapolation beyond the top standard</p>
<pre><code>--- Samples outside the standard curve range ---

tibble [4 × 7] (S3: tbl_df/tbl/data.frame)
 $ sample_id      : chr [1:4] "1_08_ambient" "1_06_ambient" "1_05_36C" "9_05_ambient"
 $ family         : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 2
 $ temperature    : Factor w/ 2 levels "ambient","36C": 1 1 2 1
 $ mean_lum       : num [1:4] 200961 97291 94104 70209
 $ well_conc_ug_mL: num [1:4] 65.9 31.7 30.7 22.8
 $ weight_mg      : num [1:4] 24.8 11 25.7 9.2
 $ norm_glycogen  : num [1:4] 66.4 72.1 29.9 62.1</code></pre>
<p>All four are <strong>above</strong> the 20 µg/mL top standard, so their concentrations are extrapolated rather than interpolated. Notably, <code>1_08_ambient</code> reads ~201,000 RLU (3.3× the top standard) with a very tight triplicate CV (0.2%), which is the signature of a well near the top of the detector’s usable range. The other three (<code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>) are more modestly above range (~70,000-97,000 RLU, roughly 1.5-1.6× the top standard). These samples should be re-run at a higher dilution (e.g.&nbsp;1:50-1:100 for <code>1_08_ambient</code>) before the values are treated as quantitative. Group comparisons below are therefore repeated with these samples excluded as a sensitivity check.</p>
</section>
<section id="plate-01-luminescence-map" class="level2">
<h2 class="anchored" data-anchor-id="plate-01-luminescence-map">5.3 Plate 01 luminescence map</h2>
<p>A well-position map checks for edge effects or systematic gradients that would confound the family/temperature contrasts. In this design, family and temperature are both encoded as two-row blocks (rows A/B = family 1 ambient, C/D = family 1 36°C, E/F = family 9 ambient, G/H = family 9 36°C), while column position encodes only the individual (with each individual’s triplicate occupying 3 adjacent columns). Any row-wise artifact would therefore alias directly onto the family/temperature contrasts of interest; a column-wise artifact would not, since individuals are distributed independently of family and temperature group.</p>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">plate_map_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(samples_wells,</span>
<span id="cb27-2">                         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(plate_col), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(plate_row, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rev</span>(LETTERS[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>])))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_tile</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log10</span>(luminescence)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_text</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">format</span>(luminescence, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">big.mark =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">","</span>)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey15"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_viridis_c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">option =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"magma"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"log10(RLU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb27-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate 01 raw luminescence by well"</span>,</span>
<span id="cb27-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Row-pairs A/B, C/D, E/F, G/H = family1-amb, family1-36C, family9-amb, family9-36C; columns = individual (triplicate)"</span>,</span>
<span id="cb27-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate column"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate row"</span></span>
<span id="cb27-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_minimal</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb27-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">panel.grid =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>())</span>
<span id="cb27-14"></span>
<span id="cb27-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- plate_map_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb27-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(plate_map_plot)</span>
<span id="cb27-17"></span>
<span id="cb27-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate01_luminescence_map.png"</span>), plate_map_plot,</span>
<span id="cb27-19">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb27-20"></span>
<span id="cb27-21">plate_map_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/Gen5-20260730-mgig-fams1_9-glycogen-glo_files/figure-gfm/plate-heatmap-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- plate_map_plot: ggplot object structure ---

data: plate_row_idx, plate_col, plate, plate_row, well, label,
  luminescence, label_clean, sample_id, family, individual,
  temperature, weight_mg, dilution [96x14]
mapping:  x = ~factor(plate_col), y = ~factor(plate_row, levels = rev(LETTERS[1:8]))
scales:   fill 
faceting:  &lt;empty&gt; 
-----------------------------------
mapping: fill = ~log10(luminescence) 
geom_tile: na.rm = FALSE, lineend = butt, linejoin = mitre
stat_identity: na.rm = FALSE
position_identity 

mapping: label = ~format(luminescence, big.mark = ",") 
geom_text: na.rm = FALSE, parse = FALSE, check_overlap = FALSE, size.unit = mm
stat_identity: na.rm = FALSE
position_nudge </code></pre>
</section>
<section id="relationship-between-tissue-weight-and-signal" class="level2">
<h2 class="anchored" data-anchor-id="relationship-between-tissue-weight-and-signal">5.4 Relationship between tissue weight and signal</h2>
<p>If normalization by tissue weight is working, normalized glycogen should show no strong trend against input tissue weight.</p>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">weight_check <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(sample_id, family, temperature, weight_mg,</span>
<span id="cb29-3">         homogenate_conc_ug_mL, norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pivot_longer</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(homogenate_conc_ug_mL, norm_glycogen),</span>
<span id="cb29-5">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">names_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metric"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values_to =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"value"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">metric =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">recode</span>(metric,</span>
<span id="cb29-7">                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">homogenate_conc_ug_mL =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Homogenate glycogen (ug/mL)"</span>,</span>
<span id="cb29-8">                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">norm_glycogen         =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen (ug/mL/mg tissue)"</span>))</span>
<span id="cb29-9"></span>
<span id="cb29-10">weight_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(weight_check, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> weight_mg, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_smooth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lm"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey50"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> temperature), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.8</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> metric, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">scales =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"free_y"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1b7837"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#762a83"</span>),</span>
<span id="cb29-15">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">17</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_y_log10</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Input tissue weight vs. glycogen signal"</span>,</span>
<span id="cb29-19">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ctenidia tissue weight (mg)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb29-22">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb29-23"></span>
<span id="cb29-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- weight_check: long-format data for the two-panel weight check ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(weight_check)</span>
<span id="cb29-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- weight_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb29-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(weight_plot)</span>
<span id="cb29-28"></span>
<span id="cb29-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tissue_weight_vs_glycogen.png"</span>), weight_plot,</span>
<span id="cb29-30">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb29-31"></span>
<span id="cb29-32">weight_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/Gen5-20260730-mgig-fams1_9-glycogen-glo_files/figure-gfm/weight-vs-signal-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Spearman correlation, tissue weight vs. homogenate glycogen concentration:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(sample_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg, sample_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>homogenate_conc_ug_mL,</span>
<span id="cb30-3">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"spearman"</span>))</span>
<span id="cb30-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Spearman correlation, tissue weight vs. weight-normalized glycogen:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb30-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cor.test</span>(sample_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>weight_mg, sample_glycogen<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>norm_glycogen,</span>
<span id="cb30-6">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"spearman"</span>))</span></code></pre></div>
<pre><code>--- weight_check: long-format data for the two-panel weight check ---

tibble [64 × 6] (S3: tbl_df/tbl/data.frame)
 $ sample_id  : chr [1:64] "1_01_ambient" "1_01_ambient" "1_02_ambient" "1_02_ambient" ...
 $ family     : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ temperature: Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 1 1 ...
 $ weight_mg  : num [1:64] 7 7 4.7 4.7 2.5 2.5 10.7 10.7 7.9 7.9 ...
 $ metric     : chr [1:64] "Homogenate glycogen (ug/mL)" "Normalized glycogen (ug/mL/mg tissue)" "Homogenate glycogen (ug/mL)" "Normalized glycogen (ug/mL/mg tissue)" ...
 $ value      : num [1:64] 82.2 11.7 113.8 24.2 54 ...

--- weight_plot: ggplot object structure ---

data: sample_id, family, temperature, weight_mg, metric, value [64x6]
mapping:  x = ~weight_mg, y = ~value
scales:   colour, shape, y, ymin, ymax, yend, yintercept, ymin_final, ymax_final, lower, middle, upper, y0 
faceting:  ~metric 
-----------------------------------
geom_smooth: na.rm = FALSE, orientation = NA, se = FALSE
stat_smooth: na.rm = FALSE, orientation = NA, se = FALSE, method = lm
position_identity 

mapping: colour = ~family, shape = ~temperature 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity 

Spearman correlation, tissue weight vs. homogenate glycogen concentration:


    Spearman's rank correlation rho

data:  sample_glycogen$weight_mg and sample_glycogen$homogenate_conc_ug_mL
S = 1860.7, p-value = 4.114e-05
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.6589619 


Spearman correlation, tissue weight vs. weight-normalized glycogen:


    Spearman's rank correlation rho

data:  sample_glycogen$weight_mg and sample_glycogen$norm_glycogen
S = 3839.5, p-value = 0.09966
alternative hypothesis: true rho is not equal to 0
sample estimates:
     rho 
0.296276 </code></pre>
<p><strong>Interpretation.</strong> Homogenate glycogen concentration (before dividing by weight) is strongly and significantly correlated with input tissue weight (rho = 0.66, p &lt; 0.0001). This is expected, not a sign of a problem: every sample was homogenized and diluted by the same fixed protocol regardless of starting tissue mass, so a heavier piece of ctenidia simply contributes proportionally more total glycogen into the same assay volume, mechanically inflating homogenate-level concentration. It reflects a feature of the protocol (fixed homogenization/dilution volume, variable input mass), not biological variation in glycogen content per se.</p>
<p>Dividing by tissue weight is meant to remove exactly this scaling artifact. After normalization, the correlation with weight drops sharply, to a weak and non-significant residual (rho = 0.30, p = 0.10) – roughly a threefold reduction in the strength of association, and no longer distinguishable from no relationship at this sample size (n = 32). This is the expected signature of normalization working as intended: most, though perhaps not quite all, of the weight-driven scaling has been removed, leaving normalized glycogen approximately independent of how much tissue went into each homogenate. The residual rho = 0.30 is small enough that it does not indicate normalization failure, but it is also not exactly zero, so a mild weight-related trend in the normalized values cannot be fully excluded from this dataset alone (possible contributors include measurement noise at low tissue weights, where small absolute pipetting/weighing errors have larger proportional effects, or a true small biological effect such as larger individuals tending to have either richer or more dilute ctenidia glycogen stores). Because none of the family or temperature comparisons above showed a significant effect, this residual weight association is not currently a confound for the reported group comparisons, but it is worth re-checking if a future dataset shows a significant family or temperature effect that also happens to coincide with a weight imbalance between groups.</p>
</section>
</section>
<section id="sample-glycogen-table" class="level1">
<h1>6 SAMPLE GLYCOGEN TABLE</h1>
<div class="sourceCode" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1">sample_table <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">transmute</span>(</span>
<span id="cb32-3">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Sample        =</span> sample_id,</span>
<span id="cb32-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family        =</span> family,</span>
<span id="cb32-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature   =</span> temperature,</span>
<span id="cb32-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Individual    =</span> individual,</span>
<span id="cb32-7">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Tissue (mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> weight_mg,</span>
<span id="cb32-8">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Dilution</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> dilution,</span>
<span id="cb32-9">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Mean lum.</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(mean_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb32-10">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">CV (%)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(cv_lum, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>),</span>
<span id="cb32-11">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Well glycogen (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>        <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(well_conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>),</span>
<span id="cb32-12">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Homogenate glycogen (ug/mL)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span>  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(homogenate_conc_ug_mL, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb32-13">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Normalized glycogen (ug/mL/mg)</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">round</span>(norm_glycogen, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>),</span>
<span id="cb32-14">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">In std range</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">`</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(in_std_range, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"yes"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"NO - extrapolated"</span>)</span>
<span id="cb32-15">  )</span>
<span id="cb32-16"></span>
<span id="cb32-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(sample_table, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Per-sample glycogen quantification (mean of technical triplicate)"</span>)</span>
<span id="cb32-18"></span>
<span id="cb32-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(sample_table, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_glycogen_results.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb32-20"></span>
<span id="cb32-21"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- sample_table: formatted per-sample results written to CSV ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb32-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(sample_table)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
<col style="width: 8%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: left;">Individual</th>
<th style="text-align: right;">Tissue (mg)</th>
<th style="text-align: right;">Dilution</th>
<th style="text-align: right;">Mean lum.</th>
<th>CV (%)</th>
<th style="text-align: right;">Well glycogen (ug/mL)</th>
<th style="text-align: right;">Homogenate glycogen (ug/mL)</th>
<th style="text-align: right;">Normalized glycogen (ug/mL/mg)</th>
<th style="text-align: left;">In std range</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">1_01_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">7.0</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">10802</td>
<td>5.0</td>
<td style="text-align: right;">3.290</td>
<td style="text-align: right;">82.25</td>
<td style="text-align: right;">11.75</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_02_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">4.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">14632</td>
<td>1.3</td>
<td style="text-align: right;">4.550</td>
<td style="text-align: right;">113.76</td>
<td style="text-align: right;">24.20</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_03_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">2.5</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">7373</td>
<td>3.8</td>
<td style="text-align: right;">2.162</td>
<td style="text-align: right;">54.05</td>
<td style="text-align: right;">21.62</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_04_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">10.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">39486</td>
<td>6.4</td>
<td style="text-align: right;">12.727</td>
<td style="text-align: right;">318.18</td>
<td style="text-align: right;">29.74</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_05_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">7.9</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">22099</td>
<td>2.7</td>
<td style="text-align: right;">7.007</td>
<td style="text-align: right;">175.17</td>
<td style="text-align: right;">22.17</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_06_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">11.0</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">97291</td>
<td>6.0</td>
<td style="text-align: right;">31.745</td>
<td style="text-align: right;">793.63</td>
<td style="text-align: right;">72.15</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_07_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">6.1</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">5076</td>
<td>5.4</td>
<td style="text-align: right;">1.406</td>
<td style="text-align: right;">35.15</td>
<td style="text-align: right;">5.76</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_08_ambient</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">24.8</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">200961</td>
<td>0.2</td>
<td style="text-align: right;">65.853</td>
<td style="text-align: right;">1646.32</td>
<td style="text-align: right;">66.38</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_01_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">9.6</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">31844</td>
<td>5.0</td>
<td style="text-align: right;">10.213</td>
<td style="text-align: right;">255.32</td>
<td style="text-align: right;">26.60</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_02_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">5679</td>
<td>6.6</td>
<td style="text-align: right;">1.605</td>
<td style="text-align: right;">40.12</td>
<td style="text-align: right;">4.36</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_03_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">3.1</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">4832</td>
<td>9.9</td>
<td style="text-align: right;">1.326</td>
<td style="text-align: right;">33.15</td>
<td style="text-align: right;">10.69</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_04_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">12.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">5075</td>
<td>30.1</td>
<td style="text-align: right;">1.406</td>
<td style="text-align: right;">35.15</td>
<td style="text-align: right;">2.83</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_05_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">25.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">94104</td>
<td>4.9</td>
<td style="text-align: right;">30.697</td>
<td style="text-align: right;">767.42</td>
<td style="text-align: right;">29.86</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_06_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">13.0</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">56800</td>
<td>1.9</td>
<td style="text-align: right;">18.424</td>
<td style="text-align: right;">460.59</td>
<td style="text-align: right;">35.43</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1_07_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">6.1</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">21660</td>
<td>4.1</td>
<td style="text-align: right;">6.862</td>
<td style="text-align: right;">171.56</td>
<td style="text-align: right;">28.12</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">1_08_36C</td>
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">8.8</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">46235</td>
<td>3.5</td>
<td style="text-align: right;">14.948</td>
<td style="text-align: right;">373.69</td>
<td style="text-align: right;">42.46</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_01_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">7.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">7336</td>
<td>3.3</td>
<td style="text-align: right;">2.150</td>
<td style="text-align: right;">53.75</td>
<td style="text-align: right;">7.36</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_02_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">4.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">4991</td>
<td>4.7</td>
<td style="text-align: right;">1.378</td>
<td style="text-align: right;">34.45</td>
<td style="text-align: right;">7.83</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_03_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">11467</td>
<td>5.1</td>
<td style="text-align: right;">3.509</td>
<td style="text-align: right;">87.72</td>
<td style="text-align: right;">20.40</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_04_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">1.8</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">5653</td>
<td>6.4</td>
<td style="text-align: right;">1.596</td>
<td style="text-align: right;">39.90</td>
<td style="text-align: right;">22.17</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_05_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">70209</td>
<td>1.1</td>
<td style="text-align: right;">22.835</td>
<td style="text-align: right;">570.88</td>
<td style="text-align: right;">62.05</td>
<td style="text-align: left;">NO - extrapolated</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_06_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">3649</td>
<td>6.5</td>
<td style="text-align: right;">0.937</td>
<td style="text-align: right;">23.42</td>
<td style="text-align: right;">5.45</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_07_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">9969</td>
<td>4.9</td>
<td style="text-align: right;">3.016</td>
<td style="text-align: right;">75.40</td>
<td style="text-align: right;">31.42</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_08_ambient</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">7.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">2678</td>
<td>5.3</td>
<td style="text-align: right;">0.617</td>
<td style="text-align: right;">15.43</td>
<td style="text-align: right;">2.09</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_01_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">01</td>
<td style="text-align: right;">7.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">14413</td>
<td>5.9</td>
<td style="text-align: right;">4.478</td>
<td style="text-align: right;">111.95</td>
<td style="text-align: right;">14.54</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_02_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">02</td>
<td style="text-align: right;">15.7</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">12523</td>
<td>4.4</td>
<td style="text-align: right;">3.856</td>
<td style="text-align: right;">96.41</td>
<td style="text-align: right;">6.14</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_03_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">03</td>
<td style="text-align: right;">10.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">43857</td>
<td>3.2</td>
<td style="text-align: right;">14.165</td>
<td style="text-align: right;">354.13</td>
<td style="text-align: right;">34.05</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_04_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">04</td>
<td style="text-align: right;">11.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">23983</td>
<td>2.2</td>
<td style="text-align: right;">7.627</td>
<td style="text-align: right;">190.67</td>
<td style="text-align: right;">16.87</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_05_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">05</td>
<td style="text-align: right;">9.2</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">49781</td>
<td>4.3</td>
<td style="text-align: right;">16.114</td>
<td style="text-align: right;">402.85</td>
<td style="text-align: right;">43.79</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_06_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">06</td>
<td style="text-align: right;">4.3</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">14106</td>
<td>3.2</td>
<td style="text-align: right;">4.377</td>
<td style="text-align: right;">109.43</td>
<td style="text-align: right;">25.45</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="odd">
<td style="text-align: left;">9_07_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">07</td>
<td style="text-align: right;">2.4</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">2408</td>
<td>11.0</td>
<td style="text-align: right;">0.528</td>
<td style="text-align: right;">13.21</td>
<td style="text-align: right;">5.50</td>
<td style="text-align: left;">yes</td>
</tr>
<tr class="even">
<td style="text-align: left;">9_08_36C</td>
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: left;">08</td>
<td style="text-align: right;">4.9</td>
<td style="text-align: right;">25</td>
<td style="text-align: right;">18651</td>
<td>6.6</td>
<td style="text-align: right;">5.872</td>
<td style="text-align: right;">146.81</td>
<td style="text-align: right;">29.96</td>
<td style="text-align: left;">yes</td>
</tr>
</tbody>
</table>
<p>Per-sample glycogen quantification (mean of technical triplicate)</p>
<pre><code>--- sample_table: formatted per-sample results written to CSV ---

tibble [32 × 12] (S3: tbl_df/tbl/data.frame)
 $ Sample                        : chr [1:32] "1_01_ambient" "1_02_ambient" "1_03_ambient" "1_04_ambient" ...
 $ Family                        : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ Temperature                   : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 1 1 2 2 ...
 $ Individual                    : chr [1:32] "01" "02" "03" "04" ...
 $ Tissue (mg)                   : num [1:32] 7 4.7 2.5 10.7 7.9 11 6.1 24.8 9.6 9.2 ...
 $ Dilution                      : num [1:32] 25 25 25 25 25 25 25 25 25 25 ...
 $ Mean lum.                     : num [1:32] 10802 14632 7373 39486 22099 ...
 $ CV (%)                        : num [1:32] 5 1.3 3.8 6.4 2.7 6 5.4 0.2 5 6.6 ...
 $ Well glycogen (ug/mL)         : num [1:32] 3.29 4.55 2.16 12.73 7.01 ...
 $ Homogenate glycogen (ug/mL)   : num [1:32] 82.2 113.8 54 318.2 175.2 ...
 $ Normalized glycogen (ug/mL/mg): num [1:32] 11.8 24.2 21.6 29.7 22.2 ...
 $ In std range                  : chr [1:32] "yes" "yes" "yes" "yes" ...</code></pre>
</section>
<section id="family-and-temperature-comparisons" class="level1">
<h1>7 FAMILY AND TEMPERATURE COMPARISONS</h1>
<section id="group-summary-statistics" class="level2">
<h2 class="anchored" data-anchor-id="group-summary-statistics">7.1 Group summary statistics</h2>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1">group_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature =</span> temperature) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb34-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb34-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(norm_glycogen),</span>
<span id="cb34-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(norm_glycogen),</span>
<span id="cb34-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()),</span>
<span id="cb34-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(norm_glycogen),</span>
<span id="cb34-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">min    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(norm_glycogen),</span>
<span id="cb34-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(norm_glycogen),</span>
<span id="cb34-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb34-12">  )</span>
<span id="cb34-13"></span>
<span id="cb34-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(group_summary, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb34-15">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen (ug/mL per mg tissue) by family and temperature"</span>)</span>
<span id="cb34-16"></span>
<span id="cb34-17"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(group_summary, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"group_summary_stats.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb34-18"></span>
<span id="cb34-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Same summary excluding the 4 extrapolated samples:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-20">group_summary_inrange <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(in_std_range) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Family =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">Temperature =</span> temperature) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(norm_glycogen), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(norm_glycogen),</span>
<span id="cb34-24">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(norm_glycogen), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb34-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(group_summary_inrange), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>)</span>
<span id="cb34-26"></span>
<span id="cb34-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- group_summary: family x temperature summary, all 32 samples ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(group_summary)</span>
<span id="cb34-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- group_summary_inrange: same summary, extrapolated samples excluded ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb34-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(group_summary_inrange)</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 14%">
<col style="width: 18%">
<col style="width: 7%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 8%">
<col style="width: 11%">
<col style="width: 8%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Temperature</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">mean</th>
<th style="text-align: right;">sd</th>
<th style="text-align: right;">se</th>
<th style="text-align: right;">median</th>
<th style="text-align: right;">min</th>
<th style="text-align: right;">max</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">31.72</td>
<td style="text-align: right;">24.38</td>
<td style="text-align: right;">8.62</td>
<td style="text-align: right;">23.19</td>
<td style="text-align: right;">5.76</td>
<td style="text-align: right;">72.15</td>
</tr>
<tr class="even">
<td style="text-align: left;">Family 1</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">22.55</td>
<td style="text-align: right;">14.75</td>
<td style="text-align: right;">5.22</td>
<td style="text-align: right;">27.36</td>
<td style="text-align: right;">2.83</td>
<td style="text-align: right;">42.46</td>
</tr>
<tr class="odd">
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">ambient</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">19.84</td>
<td style="text-align: right;">19.80</td>
<td style="text-align: right;">7.00</td>
<td style="text-align: right;">14.12</td>
<td style="text-align: right;">2.09</td>
<td style="text-align: right;">62.05</td>
</tr>
<tr class="even">
<td style="text-align: left;">Family 9</td>
<td style="text-align: left;">36C</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">22.04</td>
<td style="text-align: right;">13.63</td>
<td style="text-align: right;">4.82</td>
<td style="text-align: right;">21.16</td>
<td style="text-align: right;">5.50</td>
<td style="text-align: right;">43.79</td>
</tr>
</tbody>
</table>
<p>Normalized glycogen (ug/mL per mg tissue) by family and temperature</p>
<pre><code>Same summary excluding the 4 extrapolated samples:

   Family Temperature n  mean     sd median
 Family 1     ambient 6 19.21  8.795  21.90
 Family 1         36C 7 21.50 15.612  26.60
 Family 9     ambient 7 13.82 10.863   7.83
 Family 9         36C 8 22.04 13.632  21.16

--- group_summary: family x temperature summary, all 32 samples ---

tibble [4 × 9] (S3: tbl_df/tbl/data.frame)
 $ Family     : Factor w/ 2 levels "Family 1","Family 9": 1 1 2 2
 $ Temperature: Factor w/ 2 levels "ambient","36C": 1 2 1 2
 $ n          : int [1:4] 8 8 8 8
 $ mean       : num [1:4] 31.7 22.5 19.8 22
 $ sd         : num [1:4] 24.4 14.8 19.8 13.6
 $ se         : num [1:4] 8.62 5.22 7 4.82
 $ median     : num [1:4] 23.2 27.4 14.1 21.2
 $ min        : num [1:4] 5.76 2.83 2.09 5.5
 $ max        : num [1:4] 72.1 42.5 62.1 43.8

--- group_summary_inrange: same summary, extrapolated samples excluded ---

tibble [4 × 6] (S3: tbl_df/tbl/data.frame)
 $ Family     : Factor w/ 2 levels "Family 1","Family 9": 1 1 2 2
 $ Temperature: Factor w/ 2 levels "ambient","36C": 1 2 1 2
 $ n          : int [1:4] 6 7 7 8
 $ mean       : num [1:4] 19.2 21.5 13.8 22
 $ sd         : num [1:4] 8.8 15.6 10.9 13.6
 $ median     : num [1:4] 21.9 26.6 7.83 21.16</code></pre>
</section>
<section id="plot-glycogen-by-family-and-temperature" class="level2">
<h2 class="anchored" data-anchor-id="plot-glycogen-by-family-and-temperature">7.2 Plot: glycogen by family and temperature</h2>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">group_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(sample_glycogen,</span>
<span id="cb36-2">                     <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> norm_glycogen, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.35</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>,</span>
<span id="cb36-4">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_dodge</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">shape =</span> in_std_range, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> family),</span>
<span id="cb36-6">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">position =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">position_jitterdodge</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">jitter.width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dodge.width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.75</span>,</span>
<span id="cb36-7">                                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">seed =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">42</span>),</span>
<span id="cb36-8">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.8</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1b7837"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#762a83"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1b7837"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#762a83"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_shape_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">16</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FALSE"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>),</span>
<span id="cb36-12">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"within standard curve"</span>,</span>
<span id="cb36-13">                                <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FALSE"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"extrapolated"</span>),</span>
<span id="cb36-14">                     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb36-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Ctenidia glycogen content by USDA family and temperature exposure"</span>,</span>
<span id="cb36-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Each point is one individual (mean of technical triplicate); n = 8 per group"</span>,</span>
<span id="cb36-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature exposure"</span>,</span>
<span id="cb36-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Normalized glycogen (ug/mL per mg tissue)"</span>,</span>
<span id="cb36-20">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"x = value extrapolated above the 20 ug/mL top standard"</span></span>
<span id="cb36-21">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb36-23">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(</span>
<span id="cb36-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">14</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb36-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb36-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">legend.position =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bottom"</span></span>
<span id="cb36-27">  )</span>
<span id="cb36-28"></span>
<span id="cb36-29"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- group_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb36-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(group_plot)</span>
<span id="cb36-31"></span>
<span id="cb36-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glycogen_by_family_temperature.png"</span>), group_plot,</span>
<span id="cb36-33">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb36-34"></span>
<span id="cb36-35">group_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/Gen5-20260730-mgig-fams1_9-glycogen-glo_files/figure-gfm/plot-family-temp-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- group_plot: ggplot object structure ---

data: sample_id, family, individual, temperature, weight_mg, dilution,
  n_reps, mean_lum, sd_lum, cv_lum, well_conc_ug_mL,
  homogenate_conc_ug_mL, norm_glycogen, in_std_range [32x14]
mapping:  x = ~temperature, y = ~norm_glycogen, fill = ~family
scales:   fill, colour, shape 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_boxplot: outliers = TRUE, outlier_gp = list(colour = NULL, fill = NULL, shape = NA, size = NULL, stroke = 0.5, alpha = NULL), whisker_gp = list(colour = NULL, linetype = NULL, linewidth = NULL), staple_gp = list(colour = NULL, linetype = NULL, linewidth = NULL), median_gp = list(colour = NULL, linetype = NULL, linewidth = NULL), box_gp = list(colour = NULL, linetype = NULL, linewidth = NULL), notch = FALSE, notchwidth = 0.5, staplewidth = 0, varwidth = FALSE, na.rm = FALSE, orientation = NA
stat_boxplot: na.rm = FALSE, orientation = NA, width = 0.6
position_dodge 

mapping: colour = ~family, shape = ~in_std_range, group = ~family 
geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_jitterdodge </code></pre>
<p>Note: this boxplot uses a linear y-axis. Given the ~30-fold range of values and the four extrapolated high points, the linear scale visually compresses the lower/mid-range groups toward the bottom of the plot; a log-scale version was reviewed and rejected in favor of this one, but keep the compression in mind when comparing box heights/positions across groups by eye – the statistical tests below are unaffected either way, since they are run on log10-transformed values regardless of which scale is plotted.</p>
</section>
<section id="plot-family-x-temperature-interaction" class="level2">
<h2 class="anchored" data-anchor-id="plot-family-x-temperature-interaction">7.3 Plot: family x temperature interaction</h2>
<p>The boxplot above shows the full per-individual distribution, which makes it hard to visually judge whether the family gap widens, narrows, or reverses with temperature – exactly the question an interaction test asks. The plot below isolates that comparison: group means +/- SEM only, connected by family, so that the two line slopes are a visual proxy for the interaction effect size being tested in the ANOVA (Family x Temperature, p = 0.268 on log10-transformed values; see Statistical tests below). Near-parallel lines indicate no interaction; converging, diverging, or crossing lines would indicate the families respond differently to temperature.</p>
<div class="sourceCode" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1">interaction_data <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> sample_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family, temperature) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_glyc =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(norm_glycogen),</span>
<span id="cb38-4">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_glyc   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>()),</span>
<span id="cb38-5">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb38-6"></span>
<span id="cb38-7">interaction_plot <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(interaction_data,</span>
<span id="cb38-8">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_glyc,</span>
<span id="cb38-9">                               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">color =</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> family)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_errorbar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_glyc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_glyc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_glyc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_glyc),</span>
<span id="cb38-12">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.08</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.9</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_color_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#1b7837"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span> <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#762a83"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(</span>
<span id="cb38-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family x temperature interaction"</span>,</span>
<span id="cb38-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">subtitle =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group means +/- SEM, linear scale (n = 8 per group)"</span>,</span>
<span id="cb38-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Temperature exposure"</span>,</span>
<span id="cb38-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean normalized glycogen (ug/mL/mg tissue)"</span></span>
<span id="cb38-20">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_bw</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb38-22">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plot.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>),</span>
<span id="cb38-23">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.title =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">11</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb38-24"></span>
<span id="cb38-25"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--- interaction_data: group means and SEM plotted below ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb38-26"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(interaction_data)</span>
<span id="cb38-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- interaction_plot: ggplot object structure ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb38-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(interaction_plot)</span>
<span id="cb38-29"></span>
<span id="cb38-30"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"glycogen_family_temperature_interaction.png"</span>), interaction_plot,</span>
<span id="cb38-31">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">dpi =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">300</span>)</span>
<span id="cb38-32"></span>
<span id="cb38-33">interaction_plot</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/Gen5-20260730-mgig-fams1_9-glycogen-glo_files/figure-gfm/plot-interaction-1.png" class="img-fluid"><!-- --></p>
<pre><code>--- interaction_data: group means and SEM plotted below ---
tibble [4 × 4] (S3: tbl_df/tbl/data.frame)
 $ family     : Factor w/ 2 levels "Family 1","Family 9": 1 1 2 2
 $ temperature: Factor w/ 2 levels "ambient","36C": 1 2 1 2
 $ mean_glyc  : num [1:4] 31.7 22.5 19.8 22
 $ se_glyc    : num [1:4] 8.62 5.22 7 4.82

--- interaction_plot: ggplot object structure ---
data: family, temperature, mean_glyc, se_glyc [4x4]
mapping:  x = ~temperature, y = ~mean_glyc, colour = ~family, group = ~family
scales:   colour 
faceting:  &lt;empty&gt; 
-----------------------------------
geom_line: na.rm = FALSE, orientation = NA, arrow = NULL, arrow.fill = NULL, lineend = butt, linejoin = round, linemitre = 10
stat_identity: na.rm = FALSE
position_identity 

mapping: ymin = ~mean_glyc - se_glyc, ymax = ~mean_glyc + se_glyc 
geom_errorbar: na.rm = FALSE, orientation = NA, lineend = butt, width = 0.08
stat_identity: na.rm = FALSE
position_identity 

geom_point: na.rm = FALSE
stat_identity: na.rm = FALSE
position_identity </code></pre>
</section>
<section id="statistical-tests" class="level2">
<h2 class="anchored" data-anchor-id="statistical-tests">7.4 Statistical tests</h2>
<p>Normalized glycogen spans roughly two orders of magnitude and is strongly right-skewed, so residuals from a two-way ANOVA on the raw scale are non-normal. A log10 transform fixes this, so the log-scale ANOVA is the primary test and the raw-scale ANOVA plus distribution-free rank tests are reported alongside it.</p>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">aov_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aov</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sample_glycogen)</span>
<span id="cb40-2">aov_log <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aov</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log10</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sample_glycogen)</span>
<span id="cb40-3"></span>
<span id="cb40-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Shapiro-Wilk on ANOVA residuals:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  raw scale:   p ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signif</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">shapiro.test</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">residuals</span>(aov_raw))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"  log10 scale: p ="</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signif</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">shapiro.test</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">residuals</span>(aov_log))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">Bartlett test of homogeneity of variance (log10 scale): p ="</span>,</span>
<span id="cb40-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">signif</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bartlett.test</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log10</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">interaction</span>(family, temperature),</span>
<span id="cb40-9">                         <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sample_glycogen)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-10"></span>
<span id="cb40-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- aov_raw: two-way ANOVA model, raw scale ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-12"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(aov_raw, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb40-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- aov_log: two-way ANOVA model, log10 scale (primary test) ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb40-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(aov_log, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">max.level =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">give.attr =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span></code></pre></div>
<pre><code>Shapiro-Wilk on ANOVA residuals:
  raw scale:   p = 0.02786 
  log10 scale: p = 0.1979 

Bartlett test of homogeneity of variance (log10 scale): p = 0.7831 

--- aov_raw: two-way ANOVA model, raw scale ---
List of 13
 $ coefficients : Named num [1:4] 31.72 -11.88 -9.18 11.37
 $ residuals    : Named num [1:32] -19.97 -7.52 -10.1 -1.99 -9.55 ...
 $ effects      : Named num [1:32] -135.98 -17.51 -9.88 -16.08 -5.45 ...
 $ rank         : int 4
 $ fitted.values: Named num [1:32] 31.7 31.7 31.7 31.7 31.7 ...
 $ assign       : int [1:4] 0 1 2 3
 $ qr           :List of 5
 $ df.residual  : int 28
 $ contrasts    :List of 2
 $ xlevels      :List of 2
 $ call         : language aov(formula = norm_glycogen ~ family * temperature, data = sample_glycogen)
 $ terms        :Classes 'terms', 'formula'  language norm_glycogen ~ family * temperature
 $ model        :'data.frame':  32 obs. of  3 variables:

--- aov_log: two-way ANOVA model, log10 scale (primary test) ---
List of 13
 $ coefficients : Named num [1:4] 1.381 -0.286 -0.175 0.327
 $ residuals    : Named num [1:32] -0.31106 0.00278 -0.04627 0.09219 -0.03526 ...
 $ effects      : Named num [1:32] -6.97065 -0.3466 -0.03325 -0.46218 -0.00809 ...
 $ rank         : int 4
 $ fitted.values: Named num [1:32] 1.38 1.38 1.38 1.38 1.38 ...
 $ assign       : int [1:4] 0 1 2 3
 $ qr           :List of 5
 $ df.residual  : int 28
 $ contrasts    :List of 2
 $ xlevels      :List of 2
 $ call         : language aov(formula = log10(norm_glycogen) ~ family * temperature, data = sample_glycogen)
 $ terms        :Classes 'terms', 'formula'  language log10(norm_glycogen) ~ family * temperature
 $ model        :'data.frame':  32 obs. of  3 variables:</code></pre>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"=== Two-way ANOVA on log10(normalized glycogen) [primary] ===</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(aov_log))</span>
<span id="cb42-3"></span>
<span id="cb42-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">=== Two-way ANOVA on raw normalized glycogen [for reference] ===</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb42-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(aov_raw))</span></code></pre></div>
<pre><code>=== Two-way ANOVA on log10(normalized glycogen) [primary] ===
                   Df Sum Sq Mean Sq F value Pr(&gt;F)
family              1  0.120 0.12013   0.719  0.404
temperature         1  0.001 0.00111   0.007  0.936
family:temperature  1  0.214 0.21361   1.278  0.268
Residuals          28  4.681 0.16717               

=== Two-way ANOVA on raw normalized glycogen [for reference] ===
                   Df Sum Sq Mean Sq F value Pr(&gt;F)
family              1    307   306.7   0.883  0.356
temperature         1     98    97.5   0.281  0.600
family:temperature  1    259   258.6   0.744  0.396
Residuals          28   9730   347.5               </code></pre>
<div class="sourceCode" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"=== Wilcoxon rank-sum: family 1 vs family 9 (temperatures pooled) ===</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sample_glycogen))</span>
<span id="cb44-3"></span>
<span id="cb44-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"=== Wilcoxon rank-sum: ambient vs 36C (families pooled) ===</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> sample_glycogen))</span>
<span id="cb44-6"></span>
<span id="cb44-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"=== Stratified comparisons ===</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-8">strat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rbind</span>(</span>
<span id="cb44-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient vs 36C, within family 1"</span>,</span>
<span id="cb44-10">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> temperature,</span>
<span id="cb44-11">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_glycogen, family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 1"</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value),</span>
<span id="cb44-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient vs 36C, within family 9"</span>,</span>
<span id="cb44-13">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> temperature,</span>
<span id="cb44-14">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_glycogen, family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family 9"</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value),</span>
<span id="cb44-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family 1 vs 9, within ambient"</span>,</span>
<span id="cb44-16">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family,</span>
<span id="cb44-17">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_glycogen, temperature <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ambient"</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value),</span>
<span id="cb44-18">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">data.frame</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family 1 vs 9, within 36C"</span>,</span>
<span id="cb44-19">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">p =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family,</span>
<span id="cb44-20">                             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_glycogen, temperature <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"36C"</span>))<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p.value)</span>
<span id="cb44-21">)</span>
<span id="cb44-22">strat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p_holm <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">p.adjust</span>(strat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"holm"</span>)</span>
<span id="cb44-23"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(strat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>,</span>
<span id="cb44-24">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Comparison"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p (Wilcoxon)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"p (Holm-adjusted)"</span>),</span>
<span id="cb44-25">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Stratified pairwise comparisons of normalized glycogen"</span>)</span>
<span id="cb44-26"></span>
<span id="cb44-27"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- strat: stratified Wilcoxon comparisons with Holm-adjusted p-values ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb44-28"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(strat)</span></code></pre></div>
<pre><code>=== Wilcoxon rank-sum: family 1 vs family 9 (temperatures pooled) ===

    Wilcoxon rank sum exact test

data:  norm_glycogen by family
W = 150, p-value = 0.423
alternative hypothesis: true location shift is not equal to 0

=== Wilcoxon rank-sum: ambient vs 36C (families pooled) ===

    Wilcoxon rank sum exact test

data:  norm_glycogen by temperature
W = 123, p-value = 0.8672
alternative hypothesis: true location shift is not equal to 0

=== Stratified comparisons ===</code></pre>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Comparison</th>
<th style="text-align: right;">p (Wilcoxon)</th>
<th style="text-align: right;">p (Holm-adjusted)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">ambient vs 36C, within family 1</td>
<td style="text-align: right;">0.7984</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">ambient vs 36C, within family 9</td>
<td style="text-align: right;">0.5737</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family 1 vs 9, within ambient</td>
<td style="text-align: right;">0.1949</td>
<td style="text-align: right;">0.7795</td>
</tr>
<tr class="even">
<td style="text-align: left;">family 1 vs 9, within 36C</td>
<td style="text-align: right;">0.9591</td>
<td style="text-align: right;">1.0000</td>
</tr>
</tbody>
</table>
<p>Stratified pairwise comparisons of normalized glycogen</p>
<pre><code>--- strat: stratified Wilcoxon comparisons with Holm-adjusted p-values ---
'data.frame':   4 obs. of  3 variables:
 $ comparison: chr  "ambient vs 36C, within family 1" "ambient vs 36C, within family 9" "family 1 vs 9, within ambient" "family 1 vs 9, within 36C"
 $ p         : num  0.798 0.574 0.195 0.959
 $ p_holm    : num  1 1 0.779 1</code></pre>
<section id="sensitivity-analysis-excluding-extrapolated-samples" class="level3">
<h3 class="anchored" data-anchor-id="sensitivity-analysis-excluding-extrapolated-samples">7.4.1 Sensitivity analysis: excluding extrapolated samples</h3>
<p>Three of the four samples that read above the top standard are family 1 (<code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>) and one is family 9 (<code>9_05_ambient</code>), so it is important to confirm they are not driving any apparent family or temperature effect.</p>
<div class="sourceCode" id="cb47" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb47-1">in_range_only <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(sample_glycogen, in_std_range)</span>
<span id="cb47-2"></span>
<span id="cb47-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"n retained:"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(in_range_only), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"of"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sample_glycogen), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"=== Two-way ANOVA on log10(normalized glycogen), in-range samples only ===</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summary</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aov</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">log10</span>(norm_glycogen) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> temperature, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> in_range_only)))</span>
<span id="cb47-6"></span>
<span id="cb47-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">=== Wilcoxon, family 1 vs 9 (in-range only, temperatures pooled) ===</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(norm_glycogen <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> in_range_only))</span>
<span id="cb47-9"></span>
<span id="cb47-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">--- in_range_only: sample_glycogen with extrapolated samples removed ---</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb47-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(in_range_only)</span></code></pre></div>
<pre><code>n retained: 28 of 32 

=== Two-way ANOVA on log10(normalized glycogen), in-range samples only ===
                   Df Sum Sq Mean Sq F value Pr(&gt;F)
family              1  0.030 0.03027   0.209  0.652
temperature         1  0.079 0.07915   0.546  0.467
family:temperature  1  0.168 0.16849   1.162  0.292
Residuals          24  3.479 0.14497               

=== Wilcoxon, family 1 vs 9 (in-range only, temperatures pooled) ===

    Wilcoxon rank sum exact test

data:  norm_glycogen by family
W = 107, p-value = 0.6832
alternative hypothesis: true location shift is not equal to 0


--- in_range_only: sample_glycogen with extrapolated samples removed ---
tibble [28 × 14] (S3: tbl_df/tbl/data.frame)
 $ sample_id            : chr [1:28] "1_01_ambient" "1_02_ambient" "1_03_ambient" "1_04_ambient" ...
 $ family               : Factor w/ 2 levels "Family 1","Family 9": 1 1 1 1 1 1 1 1 1 1 ...
 $ individual           : chr [1:28] "01" "02" "03" "04" ...
 $ temperature          : Factor w/ 2 levels "ambient","36C": 1 1 1 1 1 1 2 2 2 2 ...
 $ weight_mg            : num [1:28] 7 4.7 2.5 10.7 7.9 6.1 9.6 9.2 3.1 12.4 ...
 $ dilution             : num [1:28] 25 25 25 25 25 25 25 25 25 25 ...
 $ n_reps               : int [1:28] 3 3 3 3 3 3 3 3 3 3 ...
 $ mean_lum             : num [1:28] 10802 14632 7373 39486 22099 ...
 $ sd_lum               : num [1:28] 543 189 278 2525 603 ...
 $ cv_lum               : num [1:28] 5.03 1.29 3.77 6.4 2.73 ...
 $ well_conc_ug_mL      : num [1:28] 3.29 4.55 2.16 12.73 7.01 ...
 $ homogenate_conc_ug_mL: num [1:28] 82.2 113.8 54 318.2 175.2 ...
 $ norm_glycogen        : num [1:28] 11.7 24.2 21.6 29.7 22.2 ...
 $ in_std_range         : logi [1:28] TRUE TRUE TRUE TRUE TRUE TRUE ...</code></pre>
<div class="sourceCode" id="cb49" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Persist the tidy well-level data alongside the summaries for downstream reuse</span></span>
<span id="cb49-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(samples_wells <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb49-3">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(plate, well, sample_id, family, temperature, individual,</span>
<span id="cb49-4">                   weight_mg, dilution, luminescence),</span>
<span id="cb49-5">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_level_luminescence.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb49-6"></span>
<span id="cb49-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(glycogen_summary_data,</span>
<span id="cb49-8">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"standard_curve_summary.csv"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb49-9"></span>
<span id="cb49-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Files written to"</span>, output_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb49-11"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" -"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list.files</span>(output_dir)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span></code></pre></div>
<pre><code>Files written to ../output/Gen5-20260730-mgig-fams1_9-glycogen-glo :
 - glycogen_by_family_temperature.png
 - glycogen_family_temperature_interaction.png
 - glycogen_standard_curve_loglog.png
 - glycogen_standard_curve.png
 - group_summary_stats.csv
 - plate01_luminescence_map.png
 - sample_glycogen_results.csv
 - standard_curve_summary.csv
 - tissue_weight_vs_glycogen.png
 - well_level_luminescence.csv</code></pre>
</section>
</section>
</section>
<section id="summary" class="level1">
<h1>8 SUMMARY</h1>
<p><strong>Standard curve.</strong> The four-point glycogen curve plus zero standard is linear across the full range when fit to concentration means (R² = 0.9999), but the fit is dominated by the single 20 µg/mL point; fit to individual replicate wells R² drops to 0.986, and the 20 µg/mL standard itself has a 12.6% CV. The three lowest standards (0.02-2 µg/mL) are barely resolved above the buffer-only background (~910 RLU). Adding intermediate standards (e.g.&nbsp;5 and 10 µg/mL) and tightening replicate pipetting at the top standard would make back-calculation in the mid-range considerably more trustworthy.</p>
<p><strong>Technical quality.</strong> Triplicate CVs are good overall (median 4.9%, mean 5.5%); only <code>1_04_36C</code> exceeds 15% (30.1%, driven by one low replicate). The plate map shows no obvious row-wise gradient across the family/temperature row-blocks (A/B, C/D, E/F, G/H), so the row-block design does not appear to be confounded with plate position.</p>
<p><strong>Range.</strong> Four samples read above the top standard and are extrapolated: <code>1_08_ambient</code>, <code>1_06_ambient</code>, <code>1_05_36C</code>, <code>9_05_ambient</code>. <code>1_08_ambient</code> in particular (~201,000 RLU, 3.3× the top standard) should be re-run at a higher dilution; the other three are more modestly above range (~94,000-97,000 RLU). The extrapolated samples are not concentrated in a single family.</p>
<p>Recommended re-assay dilutions for these four samples, targeting a well-level concentration near the middle of the quantifiable curve (~10 µg/mL, i.e.&nbsp;roughly the midpoint between the 2 and 20 µg/mL standards, corresponding to ~10 µg/mL/mg tissue-normalized once re-scaled by weight) rather than just clearing the 20 µg/mL ceiling:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 20%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Sample</th>
<th style="text-align: right;">Mean luminescence (RLU, current 1:25)</th>
<th style="text-align: right;">Current dilution</th>
<th style="text-align: right;">Recommended total dilution</th>
<th style="text-align: right;">Approx. fold increase</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>1_08_ambient</code></td>
<td style="text-align: right;">~201,000</td>
<td style="text-align: right;">1:25</td>
<td style="text-align: right;">~1:150</td>
<td style="text-align: right;">~6×</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>1_06_ambient</code></td>
<td style="text-align: right;">~97,300</td>
<td style="text-align: right;">1:25</td>
<td style="text-align: right;">~1:80</td>
<td style="text-align: right;">~3×</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>1_05_36C</code></td>
<td style="text-align: right;">~94,100</td>
<td style="text-align: right;">1:25</td>
<td style="text-align: right;">~1:75</td>
<td style="text-align: right;">~3×</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>9_05_ambient</code></td>
<td style="text-align: right;">~70,200</td>
<td style="text-align: right;">1:25</td>
<td style="text-align: right;">~1:60</td>
<td style="text-align: right;">~2×</td>
</tr>
</tbody>
</table>
<p>These are rough targets based on each sample’s current homogenate-level glycogen estimate (extrapolated off the standard curve) and are intended as a starting point for the next dilution series, not a precise prescription – actual optimal dilution should be confirmed empirically, since the extrapolated homogenate concentrations that these estimates are based on are themselves the values in question.</p>
<p><strong>Family effect.</strong> Pooling temperatures, group means are 27.1 (family 1) vs 20.9 (family 9) µg/mL/mg tissue. The effect is not significant in the log-scale two-way ANOVA (F = 0.72, p = 0.404) or by Wilcoxon (W = 150, p = 0.423). None of the four stratified family/temperature contrasts reach significance either before or after Holm correction (smallest unadjusted p = 0.195, within ambient).</p>
<p><strong>Temperature effect.</strong> No detectable effect of 36°C exposure. Neither the main effect (log-scale ANOVA p = 0.936; Wilcoxon p = 0.867) nor the family × temperature interaction (p = 0.268) reaches significance. Group means by family and temperature are: family 1 ambient 31.7, family 1 36°C 22.5, family 9 ambient 19.8, family 9 36°C 22.0 µg/mL/mg tissue – no consistent within-family shift with temperature, and no interaction pattern suggestive of family-specific heat response.</p>
<p><strong>Weight relationship.</strong> Homogenate glycogen concentration correlates with input tissue weight (Spearman rho = 0.66, p &lt; 0.0001), as expected since larger samples were run at the same fixed dilution rather than volume-adjusted – this is a protocol artifact of fixed homogenization volume, not a biological signal. Weight-normalized glycogen shows a much weaker, non-significant residual correlation with weight (rho = 0.30, p = 0.10), consistent with the normalization step removing most, though perhaps not all, of that scaling effect. The residual association is small enough not to indicate a normalization failure, and since neither family nor temperature showed a significant effect in this dataset, it is not currently confounding those comparisons – but it would be worth revisiting if a future run shows a significant group difference alongside a weight imbalance between groups.</p>
<p><strong>Caveats.</strong></p>
<ol type="1">
<li>None of the family, temperature, or family × temperature effects are statistically significant at n = 8 per group – excluding the four extrapolated samples changes this picture only slightly (log-scale ANOVA family p = 0.652, temperature p = 0.467, interaction p = 0.292, n = 28), so the qualitative conclusion (no detectable family or temperature effect) is robust to that exclusion.</li>
<li>Standards were on a separate plate from the samples, so plate-to-plate signal offset is uncorrected. Including a short standard curve on each sample plate would remove this assumption.</li>
<li>Homogenization volume is not recorded in these files; normalized values are therefore per mL of homogenate per mg tissue. Group comparisons are unaffected provided the volume was constant, but absolute glycogen per mg tissue cannot be stated without it.</li>
</ol>


</section>

 ]]></description>
  <category>2026</category>
  <category>glycogen</category>
  <category>Glycogen-Glo</category>
  <category>SORMI</category>
  <category>Pacific oyster</category>
  <category>Magallana gigas</category>
  <category>Crassostrea gigas</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-30-Glycogen-Assay---SORMI-June-2026-M.gigas-USDA-Families-1-and-9-Comparisons-Using-Glycogen-Glo-Kit/</guid>
  <pubDate>Thu, 30 Jul 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Homogenization - June 2026 SORMI M.gigas Ctenidia from Families 1 and 9 for Glycogen Glo Assay</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-22-Homogenization---June-2026-SORMI-M.gigas-Ctenidia-from-Families-1-and-9-for-Glycogen-Glo-Assay/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>A large experiment and sampling event was conducted on <a href="https://github.com/RobertsLab/sormi-assay-development/tree/main/sampling-event-metadata/june-2026">20260626</a> (GitHub repo) as part of the <a href="https://github.com/RobertsLab/sormi-assay-development/tree/main"><code>sormi-assay-development</code> project</a> (GitHub repo). As part of this, we decided to evaluate glycogen content in ctenidia from two families of oysters (USDA Families 1 and 9) from the ambient and 36°C treatments using the Glycogen Glo Assay. Family selection was decided by Steven.</p>
</section>
<section id="materials-methods" class="level1">
<h1>MATERIALS &amp; METHODS</h1>
<p>Frozen ctenidia samples (stored at -80°C) from Families 1 and 9, ambient and 36°C treatments (n = 8 from each treatment in each family), were placed on dry ice. A small portion of each ctenidia sample was weighed (to the nearest 0.01 g) and placed into a 1.5mL Safe-Lock tube (Eppendorf) containting ~300uL of 0.5mm glass beads (Research Products International) and 500uL of PBS. Immediately after adding tissue, 250uL of 0.3N HCl was added and vortexed, per the Glycogen Glo Assay protocol. The samples were then homogenized in a Bullet Blender 5E Gold+ using the 1.5mL adapters. Homogenization was performed for 10 minutes at Speed 12. After homogenization, 250uL of TRIS Buffer was added to each tube and vortexed, per the Glycogen Glo Assay protocol. Samples were stored at -20°C until further processing.</p>
<p>Table of oyster IDs and weights (mg) of ctenidia samples used for the Glycogen Glo Assay:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>oyster_ID</th>
<th>weight.mg</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1-01-Ambient</td>
<td>7</td>
</tr>
<tr class="even">
<td>1-02-Ambient</td>
<td>4.7</td>
</tr>
<tr class="odd">
<td>1-03-Ambient</td>
<td>2.5</td>
</tr>
<tr class="even">
<td>1-04-Ambient</td>
<td>10.7</td>
</tr>
<tr class="odd">
<td>1-05-Ambient</td>
<td>7.9</td>
</tr>
<tr class="even">
<td>1-06-Ambient</td>
<td>11</td>
</tr>
<tr class="odd">
<td>1-07-Ambient</td>
<td>6.1</td>
</tr>
<tr class="even">
<td>1-08-Ambient</td>
<td>24.8</td>
</tr>
<tr class="odd">
<td>1-01-36C</td>
<td>9.6</td>
</tr>
<tr class="even">
<td>1-02-36C</td>
<td>9.2</td>
</tr>
<tr class="odd">
<td>1-03-36C</td>
<td>3.1</td>
</tr>
<tr class="even">
<td>1-04-36C</td>
<td>12.4</td>
</tr>
<tr class="odd">
<td>1-05-36C</td>
<td>25.7</td>
</tr>
<tr class="even">
<td>1-06-36C</td>
<td>13</td>
</tr>
<tr class="odd">
<td>1-07-36C</td>
<td>6.1</td>
</tr>
<tr class="even">
<td>1-08-36C</td>
<td>8.8</td>
</tr>
<tr class="odd">
<td>9-01-Ambient</td>
<td>7.3</td>
</tr>
<tr class="even">
<td>9-02-Ambient</td>
<td>4.4</td>
</tr>
<tr class="odd">
<td>9-03-Ambient</td>
<td>4.3</td>
</tr>
<tr class="even">
<td>9-04-Ambient</td>
<td>1.8</td>
</tr>
<tr class="odd">
<td>9-05-Ambient</td>
<td>18.6</td>
</tr>
<tr class="even">
<td>9-06-Ambient</td>
<td>2.8</td>
</tr>
<tr class="odd">
<td>9-07-Ambient</td>
<td>5.8</td>
</tr>
<tr class="even">
<td>9-08-Ambient</td>
<td>7.4</td>
</tr>
<tr class="odd">
<td>9-01-36C</td>
<td>7.7</td>
</tr>
<tr class="even">
<td>9-02-36C</td>
<td>15.7</td>
</tr>
<tr class="odd">
<td>9-03-36C</td>
<td>10.4</td>
</tr>
<tr class="even">
<td>9-04-36C</td>
<td>11.3</td>
</tr>
<tr class="odd">
<td>9-05-36C</td>
<td>9.2</td>
</tr>
<tr class="even">
<td>9-06-36C</td>
<td>4.3</td>
</tr>
<tr class="odd">
<td>9-07-36C</td>
<td>2.4</td>
</tr>
<tr class="even">
<td>9-08-36C</td>
<td>4.9</td>
</tr>
</tbody>
</table>
<p>For reference, here’s a link to the experiment metadata for the June 2026 SORMI experiment:</p>
<ul>
<li><a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/sampling-event-metadata/june-2026/sampling-log.csv">https://github.com/RobertsLab/sormi-assay-development/blob/main/sampling-event-metadata/june-2026/sampling-log.csv</a> (GitHub).</li>
</ul>


</section>

 ]]></description>
  <category>2026</category>
  <category>SORMI</category>
  <category>Magallana gigas</category>
  <category>ctenidia</category>
  <category>Pacific oyster</category>
  <category>Crassostrea gigas</category>
  <category>glycogen</category>
  <category>Glycogen Glo</category>
  <category>homogenization</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-22-Homogenization---June-2026-SORMI-M.gigas-Ctenidia-from-Families-1-and-9-for-Glycogen-Glo-Assay/</guid>
  <pubDate>Wed, 22 Jul 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Data Received - Full RNA-seq Data for Andy Dittman and NOAA</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-15-Data-Received---Full-RNA-seq-Data-for-Andy-Dittman-and-NOAA/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Received RNA-seq data for Andy Dittman at NOAA from UW’s Northwest Genomics Center. <a href="https://github.com/RobertsLab/resources/issues/2397">This is part of a project initiated a while ago</a> (GitHub Issue). The initial RNA submitted was potentially questionable, based on Bionalyzer RIN scores and <a href="../../../posts/2026/2026-05-08-Data-Received---RNA-seq-Subset-for-Andy-Dittman-and-NOAA/index.html">a subset of the data was previously received on 20260508</a> (Notebook entry) and <a href="../../../posts/2026/2026-05-19-FastQC-MultiQC---Andy-Dittman-Preliminary-RNA-seq-Data-on-Hyak/index.html">QC’d on 20260519</a> (Notebook entry). This is the remainder of the data that was sequenced and received.</p>
</section>
<section id="data" class="level1">
<h1>DATA</h1>
<p>Data was downloaded to our server, Owl, via GlobusConnect. It took a full 24hrs to complete.</p>
<p>Data is currently available at:</p>
<ul>
<li><a href="https://owl.fish.washington.edu/nightingales/dittman_grc_rnaseq_1/">https://owl.fish.washington.edu/nightingales/dittman_grc_rnaseq_1/</a></li>
</ul>
<p>MD5 checksums were verified:</p>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213507_sample_1703710_S21_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213524_sample_1703765_S143_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213501_sample_1703771_S148_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213492_sample_1703673_S126_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213476_sample_1703761_S139_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-6"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213518_sample_1703702_S14_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-7"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213562_sample_1703786_S64_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-8"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213525_sample_1703773_S53_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-9"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213489_sample_1703770_S147_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-10"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213557_sample_1703740_S42_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-11"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213487_sample_1703753_S132_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-12"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213567_sample_1703719_S26_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-13"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213554_sample_1703705_S17_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-14"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213566_sample_1703706_S18_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-15"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213528_sample_1703679_S129_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-16"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213513_sample_1703772_S52_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-17"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213508_sample_1703727_S30_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-18"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213546_sample_1703749_S49_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-19"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213485_sample_1703734_S36_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-20"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213529_sample_1703694_S7_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-21"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213510_sample_1703744_S46_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-22"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213565_sample_1703698_S10_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-23"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213498_sample_1703743_S45_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-24"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213542_sample_1703704_S16_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-25"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213508_sample_1703727_S30_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-26"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213553_sample_1703696_S9_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-27"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213493_sample_1703689_S4_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-28"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213550_sample_1703785_S63_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-29"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213515_sample_1703790_S66_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-30"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213510_sample_1703744_S46_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-31"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213504_sample_1703675_S127_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-32"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213473_sample_1703732_S35_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-33"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213520_sample_1703728_S31_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-34"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213517_sample_1703693_S6_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-35"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213483_sample_1703707_S19_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-36"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213534_sample_1703747_S48_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-37"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213541_sample_1703695_S8_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-38"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213486_sample_1703742_S44_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-39"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213524_sample_1703765_S143_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-40"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213545_sample_1703739_S41_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-41"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213479_sample_1703787_S149_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-42"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213543_sample_1703715_S24_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-43"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213496_sample_1703726_S29_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-44"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213553_sample_1703696_S9_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-45"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213566_sample_1703706_S18_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-46"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213476_sample_1703761_S139_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-47"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213494_sample_1703700_S12_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-48"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213549_sample_1703775_S55_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-49"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213539_sample_1703792_S68_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-50"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213555_sample_1703717_S25_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-51"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213538_sample_1703784_S62_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-52"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213498_sample_1703743_S45_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-53"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213489_sample_1703770_S147_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-54"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213478_sample_1703777_S57_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-55"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213497_sample_1703735_S37_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-56"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213504_sample_1703675_S127_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-57"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213519_sample_1703711_S22_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-58"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213537_sample_1703774_S54_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-59"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213555_sample_1703717_S25_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-60"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213531_sample_1703713_S23_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-61"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213522_sample_1703746_S47_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-62"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213474_sample_1703741_S43_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-63"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213544_sample_1703730_S33_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-64"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213532_sample_1703729_S32_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-65"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213474_sample_1703741_S43_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-66"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213543_sample_1703715_S24_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-67"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213514_sample_1703781_S60_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-68"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213497_sample_1703735_S37_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-69"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213516_sample_1703676_S128_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-70"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213509_sample_1703736_S38_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-71"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213558_sample_1703750_S50_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-72"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213490_sample_1703778_S58_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-73"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213517_sample_1703693_S6_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-74"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213522_sample_1703746_S47_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-75"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213487_sample_1703753_S132_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-76"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213539_sample_1703792_S68_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-77"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213530_sample_1703703_S15_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-78"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213514_sample_1703781_S60_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-79"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213495_sample_1703709_S20_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-80"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213482_sample_1703699_S11_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-81"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213473_sample_1703732_S35_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-82"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213494_sample_1703700_S12_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-83"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213513_sample_1703772_S52_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-84"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213552_sample_1703684_S1_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-85"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213519_sample_1703711_S22_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-86"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213503_sample_1703789_S65_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-87"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213565_sample_1703698_S10_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-88"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213546_sample_1703749_S49_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-89"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213525_sample_1703773_S53_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-90"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213496_sample_1703726_S29_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-91"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213560_sample_1703768_S146_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-92"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213521_sample_1703737_S39_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-93"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213532_sample_1703729_S32_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-94"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213482_sample_1703699_S11_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-95"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213521_sample_1703737_S39_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-96"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213533_sample_1703738_S40_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-97"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213551_sample_1703793_S69_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-98"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213516_sample_1703676_S128_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-99"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213545_sample_1703739_S41_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-100"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213540_sample_1703680_S130_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-101"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213560_sample_1703768_S146_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-102"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213564_sample_1703685_S2_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-103"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213548_sample_1703767_S145_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-104"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213523_sample_1703756_S135_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-105"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213475_sample_1703751_S131_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-106"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213533_sample_1703738_S40_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-107"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213531_sample_1703713_S23_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-108"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213512_sample_1703764_S142_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-109"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213536_sample_1703766_S144_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-110"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213528_sample_1703679_S129_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-111"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213559_sample_1703760_S138_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-112"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213534_sample_1703747_S48_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-113"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213535_sample_1703757_S136_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-114"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213495_sample_1703709_S20_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-115"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213526_sample_1703782_S61_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-116"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213550_sample_1703785_S63_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-117"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213558_sample_1703750_S50_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-118"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213523_sample_1703756_S135_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-119"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213511_sample_1703755_S134_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-120"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213556_sample_1703731_S34_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-121"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213491_sample_1703788_S150_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-122"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213559_sample_1703760_S138_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-123"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213483_sample_1703707_S19_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-124"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213551_sample_1703793_S69_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-125"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213505_sample_1703692_S5_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-126"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213544_sample_1703730_S33_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-127"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213547_sample_1703758_S137_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-128"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213529_sample_1703694_S7_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-129"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213503_sample_1703789_S65_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-130"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213500_sample_1703763_S141_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-131"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213515_sample_1703790_S66_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-132"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213499_sample_1703754_S133_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-133"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213556_sample_1703731_S34_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-134"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213492_sample_1703673_S126_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-135"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213506_sample_1703701_S13_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-136"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213567_sample_1703719_S26_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-137"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213472_sample_1703724_S27_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-138"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213518_sample_1703702_S14_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-139"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213485_sample_1703734_S36_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-140"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213493_sample_1703689_S4_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-141"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213554_sample_1703705_S17_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-142"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213478_sample_1703777_S57_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-143"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213537_sample_1703774_S54_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-144"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213472_sample_1703724_S27_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-145"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213507_sample_1703710_S21_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-146"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213502_sample_1703779_S59_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-147"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213502_sample_1703779_S59_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-148"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213535_sample_1703757_S136_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-149"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213501_sample_1703771_S148_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-150"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213490_sample_1703778_S58_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-151"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213547_sample_1703758_S137_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-152"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213509_sample_1703736_S38_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-153"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213484_sample_1703725_S28_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-154"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213491_sample_1703788_S150_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-155"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213486_sample_1703742_S44_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-156"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213499_sample_1703754_S133_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-157"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213527_sample_1703791_S67_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-158"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213475_sample_1703751_S131_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-159"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213506_sample_1703701_S13_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-160"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213480_sample_1703672_S125_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-161"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213538_sample_1703784_S62_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-162"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213481_sample_1703686_S3_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-163"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213477_sample_1703769_S51_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-164"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213526_sample_1703782_S61_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-165"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213564_sample_1703685_S2_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-166"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213563_sample_1703794_S70_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-167"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213477_sample_1703769_S51_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-168"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213549_sample_1703775_S55_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-169"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213536_sample_1703766_S144_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-170"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213511_sample_1703755_S134_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-171"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213540_sample_1703680_S130_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-172"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213480_sample_1703672_S125_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-173"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213520_sample_1703728_S31_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-174"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213505_sample_1703692_S5_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-175"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213488_sample_1703762_S140_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-176"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213552_sample_1703684_S1_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-177"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213512_sample_1703764_S142_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-178"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213488_sample_1703762_S140_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-179"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213479_sample_1703787_S149_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-180"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213561_sample_1703776_S56_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-181"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213541_sample_1703695_S8_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-182"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213548_sample_1703767_S145_L002_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-183"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213557_sample_1703740_S42_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-184"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213542_sample_1703704_S16_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-185"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213561_sample_1703776_S56_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-186"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213500_sample_1703763_S141_L002_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-187"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213530_sample_1703703_S15_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-188"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213562_sample_1703786_S64_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-189"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213563_sample_1703794_S70_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-190"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213527_sample_1703791_S67_L001_R2_001.fastq.gz:</span> OK</span>
<span id="cb1-191"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213484_sample_1703725_S28_L001_R1_001.fastq.gz:</span> OK</span>
<span id="cb1-192"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">lib_213481_sample_1703686_S3_L001_R1_001.fastq.gz:</span> OK</span></code></pre></div>


</section>

 ]]></description>
  <category>Data Received</category>
  <category>RNA-seq</category>
  <category>2026</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-15-Data-Received---Full-RNA-seq-Data-for-Andy-Dittman-and-NOAA/</guid>
  <pubDate>Wed, 15 Jul 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Resazurin Assays - USDA M.gigas Families in Response to Temperature Stress</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Twenty adult oysters from each of four different USDA families (1, 5, 7, &amp; 9) were subjected to acute heat stress at 36<sup>o</sup>C for four hours in an upright incubator. Oysters were photographed for measurement and then submerged in ~70mL of freshly prepared resazuring solution in plastic drink cups. Resazurin fluorescence was measured by extracting 200uL from each cup and placing in a 96-well plate, then measuring fluorescence in a Synergy HTX plate reader (Agilent).</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/20260713-mgig-resazurin.jpg" class="img-fluid figure-img" alt="Image of undergrad loading tray of cups containing oysters and resazurin into incubator in Graham Young's lab"></p>
<figcaption>Image of undergrad loading tray of cups containing oysters and resazurin into incubator in Graham Young’s lab</figcaption>
</figure>
</div>
<p>To speed up sampling and reduce the amount of time cups were out of the incubator, sampling was periodcially divided between two people and two plates (i.e.&nbsp;half the samples collected into plate B, the other half into plate C).</p>
<blockquote class="blockquote">
<p>[!NOTE] Based on our experience with resazurin fluorescence stability and the sheer number of samples being handled, resazurin fluorescence was <em>not</em> measured immediately. Plates were measured when time was available, however, no plates sat for longer than 30 minutes at room temperature.</p>
</blockquote>
<p>Resazurin temperatures were measured with an infrared thermometer over the course of the experiment:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>Timepoint (hrs)</th>
<th>Temp_range (C)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>0</td>
<td>18</td>
</tr>
<tr class="even">
<td>0.5</td>
<td>23-29</td>
</tr>
<tr class="odd">
<td>1</td>
<td>27-29</td>
</tr>
<tr class="even">
<td>1.5</td>
<td>29-31</td>
</tr>
<tr class="odd">
<td>2</td>
<td>30-32</td>
</tr>
<tr class="even">
<td>2.5</td>
<td>31.5-32.5</td>
</tr>
<tr class="odd">
<td>3</td>
<td>31.5-32.5</td>
</tr>
<tr class="even">
<td>3.5</td>
<td>31-32.5</td>
</tr>
<tr class="odd">
<td>4</td>
<td>31.5-33</td>
</tr>
</tbody>
</table>
<p>Notebook was knitted from <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Resazurin/code/01.00-resazurin-20260713-mgig-36C.Rmd">01.00-resazurin-20260713-mgig-36C.Rmd</a> (GitHub).</p>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Family significantly affected size-normalized metabolic rate (AUC ANOVA: F=4.37, p=0.0069), with a significant time × family interaction in the time-series model (LME: p=0.0006). Family 7 had the highest mean metabolic activity and Family 9 the lowest; this contrast was the only significant pairwise difference (Tukey: p=0.0051). The divergence emerged by 1.5 h and strengthened through 4 h (p=0.0002). Families 1 and 5 were intermediate and not significantly different from any other family.</p>
<table class="caption-top table">
<caption>Mean area-under-the-curve (AUC) of blank-corrected metabolism (fold change / mm² shell area) per family across the 4 h heat stress period.</caption>
<thead>
<tr class="header">
<th style="text-align: center;">Family</th>
<th style="text-align: right;">n</th>
<th style="text-align: right;">Mean AUC</th>
<th style="text-align: right;">SE</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">7</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">0.0511</td>
<td style="text-align: right;">0.0040</td>
</tr>
<tr class="even">
<td style="text-align: center;">1</td>
<td style="text-align: right;">19</td>
<td style="text-align: right;">0.0446</td>
<td style="text-align: right;">0.0049</td>
</tr>
<tr class="odd">
<td style="text-align: center;">5</td>
<td style="text-align: right;">19</td>
<td style="text-align: right;">0.0373</td>
<td style="text-align: right;">0.0047</td>
</tr>
<tr class="even">
<td style="text-align: center;">9</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">0.0285</td>
<td style="text-align: right;">0.0051</td>
</tr>
</tbody>
</table>
<p>Two wells were excluded due to a cup mix-up (samples 70 and 71: one cup contained two oysters, the other none).</p>
<p><a href="https://robertslab.github.io/resources/Agentic-Coding-Tools/#five-level-rubric"><img alt="AI Use Level 4: Substantial AI contribution" src="https://img.shields.io/badge/AI%20Use-Level%204%20Substantial%20AI%20Contribution-red"></a></p>
<hr>
</section>
<section id="background" class="level1">
<h1>1 Background</h1>
<p>To speed up sampling and reduce the amount of time cups were out of the incubator, sampling was periodcially divided between two people and two plates (i.e.&nbsp;half the samples collected into plate B, the other half into plate C).</p>
<blockquote class="blockquote">
<p><img src="https://latex.codecogs.com/png.latex?!NOTE"> Based on our experience with resazurin fluorescence stability and the sheer number of samples being handled, resazurin fluorescence was <em>not</em> measured immediately. Plates were measured when time was available, however, no plates sat for longer than 30 minutes at room temperature.</p>
</blockquote>
<p>Resazurin temperatures were measured with an infrared thermometer over the course of the experiment:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">Timepoint (hrs)</th>
<th style="text-align: left;">Temp_range (C)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">0</td>
<td style="text-align: left;">18</td>
</tr>
<tr class="even">
<td style="text-align: left;">0.5</td>
<td style="text-align: left;">23-29</td>
</tr>
<tr class="odd">
<td style="text-align: left;">1</td>
<td style="text-align: left;">27-29</td>
</tr>
<tr class="even">
<td style="text-align: left;">1.5</td>
<td style="text-align: left;">29-31</td>
</tr>
<tr class="odd">
<td style="text-align: left;">2</td>
<td style="text-align: left;">30-32</td>
</tr>
<tr class="even">
<td style="text-align: left;">2.5</td>
<td style="text-align: left;">31.5-32.5</td>
</tr>
<tr class="odd">
<td style="text-align: left;">3</td>
<td style="text-align: left;">31.5-32.5</td>
</tr>
<tr class="even">
<td style="text-align: left;">3.5</td>
<td style="text-align: left;">31-32.5</td>
</tr>
<tr class="odd">
<td style="text-align: left;">4</td>
<td style="text-align: left;">31.5-33</td>
</tr>
</tbody>
</table>
<p>See <code>Resazurin/data/20260713-mgig-36C/README.md</code> for full experimental notes.</p>
<section id="expected-inputs" class="level2">
<h2 class="anchored" data-anchor-id="expected-inputs">1.1 Expected inputs</h2>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Path</th>
<th style="text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>Resazurin/data/20260713-mgig-36C/plate-*-T*.txt</code></td>
<td style="text-align: left;">Plate reader fluorescence exports (one file per plate per timepoint)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>Resazurin/data/20260713-mgig-36C/layout.csv</code></td>
<td style="text-align: left;">Well metadata: plate ID, well ID, blank flag, family groups, sample IDs, area measurements (mm², from ImageJ)</td>
</tr>
</tbody>
</table>
</section>
<section id="expected-outputs" class="level2">
<h2 class="anchored" data-anchor-id="expected-outputs">1.2 Expected outputs</h2>
<p>All outputs are written to <code>Resazurin/outputs/01.00-resazurin-20260713-mgig-36C/</code>.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">File</th>
<th style="text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>figures/</code></td>
<td style="text-align: left;">All plots generated by this script</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>auc_all_metrics.csv</code></td>
<td style="text-align: left;">Per-individual AUC values for every active measurement metric</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>auc_summary.csv</code></td>
<td style="text-align: left;">Group-level AUC summary statistics (mean, SD, SE, median)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>metabolism.csv</code></td>
<td style="text-align: left;">Full per-well per-timepoint metabolism data frame</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>pairwise_stats.csv</code></td>
<td style="text-align: left;">Tukey-adjusted pairwise comparisons from AUC linear models</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="setup" class="level1">
<h1>2 Setup</h1>
<section id="knitr-options" class="level2">
<h2 class="anchored" data-anchor-id="knitr-options">2.1 Knitr options</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb1-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb1-8">)</span></code></pre></div>
</section>
<section id="load-libraries" class="level2">
<h2 class="anchored" data-anchor-id="load-libraries">2.2 Load libraries</h2>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb2-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(pracma)       <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># trapz()</span></span>
<span id="cb2-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(lme4)</span>
<span id="cb2-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(lmerTest)</span>
<span id="cb2-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(emmeans)</span>
<span id="cb2-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(multcompView)</span>
<span id="cb2-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(cowplot)</span>
<span id="cb2-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(colorspace)   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># qualitative_hcl() for large palettes</span></span></code></pre></div>
</section>
</section>
<section id="helper-functions" class="level1">
<h1>3 Helper Functions</h1>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">normalize_well_id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb3-2">  x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(x))</span>
<span id="cb3-3">  valid <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Z]+[0-9]+$"</span>)</span>
<span id="cb3-4">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(x))</span>
<span id="cb3-5">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(valid)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(out)</span>
<span id="cb3-6">  m <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(x[valid], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([A-Z]+)([0-9]+)$"</span>)</span>
<span id="cb3-7">  out[valid] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]))</span>
<span id="cb3-8">  out</span>
<span id="cb3-9">}</span>
<span id="cb3-10"></span>
<span id="cb3-11">parse_time_hr <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-12">  hit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path),</span>
<span id="cb3-13">                   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)-T([0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>)</span>
<span id="cb3-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(hit[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb3-15">}</span>
<span id="cb3-16"></span>
<span id="cb3-17">parse_plate_id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-18">  hit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path),</span>
<span id="cb3-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)^plate-([A-Za-z0-9-]+)-T[0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>)</span>
<span id="cb3-20">  id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> hit[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb3-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"unknown"</span>, id)</span>
<span id="cb3-22">}</span>
<span id="cb3-23"></span>
<span id="cb3-24">extract_results_block <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(lines) {</span>
<span id="cb3-25">  results_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(lines) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Results"</span>)</span>
<span id="cb3-26">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(results_idx) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stop</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No Results section found"</span>)</span>
<span id="cb3-27">  idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb3-28">  header_tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(lines[idx <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>()</span>
<span id="cb3-29">  col_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> header_tokens[</span>
<span id="cb3-30">    header_tokens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(header_tokens, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[0-9]+$"</span>)]</span>
<span id="cb3-31">  j <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> idx <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb3-32">  data_lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>()</span>
<span id="cb3-33">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> (j <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(lines)) {</span>
<span id="cb3-34">    line <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> lines[j]</span>
<span id="cb3-35">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(line) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span></span>
<span id="cb3-36">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(line, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Za-z]</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span></span>
<span id="cb3-37">    data_lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(data_lines, line)</span>
<span id="cb3-38">    j <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> j <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb3-39">  }</span>
<span id="cb3-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_ids =</span> col_ids, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data_lines =</span> data_lines)</span>
<span id="cb3-41">}</span>
<span id="cb3-42"></span>
<span id="cb3-43">parse_plate_export <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-44">  lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb3-45">  res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">extract_results_block</span>(lines)</span>
<span id="cb3-46"></span>
<span id="cb3-47">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data_lines, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(line) {</span>
<span id="cb3-48">    tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(line, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>()</span>
<span id="cb3-49">    tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tokens[tokens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>]</span>
<span id="cb3-50">    row_letter <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tokens[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb3-51">    nums <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(tokens[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]))</span>
<span id="cb3-52">    valid_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(nums))</span>
<span id="cb3-53">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(valid_idx) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>())</span>
<span id="cb3-54">    vals <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> nums[valid_idx]</span>
<span id="cb3-55">    n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(vals), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids))</span>
<span id="cb3-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb3-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(row_letter),</span>
<span id="cb3-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)]),</span>
<span id="cb3-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normalize_well_id</span>(</span>
<span id="cb3-60">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(row_letter), res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)])),</span>
<span id="cb3-61">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value   =</span> vals[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)]</span>
<span id="cb3-62">    )</span>
<span id="cb3-63">  }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-64">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb3-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_id</span>(path)),</span>
<span id="cb3-66">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_hr  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_time_hr</span>(path)</span>
<span id="cb3-67">    )</span>
<span id="cb3-68">}</span>
<span id="cb3-69"></span>
<span id="cb3-70">trapezoid_auc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(time_hr, value) {</span>
<span id="cb3-71">  ok <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)</span>
<span id="cb3-72">  t <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> time_hr[ok]</span>
<span id="cb3-73">  v <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> value[ok]</span>
<span id="cb3-74">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(t) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb3-75">  ord <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(t)</span>
<span id="cb3-76">  t <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t[ord]; v <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> v[ord]</span>
<span id="cb3-77">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(t) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(v, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tail</span>(v, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb3-78">}</span>
<span id="cb3-79"></span>
<span id="cb3-80"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Shared helper: extract display unit string from a measurement column name.</span></span>
<span id="cb3-81"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># e.g. "area_mm2_measurement" -&gt; "mm²", "weight_mg_measurement" -&gt; "mg"</span></span>
<span id="cb3-82">parse_meas_unit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col_name) {</span>
<span id="cb3-83">  unit_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> col_name <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-84">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-85">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_measurement$"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_extract</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^_]+$"</span>)</span>
<span id="cb3-87">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb3-88">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm2"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm²"</span>,</span>
<span id="cb3-89">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm2"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm²"</span>,</span>
<span id="cb3-90">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm3"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm³"</span>,</span>
<span id="cb3-91">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm3"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm³"</span>,</span>
<span id="cb3-92">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>              <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> unit_raw</span>
<span id="cb3-93">  )</span>
<span id="cb3-94">}</span>
<span id="cb3-95"></span>
<span id="cb3-96"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y-axis label for metabolism line plots: "fold change/mm²"</span></span>
<span id="cb3-97">metabolism_y_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col_name) {</span>
<span id="cb3-98">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Metabolism (fold change/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_meas_unit</span>(col_name), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>)</span>
<span id="cb3-99">}</span>
<span id="cb3-100"></span>
<span id="cb3-101"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y-axis label for AUC box plots: "Metabolism (AUC; mm²)"</span></span>
<span id="cb3-102">auc_y_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(metric_name) {</span>
<span id="cb3-103">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Metabolism (AUC; "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_meas_unit</span>(metric_name), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>)</span>
<span id="cb3-104">}</span></code></pre></div>
</section>
<section id="load-data" class="level1">
<h1>4 Load Data</h1>
<section id="plate-export-files" class="level2">
<h2 class="anchored" data-anchor-id="plate-export-files">4.1 Plate export files</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">proj_root <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> rprojroot<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">find_rstudio_root_file</span>()</span>
<span id="cb4-2">data_dir  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(proj_root, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resazurin"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"20260713-mgig-36C"</span>)</span>
<span id="cb4-3">out_dir   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(proj_root, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resazurin"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outputs"</span>,</span>
<span id="cb4-4">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01.00-resazurin-20260713-mgig-36C"</span>)</span>
<span id="cb4-5">fig_dir   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"figures"</span>)</span>
<span id="cb4-6"></span>
<span id="cb4-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(fig_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(out_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-9"></span>
<span id="cb4-10">plate_files <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list.files</span>(</span>
<span id="cb4-11">  data_dir,</span>
<span id="cb4-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)^plate-.*-T[0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>,</span>
<span id="cb4-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">full.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb4-14">)</span>
<span id="cb4-15"></span>
<span id="cb4-16">plate_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(plate_files, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatch</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_export</span>(path),</span>
<span id="cb4-18">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">error =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(e) {</span>
<span id="cb4-19">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Parse error in "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">": "</span>, e<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>message)</span>
<span id="cb4-20">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb4-21">           })</span>
<span id="cb4-22">})</span>
<span id="cb4-23"></span>
<span id="cb4-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_raw)</span></code></pre></div>
<pre><code>tibble [1,248 × 6] (S3: tbl_df/tbl/data.frame)
 $ row_id  : chr [1:1248] "A" "A" "A" "A" ...
 $ col_id  : int [1:1248] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id : chr [1:1248] "A1" "A2" "A3" "A4" ...
 $ value   : num [1:1248] 596 597 605 613 601 626 626 626 610 636 ...
 $ plate_id: chr [1:1248] "a" "a" "a" "a" ...
 $ time_hr : num [1:1248] 0 0 0 0 0 0 0 0 0 0 ...</code></pre>
</section>
<section id="plate-consistency-check" class="level2">
<h2 class="anchored" data-anchor-id="plate-consistency-check">4.2 Plate consistency check</h2>
<p>Checks that every plate has the same number of wells at every timepoint. The expected well count is the mode across all plate × timepoint reads. Any plate with at least one deviating read is flagged and dropped entirely before any further analysis — removing only the aberrant timepoint would break the fold-change baseline calculation.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">well_counts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(plate_id, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(well_id), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb6-4"></span>
<span id="cb6-5">expected_n_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(</span>
<span id="cb6-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(well_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells)))</span>
<span id="cb6-7">)</span>
<span id="cb6-8"></span>
<span id="cb6-9">inconsistent_reads <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_counts <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_wells <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> expected_n_wells) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_id, time_hr)</span>
<span id="cb6-12"></span>
<span id="cb6-13">inconsistent_plate_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(inconsistent_reads<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_id)</span>
<span id="cb6-14"></span>
<span id="cb6-15"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(inconsistent_reads) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb6-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Plate consistency check FAILED.**"</span>,</span>
<span id="cb6-17">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected"</span>, expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells per plate-timepoint read."</span>,</span>
<span id="cb6-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(inconsistent_plate_ids),</span>
<span id="cb6-19">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate(s) have at least one deviating read and are excluded"</span>,</span>
<span id="cb6-20">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"from all analyses:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(</span>
<span id="cb6-22">    inconsistent_reads,</span>
<span id="cb6-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells read"</span>),</span>
<span id="cb6-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected:"</span>, expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells per read"</span>)</span>
<span id="cb6-25">  ), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-27">  plate_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>plate_id <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> inconsistent_plate_ids)</span>
<span id="cb6-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(inconsistent_plate_ids),</span>
<span id="cb6-30">          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" plate(s) removed from plate_raw: "</span>,</span>
<span id="cb6-31">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(inconsistent_plate_ids, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb6-32">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb6-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate consistency check passed: all"</span>,</span>
<span id="cb6-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(well_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plates have"</span>,</span>
<span id="cb6-35">      expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells at every timepoint.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-36">}</span></code></pre></div>
<p>Plate consistency check passed: all 3 plates have 96 wells at every timepoint.</p>
</section>
<section id="layout-file" class="level2">
<h2 class="anchored" data-anchor-id="layout-file">4.3 Layout file</h2>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">layout_path <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout.csv"</span>)</span>
<span id="cb7-2"></span>
<span id="cb7-3">layout_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_csv</span>(layout_path,</span>
<span id="cb7-4">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_types =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cols</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.default =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>),</span>
<span id="cb7-5">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">show_col_types =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb7-6"></span>
<span id="cb7-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standardise column names to snake_case</span></span>
<span id="cb7-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^a-z0-9]+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb7-13"></span>
<span id="cb7-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalise plate_id to match plate file ids (strip "plate-" prefix)</span></span>
<span id="cb7-15">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(plate_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^plate-"</span>),</span>
<span id="cb7-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normalize_well_id</span>(plate_well),</span>
<span id="cb7-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_blank =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"is_blank"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw))</span>
<span id="cb7-20">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(is_blank)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"YES"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Y"</span>)</span>
<span id="cb7-21">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-22">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb7-23">  )</span>
<span id="cb7-24"></span>
<span id="cb7-25">found_exclude_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb7-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_from_analysis"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"omit"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"not_analyzed"</span>),</span>
<span id="cb7-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)</span>
<span id="cb7-28">)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb7-29">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-31">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exclude_from_analysis =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(found_exclude_col))</span>
<span id="cb7-32">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(.data[[found_exclude_col]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span></span>
<span id="cb7-33">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"YES"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Y"</span>)</span>
<span id="cb7-34">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-35">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb7-36">  )</span>
<span id="cb7-37"></span>
<span id="cb7-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Identify measurement columns and group columns</span></span>
<span id="cb7-39">measurement_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)[</span>
<span id="cb7-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_measurement$"</span>)]</span>
<span id="cb7-41">group_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)[</span>
<span id="cb7-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_group$"</span>)]</span>
<span id="cb7-43"></span>
<span id="cb7-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cast measurement columns to numeric</span></span>
<span id="cb7-45">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-46">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(measurement_cols),</span>
<span id="cb7-47">                <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(.x))))</span>
<span id="cb7-48"></span>
<span id="cb7-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Determine which measurement columns actually contain finite data</span></span>
<span id="cb7-50">active_meas_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> measurement_cols[</span>
<span id="cb7-51">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(measurement_cols, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col)</span>
<span id="cb7-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(layout_clean[[col]]), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))]</span>
<span id="cb7-53"></span>
<span id="cb7-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalise group values to lowercase so they match colour scale definitions</span></span>
<span id="cb7-55">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_cols),</span>
<span id="cb7-57">                <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(.x)))))</span>
<span id="cb7-58"></span>
<span id="cb7-59"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group columns: "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(group_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb7-60"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Active measurement columns: "</span>,</span>
<span id="cb7-61">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(active_meas_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb7-62"></span>
<span id="cb7-63"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(layout_clean)</span></code></pre></div>
<pre><code>tibble [235 × 14] (S3: tbl_df/tbl/data.frame)
 $ plate_id             : chr [1:235] "a" "a" "a" "a" ...
 $ plate_well           : chr [1:235] "A01" "A02" "A03" "A04" ...
 $ is_blank             : logi [1:235] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ family_id_group      : chr [1:235] "7" "5" "1" "9" ...
 $ sample_id_group      : chr [1:235] "1" "2" "3" "4" ...
 $ treatment_group      : chr [1:235] NA NA NA NA ...
 $ exclude_from_analysis: logi [1:235] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:235] NA NA NA NA ...
 $ width_mm_measurement : num [1:235] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:235] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:235] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:235] 538 586 713 757 823 ...
 $ imagej_id            : chr [1:235] "2" "4" "1" "1" ...
 $ well_id              : chr [1:235] "A1" "A2" "A3" "A4" ...</code></pre>
</section>
</section>
<section id="merge-plate-data-with-layout" class="level1">
<h1>5 Merge Plate Data with Layout</h1>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(</span>
<span id="cb9-3">    layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-4">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(plate_id, well_id, is_blank, exclude_from_analysis,</span>
<span id="cb9-5">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any_of</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span>),</span>
<span id="cb9-6">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_cols), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(measurement_cols)),</span>
<span id="cb9-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span>)</span>
<span id="cb9-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb9-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_blank =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace_na</span>(is_blank, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>),</span>
<span id="cb9-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exclude_from_analysis =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace_na</span>(exclude_from_analysis, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb9-12">  )</span>
<span id="cb9-13"></span>
<span id="cb9-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(dat)</span></code></pre></div>
<pre><code>tibble [1,248 × 16] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:1248] "A" "A" "A" "A" ...
 $ col_id               : int [1:1248] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id              : chr [1:1248] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:1248] 596 597 605 613 601 626 626 626 610 636 ...
 $ plate_id             : chr [1:1248] "a" "a" "a" "a" ...
 $ time_hr              : num [1:1248] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:1248] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:1248] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:1248] NA NA NA NA ...
 $ family_id_group      : chr [1:1248] "7" "5" "1" "9" ...
 $ sample_id_group      : chr [1:1248] "1" "2" "3" "4" ...
 $ treatment_group      : chr [1:1248] NA NA NA NA ...
 $ width_mm_measurement : num [1:1248] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:1248] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:1248] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:1248] 538 586 713 757 823 ...</code></pre>
</section>
<section id="raw-fluorescence" class="level1">
<h1>6 Raw Fluorescence</h1>
<section id="data-frame" class="level2">
<h2 class="anchored" data-anchor-id="data-frame">6.1 Data frame</h2>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Wells in the plate reader output that have no layout entry get all-NA group</span></span>
<span id="cb11-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># columns after the join. Keep only wells assigned to at least one group.</span></span>
<span id="cb11-3">active_gc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(group_cols, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(dat))</span>
<span id="cb11-4"></span>
<span id="cb11-5">raw_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(</span>
<span id="cb11-7">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank,</span>
<span id="cb11-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(active_gc) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb11-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(active_gc), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(.))</span>
<span id="cb11-10">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb11-11">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb11-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb11-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb11-15">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb11-16">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb11-17">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb11-18">    )</span>
<span id="cb11-19">  )</span>
<span id="cb11-20"></span>
<span id="cb11-21">families   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(raw_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb11-22">treatments <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(raw_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group)))</span>
<span id="cb11-23"></span>
<span id="cb11-24">n_fam <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(families)</span>
<span id="cb11-25">n_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(treatments)</span>
<span id="cb11-26"></span>
<span id="cb11-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Palette strategy:</span></span>
<span id="cb11-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   &lt;= 7 groups : Okabe-Ito (gold standard for colorblind-safe figures).</span></span>
<span id="cb11-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   &gt;  7 groups : colorspace::qualitative_hcl("Dynamic") scales to any N</span></span>
<span id="cb11-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                 using perceptually uniform HCL space — no colour collisions.</span></span>
<span id="cb11-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Black (#000000) is excluded from both and reserved for blank wells.</span></span>
<span id="cb11-32">okabe_ito_7 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb11-33">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#E69F00"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#56B4E9"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#009E73"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#F0E442"</span>,</span>
<span id="cb11-34">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0072B2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D55E00"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#CC79A7"</span></span>
<span id="cb11-35">)</span>
<span id="cb11-36">make_palette <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n) {</span>
<span id="cb11-37">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>L) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb11-38">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(okabe_ito_7)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(okabe_ito_7[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)])</span>
<span id="cb11-39">  colorspace<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qualitative_hcl</span>(n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">palette =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dynamic"</span>)</span>
<span id="cb11-40">}</span>
<span id="cb11-41"></span>
<span id="cb11-42">all_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">make_palette</span>(n_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> n_trt)</span>
<span id="cb11-43">fam_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(all_colours[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_fam)], families)</span>
<span id="cb11-44">trt_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(all_colours[n_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_trt)], treatments)</span>
<span id="cb11-45"></span>
<span id="cb11-46">lty_pool <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"solid"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotdash"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"longdash"</span>)</span>
<span id="cb11-47">trt_linetypes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(</span>
<span id="cb11-48">  lty_pool[(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_trt) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(lty_pool) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L],</span>
<span id="cb11-49">  treatments</span>
<span id="cb11-50">)</span>
<span id="cb11-51">plate_well_colours <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blank =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, fam_colours)</span>
<span id="cb11-52"></span>
<span id="cb11-53">has_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> n_trt <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb11-54"></span>
<span id="cb11-55"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(raw_df)</span></code></pre></div>
<pre><code>tibble [720 × 17] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:720] "A" "A" "A" "A" ...
 $ col_id               : int [1:720] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id              : chr [1:720] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:720] 596 597 605 613 601 626 626 626 610 636 ...
 $ plate_id             : chr [1:720] "a" "a" "a" "a" ...
 $ time_hr              : num [1:720] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:720] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:720] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:720] NA NA NA NA ...
 $ family_id_group      : chr [1:720] "7" "5" "1" "9" ...
 $ sample_id_group      : chr [1:720] "1" "2" "3" "4" ...
 $ treatment_group      : chr [1:720] NA NA NA NA ...
 $ width_mm_measurement : num [1:720] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:720] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:720] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:720] 538 586 713 757 823 ...
 $ trace_id             : chr [1:720] "1" "2" "3" "4" ...</code></pre>
</section>
<section id="raw-fluorescence-by-plate-including-blanks" class="level2">
<h2 class="anchored" data-anchor-id="raw-fluorescence-by-plate-including-blanks">6.2 Raw fluorescence by plate (including blanks)</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">p_raw_plates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb13-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour_group =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(is_blank, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank"</span>,</span>
<span id="cb13-5">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coalesce</span>(family_id_group, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb13-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb13-7">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value,</span>
<span id="cb13-9">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> colour_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> plate_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb13-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values   =</span> plate_well_colours,</span>
<span id="cb13-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name     =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>,</span>
<span id="cb13-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(plate_well_colours),</span>
<span id="cb13-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.value =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey80"</span></span>
<span id="cb13-18">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb13-22">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb13-23"></span>
<span id="cb13-24">p_raw_plates</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/raw-fluor-by-plate-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_fluor_by_plate.png"</span>),</span>
<span id="cb14-2">       p_raw_plates, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)</span></code></pre></div>
</section>
<section id="mean-raw-fluorescence-by-family" class="level2">
<h2 class="anchored" data-anchor-id="mean-raw-fluorescence-by-family">6.3 Mean raw fluorescence by family</h2>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">raw_family_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb15-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_fluor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb15-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_fluor   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb15-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(value))),</span>
<span id="cb15-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(value)),</span>
<span id="cb15-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups    =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb15-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb15-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb15-13">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb15-14">    family_id_group)</span>
<span id="cb15-15"></span>
<span id="cb15-16">p_raw_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(raw_family_summary,</span>
<span id="cb15-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_fluor,</span>
<span id="cb15-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb15-19">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_fluor <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_fluor,</span>
<span id="cb15-21">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_fluor <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_fluor,</span>
<span id="cb15-22">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb15-23">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb15-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb15-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb15-29">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb15-31">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean raw fluorescence (RFU ± SE)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-34">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb15-35"></span>
<span id="cb15-36">p_raw_mean</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/raw-mean-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_mean_by_family.png"</span>),</span>
<span id="cb16-2">       p_raw_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-raw-fluorescence-traces-by-family" class="level2">
<h2 class="anchored" data-anchor-id="individual-raw-fluorescence-traces-by-family">6.4 Individual raw fluorescence traces by family</h2>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">p_raw_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb17-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb17-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb17-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb17-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb17-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb17-16"></span>
<span id="cb17-17">p_raw_by_family</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/raw-individual-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_individual_by_family.png"</span>),</span>
<span id="cb18-2">       p_raw_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-raw-fluorescence-traces-by-treatment" class="level2">
<h2 class="anchored" data-anchor-id="individual-raw-fluorescence-traces-by-treatment">6.5 Individual raw fluorescence traces by treatment</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb19-2">  p_raw_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value,</span>
<span id="cb19-4">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb19-9">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb19-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb19-14"></span>
<span id="cb19-15">  p_raw_by_treatment</span>
<span id="cb19-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_individual_by_treatment.png"</span>),</span>
<span id="cb19-17">         p_raw_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb19-18">}</span></code></pre></div>
</section>
<section id="excluded-samples" class="level2">
<h2 class="anchored" data-anchor-id="excluded-samples">6.6 Excluded samples</h2>
<p>Wells flagged <code>exclude_from_analysis = TRUE</code> appear in the raw fluorescence plots above but are omitted from all analyses that follow.</p>
<div class="sourceCode" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">excluded_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb20-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb20-5">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb20-6">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb20-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb20-8">    )</span>
<span id="cb20-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(plate_id, well_id, sample, family_id_group, treatment_group,</span>
<span id="cb20-11">         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any_of</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_id, well_id)</span>
<span id="cb20-14"></span>
<span id="cb20-15"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(excluded_wells) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb20-16">  col_names <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>)</span>
<span id="cb20-17">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(excluded_wells))</span>
<span id="cb20-18">    col_names <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(col_names, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Reason"</span>)</span>
<span id="cb20-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> col_names), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-20">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb20-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No wells are excluded from analysis.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-22">}</span></code></pre></div>
<table class="caption-top table">
<colgroup>
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Plate</th>
<th style="text-align: left;">Well</th>
<th style="text-align: left;">Sample</th>
<th style="text-align: left;">Family</th>
<th style="text-align: left;">Treatment</th>
<th style="text-align: left;">Reason</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">a</td>
<td style="text-align: left;">F10</td>
<td style="text-align: left;">70</td>
<td style="text-align: left;">5</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">missing oyster - probably second oyster in 71</td>
</tr>
<tr class="even">
<td style="text-align: left;">a</td>
<td style="text-align: left;">F11</td>
<td style="text-align: left;">71</td>
<td style="text-align: left;">1</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">two oysters - probably the missing one from 70</td>
</tr>
<tr class="odd">
<td style="text-align: left;">b</td>
<td style="text-align: left;">C6</td>
<td style="text-align: left;">70</td>
<td style="text-align: left;">5</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">missing oyster - probably second oyster in 71</td>
</tr>
<tr class="even">
<td style="text-align: left;">b</td>
<td style="text-align: left;">C7</td>
<td style="text-align: left;">71</td>
<td style="text-align: left;">1</td>
<td style="text-align: left;">NA</td>
<td style="text-align: left;">two oysters - probably the missing one from 70</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="blank-correction-via-fold-change-normalization" class="level1">
<h1>7 Blank Correction via Fold-Change Normalization</h1>
<p>T0 is the earliest timepoint present in the dataset (not necessarily 0 hr). Sample fold-change is expressed relative to each individual’s T0 reading, resolved by <code>sample_id_group</code> when that column is populated — allowing the same animal to be tracked across plates — or by <code>plate_id + well_id</code> when no sample IDs exist (backward-compatible with single-plate, multi-timepoint designs). Blank fold-change is the per-plate mean blank RFU at each timepoint divided by the pooled mean blank RFU at T0. Subtracting blank fold-change from sample fold-change removes background fluorescence drift; all samples start at exactly 0 at T0 by construction.</p>
<section id="step-1-identify-t0-and-compute-per-sample-fold-change" class="level2">
<h2 class="anchored" data-anchor-id="step-1-identify-t0-and-compute-per-sample-fold-change">7.1 Step 1 – Identify T0 and compute per-sample fold-change</h2>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># T0 = earliest timepoint present in the dataset</span></span>
<span id="cb21-2">t0_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_hr[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_hr)], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb21-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T0 timepoint: "</span>, t0_time, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" hr"</span>)</span>
<span id="cb21-4"></span>
<span id="cb21-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># T0 reference value per individual.</span></span>
<span id="cb21-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Resolved by sample_id_group (cross-plate tracking) when available;</span></span>
<span id="cb21-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># falls back to plate+well for layouts without explicit sample IDs.</span></span>
<span id="cb21-8">t0_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(time_hr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> t0_time, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_key =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-11">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb21-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb21-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb21-14">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_key) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value_t0 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb21-17"></span>
<span id="cb21-18">dat_fc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_key =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-20">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb21-21">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb21-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb21-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb21-24">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(t0_all, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_key"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fold_change =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-27">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value_t0) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> value_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb21-28">    value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> value_t0,</span>
<span id="cb21-29">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb21-30">  ))</span>
<span id="cb21-31"></span>
<span id="cb21-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(dat_fc)</span></code></pre></div>
<pre><code>tibble [1,248 × 19] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:1248] "A" "A" "A" "A" ...
 $ col_id               : int [1:1248] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id              : chr [1:1248] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:1248] 596 597 605 613 601 626 626 626 610 636 ...
 $ plate_id             : chr [1:1248] "a" "a" "a" "a" ...
 $ time_hr              : num [1:1248] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:1248] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:1248] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:1248] NA NA NA NA ...
 $ family_id_group      : chr [1:1248] "7" "5" "1" "9" ...
 $ sample_id_group      : chr [1:1248] "1" "2" "3" "4" ...
 $ treatment_group      : chr [1:1248] NA NA NA NA ...
 $ width_mm_measurement : num [1:1248] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:1248] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:1248] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:1248] 538 586 713 757 823 ...
 $ sample_key           : chr [1:1248] "1" "2" "3" "4" ...
 $ value_t0             : num [1:1248] 596 597 605 613 601 626 626 626 610 636 ...
 $ fold_change          : num [1:1248] 1 1 1 1 1 1 1 1 1 1 ...</code></pre>
</section>
<section id="step-2-blank-fold-change-reference-per-plate-per-timepoint" class="level2">
<h2 class="anchored" data-anchor-id="step-2-blank-fold-change-reference-per-plate-per-timepoint">7.2 Step 2 – Blank fold-change reference per plate per timepoint</h2>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pooled mean blank RFU at T0 across all T0 plates</span></span>
<span id="cb23-2">mean_blank_t0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_blank, time_hr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> t0_time, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(value) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb23-6"></span>
<span id="cb23-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(mean_blank_t0))</span>
<span id="cb23-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No blank readings found at T0 ("</span>, t0_time,</span>
<span id="cb23-9">          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" hr); blank correction will produce NA."</span>)</span>
<span id="cb23-10"></span>
<span id="cb23-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Per-plate per-timepoint mean blank expressed as fold-change relative to T0</span></span>
<span id="cb23-12">blank_fc_ref <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_blank, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(plate_id, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_blank_rfu =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_blank_fc =</span> mean_blank_rfu <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_blank_t0)</span>
<span id="cb23-17"></span>
<span id="cb23-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(blank_fc_ref)</span></code></pre></div>
<pre><code>tibble [13 × 4] (S3: tbl_df/tbl/data.frame)
 $ plate_id      : chr [1:13] "a" "a" "a" "a" ...
 $ time_hr       : num [1:13] 0 2.5 3 3.5 4 0.5 1 1.5 2 0.5 ...
 $ mean_blank_rfu: num [1:13] 663 731 711 704 722 ...
 $ mean_blank_fc : num [1:13] 1 1.1 1.07 1.06 1.09 ...</code></pre>
</section>
<section id="step-3-subtract-blank-fold-change-from-sample-fold-change" class="level2">
<h2 class="anchored" data-anchor-id="step-3-subtract-blank-fold-change-from-sample-fold-change">7.3 Step 3 – Subtract blank fold-change from sample fold-change</h2>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb25-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb25-5">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb25-6">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb25-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb25-8">    )</span>
<span id="cb25-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(blank_fc_ref, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"time_hr"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">corrected_fc =</span> fold_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean_blank_fc)</span>
<span id="cb25-12"></span>
<span id="cb25-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples)</span></code></pre></div>
<pre><code>tibble [1,191 × 23] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:1191] "A" "A" "A" "A" ...
 $ col_id               : int [1:1191] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id              : chr [1:1191] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:1191] 596 597 605 613 601 626 626 626 610 636 ...
 $ plate_id             : chr [1:1191] "a" "a" "a" "a" ...
 $ time_hr              : num [1:1191] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:1191] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:1191] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:1191] NA NA NA NA ...
 $ family_id_group      : chr [1:1191] "7" "5" "1" "9" ...
 $ sample_id_group      : chr [1:1191] "1" "2" "3" "4" ...
 $ treatment_group      : chr [1:1191] NA NA NA NA ...
 $ width_mm_measurement : num [1:1191] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:1191] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement: num [1:1191] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:1191] 538 586 713 757 823 ...
 $ sample_key           : chr [1:1191] "1" "2" "3" "4" ...
 $ value_t0             : num [1:1191] 596 597 605 613 601 626 626 626 610 636 ...
 $ fold_change          : num [1:1191] 1 1 1 1 1 1 1 1 1 1 ...
 $ trace_id             : chr [1:1191] "1" "2" "3" "4" ...
 $ mean_blank_rfu       : num [1:1191] 663 663 663 663 663 ...
 $ mean_blank_fc        : num [1:1191] 1 1 1 1 1 1 1 1 1 1 ...
 $ corrected_fc         : num [1:1191] 0 0 0 0 0 0 0 0 0 0 ...</code></pre>
</section>
</section>
<section id="blank-corrected-fold-change" class="level1">
<h1>8 Blank-Corrected Fold-Change</h1>
<section id="mean-by-family" class="level2">
<h2 class="anchored" data-anchor-id="mean-by-family">8.1 Mean by family</h2>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">bc_fc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb27-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_val =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb27-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_val   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb27-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(corrected_fc))),</span>
<span id="cb27-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(corrected_fc)),</span>
<span id="cb27-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb27-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb27-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb27-13">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb27-14">    family_id_group)</span>
<span id="cb27-15"></span>
<span id="cb27-16">p_bc_fc_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(bc_fc_summary,</span>
<span id="cb27-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_val,</span>
<span id="cb27-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb27-19">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_val,</span>
<span id="cb27-21">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_val,</span>
<span id="cb27-22">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb27-23">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb27-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb27-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb27-29">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb27-31">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>,</span>
<span id="cb27-33">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean blank-corrected fold-change (± SE)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-35">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb27-36"></span>
<span id="cb27-37">p_bc_fc_mean</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/bc-fc-mean-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_mean_by_family.png"</span>),</span>
<span id="cb28-2">       p_bc_fc_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-traces-by-family" class="level2">
<h2 class="anchored" data-anchor-id="individual-traces-by-family">8.2 Individual traces by family</h2>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">p_bc_fc_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb29-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb29-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb29-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb29-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Blank-corrected fold-change"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb29-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb29-16"></span>
<span id="cb29-17">p_bc_fc_by_family</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/bc-fc-individual-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_by_family.png"</span>),</span>
<span id="cb30-2">       p_bc_fc_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-blank-corrected-fold-change-traces-by-treatment" class="level2">
<h2 class="anchored" data-anchor-id="individual-blank-corrected-fold-change-traces-by-treatment">8.3 Individual blank-corrected fold-change traces by treatment</h2>
<div class="sourceCode" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb31-2">  p_bc_fc_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb31-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> corrected_fc,</span>
<span id="cb31-4">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb31-9">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Blank-corrected fold-change"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb31-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb31-14"></span>
<span id="cb31-15">  p_bc_fc_by_treatment</span>
<span id="cb31-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_by_treatment.png"</span>),</span>
<span id="cb31-17">         p_bc_fc_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb31-18">}</span></code></pre></div>
</section>
</section>
<section id="metabolism-size-normalised-fold-change" class="level1">
<h1>9 Metabolism (Size-Normalised Fold-Change)</h1>
<p>Blank-corrected fold-change divided by each active measurement column. This is “metabolism” as defined in Huffmyer et al.</p>
<div class="sourceCode" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(active_meas_cols) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb32-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No active measurement columns: skipping metabolism calculation."</span>)</span>
<span id="cb32-3">  metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb32-4">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb32-5">  metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples</span>
<span id="cb32-6">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb32-7">    out_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb32-8">    metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!!</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">out_col :=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb32-10">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[mc]]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> .data[[mc]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb32-11">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(corrected_fc),</span>
<span id="cb32-12">        corrected_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> .data[[mc]],</span>
<span id="cb32-13">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb32-14">      ))</span>
<span id="cb32-15">  }</span>
<span id="cb32-16">}</span>
<span id="cb32-17"></span>
<span id="cb32-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(metabolism_df)</span></code></pre></div>
<pre><code>tibble [1,191 × 24] (S3: tbl_df/tbl/data.frame)
 $ row_id                             : chr [1:1191] "A" "A" "A" "A" ...
 $ col_id                             : int [1:1191] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id                            : chr [1:1191] "A1" "A2" "A3" "A4" ...
 $ value                              : num [1:1191] 596 597 605 613 601 626 626 626 610 636 ...
 $ plate_id                           : chr [1:1191] "a" "a" "a" "a" ...
 $ time_hr                            : num [1:1191] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank                           : logi [1:1191] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis              : logi [1:1191] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason                     : chr [1:1191] NA NA NA NA ...
 $ family_id_group                    : chr [1:1191] "7" "5" "1" "9" ...
 $ sample_id_group                    : chr [1:1191] "1" "2" "3" "4" ...
 $ treatment_group                    : chr [1:1191] NA NA NA NA ...
 $ width_mm_measurement               : num [1:1191] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement              : num [1:1191] NA NA NA NA NA NA NA NA NA NA ...
 $ weight_mg_measurement              : num [1:1191] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement               : num [1:1191] 538 586 713 757 823 ...
 $ sample_key                         : chr [1:1191] "1" "2" "3" "4" ...
 $ value_t0                           : num [1:1191] 596 597 605 613 601 626 626 626 610 636 ...
 $ fold_change                        : num [1:1191] 1 1 1 1 1 1 1 1 1 1 ...
 $ trace_id                           : chr [1:1191] "1" "2" "3" "4" ...
 $ mean_blank_rfu                     : num [1:1191] 663 663 663 663 663 ...
 $ mean_blank_fc                      : num [1:1191] 1 1 1 1 1 1 1 1 1 1 ...
 $ corrected_fc                       : num [1:1191] 0 0 0 0 0 0 0 0 0 0 ...
 $ metabolism_per_area_mm2_measurement: num [1:1191] 0 0 0 0 0 0 0 0 0 0 ...</code></pre>
<section id="mean-metabolism-by-family" class="level2">
<h2 class="anchored" data-anchor-id="mean-metabolism-by-family">9.1 Mean metabolism by family</h2>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb34-2"></span>
<span id="cb34-3">  metab_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, active_meas_cols)</span>
<span id="cb34-4"></span>
<span id="cb34-5">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metab_cols) {</span>
<span id="cb34-6">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb34-7">    mc_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>)</span>
<span id="cb34-8"></span>
<span id="cb34-9">    metab_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-10">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb34-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_val =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(.data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb34-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_val   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(.data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb34-15">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(.data[[col]]))),</span>
<span id="cb34-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb34-17">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb34-19">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb34-20">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb34-21">        family_id_group)</span>
<span id="cb34-22"></span>
<span id="cb34-23">    p_metab_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(metab_summary,</span>
<span id="cb34-24">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_val,</span>
<span id="cb34-25">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb34-26">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-27">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_val,</span>
<span id="cb34-28">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_val,</span>
<span id="cb34-29">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb34-30">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-31">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb34-32">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb34-33">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-35">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb34-36">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-37">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb34-38">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-39">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>,</span>
<span id="cb34-40">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" (± SE)"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-41">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-42">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb34-43"></span>
<span id="cb34-44">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_mean)</span>
<span id="cb34-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb34-46">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb34-47">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_mean_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb34-48">      p_metab_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb34-49">  }</span>
<span id="cb34-50">}</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/metabolism-mean-by-family-1.png" class="img-fluid"><!-- --></p>
</section>
<section id="individual-metabolism-traces-by-family" class="level2">
<h2 class="anchored" data-anchor-id="individual-metabolism-traces-by-family">9.2 Individual metabolism traces by family</h2>
<div class="sourceCode" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb35-2"></span>
<span id="cb35-3">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metab_cols) {</span>
<span id="cb35-4">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb35-5">    mc_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>)</span>
<span id="cb35-6"></span>
<span id="cb35-7">    p_metab_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-8">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> .data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb35-10">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-14">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb35-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb35-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb35-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-19">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-20">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb35-21">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb35-22"></span>
<span id="cb35-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_by_family)</span>
<span id="cb35-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb35-25">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb35-26">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_individual_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_by_family.png"</span>)),</span>
<span id="cb35-27">      p_metab_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb35-28"></span>
<span id="cb35-29">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb35-30">      p_metab_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(metabolism_df,</span>
<span id="cb35-31">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> .data[[col]],</span>
<span id="cb35-32">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-33">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-34">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-35">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-36">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb35-37">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-38">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-39">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-40">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb35-41">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb35-42"></span>
<span id="cb35-43">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_by_treatment)</span>
<span id="cb35-44">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb35-45">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb35-46">                  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_individual_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_by_treatment.png"</span>)),</span>
<span id="cb35-47">        p_metab_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb35-48">    }</span>
<span id="cb35-49">  }</span>
<span id="cb35-50">}</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/metabolism-individual-by-family-1.png" class="img-fluid"><!-- --></p>
</section>
</section>
<section id="time-series-statistical-analysis" class="level1">
<h1>10 Time-Series Statistical Analysis</h1>
<p>Linear mixed effects models test the effect of experimental variables on metabolism over time. Individual (<code>sample_id_group</code>) is included as a random intercept to account for repeated measures across timepoints. Type III ANOVA with Satterthwaite’s approximation (lmerTest) assesses significance; post-hoc pairwise comparisons use estimated marginal means (emmeans, Tukey adjustment).</p>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">run_ts_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(df, value_col) {</span>
<span id="cb36-2">  has_family    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb36-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb36-4">  has_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb36-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb36-6"></span>
<span id="cb36-7">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_treatment) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-8"></span>
<span id="cb36-9">  df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb36-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[value_col]]), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb36-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb36-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_f     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(time_hr),</span>
<span id="cb36-13">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(trace_id)</span>
<span id="cb36-14">    )</span>
<span id="cb36-15"></span>
<span id="cb36-16">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-17"></span>
<span id="cb36-18">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family)    df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family_id_group))</span>
<span id="cb36-19">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment) df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(treatment_group))</span>
<span id="cb36-20"></span>
<span id="cb36-21">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family)))    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-22">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-23"></span>
<span id="cb36-24">  fixed <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb36-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * family * treatment"</span>)</span>
<span id="cb36-26">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb36-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * family"</span>)</span>
<span id="cb36-28">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb36-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * treatment"</span>)</span>
<span id="cb36-30">  }</span>
<span id="cb36-31"></span>
<span id="cb36-32">  model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lmer</span>(</span>
<span id="cb36-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.formula</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(fixed, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" + (1 | individual)"</span>)),</span>
<span id="cb36-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df</span>
<span id="cb36-35">  )</span>
<span id="cb36-36"></span>
<span id="cb36-37">  anova_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ddf =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Satterthwaite"</span>)</span>
<span id="cb36-38"></span>
<span id="cb36-39">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pairwise comparisons of group combinations at each timepoint</span></span>
<span id="cb36-40">  emm_spec <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb36-41">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb36-42">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb36-43">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb36-44">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb36-45">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb36-46">  }</span>
<span id="cb36-47"></span>
<span id="cb36-48">  emm       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, emm_spec)</span>
<span id="cb36-49">  pairs_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(emm, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb36-50"></span>
<span id="cb36-51">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Main-effect marginal means (collapsed across time)</span></span>
<span id="cb36-52">  emm_main <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb36-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment)</span>
<span id="cb36-54">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb36-55">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family)</span>
<span id="cb36-56">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb36-57">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment)</span>
<span id="cb36-58">  }</span>
<span id="cb36-59"></span>
<span id="cb36-60">  pairs_main <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(emm_main, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb36-61"></span>
<span id="cb36-62">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb36-63">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model         =</span> model,</span>
<span id="cb36-64">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anova         =</span> anova_res,</span>
<span id="cb36-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_by_time =</span> pairs_res,</span>
<span id="cb36-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_main    =</span> pairs_main,</span>
<span id="cb36-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_family    =</span> has_family,</span>
<span id="cb36-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_treatment =</span> has_treatment</span>
<span id="cb36-69">  )</span>
<span id="cb36-70">}</span>
<span id="cb36-71"></span>
<span id="cb36-72">ts_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb36-73"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb36-74">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb36-75">    col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb36-76">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df))</span>
<span id="cb36-77">      ts_stats[[col]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">run_ts_stats</span>(metabolism_df, col)</span>
<span id="cb36-78">  }</span>
<span id="cb36-79">}</span></code></pre></div>
<section id="results-1" class="level2">
<h2 class="anchored" data-anchor-id="results-1">10.1 Results</h2>
<div class="sourceCode" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(ts_stats)) {</span>
<span id="cb37-2">  res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ts_stats[[col]]</span>
<span id="cb37-3">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(res)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb37-4"></span>
<span id="cb37-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">### Metric:"</span>, col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-6"></span>
<span id="cb37-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Type III ANOVA (Satterthwaite approximation):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>anova), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-10"></span>
<span id="cb37-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Marginal means – main effects (collapsed across time):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_main), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-14"></span>
<span id="cb37-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise comparisons by timepoint (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_by_time), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-18">}</span></code></pre></div>
<section id="metric-metabolism_per_area_mm2_measurement" class="level3">
<h3 class="anchored" data-anchor-id="metric-metabolism_per_area_mm2_measurement">10.1.1 Metric: metabolism_per_area_mm2_measurement</h3>
<p><strong>Type III ANOVA (Satterthwaite approximation):</strong></p>
<table class="caption-top table">
<colgroup>
<col style="width: 23%">
<col style="width: 12%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 15%">
<col style="width: 13%">
</colgroup>
<thead>
<tr class="header">
<th></th>
<th style="text-align: right;">Sum Sq</th>
<th style="text-align: right;">Mean Sq</th>
<th style="text-align: right;">NumDF</th>
<th style="text-align: right;">DenDF</th>
<th style="text-align: right;">F value</th>
<th style="text-align: right;">Pr(&gt;F)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>time_f</td>
<td style="text-align: right;">0.0269</td>
<td style="text-align: right;">0.0034</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">592</td>
<td style="text-align: right;">201.3951</td>
<td style="text-align: right;">0.0000</td>
</tr>
<tr class="even">
<td>family</td>
<td style="text-align: right;">0.0002</td>
<td style="text-align: right;">0.0001</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">4.1895</td>
<td style="text-align: right;">0.0085</td>
</tr>
<tr class="odd">
<td>time_f:family</td>
<td style="text-align: right;">0.0009</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">592</td>
<td style="text-align: right;">2.2689</td>
<td style="text-align: right;">0.0006</td>
</tr>
</tbody>
</table>
<p><strong>Marginal means – main effects (collapsed across time):</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: right;">0.0018</td>
<td style="text-align: right;">0.0017</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">1.0878</td>
<td style="text-align: right;">0.6980</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: right;">-0.0015</td>
<td style="text-align: right;">0.0017</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">-0.9143</td>
<td style="text-align: right;">0.7973</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: right;">0.0040</td>
<td style="text-align: right;">0.0017</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">2.4052</td>
<td style="text-align: right;">0.0849</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: right;">-0.0033</td>
<td style="text-align: right;">0.0017</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">-2.0160</td>
<td style="text-align: right;">0.1914</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: right;">0.0022</td>
<td style="text-align: right;">0.0017</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">1.3035</td>
<td style="text-align: right;">0.5636</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: right;">0.0055</td>
<td style="text-align: right;">0.0016</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">3.3629</td>
<td style="text-align: right;">0.0066</td>
</tr>
</tbody>
</table>
<p><strong>Pairwise comparisons by timepoint (Tukey):</strong></p>
<table class="caption-top table">
<colgroup>
<col style="width: 26%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 12%">
<col style="width: 12%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: left;">time_f</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.0000</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">0.5</td>
<td style="text-align: right;">-0.0004</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.1799</td>
<td style="text-align: right;">0.9979</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">0.5</td>
<td style="text-align: right;">-0.0015</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.7412</td>
<td style="text-align: right;">0.8803</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">0.5</td>
<td style="text-align: right;">0.0007</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.3484</td>
<td style="text-align: right;">0.9854</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">0.5</td>
<td style="text-align: right;">-0.0012</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.5591</td>
<td style="text-align: right;">0.9440</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">0.5</td>
<td style="text-align: right;">0.0011</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.5306</td>
<td style="text-align: right;">0.9515</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">0.5</td>
<td style="text-align: right;">0.0023</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.1039</td>
<td style="text-align: right;">0.6876</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">0.0001</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.0474</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-0.0029</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-1.4243</td>
<td style="text-align: right;">0.4860</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">0.0019</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.9313</td>
<td style="text-align: right;">0.7881</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-0.0030</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-1.4723</td>
<td style="text-align: right;">0.4565</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">0.0018</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.8833</td>
<td style="text-align: right;">0.8135</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">0.0049</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">2.3864</td>
<td style="text-align: right;">0.0835</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">1.5</td>
<td style="text-align: right;">0.0014</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.6526</td>
<td style="text-align: right;">0.9145</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">1.5</td>
<td style="text-align: right;">-0.0023</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-1.1083</td>
<td style="text-align: right;">0.6849</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">1.5</td>
<td style="text-align: right;">0.0030</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.4675</td>
<td style="text-align: right;">0.4594</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">1.5</td>
<td style="text-align: right;">-0.0037</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-1.7692</td>
<td style="text-align: right;">0.2917</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">1.5</td>
<td style="text-align: right;">0.0017</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.8066</td>
<td style="text-align: right;">0.8512</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">1.5</td>
<td style="text-align: right;">0.0053</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">2.6095</td>
<td style="text-align: right;">0.0481</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">2</td>
<td style="text-align: right;">0.0023</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.0860</td>
<td style="text-align: right;">0.6985</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">2</td>
<td style="text-align: right;">-0.0018</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.8513</td>
<td style="text-align: right;">0.8297</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">2</td>
<td style="text-align: right;">0.0041</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.9992</td>
<td style="text-align: right;">0.1923</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">2</td>
<td style="text-align: right;">-0.0040</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-1.9512</td>
<td style="text-align: right;">0.2108</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">2</td>
<td style="text-align: right;">0.0019</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">0.8994</td>
<td style="text-align: right;">0.8052</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">2</td>
<td style="text-align: right;">0.0059</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">2.8878</td>
<td style="text-align: right;">0.0225</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">2.5</td>
<td style="text-align: right;">0.0032</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.5385</td>
<td style="text-align: right;">0.4168</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">2.5</td>
<td style="text-align: right;">-0.0013</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.6306</td>
<td style="text-align: right;">0.9221</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">2.5</td>
<td style="text-align: right;">0.0056</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">2.7107</td>
<td style="text-align: right;">0.0368</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">2.5</td>
<td style="text-align: right;">-0.0045</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-2.1887</td>
<td style="text-align: right;">0.1305</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">2.5</td>
<td style="text-align: right;">0.0024</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.1526</td>
<td style="text-align: right;">0.6575</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">2.5</td>
<td style="text-align: right;">0.0069</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">3.3850</td>
<td style="text-align: right;">0.0048</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">3</td>
<td style="text-align: right;">0.0031</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.4628</td>
<td style="text-align: right;">0.4623</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">3</td>
<td style="text-align: right;">-0.0011</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.5329</td>
<td style="text-align: right;">0.9510</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">3</td>
<td style="text-align: right;">0.0062</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">3.0222</td>
<td style="text-align: right;">0.0152</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">3</td>
<td style="text-align: right;">-0.0042</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-2.0143</td>
<td style="text-align: right;">0.1867</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">3</td>
<td style="text-align: right;">0.0032</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.5408</td>
<td style="text-align: right;">0.4155</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">3</td>
<td style="text-align: right;">0.0073</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">3.6016</td>
<td style="text-align: right;">0.0023</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">3.5</td>
<td style="text-align: right;">0.0031</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.4823</td>
<td style="text-align: right;">0.4504</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">3.5</td>
<td style="text-align: right;">-0.0015</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.7074</td>
<td style="text-align: right;">0.8940</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">3.5</td>
<td style="text-align: right;">0.0067</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">3.2489</td>
<td style="text-align: right;">0.0075</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">3.5</td>
<td style="text-align: right;">-0.0046</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-2.2086</td>
<td style="text-align: right;">0.1250</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">3.5</td>
<td style="text-align: right;">0.0036</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.7477</td>
<td style="text-align: right;">0.3024</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">3.5</td>
<td style="text-align: right;">0.0082</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">4.0080</td>
<td style="text-align: right;">0.0005</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">4</td>
<td style="text-align: right;">0.0037</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.7631</td>
<td style="text-align: right;">0.2948</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">4</td>
<td style="text-align: right;">-0.0012</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-0.6040</td>
<td style="text-align: right;">0.9307</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">4</td>
<td style="text-align: right;">0.0075</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">3.6345</td>
<td style="text-align: right;">0.0021</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">4</td>
<td style="text-align: right;">-0.0049</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">-2.3895</td>
<td style="text-align: right;">0.0829</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">4</td>
<td style="text-align: right;">0.0038</td>
<td style="text-align: right;">0.0021</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">1.8489</td>
<td style="text-align: right;">0.2542</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">4</td>
<td style="text-align: right;">0.0088</td>
<td style="text-align: right;">0.0020</td>
<td style="text-align: right;">172.1828</td>
<td style="text-align: right;">4.2938</td>
<td style="text-align: right;">0.0002</td>
</tr>
</tbody>
</table>
</section>
</section>
</section>
<section id="area-under-the-curve-auc" class="level1">
<h1>11 Area Under the Curve (AUC)</h1>
<p>AUC computed per individual via the trapezoid rule across all timepoints. <code>metabolism_per_*</code> is the primary metric matching the paper; <code>corrected_fc</code> and <code>raw_fluorescence</code> are retained for reference.</p>
<div class="sourceCode" id="cb38" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb38-1">compute_auc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(df, value_col, group_vars) {</span>
<span id="cb38-2">  df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[value_col]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-4">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_vars))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb38-6">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">AUC          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trapezoid_auc</span>(time_hr, .data[[value_col]]),</span>
<span id="cb38-7">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_timepoints =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb38-8">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups      =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb38-9">    ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(AUC))</span>
<span id="cb38-11">}</span>
<span id="cb38-12"></span>
<span id="cb38-13"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Only include grouping columns that are actually present in the data</span></span>
<span id="cb38-14">individual_vars <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb38-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"trace_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span>),</span>
<span id="cb38-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)</span>
<span id="cb38-17">)</span>
<span id="cb38-18"></span>
<span id="cb38-19">auc_metab_list <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb38-20"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb38-21">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb38-22">    col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb38-23">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) {</span>
<span id="cb38-24">      auc_metab_list[[col]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb38-25">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">compute_auc</span>(metabolism_df, col, individual_vars) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb38-26">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">metric =</span> col)</span>
<span id="cb38-27">    }</span>
<span id="cb38-28">  }</span>
<span id="cb38-29">}</span>
<span id="cb38-30"></span>
<span id="cb38-31">auc_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(auc_metab_list)</span>
<span id="cb38-32"></span>
<span id="cb38-33"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(auc_all)</span></code></pre></div>
<pre><code>tibble [78 × 6] (S3: tbl_df/tbl/data.frame)
 $ trace_id       : chr [1:78] "1" "10" "11" "12" ...
 $ family_id_group: chr [1:78] "7" "5" "1" "9" ...
 $ treatment_group: chr [1:78] NA NA NA NA ...
 $ AUC            : num [1:78] 0.0359 0.0813 0.0489 0.0122 0.0505 ...
 $ n_timepoints   : int [1:78] 9 9 9 9 9 9 9 9 9 9 ...
 $ metric         : chr [1:78] "metabolism_per_area_mm2_measurement" "metabolism_per_area_mm2_measurement" "metabolism_per_area_mm2_measurement" "metabolism_per_area_mm2_measurement" ...</code></pre>
<section id="auc-summary-tables" class="level2">
<h2 class="anchored" data-anchor-id="auc-summary-tables">11.1 AUC summary tables</h2>
<div class="sourceCode" id="cb40" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1">sum_vars <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb40-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metric"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span>),</span>
<span id="cb40-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(auc_all)</span>
<span id="cb40-4">)</span>
<span id="cb40-5">auc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb40-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(sum_vars))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb40-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb40-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n      =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n</span>(),</span>
<span id="cb40-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb40-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sd     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb40-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se     =</span> sd <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(n),</span>
<span id="cb40-12">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">median =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">median</span>(AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb40-13">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb40-14">  )</span>
<span id="cb40-15"></span>
<span id="cb40-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(auc_summary)</span></code></pre></div>
<pre><code># A tibble: 4 × 8
  metric      family_id_group treatment_group     n   mean     sd      se median
  &lt;chr&gt;       &lt;chr&gt;           &lt;chr&gt;           &lt;int&gt;  &lt;dbl&gt;  &lt;dbl&gt;   &lt;dbl&gt;  &lt;dbl&gt;
1 metabolism… 1               &lt;NA&gt;               19 0.0446 0.0215 0.00493 0.0441
2 metabolism… 5               &lt;NA&gt;               19 0.0373 0.0204 0.00467 0.0366
3 metabolism… 7               &lt;NA&gt;               20 0.0511 0.0179 0.00400 0.0513
4 metabolism… 9               &lt;NA&gt;               20 0.0285 0.0228 0.00510 0.0124</code></pre>
</section>
</section>
<section id="statistical-analysis" class="level1">
<h1>12 Statistical Analysis</h1>
<p>Each individual oyster (<code>sample_id_group</code>) is the observational unit. The model is built from whichever grouping factors are present: both family and treatment (with interaction) when both exist, or a one-way model when only one factor is available. Each plate maps to a unique family × treatment combination, so plate-level and group-level variance are confounded; interpret accordingly.</p>
<div class="sourceCode" id="cb42" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1">run_auc_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(auc_df) {</span>
<span id="cb42-2">  empty <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb42-3"></span>
<span id="cb42-4">  has_family    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(auc_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb42-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(auc_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb42-6">  has_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(auc_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb42-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(auc_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb42-8"></span>
<span id="cb42-9">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_treatment) {</span>
<span id="cb42-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anova =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb42-11">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_full =</span> empty, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_family =</span> empty,</span>
<span id="cb42-12">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_trt =</span> empty,</span>
<span id="cb42-13">                <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_family =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_treatment =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>))</span>
<span id="cb42-14">  }</span>
<span id="cb42-15"></span>
<span id="cb42-16">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family)    auc_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family_id_group))</span>
<span id="cb42-17">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment) auc_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(treatment_group))</span>
<span id="cb42-18"></span>
<span id="cb42-19">  formula_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb42-20">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AUC ~ family * treatment"</span></span>
<span id="cb42-21">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb42-22">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AUC ~ family"</span></span>
<span id="cb42-23">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb42-24">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"AUC ~ treatment"</span></span>
<span id="cb42-25">  }</span>
<span id="cb42-26">  model     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lm</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.formula</span>(formula_str), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> auc_df)</span>
<span id="cb42-27">  anova_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(model)</span>
<span id="cb42-28"></span>
<span id="cb42-29">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb42-30">    pairs_full   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment),</span>
<span id="cb42-31">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb42-32">    pairs_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family),</span>
<span id="cb42-33">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb42-34">    pairs_trt    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment),</span>
<span id="cb42-35">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb42-36">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb42-37">    pairs_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family),</span>
<span id="cb42-38">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb42-39">    pairs_full   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_family</span>
<span id="cb42-40">    pairs_trt    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> empty</span>
<span id="cb42-41">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb42-42">    pairs_trt    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment),</span>
<span id="cb42-43">                                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb42-44">    pairs_full   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_trt</span>
<span id="cb42-45">    pairs_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> empty</span>
<span id="cb42-46">  }</span>
<span id="cb42-47"></span>
<span id="cb42-48">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb42-49">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model         =</span> model,</span>
<span id="cb42-50">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anova         =</span> anova_res,</span>
<span id="cb42-51">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_full    =</span> pairs_full,</span>
<span id="cb42-52">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_family  =</span> pairs_family,</span>
<span id="cb42-53">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_trt     =</span> pairs_trt,</span>
<span id="cb42-54">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_family    =</span> has_family,</span>
<span id="cb42-55">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_treatment =</span> has_treatment</span>
<span id="cb42-56">  )</span>
<span id="cb42-57">}</span>
<span id="cb42-58"></span>
<span id="cb42-59">metrics_to_test <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(auc_all<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>metric)</span>
<span id="cb42-60">stats_results   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map</span>(</span>
<span id="cb42-61">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set_names</span>(metrics_to_test),</span>
<span id="cb42-62">  <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">run_auc_stats</span>(auc_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(metric <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> .x))</span>
<span id="cb42-63">)</span></code></pre></div>
<section id="results-by-metric" class="level2">
<h2 class="anchored" data-anchor-id="results-by-metric">12.1 Results by metric</h2>
<div class="sourceCode" id="cb43" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (met <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metrics_to_test) {</span>
<span id="cb43-2">  stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats_results[[met]]</span>
<span id="cb43-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">### Metric:"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**ANOVA:**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>anova), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-7">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_treatment) {</span>
<span id="cb43-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: family × treatment (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-9">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_full), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: family main effect:**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-14">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: treatment main effect:**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-15">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-17">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_family) {</span>
<span id="cb43-18">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: family (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-19">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-21">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_treatment) {</span>
<span id="cb43-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise: treatment (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb43-25">  }</span>
<span id="cb43-26">}</span></code></pre></div>
<section id="metric-metabolism_per_area_mm2_measurement-1" class="level3">
<h3 class="anchored" data-anchor-id="metric-metabolism_per_area_mm2_measurement-1">12.1.1 Metric: metabolism_per_area_mm2_measurement</h3>
<p><strong>ANOVA:</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th></th>
<th style="text-align: right;">Df</th>
<th style="text-align: right;">Sum Sq</th>
<th style="text-align: right;">Mean Sq</th>
<th style="text-align: right;">F value</th>
<th style="text-align: right;">Pr(&gt;F)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>family</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.0056</td>
<td style="text-align: right;">0.0019</td>
<td style="text-align: right;">4.3721</td>
<td style="text-align: right;">0.0069</td>
</tr>
<tr class="even">
<td>Residuals</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">0.0317</td>
<td style="text-align: right;">0.0004</td>
<td style="text-align: right;">NA</td>
<td style="text-align: right;">NA</td>
</tr>
</tbody>
</table>
<p><strong>Pairwise: family (Tukey):</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: right;">0.0073</td>
<td style="text-align: right;">0.0067</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">1.0858</td>
<td style="text-align: right;">0.6993</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: right;">-0.0065</td>
<td style="text-align: right;">0.0066</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">-0.9809</td>
<td style="text-align: right;">0.7607</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: right;">0.0161</td>
<td style="text-align: right;">0.0066</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">2.4212</td>
<td style="text-align: right;">0.0819</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: right;">-0.0138</td>
<td style="text-align: right;">0.0066</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">-2.0806</td>
<td style="text-align: right;">0.1690</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: right;">0.0088</td>
<td style="text-align: right;">0.0066</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">1.3216</td>
<td style="text-align: right;">0.5523</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: right;">0.0226</td>
<td style="text-align: right;">0.0065</td>
<td style="text-align: right;">74</td>
<td style="text-align: right;">3.4467</td>
<td style="text-align: right;">0.0051</td>
</tr>
</tbody>
</table>
</section>
</section>
</section>
<section id="auc-box-plots-with-statistical-annotations" class="level1">
<h1>13 AUC Box Plots with Statistical Annotations</h1>
<p>Significance labels: <code>***</code> p &lt; 0.001, <code>**</code> p &lt; 0.01, <code>*</code> p &lt; 0.05. Brackets are drawn only for significant pairs (p &lt; 0.05). Plots are generated for whichever grouping factors are present: treatment-only, family-only, all-groups, within-family, and within-treatment.</p>
<div class="sourceCode" id="cb44" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1">sig_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p) {</span>
<span id="cb44-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"***"</span>, p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**"</span>, p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.05</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"*"</span>,</span>
<span id="cb44-3">            <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ns"</span>)</span>
<span id="cb44-4">}</span>
<span id="cb44-5"></span>
<span id="cb44-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Add significance brackets to an existing ggplot.</span></span>
<span id="cb44-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># pairs_df   : data frame with $contrast and $p.value columns</span></span>
<span id="cb44-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># group_levels: ordered character vector matching x-axis factor levels</span></span>
<span id="cb44-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y_vals     : numeric vector of AUC values used to set bracket heights</span></span>
<span id="cb44-10">add_sig_brackets <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(p, pairs_df, group_levels, y_vals) {</span>
<span id="cb44-11">  sig_pairs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb44-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sig_label</span>(p.value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb44-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(label <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"ns"</span>)</span>
<span id="cb44-14">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_pairs) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(p)</span>
<span id="cb44-15"></span>
<span id="cb44-16">  y_max   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">max</span>(y_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb44-17">  y_range <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">range</span>(y_vals, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))</span>
<span id="cb44-18">  step    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> y_range <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.12</span></span>
<span id="cb44-19"></span>
<span id="cb44-20">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># emmeans prefixes factor levels with the variable name (e.g. "family7");</span></span>
<span id="cb44-21">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># resolve back to the bare level used on the x-axis.</span></span>
<span id="cb44-22">  resolve_level <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x, lvls) {</span>
<span id="cb44-23">    x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(x)</span>
<span id="cb44-24">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (x <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> lvls) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(x)</span>
<span id="cb44-25">    lvls_sorted <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> lvls[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nchar</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(lvls)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">decreasing =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)]</span>
<span id="cb44-26">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (lvl <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> lvls_sorted) {</span>
<span id="cb44-27">      lvl_str <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(lvl)</span>
<span id="cb44-28">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">endsWith</span>(x, lvl_str) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nchar</span>(x) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nchar</span>(lvl_str)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(lvl_str)</span>
<span id="cb44-29">    }</span>
<span id="cb44-30">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span></span>
<span id="cb44-31">  }</span>
<span id="cb44-32"></span>
<span id="cb44-33">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(sig_pairs))) {</span>
<span id="cb44-34">    parts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sig_pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>contrast[i]), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" - "</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]]</span>
<span id="cb44-35">    g1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">resolve_level</span>(parts[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], group_levels)</span>
<span id="cb44-36">    g2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">resolve_level</span>(parts[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], group_levels)</span>
<span id="cb44-37">    x1 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(g1, group_levels)</span>
<span id="cb44-38">    x2 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(g2, group_levels)</span>
<span id="cb44-39">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(x1) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(x2)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb44-40">    bar_y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> y_max <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> i <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> step</span>
<span id="cb44-41">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> p <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb44-42">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x2,</span>
<span id="cb44-43">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> bar_y,</span>
<span id="cb44-44">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb44-45">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x1, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x1,</span>
<span id="cb44-46">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> bar_y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> step <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb44-47">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb44-48">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"segment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x2, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">xend =</span> x2,</span>
<span id="cb44-49">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">yend =</span> bar_y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> step <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,</span>
<span id="cb44-50">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb44-51">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">annotate</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"text"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> (x1 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> x2) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>,</span>
<span id="cb44-52">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> bar_y <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> step <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>,</span>
<span id="cb44-53">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">label =</span> sig_pairs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>label[i], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.5</span>)</span>
<span id="cb44-54">  }</span>
<span id="cb44-55">  p</span>
<span id="cb44-56">}</span></code></pre></div>
<div class="sourceCode" id="cb45" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb45-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (met <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metrics_to_test) {</span>
<span id="cb45-2">  df      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> auc_all <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(metric <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> met)</span>
<span id="cb45-3">  stats   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats_results[[met]]</span>
<span id="cb45-4">  y_lab   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">auc_y_label</span>(met)</span>
<span id="cb45-5">  has_fam <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_family</span>
<span id="cb45-6">  has_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>has_treatment</span>
<span id="cb45-7"></span>
<span id="cb45-8">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Treatment main effect (x = treatment, tick = treatment name) ───────</span></span>
<span id="cb45-9">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb45-10">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(treatment_group))))</span>
<span id="cb45-12">    grps <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb45-13">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-14">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-15">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-16">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_colours[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-17">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb45-19">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb45-20">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb45-21">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_treatment_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb45-22">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb45-23">  }</span>
<span id="cb45-24"></span>
<span id="cb45-25">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Family main effect (x = family, tick = family name) ───────────────</span></span>
<span id="cb45-26">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_fam) {</span>
<span id="cb45-27">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-28">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family_id_group,</span>
<span id="cb45-29">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(family_id_group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)))</span>
<span id="cb45-30">    grps <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb45-31">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-32">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-33">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-35">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-36">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb45-37">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb45-38">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb45-39">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_family_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb45-40">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb45-41">  }</span>
<span id="cb45-42"></span>
<span id="cb45-43">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Remaining plots require both factors</span></span>
<span id="cb45-44">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">||</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_trt) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb45-45"></span>
<span id="cb45-46">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── All family:treatment groups (x = family:treatment) ─────────────────</span></span>
<span id="cb45-47">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># emmeans contrasts use spaces; convert to colon to match tick labels</span></span>
<span id="cb45-48">  pairs_fc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_full <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-49">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">contrast =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(</span>
<span id="cb45-50">      contrast,</span>
<span id="cb45-51">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"([a-z]+) ([a-z]+)( - )([a-z]+) ([a-z]+)"</span>,</span>
<span id="cb45-52">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">2</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">3</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">4:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">5"</span></span>
<span id="cb45-53">    ))</span>
<span id="cb45-54">  df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-55">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(</span>
<span id="cb45-56">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>),</span>
<span id="cb45-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)),</span>
<span id="cb45-58">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb45-59">    ))</span>
<span id="cb45-60">  grps     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb45-61">  fill_map <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">make_palette</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(grps)), grps)</span>
<span id="cb45-62">  p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-63">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-64">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-65">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fill_map, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-66">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family : Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-67">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-68">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">axis.text.x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">angle =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">hjust =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>))</span>
<span id="cb45-69">  p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, pairs_fc, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb45-70">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb45-71">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_all_groups_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb45-72">         p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb45-73"></span>
<span id="cb45-74">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Within each family: treatment comparison (x = family:treatment) ────</span></span>
<span id="cb45-75">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Tick labels are family:treatment so these plots are visually distinct</span></span>
<span id="cb45-76">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># from the treatment main-effect plot above.</span></span>
<span id="cb45-77">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (fam <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)) {</span>
<span id="cb45-78">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-79">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(family_id_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> fam) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-80">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(</span>
<span id="cb45-81">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>),</span>
<span id="cb45-82">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)),</span>
<span id="cb45-83">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb45-84">      ))</span>
<span id="cb45-85">    grps     <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb45-86">    pairs_sub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-87">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_count</span>(contrast, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(fam, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb45-88">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-89">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-90">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-91">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fill_map[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-92">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family : Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-93">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb45-94">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, pairs_sub, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb45-95">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb45-96">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_"</span>, fam, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_trt_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb45-97">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb45-98">  }</span>
<span id="cb45-99"></span>
<span id="cb45-100">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ── Within each treatment: family comparison (x = family:treatment) ────</span></span>
<span id="cb45-101">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Tick labels are family:treatment so these plots are visually distinct</span></span>
<span id="cb45-102">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># from the family main-effect plot above.</span></span>
<span id="cb45-103">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (trt <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group))) {</span>
<span id="cb45-104">    df_p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-105">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(treatment_group <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> trt) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-106">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(</span>
<span id="cb45-107">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>),</span>
<span id="cb45-108">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">levels =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>)),</span>
<span id="cb45-109">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb45-110">      ))</span>
<span id="cb45-111">    grps      <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">levels</span>(df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>x)</span>
<span id="cb45-112">    pairs_sub <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> pairs_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb45-113">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_count</span>(contrast, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">":"</span>, trt)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb45-114">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(df_p, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> AUC, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> x)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-115">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_boxplot</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">outlier.shape =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-116">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_jitter</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.5</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-117">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fill_map[grps], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">guide =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"none"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-118">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family : Treatment"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> y_lab) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb45-119">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>)</span>
<span id="cb45-120">    p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">add_sig_brackets</span>(p, pairs_sub, grps, df_p<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>AUC)</span>
<span id="cb45-121">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p)</span>
<span id="cb45-122">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_"</span>, trt, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_fam_"</span>, met, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb45-123">           p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb45-124">  }</span>
<span id="cb45-125">}</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260713-mgig-36C_files/figure-gfm/auc-boxplots-1.png" class="img-fluid"><!-- --></p>
</section>
<section id="save-output-data" class="level1">
<h1>14 Save Output Data</h1>
<div class="sourceCode" id="cb46" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(auc_all,      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_all_metrics.csv"</span>))</span>
<span id="cb46-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(auc_summary,  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"auc_summary.csv"</span>))</span>
<span id="cb46-3"></span>
<span id="cb46-4"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb46-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(metabolism_df,</span>
<span id="cb46-6">            <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism.csv"</span>))</span>
<span id="cb46-7"></span>
<span id="cb46-8">stats_compiled <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(metrics_to_test, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(met) {</span>
<span id="cb46-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">bind_rows</span>(</span>
<span id="cb46-10">    stats_results[[met]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_full <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb46-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family:treatment"</span>),</span>
<span id="cb46-12">    stats_results[[met]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb46-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family"</span>),</span>
<span id="cb46-14">    stats_results[[met]]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_trt <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb46-15">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comparison =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment"</span>)</span>
<span id="cb46-16">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">metric =</span> met)</span>
<span id="cb46-17">})</span>
<span id="cb46-18"></span>
<span id="cb46-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write_csv</span>(stats_compiled,</span>
<span id="cb46-20">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pairwise_stats.csv"</span>))</span>
<span id="cb46-21"></span>
<span id="cb46-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Output files written to: "</span>, out_dir)</span></code></pre></div>


</section>

 ]]></description>
  <category>2026</category>
  <category>resazurin</category>
  <category>Magallana gigas</category>
  <category>Crassostrea gigas</category>
  <category>Pacific oyster</category>
  <category>heat stress</category>
  <guid>https://robertslab.github.io/sams-notebook/posts/2026/2026-07-13-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/</guid>
  <pubDate>Mon, 13 Jul 2026 07:00:00 GMT</pubDate>
</item>
<item>
  <title>Resazurin Assays - USDA M.gigas Families in Response to Temperature Stress</title>
  <dc:creator>Sam White</dc:creator>
  <link>https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/</link>
  <description><![CDATA[ 





<section id="intro" class="level1">
<h1>INTRO</h1>
<p>Notebook was knitted from <a href="https://github.com/RobertsLab/sormi-assay-development/blob/main/Resazurin/code/01.00-resazurin-20260624-mgig-33C.Rmd">01.00-resazurin-20260624-mgig-33C.Rmd</a></p>
</section>
<section id="results" class="level1">
<h1>RESULTS</h1>
<p>Resazurin-based metabolic activity was measured in nine USDA <em>M. gigas</em> families (1, 2, 3, 5, 6, 7, 8, 9, 10) at four timepoints (0, 1, 2, 3 h) during 33°C heat stress, with fluorescence normalized to shell area (mm²) across three replicate measurement rounds (n = 18 individuals per family).</p>
<p>Metabolic activity increased significantly over time (Type III LME ANOVA: F₃,₄₅₉ = 389.9, p &lt; 0.0001), confirming that the resazurin assay detected a biologically meaningful response to heat exposure. However, no significant differences in metabolism were detected among families, either as a main effect (F₈,₁₅₃ = 0.95, p = 0.48) or as a family × time interaction (F₂₄,₄₅₉ = 0.94, p = 0.54).</p>
<p>AUC (area under the curve) analysis corroborated these findings: the one-way ANOVA on per-individual AUC values showed no significant family effect (F₈,₁₅₃ = 1.03, p = 0.42), and no pairwise family comparisons reached significance after Tukey adjustment (all p ≥ 0.24). Family 3 had the numerically highest mean AUC (0.00377 ± 0.000414 SE) and Family 1 the lowest (0.00234 ± 0.000157 SE), but these differences were not statistically distinguishable given the high within-family variability.</p>
<hr>
</section>
<section id="background" class="level1">
<h1>1 Background</h1>
<p>Adult oysters from nine USDA families were placed in plastic cups and submerged in ~100 mL of freshly prepared resazurin working solution at room temperature (~22°C). Cups were incubated in a water table at 33°C. Three rounds of measurements were performed, with different individuals from each family used in each round. At designated timepoints, 200 µL of resazurin was sampled from each cup and placed in a 96-well plate. Fluorescence was measured using a Synergy HTX (Agilent) plate reader.</p>
<p>See <code>Resazurin/data/20260624-mgig-33C/README.md</code> for full experimental notes.</p>
<section id="expected-inputs" class="level2">
<h2 class="anchored" data-anchor-id="expected-inputs">1.1 Expected inputs</h2>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">Path</th>
<th style="text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>Resazurin/data/20260624-mgig-33C/plate-*-T*.txt</code></td>
<td style="text-align: left;">Plate reader fluorescence exports (one file per plate per timepoint)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>Resazurin/data/20260624-mgig-33C/layout.csv</code></td>
<td style="text-align: left;">Well metadata: plate ID, well ID, blank flag, family groups, cup ID (<code>cup_ID.group</code>), measurement round (<code>round.group</code>), unique individual ID (<code>sample_ID.group</code>), area measurements (mm², from ImageJ)</td>
</tr>
</tbody>
</table>
</section>
<section id="expected-outputs" class="level2">
<h2 class="anchored" data-anchor-id="expected-outputs">1.2 Expected outputs</h2>
<p>All outputs are written to <code>Resazurin/outputs/01.00-resazurin-20260624-mgig-33C/</code>.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">File</th>
<th style="text-align: left;">Description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"><code>figures/</code></td>
<td style="text-align: left;">All plots generated by this script</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>auc_all_metrics.csv</code></td>
<td style="text-align: left;">Per-individual AUC values for every active measurement metric</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>auc_summary.csv</code></td>
<td style="text-align: left;">Group-level AUC summary statistics (mean, SD, SE, median)</td>
</tr>
<tr class="even">
<td style="text-align: left;"><code>metabolism.csv</code></td>
<td style="text-align: left;">Full per-well per-timepoint metabolism data frame</td>
</tr>
<tr class="odd">
<td style="text-align: left;"><code>pairwise_stats.csv</code></td>
<td style="text-align: left;">Tukey-adjusted pairwise comparisons from AUC linear models</td>
</tr>
</tbody>
</table>
</section>
</section>
<section id="setup" class="level1">
<h1>2 Setup</h1>
<section id="knitr-options" class="level2">
<h2 class="anchored" data-anchor-id="knitr-options">2.1 Knitr options</h2>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span>opts_chunk<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set</span>(</span>
<span id="cb1-2">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">echo =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Display code chunks</span></span>
<span id="cb1-3">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">eval =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Evaluate code chunks</span></span>
<span id="cb1-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warning =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide warnings</span></span>
<span id="cb1-5">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">message =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>,     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Hide messages</span></span>
<span id="cb1-6">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">comment =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,         <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Prevents appending '##' to beginning of lines in code output</span></span>
<span id="cb1-7">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">results =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'hold'</span>     <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Holds output so it's all printed together after code chunk</span></span>
<span id="cb1-8">)</span></code></pre></div>
</section>
<section id="load-libraries" class="level2">
<h2 class="anchored" data-anchor-id="load-libraries">2.2 Load libraries</h2>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(tidyverse)</span>
<span id="cb2-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(pracma)       <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># trapz()</span></span>
<span id="cb2-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(lme4)</span>
<span id="cb2-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(lmerTest)</span>
<span id="cb2-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(emmeans)</span>
<span id="cb2-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(multcompView)</span>
<span id="cb2-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(cowplot)</span>
<span id="cb2-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(colorspace)   <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># qualitative_hcl() for large palettes</span></span></code></pre></div>
</section>
</section>
<section id="helper-functions" class="level1">
<h1>3 Helper Functions</h1>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1">normalize_well_id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(x) {</span>
<span id="cb3-2">  x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(x))</span>
<span id="cb3-3">  valid <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(x, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Z]+[0-9]+$"</span>)</span>
<span id="cb3-4">  out <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_character_</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(x))</span>
<span id="cb3-5">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(valid)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(out)</span>
<span id="cb3-6">  m <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(x[valid], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^([A-Z]+)([0-9]+)$"</span>)</span>
<span id="cb3-7">  out[valid] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(m[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>]))</span>
<span id="cb3-8">  out</span>
<span id="cb3-9">}</span>
<span id="cb3-10"></span>
<span id="cb3-11">parse_time_hr <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-12">  hit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path),</span>
<span id="cb3-13">                   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)[_-]T([0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?)</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>)</span>
<span id="cb3-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(hit[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>])</span>
<span id="cb3-15">}</span>
<span id="cb3-16"></span>
<span id="cb3-17">parse_plate_id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-18">  hit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_match</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path),</span>
<span id="cb3-19">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)^[0-9]{8}_(round[0-9]+)_T[0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>)</span>
<span id="cb3-20">  id <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> hit[, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]</span>
<span id="cb3-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ifelse</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"unknown"</span>, id)</span>
<span id="cb3-22">}</span>
<span id="cb3-23"></span>
<span id="cb3-24">extract_results_block <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(lines) {</span>
<span id="cb3-25">  results_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(lines) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Results"</span>)</span>
<span id="cb3-26">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(results_idx) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stop</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No Results section found"</span>)</span>
<span id="cb3-27">  idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> results_idx[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb3-28">  header_tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(lines[idx <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>()</span>
<span id="cb3-29">  col_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> header_tokens[</span>
<span id="cb3-30">    header_tokens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(header_tokens, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[0-9]+$"</span>)]</span>
<span id="cb3-31">  j <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> idx <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb3-32">  data_lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>()</span>
<span id="cb3-33">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">while</span> (j <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(lines)) {</span>
<span id="cb3-34">    line <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> lines[j]</span>
<span id="cb3-35">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(line) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span></span>
<span id="cb3-36">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(line, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^[A-Za-z]</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">break</span></span>
<span id="cb3-37">    data_lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(data_lines, line)</span>
<span id="cb3-38">    j <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> j <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb3-39">  }</span>
<span id="cb3-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_ids =</span> col_ids, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data_lines =</span> data_lines)</span>
<span id="cb3-41">}</span>
<span id="cb3-42"></span>
<span id="cb3-43">parse_plate_export <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb3-44">  lines <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readLines</span>(path, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">warn =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb3-45">  res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">extract_results_block</span>(lines)</span>
<span id="cb3-46"></span>
<span id="cb3-47">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>data_lines, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(line) {</span>
<span id="cb3-48">    tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_split</span>(line, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">t"</span>)[[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>()</span>
<span id="cb3-49">    tokens <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tokens[tokens <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>]</span>
<span id="cb3-50">    row_letter <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> tokens[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb3-51">    nums <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(tokens[<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]))</span>
<span id="cb3-52">    valid_idx <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(nums))</span>
<span id="cb3-53">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(valid_idx) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>())</span>
<span id="cb3-54">    vals <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> nums[valid_idx]</span>
<span id="cb3-55">    n <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(vals), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids))</span>
<span id="cb3-56">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>(</span>
<span id="cb3-57">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(row_letter),</span>
<span id="cb3-58">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)]),</span>
<span id="cb3-59">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normalize_well_id</span>(</span>
<span id="cb3-60">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(row_letter), res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>col_ids[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)])),</span>
<span id="cb3-61">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value   =</span> vals[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)]</span>
<span id="cb3-62">    )</span>
<span id="cb3-63">  }) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb3-64">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb3-65">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_id</span>(path)),</span>
<span id="cb3-66">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_hr  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_time_hr</span>(path)</span>
<span id="cb3-67">    )</span>
<span id="cb3-68">}</span>
<span id="cb3-69"></span>
<span id="cb3-70">trapezoid_auc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(time_hr, value) {</span>
<span id="cb3-71">  ok <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)</span>
<span id="cb3-72">  t <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> time_hr[ok]</span>
<span id="cb3-73">  v <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> value[ok]</span>
<span id="cb3-74">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(t) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span>)</span>
<span id="cb3-75">  ord <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">order</span>(t)</span>
<span id="cb3-76">  t <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> t[ord]; v <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> v[ord]</span>
<span id="cb3-77">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">diff</span>(t) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">head</span>(v, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tail</span>(v, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>)</span>
<span id="cb3-78">}</span>
<span id="cb3-79"></span>
<span id="cb3-80"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Shared helper: extract display unit string from a measurement column name.</span></span>
<span id="cb3-81"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># e.g. "area_mm2_measurement" -&gt; "mm²", "weight_mg_measurement" -&gt; "mg"</span></span>
<span id="cb3-82">parse_meas_unit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col_name) {</span>
<span id="cb3-83">  unit_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> col_name <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-84">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-85">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_measurement$"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb3-86">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_extract</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^_]+$"</span>)</span>
<span id="cb3-87">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">case_when</span>(</span>
<span id="cb3-88">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm2"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm²"</span>,</span>
<span id="cb3-89">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm2"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm²"</span>,</span>
<span id="cb3-90">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm3"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"mm³"</span>,</span>
<span id="cb3-91">    unit_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm3"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"cm³"</span>,</span>
<span id="cb3-92">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>              <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> unit_raw</span>
<span id="cb3-93">  )</span>
<span id="cb3-94">}</span>
<span id="cb3-95"></span>
<span id="cb3-96"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y-axis label for metabolism line plots: "fold change/mm²"</span></span>
<span id="cb3-97">metabolism_y_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col_name) {</span>
<span id="cb3-98">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Metabolism (fold change/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_meas_unit</span>(col_name), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>)</span>
<span id="cb3-99">}</span>
<span id="cb3-100"></span>
<span id="cb3-101"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># y-axis label for AUC box plots: "Metabolism (AUC; mm²)"</span></span>
<span id="cb3-102">auc_y_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(metric_name) {</span>
<span id="cb3-103">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Metabolism (AUC; "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_meas_unit</span>(metric_name), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">")"</span>)</span>
<span id="cb3-104">}</span></code></pre></div>
</section>
<section id="load-data" class="level1">
<h1>4 Load Data</h1>
<section id="plate-export-files" class="level2">
<h2 class="anchored" data-anchor-id="plate-export-files">4.1 Plate export files</h2>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1">proj_root <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> rprojroot<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">find_rstudio_root_file</span>()</span>
<span id="cb4-2">data_dir  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(proj_root, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resazurin"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"data"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"20260624-mgig-33C"</span>)</span>
<span id="cb4-3">out_dir   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(proj_root, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Resazurin"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"outputs"</span>,</span>
<span id="cb4-4">                        <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"01.00-resazurin-20260624-mgig-33C"</span>)</span>
<span id="cb4-5">fig_dir   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(out_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"figures"</span>)</span>
<span id="cb4-6"></span>
<span id="cb4-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(fig_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(out_dir, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">recursive =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">showWarnings =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb4-9"></span>
<span id="cb4-10">plate_files <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list.files</span>(</span>
<span id="cb4-11">  data_dir,</span>
<span id="cb4-12">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pattern =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"(?i)^[0-9]{8}_round[0-9]+_T[0-9]+(?:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.[0-9]+)?</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">.txt$"</span>,</span>
<span id="cb4-13">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">full.names =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb4-14">)</span>
<span id="cb4-15"></span>
<span id="cb4-16">plate_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">map_dfr</span>(plate_files, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(path) {</span>
<span id="cb4-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tryCatch</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">parse_plate_export</span>(path),</span>
<span id="cb4-18">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">error =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(e) {</span>
<span id="cb4-19">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Parse error in "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">basename</span>(path), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">": "</span>, e<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>message)</span>
<span id="cb4-20">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb4-21">           })</span>
<span id="cb4-22">})</span>
<span id="cb4-23"></span>
<span id="cb4-24"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(plate_raw)</span></code></pre></div>
<pre><code>tibble [1,152 × 6] (S3: tbl_df/tbl/data.frame)
 $ row_id  : chr [1:1152] "A" "A" "A" "A" ...
 $ col_id  : int [1:1152] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id : chr [1:1152] "A1" "A2" "A3" "A4" ...
 $ value   : num [1:1152] 627 598 599 580 563 752 577 559 568 565 ...
 $ plate_id: chr [1:1152] "round1" "round1" "round1" "round1" ...
 $ time_hr : num [1:1152] 0 0 0 0 0 0 0 0 0 0 ...</code></pre>
</section>
<section id="plate-consistency-check" class="level2">
<h2 class="anchored" data-anchor-id="plate-consistency-check">4.2 Plate consistency check</h2>
<p>Checks that every plate has the same number of wells at every timepoint. The expected well count is the mode across all plate × timepoint reads. Any plate with at least one deviating read is flagged and dropped entirely before any further analysis — removing only the aberrant timepoint would break the fold-change baseline calculation.</p>
<div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1">well_counts <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(plate_id, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n_wells =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(well_id), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb6-4"></span>
<span id="cb6-5">expected_n_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.integer</span>(</span>
<span id="cb6-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">which.max</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">table</span>(well_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>n_wells)))</span>
<span id="cb6-7">)</span>
<span id="cb6-8"></span>
<span id="cb6-9">inconsistent_reads <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> well_counts <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(n_wells <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> expected_n_wells) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_id, time_hr)</span>
<span id="cb6-12"></span>
<span id="cb6-13">inconsistent_plate_ids <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(inconsistent_reads<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_id)</span>
<span id="cb6-14"></span>
<span id="cb6-15"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(inconsistent_reads) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb6-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Plate consistency check FAILED.**"</span>,</span>
<span id="cb6-17">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected"</span>, expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells per plate-timepoint read."</span>,</span>
<span id="cb6-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(inconsistent_plate_ids),</span>
<span id="cb6-19">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate(s) have at least one deviating read and are excluded"</span>,</span>
<span id="cb6-20">      <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"from all analyses:</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(</span>
<span id="cb6-22">    inconsistent_reads,</span>
<span id="cb6-23">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Wells read"</span>),</span>
<span id="cb6-24">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">caption   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Expected:"</span>, expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells per read"</span>)</span>
<span id="cb6-25">  ), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-27">  plate_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb6-28">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>plate_id <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> inconsistent_plate_ids)</span>
<span id="cb6-29">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(inconsistent_plate_ids),</span>
<span id="cb6-30">          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" plate(s) removed from plate_raw: "</span>,</span>
<span id="cb6-31">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(inconsistent_plate_ids, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb6-32">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb6-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate consistency check passed: all"</span>,</span>
<span id="cb6-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">n_distinct</span>(well_counts<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>plate_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plates have"</span>,</span>
<span id="cb6-35">      expected_n_wells, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"wells at every timepoint.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb6-36">}</span></code></pre></div>
<p>Plate consistency check passed: all 3 plates have 96 wells at every timepoint.</p>
</section>
<section id="layout-file" class="level2">
<h2 class="anchored" data-anchor-id="layout-file">4.3 Layout file</h2>
<div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1">layout_path <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(data_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"layout.csv"</span>)</span>
<span id="cb7-2"></span>
<span id="cb7-3">layout_raw <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">read_csv</span>(layout_path,</span>
<span id="cb7-4">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col_types =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cols</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.default =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"c"</span>),</span>
<span id="cb7-5">                       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">show_col_types =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb7-6"></span>
<span id="cb7-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Standardise column names to snake_case</span></span>
<span id="cb7-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"[^a-z0-9]+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace_all</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_+"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|&gt;</span></span>
<span id="cb7-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_replace</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_$"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)</span>
<span id="cb7-13"></span>
<span id="cb7-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalise plate_id to match plate file ids (strip "plate-" prefix)</span></span>
<span id="cb7-15">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">plate_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(plate_id), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^plate-"</span>),</span>
<span id="cb7-18">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">well_id  =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">normalize_well_id</span>(plate_well),</span>
<span id="cb7-19">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_blank =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"is_blank"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_raw))</span>
<span id="cb7-20">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(is_blank)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"YES"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Y"</span>)</span>
<span id="cb7-21">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-22">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb7-23">  )</span>
<span id="cb7-24"></span>
<span id="cb7-25">found_exclude_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(</span>
<span id="cb7-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_from_analysis"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"omit"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"not_analyzed"</span>),</span>
<span id="cb7-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)</span>
<span id="cb7-28">)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]</span>
<span id="cb7-29">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb7-31">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exclude_from_analysis =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(found_exclude_col))</span>
<span id="cb7-32">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">toupper</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(.data[[found_exclude_col]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span></span>
<span id="cb7-33">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"TRUE"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"1"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"YES"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Y"</span>)</span>
<span id="cb7-34">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb7-35">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span></span>
<span id="cb7-36">  )</span>
<span id="cb7-37"></span>
<span id="cb7-38"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Identify measurement columns and group columns</span></span>
<span id="cb7-39">measurement_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)[</span>
<span id="cb7-40">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_measurement$"</span>)]</span>
<span id="cb7-41">group_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean)[</span>
<span id="cb7-42">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_detect</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(layout_clean), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_group$"</span>)]</span>
<span id="cb7-43"></span>
<span id="cb7-44"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Cast measurement columns to numeric</span></span>
<span id="cb7-45">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-46">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(measurement_cols),</span>
<span id="cb7-47">                <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">suppressWarnings</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.numeric</span>(.x))))</span>
<span id="cb7-48"></span>
<span id="cb7-49"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Determine which measurement columns actually contain finite data</span></span>
<span id="cb7-50">active_meas_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> measurement_cols[</span>
<span id="cb7-51">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sapply</span>(measurement_cols, <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(col)</span>
<span id="cb7-52">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(layout_clean[[col]]), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>))]</span>
<span id="cb7-53"></span>
<span id="cb7-54"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Normalise group values to lowercase so they match colour scale definitions</span></span>
<span id="cb7-55">layout_clean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb7-56">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">across</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_cols),</span>
<span id="cb7-57">                <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_to_lower</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(.x)))))</span>
<span id="cb7-58"></span>
<span id="cb7-59"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group columns: "</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(group_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb7-60"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Active measurement columns: "</span>,</span>
<span id="cb7-61">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(active_meas_cols, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">", "</span>))</span>
<span id="cb7-62"></span>
<span id="cb7-63"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(layout_clean)</span></code></pre></div>
<pre><code>tibble [180 × 16] (S3: tbl_df/tbl/data.frame)
 $ plate_id             : chr [1:180] "round1" "round1" "round1" "round1" ...
 $ plate_well           : chr [1:180] "A1" "A2" "A3" "A4" ...
 $ is_blank             : logi [1:180] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ family_id_group      : chr [1:180] "1" "2" "3" "5" ...
 $ cup_id_group         : chr [1:180] "1" "2" "3" "4" ...
 $ round_group          : chr [1:180] "1" "1" "1" "1" ...
 $ sample_id_group      : chr [1:180] "1_01" "1_02" "1_03" "1_04" ...
 $ exclude_from_analysis: logi [1:180] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:180] NA NA NA NA ...
 $ weight_g_measurement : num [1:180] NA NA NA NA NA NA NA NA NA NA ...
 $ width_mm_measurement : num [1:180] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:180] NA NA NA NA NA NA NA NA NA NA ...
 $ treatment_group      : chr [1:180] NA NA NA NA ...
 $ area_mm2_measurement : num [1:180] 1441 1594 1362 1860 1407 ...
 $ imagej_id            : chr [1:180] "2" "2" "1" "1" ...
 $ well_id              : chr [1:180] "A1" "A2" "A3" "A4" ...</code></pre>
</section>
</section>
<section id="merge-plate-data-with-layout" class="level1">
<h1>5 Merge Plate Data with Layout</h1>
<div class="sourceCode" id="cb9" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1">dat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> plate_raw <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(</span>
<span id="cb9-3">    layout_clean <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-4">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(plate_id, well_id, is_blank, exclude_from_analysis,</span>
<span id="cb9-5">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any_of</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span>),</span>
<span id="cb9-6">             <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(group_cols), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(measurement_cols)),</span>
<span id="cb9-7">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"well_id"</span>)</span>
<span id="cb9-8">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb9-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb9-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">is_blank =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace_na</span>(is_blank, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>),</span>
<span id="cb9-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exclude_from_analysis =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replace_na</span>(exclude_from_analysis, <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)</span>
<span id="cb9-12">  )</span>
<span id="cb9-13"></span>
<span id="cb9-14"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(dat)</span></code></pre></div>
<pre><code>tibble [1,152 × 18] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:1152] "A" "A" "A" "A" ...
 $ col_id               : int [1:1152] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id              : chr [1:1152] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:1152] 627 598 599 580 563 752 577 559 568 565 ...
 $ plate_id             : chr [1:1152] "round1" "round1" "round1" "round1" ...
 $ time_hr              : num [1:1152] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:1152] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:1152] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:1152] NA NA NA NA ...
 $ family_id_group      : chr [1:1152] "1" "2" "3" "5" ...
 $ cup_id_group         : chr [1:1152] "1" "2" "3" "4" ...
 $ round_group          : chr [1:1152] "1" "1" "1" "1" ...
 $ sample_id_group      : chr [1:1152] "1_01" "1_02" "1_03" "1_04" ...
 $ treatment_group      : chr [1:1152] NA NA NA NA ...
 $ weight_g_measurement : num [1:1152] NA NA NA NA NA NA NA NA NA NA ...
 $ width_mm_measurement : num [1:1152] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:1152] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:1152] 1441 1594 1362 1860 1407 ...</code></pre>
</section>
<section id="raw-fluorescence" class="level1">
<h1>6 Raw Fluorescence</h1>
<section id="data-frame" class="level2">
<h2 class="anchored" data-anchor-id="data-frame">6.1 Data frame</h2>
<div class="sourceCode" id="cb11" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Wells in the plate reader output that have no layout entry get all-NA group</span></span>
<span id="cb11-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># columns after the join. Keep only wells assigned to at least one group.</span></span>
<span id="cb11-3">active_gc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">intersect</span>(group_cols, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(dat))</span>
<span id="cb11-4"></span>
<span id="cb11-5">raw_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(</span>
<span id="cb11-7">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank,</span>
<span id="cb11-8">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(active_gc) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb11-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_any</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">all_of</span>(active_gc), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(.))</span>
<span id="cb11-10">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb11-11">      <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span></span>
<span id="cb11-12">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb11-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb11-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb11-15">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb11-16">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb11-17">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb11-18">    )</span>
<span id="cb11-19">  )</span>
<span id="cb11-20"></span>
<span id="cb11-21">families   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(raw_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group)), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">numeric =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb11-22">treatments <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sort</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(raw_df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group)))</span>
<span id="cb11-23"></span>
<span id="cb11-24">n_fam <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(families)</span>
<span id="cb11-25">n_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(treatments)</span>
<span id="cb11-26"></span>
<span id="cb11-27"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Palette strategy:</span></span>
<span id="cb11-28"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   &lt;= 7 groups : Okabe-Ito (gold standard for colorblind-safe figures).</span></span>
<span id="cb11-29"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#   &gt;  7 groups : colorspace::qualitative_hcl("Dynamic") scales to any N</span></span>
<span id="cb11-30"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#                 using perceptually uniform HCL space — no colour collisions.</span></span>
<span id="cb11-31"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Black (#000000) is excluded from both and reserved for blank wells.</span></span>
<span id="cb11-32">okabe_ito_7 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb11-33">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#E69F00"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#56B4E9"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#009E73"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#F0E442"</span>,</span>
<span id="cb11-34">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#0072B2"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#D55E00"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"#CC79A7"</span></span>
<span id="cb11-35">)</span>
<span id="cb11-36">make_palette <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(n) {</span>
<span id="cb11-37">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>L) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">character</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>))</span>
<span id="cb11-38">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (n <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(okabe_ito_7)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(okabe_ito_7[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n)])</span>
<span id="cb11-39">  colorspace<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qualitative_hcl</span>(n, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">palette =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Dynamic"</span>)</span>
<span id="cb11-40">}</span>
<span id="cb11-41"></span>
<span id="cb11-42">all_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">make_palette</span>(n_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> n_trt)</span>
<span id="cb11-43">fam_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(all_colours[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_fam)], families)</span>
<span id="cb11-44">trt_colours   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(all_colours[n_fam <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_trt)], treatments)</span>
<span id="cb11-45"></span>
<span id="cb11-46">lty_pool <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"solid"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dashed"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotted"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dotdash"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"longdash"</span>)</span>
<span id="cb11-47">trt_linetypes <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(</span>
<span id="cb11-48">  lty_pool[(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">seq_len</span>(n_trt) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(lty_pool) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>L],</span>
<span id="cb11-49">  treatments</span>
<span id="cb11-50">)</span>
<span id="cb11-51">plate_well_colours <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">blank =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"black"</span>, fam_colours)</span>
<span id="cb11-52"></span>
<span id="cb11-53">has_trt <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> n_trt <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span></span>
<span id="cb11-54"></span>
<span id="cb11-55"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(raw_df)</span></code></pre></div>
<pre><code>tibble [648 × 19] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:648] "A" "A" "A" "A" ...
 $ col_id               : int [1:648] 1 2 3 4 5 6 7 8 9 11 ...
 $ well_id              : chr [1:648] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:648] 627 598 599 580 563 752 577 559 568 596 ...
 $ plate_id             : chr [1:648] "round1" "round1" "round1" "round1" ...
 $ time_hr              : num [1:648] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:648] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:648] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:648] NA NA NA NA ...
 $ family_id_group      : chr [1:648] "1" "2" "3" "5" ...
 $ cup_id_group         : chr [1:648] "1" "2" "3" "4" ...
 $ round_group          : chr [1:648] "1" "1" "1" "1" ...
 $ sample_id_group      : chr [1:648] "1_01" "1_02" "1_03" "1_04" ...
 $ treatment_group      : chr [1:648] NA NA NA NA ...
 $ weight_g_measurement : num [1:648] NA NA NA NA NA NA NA NA NA NA ...
 $ width_mm_measurement : num [1:648] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:648] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:648] 1441 1594 1362 1860 1407 ...
 $ trace_id             : chr [1:648] "1_01" "1_02" "1_03" "1_04" ...</code></pre>
</section>
<section id="raw-fluorescence-by-plate-including-blanks" class="level2">
<h2 class="anchored" data-anchor-id="raw-fluorescence-by-plate-including-blanks">6.2 Raw fluorescence by plate (including blanks)</h2>
<div class="sourceCode" id="cb13" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1">p_raw_plates <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb13-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour_group =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(is_blank, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank"</span>,</span>
<span id="cb13-5">                           <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">coalesce</span>(family_id_group, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample"</span>)),</span>
<span id="cb13-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb13-7">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb13-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value,</span>
<span id="cb13-9">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> colour_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> plate_id) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb13-14">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values   =</span> plate_well_colours,</span>
<span id="cb13-15">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name     =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Group"</span>,</span>
<span id="cb13-16">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(plate_well_colours),</span>
<span id="cb13-17">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.value =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"grey80"</span></span>
<span id="cb13-18">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb13-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb13-22">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb13-23"></span>
<span id="cb13-24">p_raw_plates</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260624-mgig-33C_files/figure-gfm/raw-fluor-by-plate-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb14" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_fluor_by_plate.png"</span>),</span>
<span id="cb14-2">       p_raw_plates, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>)</span></code></pre></div>
</section>
<section id="mean-raw-fluorescence-by-family" class="level2">
<h2 class="anchored" data-anchor-id="mean-raw-fluorescence-by-family">6.3 Mean raw fluorescence by family</h2>
<div class="sourceCode" id="cb15" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1">raw_family_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb15-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_fluor =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb15-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_fluor   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb15-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(value))),</span>
<span id="cb15-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n          =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(value)),</span>
<span id="cb15-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups    =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb15-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb15-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb15-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb15-13">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb15-14">    family_id_group)</span>
<span id="cb15-15"></span>
<span id="cb15-16">p_raw_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(raw_family_summary,</span>
<span id="cb15-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_fluor,</span>
<span id="cb15-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb15-19">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_fluor <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_fluor,</span>
<span id="cb15-21">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_fluor <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_fluor,</span>
<span id="cb15-22">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb15-23">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb15-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb15-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb15-29">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb15-31">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean raw fluorescence (RFU ± SE)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-33">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb15-34">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb15-35"></span>
<span id="cb15-36">p_raw_mean</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260624-mgig-33C_files/figure-gfm/raw-mean-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb16" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_mean_by_family.png"</span>),</span>
<span id="cb16-2">       p_raw_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-raw-fluorescence-traces-by-family" class="level2">
<h2 class="anchored" data-anchor-id="individual-raw-fluorescence-traces-by-family">6.4 Individual raw fluorescence traces by family</h2>
<div class="sourceCode" id="cb17" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1">p_raw_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb17-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb17-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb17-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb17-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb17-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb17-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb17-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb17-16"></span>
<span id="cb17-17">p_raw_by_family</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260624-mgig-33C_files/figure-gfm/raw-individual-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb18" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_individual_by_family.png"</span>),</span>
<span id="cb18-2">       p_raw_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-raw-fluorescence-traces-by-treatment" class="level2">
<h2 class="anchored" data-anchor-id="individual-raw-fluorescence-traces-by-treatment">6.5 Individual raw fluorescence traces by treatment</h2>
<div class="sourceCode" id="cb19" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb19-2">  p_raw_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> raw_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb19-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> value,</span>
<span id="cb19-4">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb19-9">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Raw fluorescence (RFU)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb19-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb19-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb19-14"></span>
<span id="cb19-15">  p_raw_by_treatment</span>
<span id="cb19-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"raw_individual_by_treatment.png"</span>),</span>
<span id="cb19-17">         p_raw_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb19-18">}</span></code></pre></div>
</section>
<section id="excluded-samples" class="level2">
<h2 class="anchored" data-anchor-id="excluded-samples">6.6 Excluded samples</h2>
<p>Wells flagged <code>exclude_from_analysis = TRUE</code> appear in the raw fluorescence plots above but are omitted from all analyses that follow.</p>
<div class="sourceCode" id="cb20" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1">excluded_wells <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb20-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb20-5">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb20-6">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb20-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb20-8">    )</span>
<span id="cb20-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">select</span>(plate_id, well_id, sample, family_id_group, treatment_group,</span>
<span id="cb20-11">         <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">any_of</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">distinct</span>() <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb20-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">arrange</span>(plate_id, well_id)</span>
<span id="cb20-14"></span>
<span id="cb20-15"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(excluded_wells) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb20-16">  col_names <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Plate"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Well"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Sample"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>)</span>
<span id="cb20-17">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"exclude_reason"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(excluded_wells))</span>
<span id="cb20-18">    col_names <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(col_names, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Reason"</span>)</span>
<span id="cb20-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(excluded_wells, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">col.names =</span> col_names), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-20">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb20-21">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No wells are excluded from analysis.</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb20-22">}</span></code></pre></div>
<p>No wells are excluded from analysis.</p>
</section>
</section>
<section id="blank-correction-via-fold-change-normalization" class="level1">
<h1>7 Blank Correction via Fold-Change Normalization</h1>
<p>T0 is the earliest timepoint present in the dataset (not necessarily 0 hr). Sample fold-change is expressed relative to each individual’s T0 reading, resolved by <code>sample_id_group</code> when that column is populated — allowing the same animal to be tracked across plates — or by <code>plate_id + well_id</code> when no sample IDs exist (backward-compatible with single-plate, multi-timepoint designs). Blank fold-change is the per-plate mean blank RFU at each timepoint divided by the pooled mean blank RFU at T0. Subtracting blank fold-change from sample fold-change removes background fluorescence drift; all samples start at exactly 0 at T0 by construction.</p>
<section id="step-1-identify-t0-and-compute-per-sample-fold-change" class="level2">
<h2 class="anchored" data-anchor-id="step-1-identify-t0-and-compute-per-sample-fold-change">7.1 Step 1 – Identify T0 and compute per-sample fold-change</h2>
<div class="sourceCode" id="cb21" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># T0 = earliest timepoint present in the dataset</span></span>
<span id="cb21-2">t0_time <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">min</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_hr[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(dat<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>time_hr)], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb21-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"T0 timepoint: "</span>, t0_time, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" hr"</span>)</span>
<span id="cb21-4"></span>
<span id="cb21-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># T0 reference value per individual.</span></span>
<span id="cb21-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Resolved by sample_id_group (cross-plate tracking) when available;</span></span>
<span id="cb21-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># falls back to plate+well for layouts without explicit sample IDs.</span></span>
<span id="cb21-8">t0_all <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(time_hr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> t0_time, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_key =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-11">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb21-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb21-13">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb21-14">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(sample_key) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">value_t0 =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>)</span>
<span id="cb21-17"></span>
<span id="cb21-18">dat_fc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-19">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sample_key =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-20">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb21-21">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb21-22">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb21-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb21-24">  )) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-25">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(t0_all, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sample_key"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb21-26">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fold_change =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb21-27">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value_t0) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> value_t0 <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>,</span>
<span id="cb21-28">    value <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> value_t0,</span>
<span id="cb21-29">    <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb21-30">  ))</span>
<span id="cb21-31"></span>
<span id="cb21-32"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(dat_fc)</span></code></pre></div>
<pre><code>tibble [1,152 × 21] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:1152] "A" "A" "A" "A" ...
 $ col_id               : int [1:1152] 1 2 3 4 5 6 7 8 9 10 ...
 $ well_id              : chr [1:1152] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:1152] 627 598 599 580 563 752 577 559 568 565 ...
 $ plate_id             : chr [1:1152] "round1" "round1" "round1" "round1" ...
 $ time_hr              : num [1:1152] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:1152] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:1152] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:1152] NA NA NA NA ...
 $ family_id_group      : chr [1:1152] "1" "2" "3" "5" ...
 $ cup_id_group         : chr [1:1152] "1" "2" "3" "4" ...
 $ round_group          : chr [1:1152] "1" "1" "1" "1" ...
 $ sample_id_group      : chr [1:1152] "1_01" "1_02" "1_03" "1_04" ...
 $ treatment_group      : chr [1:1152] NA NA NA NA ...
 $ weight_g_measurement : num [1:1152] NA NA NA NA NA NA NA NA NA NA ...
 $ width_mm_measurement : num [1:1152] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:1152] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:1152] 1441 1594 1362 1860 1407 ...
 $ sample_key           : chr [1:1152] "1_01" "1_02" "1_03" "1_04" ...
 $ value_t0             : num [1:1152] 627 598 599 580 563 752 577 559 568 NA ...
 $ fold_change          : num [1:1152] 1 1 1 1 1 1 1 1 1 NA ...</code></pre>
</section>
<section id="step-2-blank-fold-change-reference-per-plate-per-timepoint" class="level2">
<h2 class="anchored" data-anchor-id="step-2-blank-fold-change-reference-per-plate-per-timepoint">7.2 Step 2 – Blank fold-change reference per plate per timepoint</h2>
<div class="sourceCode" id="cb23" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pooled mean blank RFU at T0 across all T0 plates</span></span>
<span id="cb23-2">mean_blank_t0 <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_blank, time_hr <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> t0_time, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pull</span>(value) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb23-6"></span>
<span id="cb23-7"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(mean_blank_t0))</span>
<span id="cb23-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No blank readings found at T0 ("</span>, t0_time,</span>
<span id="cb23-9">          <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" hr); blank correction will produce NA."</span>)</span>
<span id="cb23-10"></span>
<span id="cb23-11"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Per-plate per-timepoint mean blank expressed as fold-change relative to T0</span></span>
<span id="cb23-12">blank_fc_ref <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(is_blank, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(value)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(plate_id, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_blank_rfu =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(value, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb23-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_blank_fc =</span> mean_blank_rfu <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> mean_blank_t0)</span>
<span id="cb23-17"></span>
<span id="cb23-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(blank_fc_ref)</span></code></pre></div>
<pre><code>tibble [12 × 4] (S3: tbl_df/tbl/data.frame)
 $ plate_id      : chr [1:12] "round1" "round1" "round1" "round1" ...
 $ time_hr       : num [1:12] 0 1 2 3 0 1 2 3 0 1 ...
 $ mean_blank_rfu: num [1:12] 568 715 612 630 632 ...
 $ mean_blank_fc : num [1:12] 0.979 1.232 1.055 1.085 1.089 ...</code></pre>
</section>
<section id="step-3-subtract-blank-fold-change-from-sample-fold-change" class="level2">
<h2 class="anchored" data-anchor-id="step-3-subtract-blank-fold-change-from-sample-fold-change">7.3 Step 3 – Subtract blank fold-change from sample fold-change</h2>
<div class="sourceCode" id="cb25" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1">samples <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> dat_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>is_blank, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb25-4">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">trace_id =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb25-5">      <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(sample_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">trimws</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!=</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>,</span>
<span id="cb25-6">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.character</span>(sample_id_group),</span>
<span id="cb25-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(plate_id, well_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>)</span>
<span id="cb25-8">    )</span>
<span id="cb25-9">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-10">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">left_join</span>(blank_fc_ref, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">by =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"plate_id"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"time_hr"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb25-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">corrected_fc =</span> fold_change <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> mean_blank_fc)</span>
<span id="cb25-12"></span>
<span id="cb25-13"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(samples)</span></code></pre></div>
<pre><code>tibble [1,080 × 25] (S3: tbl_df/tbl/data.frame)
 $ row_id               : chr [1:1080] "A" "A" "A" "A" ...
 $ col_id               : int [1:1080] 1 2 3 4 5 6 7 8 9 11 ...
 $ well_id              : chr [1:1080] "A1" "A2" "A3" "A4" ...
 $ value                : num [1:1080] 627 598 599 580 563 752 577 559 568 596 ...
 $ plate_id             : chr [1:1080] "round1" "round1" "round1" "round1" ...
 $ time_hr              : num [1:1080] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank             : logi [1:1080] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis: logi [1:1080] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason       : chr [1:1080] NA NA NA NA ...
 $ family_id_group      : chr [1:1080] "1" "2" "3" "5" ...
 $ cup_id_group         : chr [1:1080] "1" "2" "3" "4" ...
 $ round_group          : chr [1:1080] "1" "1" "1" "1" ...
 $ sample_id_group      : chr [1:1080] "1_01" "1_02" "1_03" "1_04" ...
 $ treatment_group      : chr [1:1080] NA NA NA NA ...
 $ weight_g_measurement : num [1:1080] NA NA NA NA NA NA NA NA NA NA ...
 $ width_mm_measurement : num [1:1080] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement: num [1:1080] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement : num [1:1080] 1441 1594 1362 1860 1407 ...
 $ sample_key           : chr [1:1080] "1_01" "1_02" "1_03" "1_04" ...
 $ value_t0             : num [1:1080] 627 598 599 580 563 752 577 559 568 596 ...
 $ fold_change          : num [1:1080] 1 1 1 1 1 1 1 1 1 1 ...
 $ trace_id             : chr [1:1080] "1_01" "1_02" "1_03" "1_04" ...
 $ mean_blank_rfu       : num [1:1080] 568 568 568 568 568 ...
 $ mean_blank_fc        : num [1:1080] 0.979 0.979 0.979 0.979 0.979 ...
 $ corrected_fc         : num [1:1080] 0.0206 0.0206 0.0206 0.0206 0.0206 ...</code></pre>
</section>
</section>
<section id="blank-corrected-fold-change" class="level1">
<h1>8 Blank-Corrected Fold-Change</h1>
<section id="mean-by-family" class="level2">
<h2 class="anchored" data-anchor-id="mean-by-family">8.1 Mean by family</h2>
<div class="sourceCode" id="cb27" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1">bc_fc_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-4">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb27-5">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_val =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb27-6">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_val   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb27-7">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(corrected_fc))),</span>
<span id="cb27-8">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">n        =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(corrected_fc)),</span>
<span id="cb27-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb27-10">  ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb27-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb27-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb27-13">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb27-14">    family_id_group)</span>
<span id="cb27-15"></span>
<span id="cb27-16">p_bc_fc_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(bc_fc_summary,</span>
<span id="cb27-17">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_val,</span>
<span id="cb27-18">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb27-19">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-20">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_val,</span>
<span id="cb27-21">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_val,</span>
<span id="cb27-22">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb27-23">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-24">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb27-25">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb27-26">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-27">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-28">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb27-29">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-30">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb27-31">                    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-32">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>,</span>
<span id="cb27-33">       <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Mean blank-corrected fold-change (± SE)"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-34">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb27-35">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb27-36"></span>
<span id="cb27-37">p_bc_fc_mean</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260624-mgig-33C_files/figure-gfm/bc-fc-mean-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb28" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_mean_by_family.png"</span>),</span>
<span id="cb28-2">       p_bc_fc_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-traces-by-family" class="level2">
<h2 class="anchored" data-anchor-id="individual-traces-by-family">8.2 Individual traces by family</h2>
<div class="sourceCode" id="cb29" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1">p_bc_fc_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb29-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> corrected_fc, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb29-4">             <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-6">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb29-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb29-10">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb29-11">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Blank-corrected fold-change"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb29-14">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb29-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb29-16"></span>
<span id="cb29-17">p_bc_fc_by_family</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260624-mgig-33C_files/figure-gfm/bc-fc-individual-by-family-1.png" class="img-fluid"><!-- --></p>
<div class="sourceCode" id="cb30" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_by_family.png"</span>),</span>
<span id="cb30-2">       p_bc_fc_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span></code></pre></div>
</section>
<section id="individual-blank-corrected-fold-change-traces-by-treatment" class="level2">
<h2 class="anchored" data-anchor-id="individual-blank-corrected-fold-change-traces-by-treatment">8.3 Individual blank-corrected fold-change traces by treatment</h2>
<div class="sourceCode" id="cb31" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb31-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb31-2">  p_bc_fc_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb31-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> corrected_fc,</span>
<span id="cb31-4">               <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-6">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-7">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-8">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb31-9">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Blank-corrected fold-change"</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb31-12">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb31-13">          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb31-14"></span>
<span id="cb31-15">  p_bc_fc_by_treatment</span>
<span id="cb31-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"blank_corrected_fc_by_treatment.png"</span>),</span>
<span id="cb31-17">         p_bc_fc_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb31-18">}</span></code></pre></div>
</section>
</section>
<section id="metabolism-size-normalised-fold-change" class="level1">
<h1>9 Metabolism (Size-Normalised Fold-Change)</h1>
<p>Blank-corrected fold-change divided by each active measurement column. This is “metabolism” as defined in Huffmyer et al.</p>
<div class="sourceCode" id="cb32" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(active_meas_cols) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb32-2">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">message</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"No active measurement columns: skipping metabolism calculation."</span>)</span>
<span id="cb32-3">  metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tibble</span>()</span>
<span id="cb32-4">} <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb32-5">  metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> samples</span>
<span id="cb32-6">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb32-7">    out_col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb32-8">    metabolism_df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb32-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!!</span><span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">out_col :=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">if_else</span>(</span>
<span id="cb32-10">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[mc]]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span> .data[[mc]] <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;</span></span>
<span id="cb32-11">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(corrected_fc),</span>
<span id="cb32-12">        corrected_fc <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> .data[[mc]],</span>
<span id="cb32-13">        <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA_real_</span></span>
<span id="cb32-14">      ))</span>
<span id="cb32-15">  }</span>
<span id="cb32-16">}</span>
<span id="cb32-17"></span>
<span id="cb32-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str</span>(metabolism_df)</span></code></pre></div>
<pre><code>tibble [1,080 × 26] (S3: tbl_df/tbl/data.frame)
 $ row_id                             : chr [1:1080] "A" "A" "A" "A" ...
 $ col_id                             : int [1:1080] 1 2 3 4 5 6 7 8 9 11 ...
 $ well_id                            : chr [1:1080] "A1" "A2" "A3" "A4" ...
 $ value                              : num [1:1080] 627 598 599 580 563 752 577 559 568 596 ...
 $ plate_id                           : chr [1:1080] "round1" "round1" "round1" "round1" ...
 $ time_hr                            : num [1:1080] 0 0 0 0 0 0 0 0 0 0 ...
 $ is_blank                           : logi [1:1080] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_from_analysis              : logi [1:1080] FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ exclude_reason                     : chr [1:1080] NA NA NA NA ...
 $ family_id_group                    : chr [1:1080] "1" "2" "3" "5" ...
 $ cup_id_group                       : chr [1:1080] "1" "2" "3" "4" ...
 $ round_group                        : chr [1:1080] "1" "1" "1" "1" ...
 $ sample_id_group                    : chr [1:1080] "1_01" "1_02" "1_03" "1_04" ...
 $ treatment_group                    : chr [1:1080] NA NA NA NA ...
 $ weight_g_measurement               : num [1:1080] NA NA NA NA NA NA NA NA NA NA ...
 $ width_mm_measurement               : num [1:1080] NA NA NA NA NA NA NA NA NA NA ...
 $ length_mm_measurement              : num [1:1080] NA NA NA NA NA NA NA NA NA NA ...
 $ area_mm2_measurement               : num [1:1080] 1441 1594 1362 1860 1407 ...
 $ sample_key                         : chr [1:1080] "1_01" "1_02" "1_03" "1_04" ...
 $ value_t0                           : num [1:1080] 627 598 599 580 563 752 577 559 568 596 ...
 $ fold_change                        : num [1:1080] 1 1 1 1 1 1 1 1 1 1 ...
 $ trace_id                           : chr [1:1080] "1_01" "1_02" "1_03" "1_04" ...
 $ mean_blank_rfu                     : num [1:1080] 568 568 568 568 568 ...
 $ mean_blank_fc                      : num [1:1080] 0.979 0.979 0.979 0.979 0.979 ...
 $ corrected_fc                       : num [1:1080] 0.0206 0.0206 0.0206 0.0206 0.0206 ...
 $ metabolism_per_area_mm2_measurement: num [1:1080] 1.43e-05 1.29e-05 1.51e-05 1.11e-05 1.46e-05 ...</code></pre>
<section id="mean-metabolism-by-family" class="level2">
<h2 class="anchored" data-anchor-id="mean-metabolism-by-family">9.1 Mean metabolism by family</h2>
<div class="sourceCode" id="cb34" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb34-2"></span>
<span id="cb34-3">  metab_cols <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, active_meas_cols)</span>
<span id="cb34-4"></span>
<span id="cb34-5">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metab_cols) {</span>
<span id="cb34-6">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb34-7">    mc_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>)</span>
<span id="cb34-8"></span>
<span id="cb34-9">    metab_summary <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-10">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group), <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>exclude_from_analysis) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">group_by</span>(family_id_group, treatment_group, time_hr) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">summarise</span>(</span>
<span id="cb34-13">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mean_val =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(.data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>),</span>
<span id="cb34-14">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">se_val   =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sd</span>(.data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">na.rm =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span></span>
<span id="cb34-15">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(.data[[col]]))),</span>
<span id="cb34-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">.groups  =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"drop"</span></span>
<span id="cb34-17">      ) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb34-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group_var =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt)</span>
<span id="cb34-19">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste</span>(family_id_group, treatment_group, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"."</span>)</span>
<span id="cb34-20">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span></span>
<span id="cb34-21">        family_id_group)</span>
<span id="cb34-22"></span>
<span id="cb34-23">    p_metab_mean <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(metab_summary,</span>
<span id="cb34-24">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> mean_val,</span>
<span id="cb34-25">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group,</span>
<span id="cb34-26">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> group_var)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-27">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_ribbon</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymin =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> se_val,</span>
<span id="cb34-28">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ymax =</span> mean_val <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> se_val,</span>
<span id="cb34-29">                      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">fill =</span> family_id_group),</span>
<span id="cb34-30">                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.15</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-31">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(</span>
<span id="cb34-32">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mapping   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linetype =</span> treatment_group) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>,</span>
<span id="cb34-33">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">linewidth =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-34">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-35">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb34-36">                          <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-37">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_fill_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb34-38">                        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-39">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>,</span>
<span id="cb34-40">           <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col), <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" (± SE)"</span>)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-41">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">13</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb34-42">      <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_linetype_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> trt_linetypes, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span>) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span></span>
<span id="cb34-43"></span>
<span id="cb34-44">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_mean)</span>
<span id="cb34-45">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb34-46">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb34-47">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_mean_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".png"</span>)),</span>
<span id="cb34-48">      p_metab_mean, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb34-49">  }</span>
<span id="cb34-50">}</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260624-mgig-33C_files/figure-gfm/metabolism-mean-by-family-1.png" class="img-fluid"><!-- --></p>
</section>
<section id="individual-metabolism-traces-by-family" class="level2">
<h2 class="anchored" data-anchor-id="individual-metabolism-traces-by-family">9.2 Individual metabolism traces by family</h2>
<div class="sourceCode" id="cb35" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb35-2"></span>
<span id="cb35-3">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> metab_cols) {</span>
<span id="cb35-4">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb35-5">    mc_label <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">str_remove</span>(col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"^metabolism_per_"</span>)</span>
<span id="cb35-6"></span>
<span id="cb35-7">    p_metab_by_family <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> metabolism_df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-8">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.na</span>(family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb35-9">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> .data[[col]], <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id,</span>
<span id="cb35-10">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> .data[[<span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span>]])) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-11">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-12">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-13">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family_id_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-14">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(</span>
<span id="cb35-15">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) trt_colours <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> fam_colours,</span>
<span id="cb35-16">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name   =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Treatment"</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb35-17">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) treatments <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-18">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-19">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-20">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb35-21">            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb35-22"></span>
<span id="cb35-23">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_by_family)</span>
<span id="cb35-24">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb35-25">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb35-26">                <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_individual_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_by_family.png"</span>)),</span>
<span id="cb35-27">      p_metab_by_family, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb35-28"></span>
<span id="cb35-29">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_trt) {</span>
<span id="cb35-30">      p_metab_by_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggplot</span>(metabolism_df,</span>
<span id="cb35-31">          <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">aes</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> time_hr, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> .data[[col]],</span>
<span id="cb35-32">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">group =</span> trace_id, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">colour =</span> family_id_group)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-33">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_line</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.6</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-34">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">geom_point</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">size =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">1.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alpha =</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.7</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-35">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">facet_wrap</span>(<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment_group) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-36">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">scale_colour_manual</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">values =</span> fam_colours, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">name =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Family"</span>,</span>
<span id="cb35-37">                            <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">breaks =</span> families) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-38">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">labs</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">x =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Time (h)"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">y =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">metabolism_y_label</span>(col)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-39">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme_classic</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">base_size =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">12</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span></span>
<span id="cb35-40">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">theme</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.background =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_blank</span>(),</span>
<span id="cb35-41">              <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">strip.text       =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">element_text</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">face =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"bold"</span>))</span>
<span id="cb35-42"></span>
<span id="cb35-43">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">print</span>(p_metab_by_treatment)</span>
<span id="cb35-44">      <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">ggsave</span>(</span>
<span id="cb35-45">        <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">file.path</span>(fig_dir,</span>
<span id="cb35-46">                  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_individual_"</span>, mc_label, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_by_treatment.png"</span>)),</span>
<span id="cb35-47">        p_metab_by_treatment, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb35-48">    }</span>
<span id="cb35-49">  }</span>
<span id="cb35-50">}</span></code></pre></div>
<p><img src="https://robertslab.github.io/sams-notebook/posts/2026/2026-06-24-Resazurin-Assays---USDA-M.gigas-Families-in-Response-to-Temperature-Stress/01.00-resazurin-20260624-mgig-33C_files/figure-gfm/metabolism-individual-by-family-1.png" class="img-fluid"><!-- --></p>
</section>
</section>
<section id="time-series-statistical-analysis" class="level1">
<h1>10 Time-Series Statistical Analysis</h1>
<p>Linear mixed effects models test the effect of experimental variables on metabolism over time. Individual (<code>sample_id_group</code>) is included as a random intercept to account for repeated measures across timepoints. Type III ANOVA with Satterthwaite’s approximation (lmerTest) assesses significance; post-hoc pairwise comparisons use estimated marginal means (emmeans, Tukey adjustment).</p>
<div class="sourceCode" id="cb36" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1">run_ts_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(df, value_col) {</span>
<span id="cb36-2">  has_family    <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"family_id_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb36-3">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family_id_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb36-4">  has_treatment <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"treatment_group"</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span></span>
<span id="cb36-5">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment_group))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb36-6"></span>
<span id="cb36-7">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">!</span>has_treatment) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-8"></span>
<span id="cb36-9">  df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb36-10">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">filter</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(.data[[value_col]]), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.finite</span>(time_hr)) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span></span>
<span id="cb36-11">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(</span>
<span id="cb36-12">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">time_f     =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(time_hr),</span>
<span id="cb36-13">      <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">individual =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(trace_id)</span>
<span id="cb36-14">    )</span>
<span id="cb36-15"></span>
<span id="cb36-16">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-17"></span>
<span id="cb36-18">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family)    df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">family    =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(family_id_group))</span>
<span id="cb36-19">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment) df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> df <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%&gt;%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mutate</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">treatment =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(treatment_group))</span>
<span id="cb36-20"></span>
<span id="cb36-21">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>family)))    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-22">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">length</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">unique</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">na.omit</span>(df<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>treatment))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&lt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">return</span>(<span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NULL</span>)</span>
<span id="cb36-23"></span>
<span id="cb36-24">  fixed <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb36-25">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * family * treatment"</span>)</span>
<span id="cb36-26">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb36-27">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * family"</span>)</span>
<span id="cb36-28">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb36-29">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(value_col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" ~ time_f * treatment"</span>)</span>
<span id="cb36-30">  }</span>
<span id="cb36-31"></span>
<span id="cb36-32">  model <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">lmer</span>(</span>
<span id="cb36-33">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.formula</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(fixed, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" + (1 | individual)"</span>)),</span>
<span id="cb36-34">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">data =</span> df</span>
<span id="cb36-35">  )</span>
<span id="cb36-36"></span>
<span id="cb36-37">  anova_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">anova</span>(model, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">type =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">ddf =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Satterthwaite"</span>)</span>
<span id="cb36-38"></span>
<span id="cb36-39">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Pairwise comparisons of group combinations at each timepoint</span></span>
<span id="cb36-40">  emm_spec <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb36-41">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb36-42">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb36-43">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb36-44">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb36-45">    <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">|</span> time_f</span>
<span id="cb36-46">  }</span>
<span id="cb36-47"></span>
<span id="cb36-48">  emm       <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, emm_spec)</span>
<span id="cb36-49">  pairs_res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(emm, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb36-50"></span>
<span id="cb36-51">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Main-effect marginal means (collapsed across time)</span></span>
<span id="cb36-52">  emm_main <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&amp;&amp;</span> has_treatment) {</span>
<span id="cb36-53">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> treatment)</span>
<span id="cb36-54">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (has_family) {</span>
<span id="cb36-55">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> family)</span>
<span id="cb36-56">  } <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> {</span>
<span id="cb36-57">    <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">emmeans</span>(model, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> treatment)</span>
<span id="cb36-58">  }</span>
<span id="cb36-59"></span>
<span id="cb36-60">  pairs_main <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pairs</span>(emm_main, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">adjust =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"tukey"</span>))</span>
<span id="cb36-61"></span>
<span id="cb36-62">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>(</span>
<span id="cb36-63">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">model         =</span> model,</span>
<span id="cb36-64">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">anova         =</span> anova_res,</span>
<span id="cb36-65">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_by_time =</span> pairs_res,</span>
<span id="cb36-66">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">pairs_main    =</span> pairs_main,</span>
<span id="cb36-67">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_family    =</span> has_family,</span>
<span id="cb36-68">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">has_treatment =</span> has_treatment</span>
<span id="cb36-69">  )</span>
<span id="cb36-70">}</span>
<span id="cb36-71"></span>
<span id="cb36-72">ts_stats <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">list</span>()</span>
<span id="cb36-73"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">nrow</span>(metabolism_df) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>) {</span>
<span id="cb36-74">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (mc <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> active_meas_cols) {</span>
<span id="cb36-75">    col <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"metabolism_per_"</span>, mc)</span>
<span id="cb36-76">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (col <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">%in%</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(metabolism_df))</span>
<span id="cb36-77">      ts_stats[[col]] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">run_ts_stats</span>(metabolism_df, col)</span>
<span id="cb36-78">  }</span>
<span id="cb36-79">}</span></code></pre></div>
<section id="results-1" class="level2">
<h2 class="anchored" data-anchor-id="results-1">10.1 Results</h2>
<div class="sourceCode" id="cb37" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb37-1"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (col <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">names</span>(ts_stats)) {</span>
<span id="cb37-2">  res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> ts_stats[[col]]</span>
<span id="cb37-3">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">is.null</span>(res)) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">next</span></span>
<span id="cb37-4"></span>
<span id="cb37-5">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">### Metric:"</span>, col, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-6"></span>
<span id="cb37-7">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Type III ANOVA (Satterthwaite approximation):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-8">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>anova), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-9">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-10"></span>
<span id="cb37-11">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Marginal means – main effects (collapsed across time):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-12">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_main), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-14"></span>
<span id="cb37-15">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"**Pairwise comparisons by timepoint (Tukey):**</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-16">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(knitr<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kable</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(res<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pairs_by_time), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">digits =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"pipe"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">sep =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-17">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">cat</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb37-18">}</span></code></pre></div>
<section id="metric-metabolism_per_area_mm2_measurement" class="level3">
<h3 class="anchored" data-anchor-id="metric-metabolism_per_area_mm2_measurement">10.1.1 Metric: metabolism_per_area_mm2_measurement</h3>
<p><strong>Type III ANOVA (Satterthwaite approximation):</strong></p>
<table class="caption-top table">
<colgroup>
<col style="width: 23%">
<col style="width: 12%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 15%">
<col style="width: 13%">
</colgroup>
<thead>
<tr class="header">
<th></th>
<th style="text-align: right;">Sum Sq</th>
<th style="text-align: right;">Mean Sq</th>
<th style="text-align: right;">NumDF</th>
<th style="text-align: right;">DenDF</th>
<th style="text-align: right;">F value</th>
<th style="text-align: right;">Pr(&gt;F)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>time_f</td>
<td style="text-align: right;">3e-04</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">459</td>
<td style="text-align: right;">389.9429</td>
<td style="text-align: right;">0.0000</td>
</tr>
<tr class="even">
<td>family</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.9504</td>
<td style="text-align: right;">0.4772</td>
</tr>
<tr class="odd">
<td>time_f:family</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">24</td>
<td style="text-align: right;">459</td>
<td style="text-align: right;">0.9440</td>
<td style="text-align: right;">0.5411</td>
</tr>
</tbody>
</table>
<p><strong>Marginal means – main effects (collapsed across time):</strong></p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">family1 - family10</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.6072</td>
<td style="text-align: right;">0.9995</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family2</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.6690</td>
<td style="text-align: right;">0.7643</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family3</td>
<td style="text-align: right;">-4e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-2.3926</td>
<td style="text-align: right;">0.2956</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.5462</td>
<td style="text-align: right;">0.8316</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family6</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.5621</td>
<td style="text-align: right;">0.8236</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.6770</td>
<td style="text-align: right;">0.7595</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family8</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.1174</td>
<td style="text-align: right;">0.9708</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.2970</td>
<td style="text-align: right;">0.9309</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family2</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.0618</td>
<td style="text-align: right;">0.9787</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family3</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.7854</td>
<td style="text-align: right;">0.6917</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family5</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.9390</td>
<td style="text-align: right;">0.9903</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family6</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.9549</td>
<td style="text-align: right;">0.9892</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family7</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-1.0698</td>
<td style="text-align: right;">0.9776</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family8</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.5102</td>
<td style="text-align: right;">0.9999</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family9</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.6898</td>
<td style="text-align: right;">0.9989</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family3</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.7236</td>
<td style="text-align: right;">0.9984</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family5</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.1227</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family6</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.1068</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family7</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.0081</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family8</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.5516</td>
<td style="text-align: right;">0.9998</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family9</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.3719</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family5</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.8463</td>
<td style="text-align: right;">0.9952</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family3 - family6</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.8304</td>
<td style="text-align: right;">0.9958</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family7</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.7155</td>
<td style="text-align: right;">0.9985</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family3 - family8</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">1.2752</td>
<td style="text-align: right;">0.9371</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family9</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">1.0955</td>
<td style="text-align: right;">0.9741</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family6</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.0159</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.1308</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family8</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.4288</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.2492</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family6 - family7</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.1149</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family6 - family8</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.4447</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family6 - family9</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.2651</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family8</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.5596</td>
<td style="text-align: right;">0.9998</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">0.3800</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family8 - family9</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">153</td>
<td style="text-align: right;">-0.1796</td>
<td style="text-align: right;">1.0000</td>
</tr>
</tbody>
</table>
<p><strong>Pairwise comparisons by timepoint (Tukey):</strong></p>
<table class="caption-top table">
<colgroup>
<col style="width: 27%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 9%">
<col style="width: 13%">
<col style="width: 12%">
<col style="width: 12%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;">contrast</th>
<th style="text-align: left;">time_f</th>
<th style="text-align: right;">estimate</th>
<th style="text-align: right;">SE</th>
<th style="text-align: right;">df</th>
<th style="text-align: right;">t.ratio</th>
<th style="text-align: right;">p.value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">family1 - family10</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0072</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family2</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0015</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family3</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0038</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0159</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family6</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0190</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0231</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family8</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0169</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0200</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family2</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0086</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family3</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0109</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family5</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0230</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family6</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0261</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0303</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family8</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0098</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0271</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family3</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0023</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family5</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0144</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family6</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0175</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0216</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family8</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0184</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0185</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family5</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0121</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family3 - family6</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0152</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0194</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family3 - family8</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0207</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0162</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family6</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0031</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0073</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family8</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0328</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0041</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family6 - family7</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0042</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family6 - family8</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0359</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family6 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0010</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family7 - family8</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0401</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family7 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.0031</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family8 - family9</td>
<td style="text-align: left;">0</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.0369</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family10</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.1282</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family2</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-4e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-1.6047</td>
<td style="text-align: right;">0.8019</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family3</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-5e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-2.2758</td>
<td style="text-align: right;">0.3598</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family5</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-1.3509</td>
<td style="text-align: right;">0.9149</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family6</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.7646</td>
<td style="text-align: right;">0.9977</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-1.2464</td>
<td style="text-align: right;">0.9454</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family1 - family8</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.6868</td>
<td style="text-align: right;">0.9989</td>
</tr>
<tr class="even">
<td style="text-align: left;">family1 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.6725</td>
<td style="text-align: right;">0.9991</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family2</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-1.4765</td>
<td style="text-align: right;">0.8658</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family3</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-5e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-2.1476</td>
<td style="text-align: right;">0.4427</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family5</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-1.2227</td>
<td style="text-align: right;">0.9511</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family6</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.6363</td>
<td style="text-align: right;">0.9994</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-1.1181</td>
<td style="text-align: right;">0.9712</td>
</tr>
<tr class="even">
<td style="text-align: left;">family10 - family8</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.5585</td>
<td style="text-align: right;">0.9998</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family10 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.5442</td>
<td style="text-align: right;">0.9998</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family3</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.6711</td>
<td style="text-align: right;">0.9991</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family5</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.2538</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family6</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.8402</td>
<td style="text-align: right;">0.9955</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.3583</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="even">
<td style="text-align: left;">family2 - family8</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.9180</td>
<td style="text-align: right;">0.9919</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family2 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.9323</td>
<td style="text-align: right;">0.9910</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family5</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.9249</td>
<td style="text-align: right;">0.9914</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family3 - family6</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">3e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">1.5113</td>
<td style="text-align: right;">0.8498</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">1.0294</td>
<td style="text-align: right;">0.9828</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family3 - family8</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">4e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">1.5891</td>
<td style="text-align: right;">0.8104</td>
</tr>
<tr class="even">
<td style="text-align: left;">family3 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">4e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">1.6034</td>
<td style="text-align: right;">0.8026</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family6</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.5863</td>
<td style="text-align: right;">0.9997</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">0e+00</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.1045</td>
<td style="text-align: right;">1.0000</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family5 - family8</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.6641</td>
<td style="text-align: right;">0.9992</td>
</tr>
<tr class="even">
<td style="text-align: left;">family5 - family9</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">0.6784</td>
<td style="text-align: right;">0.9990</td>
</tr>
<tr class="odd">
<td style="text-align: left;">family6 - family7</td>
<td style="text-align: left;">1</td>
<td style="text-align: right;">-1e-04</td>
<td style="text-align: right;">2e-04</td>
<td style="text-align: right;">340.5445</td>
<td style="text-align: right;">-0.4818</td>
<td style="text-align: right;">0.9999</td>
</tr>
<tr class="even">
<td style="text-align: left;">family6 - family8</td>
<td sty