<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Boolean Biotech</title><link href="/" rel="alternate"/><link href="/feeds/all.atom.xml" rel="self"/><id>/</id><updated>2026-11-08T11:00:00-08:00</updated><entry><title>Scoring protein binders with ipTM and other scores</title><link href="/iptm-and-other-scores.html" rel="alternate"/><published>2026-11-08T11:00:00-08:00</published><updated>2026-11-08T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2026-11-08:/iptm-and-other-scores.html</id><summary type="html">&lt;p&gt;Comparing metrics for scoring folding confidence&lt;/p&gt;</summary><content type="html">&lt;p&gt;Readers of this blog will be well aware that it's an exciting time for AI protein binder design. 
Since BindCraft was released in 2024, there has been plenty of activity,
but things have heated up again over the past couple of months
with the release of
&lt;a href="https://www.pacesalab.com/bindcraft"&gt;BindCraft2&lt;/a&gt; from &lt;a href="https://www.pacesalab.com"&gt;Pacesa Lab&lt;/a&gt;, 
&lt;a href="https://github.com/RosettaCommons/RFD4-Proteina"&gt;RFD4-Proteina&lt;/a&gt; from &lt;a href="https://www.bakerlab.org"&gt;Baker lab&lt;/a&gt;,
a &lt;a href="https://www.anthropic.com/research/Claude-accelerates-protein-design"&gt;report from Anthropic&lt;/a&gt;,
and several &lt;a href="https://proteinbase.com/competitions/anthropic-adaptyv-2026"&gt;high-profile competitions&lt;/a&gt; run by Adaptyv and Anthropic.&lt;/p&gt;
&lt;p&gt;There remains a pretty central question of how to rank binders to maximize wet-lab success.
Last week I posted a &lt;a href="https://x.com/btnaughton/status/2116204127940424164"&gt;table comparing the main binder ranking scores on twitter&lt;/a&gt;.
It was a quick and dirty AI-driven experiment, but it generated some interest,
so in this article I am going back to do it again a bit more carefully!&lt;/p&gt;
&lt;h2&gt;How does binder scoring work?&lt;/h2&gt;
&lt;p&gt;When designing a binder we are attempting to select a sequence that optimizes a certain score (or loss).&lt;/p&gt;
&lt;p&gt;Binder design scores are usually a weighted combination of two types of score:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;folding model confidence scores (e.g, pLDDT, ipTM, ipSAE, iPAE, actifpTM);&lt;/li&gt;
&lt;li&gt;heuristics like sequence "naturalness", and physics-based filters like surface complementarity and number of H-bonds.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Only folding model confidence scores correlate strongly with binding,
but directly optimizing these scores can easily lead to adversarial sequences.
As we know, AIs are great at "hacking the test".
It's also worth noting that these scores are not trying to measure binding per se,
but more like whether the structures appear together in a PDB file.
See the &lt;a href="https://blog.escalante.bio/building-protein-models-that-understand-biophysics/"&gt;escalante blog&lt;/a&gt; for more details on this.&lt;/p&gt;
&lt;p&gt;The heuristics and physics-based filters bias the binder sequence and structure to the part of the distribution where real binders live,
but this is something of an art for now.&lt;/p&gt;
&lt;p&gt;A simple method to help with adversarial sequences is to refold and rank with confidence scores from independent folding algorithms,
e.g., design with RFD4-Proteina, and rank with ESMFold2.&lt;/p&gt;
&lt;h2&gt;Binding score types&lt;/h2&gt;
&lt;p&gt;The original "binding score",
introduced by &lt;a href="https://www.biorxiv.org/content/10.1101/2021.10.04.463034v1"&gt;AlphaFold-Multimer&lt;/a&gt; in 2021,
is the "interface predicted TM-score" (ipTM).
ipTM is calculated directly from the &lt;a href="https://en.wikipedia.org/wiki/Predicted_Aligned_Error"&gt;predicted aligned error (PAE) distribution&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.orbion.life/blog/what-plddt-and-pae-actually-tell-you-and-what-they-don-t"&gt;PAE&lt;/a&gt;
evaluates positional error using the local backbone reference frame of each residue, rather than a global alignment.
Because each residue defines its own reference frame, PAE is asymmetric.
iPAE is just the PAE between chains (e.g., binder and target).
Despite the name, ipTM compares two &lt;em&gt;complete&lt;/em&gt; chains, not just the interface.&lt;/p&gt;
&lt;!--which gives, in Angstroms, a measure of how far off the prediction is from ground truth.--&gt;

&lt;p&gt;An obvious limitation here is in cases where the model is confident in the interface and
not confident about the rest of the protein.
In 2025, two scores were published to correct for this problem:
&lt;a href="https://www.biorxiv.org/content/10.1101/2025.02.10.637595v1"&gt;ipSAE&lt;/a&gt;
and &lt;a href="https://academic.oup.com/bioinformatics/article/41/3/btaf107/8075121"&gt;actifpTM&lt;/a&gt;.
This year, &lt;a href="https://github.com/PacesaLab/BindCraft2"&gt;BindCraft2&lt;/a&gt; introduced one additional refinement: ipDAE.
These three scores are all quite similar, differing mainly in how they select the relevant interface residues.&lt;/p&gt;
&lt;!--
Between the tweet and this post, Dunbrack posted an update to ipSAE, [ipSAE2].
ipSAE2 is the same score as ipSAE, but it the asymmetry of PAE (binder vs target is different to target vs binder) to try to gain a slight advantage over ipSAE.
--&gt;

&lt;p&gt;On twitter, I was fortunate to get some background and feedback from Julia Varga around actifpTM thresholds
and Roland Dunbrack on using ipSAE for binders (published in the new &lt;a href="https://www.biorxiv.org/content/10.64898/2026.11.02.763449v1"&gt;ipSAE2 paper&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/iptm_varga.png" width="100%" /&gt;
&lt;em&gt;&lt;a href="https://x.com/jvarga92/status/2116804405303636132"&gt;Julia Varga&lt;/a&gt; commenting on actifpTM and suggesting a threshold change. I did not test it here.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/iptm_dunbrack.png" width="100%" /&gt;
&lt;em&gt;&lt;a href="https://x.com/RolandDunbrack/status/2117486125182841245"&gt;Roland Dunbrack&lt;/a&gt; recommending a specific ipSAE variant for binders&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I was surprised to see that these scores are also in flux:
since PAE is asymmetric, you can take the minimum, maximum, mean, or a specific direction (e.g., align on target and use the binder ipSAE).
On the BindCraft2 repo, they switched from &lt;a href="https://github.com/PacesaLab/BindCraft2/pull/43"&gt;max to mean ipDAE just a couple of weeks ago&lt;/a&gt;!&lt;/p&gt;
&lt;h2&gt;Scoring&lt;/h2&gt;
&lt;p&gt;I could only find a few papers on the topic of binder ranking scores:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2025.08.14.670059v1.full.pdf"&gt;Overath et al. 2025&lt;/a&gt;, "Predicting Experimental Success in De Novo Binder Design: A Meta-Analysis of 3,766 Experimentally Characterised Binders"&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2025.04.17.648362v2.full.pdf"&gt;Cotet et al. 2025&lt;/a&gt;, "Crowdsourced Protein Design: Lessons From the
Adaptyv EGFR Binder Competition"&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.biorxiv.org/content/10.64898/2026.04.13.718094v1.full.pdf"&gt;Bozkurt 2026&lt;/a&gt;, "Beyond Structure and Affinity: Context-Dependent Signals for de novo Binder Success"&lt;/li&gt;
&lt;li&gt;&lt;a href="https://arxiv.org/pdf/2605.04118v1"&gt;Liu et al. 2026&lt;/a&gt;, "ProtDBench: A Unified Benchmark of Protein Binder Design and Evaluation"&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Overath et al. is really the only paper here that tries to compare binder scores across many targets.
They took a classic machine learning approach of calculating as many features as they could (over 200)
and attempted to predict binding across 3,766 binders and 15 targets.
Their conclusion was that AlphaFold 3 ipSAE (minimum) was the single best score,
with Rosetta interface energy and shape complementarity also contributing.&lt;/p&gt;
&lt;!--
(Confusingly, the default ipSAE score is the maximum, not the minimum.
Similarly, ipDAE just switched from using the [max to the mean TM-score a week or two back](https://github.com/PacesaLab/BindCraft2/pull/43).)
--&gt;

&lt;p&gt;&lt;img class="blogimg" src="/images/iptm_protdbench.png" width="100%" /&gt;
&lt;em&gt;&lt;a href="https://github.com/congliuUvA/ProtDBench"&gt;ProtDBench&lt;/a&gt; is a binder design benchmark. The paper includes some commonly used binder thresholds.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;My Proteinbase Benchmark&lt;/h2&gt;
&lt;p&gt;I used Adaptyv's open &lt;a href="https://proteinbase.com"&gt;Proteinbase database&lt;/a&gt; for this experiment.
For each of the 24 suitable targets in the database, I took all available binders and an equal number of non-binders.
In total, I co-folded 225 binders and 225 non-binders.
All are protein binders, of length 10-250 residues, with an average length of 92.
There were a negligible number of antibodies or antibody fragments, so these were excluded.&lt;/p&gt;
&lt;p&gt;All the data is in this &lt;a href="https://huggingface.co/datasets/btnaughton/proteinbase-confidence-benchmark"&gt;Hugging Face repo&lt;/a&gt;,
so point your agents here to reanalyze it!&lt;/p&gt;
&lt;h3&gt;Folding models&lt;/h3&gt;
&lt;p&gt;Since I work at a &lt;a href="https://decade.bio"&gt;company&lt;/a&gt;, I can't use AlphaFold 3; instead I use these MIT or Apache-2 licensed tools:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Biohub/esm"&gt;ESMFold2&lt;/a&gt; is very fast and still reliably high quality;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/aurekaresearch/OpenDDE"&gt;OpenDDE&lt;/a&gt; is an excellent new model, especially good for antibodies;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/molence/Mol-1"&gt;Mol-1&lt;/a&gt; is only a week or two old, but the benchmarks are impressive across the board, including for antibodies. Mol-1 has succeeded &lt;a href="https://github.com/bytedance/Protenix"&gt;Protenix-v2&lt;/a&gt;, which confusingly went from open to closed weights, and so is best avoided.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Depending on how much you trust the benchmarks, OpenDDE and Mol-1 can get close to or beat AlphaFold 3, even on antibodies.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/iptm_mol1.png" width="100%" /&gt;
&lt;em&gt;&lt;a href="https://x.com/MolenceBio/status/2116210990388072555"&gt;Mol-1&lt;/a&gt; showing some impressive performance on FoldBench.&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Results&lt;/h3&gt;
&lt;p&gt;There are many ways to look at the data.
I used two main scores:
the &lt;a href="https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values"&gt;PPV&lt;/a&gt;
for the top 10% of scores,
and the &lt;a href="https://developers.google.com/machine-learning/crash-course/classification/roc-and-auc"&gt;AUROC&lt;/a&gt;.
In both cases I take the average value across all targets since some targets have a lot more data than others.
Since there are equal numbers of binders and non-binders, random guessing would score 50%;
in the real world there will be many more non-binders to filter out.
I tested four folding models (ESMFold2, Protenix-v2, OpenDDE, Mol-1),
and a consensus "all four models" version where I use the worst percentile rank across the four models.&lt;/p&gt;
&lt;p&gt;In all cases I am using the default version of the score.
For example, this means I am using max ipSAE, not min ipSAE as recommended in Overath et al.
I did some additional analyses where I explored variations of the scores, and found minimal differences.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/iptm_ppv.png" width="100%" /&gt;
&lt;em&gt;Top 10% PPV. The best score is highlighted in green; 95% bootstrap CI in small font underneath.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/iptm_auroc.png" width="100%" /&gt;
&lt;em&gt;AUROC. The best score is highlighted in green; 95% bootstrap CI in small font underneath.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I was surprised at how well ipTM did.
All folding models produce this score by default, so it's easy to get, and it performs well across the board.&lt;/p&gt;
&lt;p&gt;ESMFold2 also deserves a shout-out. It's the oldest and fastest method here, but it's still performing very well.&lt;/p&gt;
&lt;p&gt;I thought I had a pretty decent amount of data here, but even so, using paired comparisons, I could not detect significant differences between any of the scores.
Maybe because they are all derived from the same aligned error data.
I don't think this means they all perform the same, but I'd need quite a bit more data to find daylight between them.&lt;/p&gt;
&lt;p&gt;Note that many of these Proteinbase submissions were selected for high ipTM, so there is also some selection bias.&lt;/p&gt;
&lt;h2&gt;Foldism&lt;/h2&gt;
&lt;p&gt;I have an open-source folding tool called &lt;a href="https://github.com/hgbrian/foldism"&gt;foldism&lt;/a&gt;.
It runs on modal and includes AlphaFold 2, ESMFold2, OpenDDE, and Mol-1. 
I removed Boltz-2, Chai-1, and OpenFold to streamline it, but these are easy for an agent to add back in.
I updated the code to calculate ipTM, ipSAE, ipDAE, and actifpTM, giving the score and a percentile
from the distribution of non-binders in my dataset above.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/iptm_foldism.png" width="100%" /&gt;
&lt;em&gt;Insulin's two chains co-folded and scored with &lt;a href="https://github.com/hgbrian/foldism"&gt;foldism&lt;/a&gt;. It's not a true binder, but only ipDAE gives a high percentile here (96–100).&lt;/em&gt;&lt;/p&gt;</content><category term="ai"/><category term="ai"/><category term="biotech"/></entry><entry><title>OCR for biological sequences</title><link href="/ocr-biological-data.html" rel="alternate"/><published>2026-09-06T11:00:00-07:00</published><updated>2026-09-06T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2026-09-06:/ocr-biological-data.html</id><summary type="html">&lt;p&gt;OCR for biological sequences with a small benchmark&lt;/p&gt;</summary><content type="html">&lt;p&gt;One of the minor irritations in my life is that OCR does not consistently work for biological sequences (nucleic acids and proteins).&lt;/p&gt;
&lt;p&gt;People think of OCR as a solved problem because AIs are very good at it, but the mistakes AIs make in human language are usually forgivable:
maybe an O instead of a 0, or a hyphen instead of an en-dash.&lt;/p&gt;
&lt;p&gt;Biological sequences have peculiar challenges:
they can be thousands of characters or more;
they are often repetitive and high entropy compared to human language;
they are fairly often embedded in images, whether that is a scanned PDF, or a rasterized figure in a paper.
Most importantly, a single typo can break the whole sequence.&lt;/p&gt;
&lt;h2&gt;Patents&lt;/h2&gt;
&lt;p&gt;Patents have some of the most useful biological sequences, and some of the worst OCR problems.
Google Patents includes the reference/original PDF of the patent (the &lt;a href="https://www.uspto.gov/patents/apply/patent-center/egrants"&gt;USPTO certifies &lt;em&gt;PDFs&lt;/em&gt;&lt;/a&gt;),
and an OCR'd html page, which can have errors.
Most of the time, the PDF contains extractable text, and no OCR is necessary, but even then, the &lt;em&gt;sequences&lt;/em&gt; often live in images.&lt;/p&gt;
&lt;p&gt;I got an AI to examine a sample of 100 patent PDFs, with 25 patents drawn from each of four publication eras (before 2000, 2000–2009, 2010–2019, 2020 onward).
11/100 contained no embedded or extractable text on any page (i.e., all images).
Surprisingly, all were published in the last five years (e.g., &lt;a href="https://patents.google.com/patent/US11584788B2/en?oq=US11584788B2"&gt;US11584788B2&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;I tried to find some illustrative examples of failed OCR:
in &lt;a href="https://patents.google.com/patent/WO2017040932A1/en"&gt;WO2017040932A1&lt;/a&gt;,
the Q in EIVLTQSP is rendered as O for SEQ ID NO: 22;
in &lt;a href="https://patents.google.com/patent/US11965030B2/en"&gt;US11965030B2&lt;/a&gt;,
Gln is rendered as GIn in two occurrences, SEQ ID NOs: 15 and 19.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/ocr_WO2017040932A_PDF.png" width="100%" /&gt;
&lt;em&gt;&lt;a href="https://patentimages.storage.googleapis.com/83/2c/6b/9c4a0e39d73696/WO2017040932A1.pdf"&gt;Patent WO2017040932A1&lt;/a&gt; PDF (top) vs &lt;a href="https://patents.google.com/patent/WO2017040932A1/en"&gt;HTML&lt;/a&gt; (bottom). There are multiple OCR errors underlined in pink. This is a grainy image, but readable by a human.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In the process of this search, I was a bit surprised to find that in most cases of impossible DNA or protein sequences,
the PDF itself contained the typo.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/ocr_US8110549.png" width="100%" /&gt;
&lt;em&gt;&lt;a href="https://patents.google.com/patent/US8110549B2/en"&gt;Patent US8110549&lt;/a&gt; has an impossible codon (underlined in pink).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I tried to do a more comprehensive evaluation of the prevalence of such errors,
but it would have taken a ton of manual review. 
I think it probably makes more sense to wait a year and get a smart AI to do it.&lt;/p&gt;
&lt;h2&gt;OCR&lt;/h2&gt;
&lt;p&gt;There are two main kinds of OCR:
specialized OCR tools like hoary mainstay &lt;a href="https://github.com/tesseract-ocr/tesseract"&gt;tesseract&lt;/a&gt;, which works well but is tuned for human language,
and AI OCR tools (just asking ChatGPT, Claude, Gemini), which are smarter but have the tendencies of a human reader, and so can get confused or distracted.&lt;/p&gt;
&lt;p&gt;Broadly, the most common failure modes I have seen for these are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;specialized: mistaking Gln for GIn (not enough intelligence to understand that this is a sequence of amino acids)&lt;/li&gt;
&lt;li&gt;AI: miscounting or losing track of the number of repeated characters (homopolymers)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Benchmark&lt;/h2&gt;
&lt;p&gt;Last year, after failing to extract some not-especially challenging protein sequences from several PDFs—forcing me to spend hours manually typing them in—I got annoyed and decided to make a benchmark.&lt;/p&gt;
&lt;p&gt;I chose &lt;a href="https://github.com/hgbrian/bio_ocr_minibenchmark/tree/main/images"&gt;six sequences&lt;/a&gt;.
These were an attempt at a representative sample, and were not chosen to be especially challenging.
I created a &lt;a href="https://github.com/hgbrian/bio_ocr_minibenchmark"&gt;bio_ocr_minibenchmark repo&lt;/a&gt; to let me test out methods and see what works best.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/ocr_montage.png" width="100%" /&gt;
&lt;em&gt;The six sequences in the benchmark are not particularly challenging.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;These are all monospace fonts, have a constrained alphabet, and clear, uncorrupted images.
Yet I have tried every OCR system I could find over the last year and so far nothing has gotten all of them correct.
Almost everyone is &lt;a href="https://x.com/jouyan11/status/2080424936699527520"&gt;surprised&lt;/a&gt; this is still an issue!&lt;/p&gt;
&lt;p&gt;There has been progress in just the past few weeks. Opus 5 and GPT-6 Astra are the best I have tested so far
(Fable refuses any biological work, so I can't evaluate it).
Specifically, Opus 5 gets 5/6 correct, failing on image 6, which is just some Gs and Cs I typed into Google Docs!
It loses count and adds some extra Gs for no reason.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/ocr_benchmark.png" width="100%" /&gt;
&lt;em&gt;The benchmark includes specialized OCR tools and AI OCR tools. There has been steady improvement over time.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;We do not yet have a robust way to extract biological sequences from images.
This is surprising, and a pain.&lt;/p&gt;
&lt;p&gt;I think we are still maybe a year or more from a fully trustworthy OCR system you don't have to double-check,
which is crazy to say given the current capabilities of AI generally.&lt;/p&gt;</content><category term="ai"/><category term="ai"/><category term="biotech"/></entry><entry><title>Personalized peptides for respiratory viruses</title><link href="/nasal-sprays-and-peptides.html" rel="alternate"/><published>2026-06-28T11:00:00-07:00</published><updated>2026-06-28T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2026-06-28:/nasal-sprays-and-peptides.html</id><summary type="html">&lt;p&gt;Nasal sprays and personalized peptide binders for respiratory viruses.&lt;/p&gt;</summary><content type="html">&lt;p&gt;The nose is the primary entry point for respiratory infections (hence &lt;a href="https://en.wikipedia.org/wiki/Rhinovirus"&gt;&lt;em&gt;rhino&lt;/em&gt;viruses&lt;/a&gt;).
This is because most of the air you breathe enters through here.
The nose has a host of defenses, including
the physical barrier of mucus (which also contains antibodies and peptidases) and the production of nitric oxide, a potent antimicrobial.&lt;/p&gt;
&lt;p&gt;The other major entrypoint is the mouth, which has its own defenses including proteases and antibodies in saliva and the fact you can swallow viruses,
yet mouth breathing is a significant &lt;a href="https://www.sciencedirect.com/science/article/abs/pii/S0165587618300387"&gt;risk factor for respiratory infections in children&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Respiratory infections are not treated as seriously as they should be.
The flu causes tens of thousands of deaths per year in the US and costs &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC1885332/"&gt;tens or hundreds of billions a year&lt;/a&gt;;
RSV is the &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC9377026/"&gt;leading cause of infant hospitalizations&lt;/a&gt;;
long COVID affects millions and globally &lt;a href="https://www.nature.com/articles/s41533-025-00460-8"&gt;costs an estimated $1T annually&lt;/a&gt;;
TB remains one of the world's &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC11995120/"&gt;deadliest infectious agents&lt;/a&gt;.
Even the "common cold", which is actually infection by any of &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC3215607/"&gt;200 or so viruses&lt;/a&gt;,
can cause &lt;a href="https://www.cdc.gov/common-cold/about/index.html"&gt;severe complications like pneumonia&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We are increasingly recognizing the accumulated burden of frequent infections,
including connections to Alzheimer's and other neurological diseases,
and the profound neurological benefits of vaccination,
like the huge relative risks in this &lt;em&gt;&lt;a href="https://academic.oup.com/ageing/article/54/11/afaf331/8339764"&gt;2025 paper from Maggi et al.&lt;/a&gt;&lt;/em&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Vaccination against herpes zoster was associated with a reduced risk of any dementia (RR 0.76, 95% CI 0.69–0.83) and Alzheimer’s disease (RR 0.53, 95% CI 0.44–0.64). Influenza vaccination was linked to a reduction in dementia risk (RR 0.87, 95% CI 0.77–0.99), as was pneumococcal vaccination (RR 0.64, 95% CI 0.47–0.87) for Alzheimer’s disease. Tetanus, diphtheria, pertussis (Tdap) vaccination was also associated with a significant reduction for any dementia (RR 0.67, 95% CI 0.54–0.83).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We should not be surprised if today's viral load is damaging.
The variety and frequency of infections we are now subjected to is an unnatural state for humans;
as a species, we are accustomed to living in small tribes with no international travel.&lt;/p&gt;
&lt;p&gt;By coincidence, just this week, Stripe launched the &lt;a href="https://x.com/nanransohoff/status/2069761661456601188"&gt;Intercept project&lt;/a&gt;,
"a $500M philanthropic initiative to make respiratory infections, like the common cold and flu, a thing of the past"
so at least some people are starting to take the problem seriously.&lt;/p&gt;
&lt;h1&gt;Nose sprays&lt;/h1&gt;
&lt;p&gt;This brings me on to one of my favorite subjects: nose sprays!
Preventing infectious disease is one of the easiest way to improve long-term health and longevity.
Luckily, nose sprays are a pretty simple, inexpensive, and effective intervention.
These sprays primarily act outside of your cells,
so the risks compared to e.g., antibiotics, are very low.&lt;/p&gt;
&lt;p&gt;There are two major types of nose spray:
those that act as a physical barrier to prevent entry of viruses,
and the more drug-like antimicrobial or antihistamine sprays.
The fact that most of the studies below are COVID-specific is just because of the timing of the pandemic and associated funding.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Physical barrier&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/dp/B07KJY1RLR"&gt;Salinex&lt;/a&gt; and &lt;a href="https://www.amazon.com/LUCA-V-Defense-Protection-Airborne-Spraying/dp/B0C2237D1Q/"&gt;LUCA V-Defense&lt;/a&gt; are carrageenan-based sprays with &lt;a href="https://pubmed.ncbi.nlm.nih.gov/36109791/"&gt;evidence for COVID infection prevention&lt;/a&gt;. $20 per bottle&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.profispray.com"&gt;Profi&lt;/a&gt; is a gellan/pectin-based spray with &lt;a href="https://jamanetwork.com/journals/jamaotolaryngology/fullarticle/2770785"&gt;evidence for influenza infection prevention in mice&lt;/a&gt;. $25 per bottle.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Xlear-Nasal-Spray-Xylitol-Pack/dp/B00IPKC622"&gt;Xlear&lt;/a&gt; is a xylitol-based spray with &lt;a href="https://pubmed.ncbi.nlm.nih.gov/33173650/"&gt;weak evidence as a COVID treatment&lt;/a&gt;. $33 per bottle&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Antimicrobial / antihistamine&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.nowonder.com/products/nowonder-nasal-cleanser"&gt;NOWONDER&lt;/a&gt; is a nitric oxide spray with &lt;a href="https://pubmed.ncbi.nlm.nih.gov/33992687/"&gt;evidence for treating mild COVID&lt;/a&gt;. $40 per bottle.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://viraldine.com"&gt;ViralDine&lt;/a&gt; is a povidone iodine spray with &lt;a href="https://jamanetwork.com/journals/jamaotolaryngology/fullarticle/2770785"&gt;evidence for COVID inactivation&lt;/a&gt;. $20 per bottle.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.walgreens.com/store/c/astepro-allergy-antihistamine-nasal-spray/ID=300420970-product"&gt;AstePro&lt;/a&gt; is an antihistamine spray with &lt;a href="https://jamanetwork.com/journals/jamainternalmedicine/fullarticle/2838335"&gt;evidence for COVID infection prevention&lt;/a&gt;. $18 per bottle&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Surprisingly, many of the papers above show pretty good evidence.
Like masks, the mechanisms of action here are very straightforward.&lt;/p&gt;
&lt;p&gt;My personal preference is for the physical barrier sprays.
They act as an additional barrier like sunscreen, and appear to be very safe.
For example, carrageenan is a &lt;a href="https://en.wikipedia.org/wiki/Generally_recognized_as_safe"&gt;GRAS&lt;/a&gt; &lt;a href="https://en.wikipedia.org/wiki/Carrageenan"&gt;food additive&lt;/a&gt;,
sometimes used as a vegan alternative to gelatin.&lt;/p&gt;
&lt;p&gt;Arguably, the successor to carrageenan sprays is &lt;a href="https://www.profispray.com"&gt;Profi&lt;/a&gt;,
which essentially builds on the "augmented mucus" concept.
Profi has two main advantages over carrageenan: it provides both a physical barrier and pathogen neutralization,
and it lasts a claimed eight hours.
In 2024, the &lt;a href="https://www.profispray.com/pages/our-science"&gt;two professors at Harvard&lt;/a&gt; behind Profi published an
&lt;a href="https://assets.super.so/59632954-f2cd-4fc3-9a2b-dba2d3295b8a/files/a97d5684-f33c-4f4c-92cc-d381e904e675/Toward_a_Radically_Simple_Multi-Modal_Nasal_Spray_for_Preventing_Respiratory_Infections_-_Joseph_et_al.pdf"&gt;intriguing study&lt;/a&gt;
showing complete protection from Influenza A in a mouse model.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_profi.jpg" width="100%" /&gt;
&lt;em&gt;Profi acts as a physical barrier and neutralizes pathogens&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I currently use Profi a maximum of once per day, but for more protection I would probably recommend Profi in the morning,
and maybe NOWONDER nitric oxide spray before bed.&lt;/p&gt;
&lt;h2&gt;The alternatives&lt;/h2&gt;
&lt;p&gt;Good evidence and real papers are the exception in the supplement/wellness space. 
Maybe the nuttiest example is &lt;a href="https://en.wikipedia.org/wiki/Oscillococcinum"&gt;Oscillococcinum&lt;/a&gt;,
which is somehow both homeopathic and snake oil,
yet still gets sold in supermarkets all over the US and Europe.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_oscillo.png" width="100%" /&gt;
&lt;em&gt;Despite its insane ingredients, Oscillococcinum had revenue of &lt;a href="https://en.wikipedia.org/wiki/Oscillococcinum#Origin_and_history"&gt;$15M/yr in the US in 2008&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Zicam"&gt;Zicam&lt;/a&gt;,
a nose spray you can find everywhere for "cold and allergy relief" appears to be exploiting the homeopathy loophole too.
The evidence in its favor is weak,
and there are &lt;a href="https://en.wikipedia.org/wiki/Zicam#Safety_concerns"&gt;hundreds of lawsuits&lt;/a&gt; filed against the company, alleging loss of sense of smell.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_zicam.png" width="100%" /&gt;
&lt;em&gt;Despite weak evidence and potential anosmia, Zicam has revenue of approximately &lt;a href="https://www.sec.gov/Archives/edgar/data/313927/000156459021006669/R13.htm"&gt;$100M/yr&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h1&gt;A viral infection case study&lt;/h1&gt;
&lt;p&gt;The children sometimes get respiratory infections at school. 
The last time this happened was a couple of months ago,
and I decided to sequence some saliva to see what the infectious agent was.&lt;/p&gt;
&lt;p&gt;Many of the likely culprits are RNA viruses,
so sadly you can't just do DNA sequencing, you need to do &lt;a href="https://en.wikipedia.org/wiki/Metatranscriptomics"&gt;metatranscriptome&lt;/a&gt; sequencing.&lt;/p&gt;
&lt;p&gt;Zymo has a great service where they will do
&lt;a href="https://ngsserviceportal.com/services/10d4b134-46a1-442f-9c1e-02c1271468d2/155f90a4-a3a1-4811-b1f8-b13a5e3178bd/"&gt;30 million paired end reads of metatranscriptomic sequencing for $375&lt;/a&gt; from an unprocessed sample (e.g., saliva).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_zymo.png" width="100%" /&gt;&lt;/p&gt;
&lt;p&gt;Zymo is very amenable to small projects, and processed my single sample.
I did need
&lt;a href="https://www.zymoresearch.com/products/dna-rna-shield?srsltid=AfmBOopKMaTBGIoVL8cyrmgv3cTuXNMza8B9e9Peox1Obl1QCGBedgjj"&gt;Zymo DNA/RNA shield&lt;/a&gt; ($74) to stabilize the RNA, but I had some from a &lt;a href="https://blog.booleanbiotech.com/oral-microbiome-biogaia"&gt;previous project&lt;/a&gt;.
The sequencing took around six weeks, and the results look exceptionally clean.&lt;/p&gt;
&lt;h2&gt;Metatranscriptomic results&lt;/h2&gt;
&lt;p&gt;The metatranscriptomic analysis found a normal, healthy distribution of bacteria.&lt;/p&gt;
&lt;h3&gt;Top bacterial species&lt;/h3&gt;
&lt;style&gt;
th {font-size:90%}
.nm {font-size:80%;}
.pct {font-size:90%;}
.ph {font-size:80%;}
.qc {font-size:90%;}
.bar {background:#eef1f4;border-radius:3px;height:10px;width:80px}
&lt;/style&gt;

&lt;table&gt;
    &lt;tr&gt;&lt;th&gt;Species&lt;/th&gt;&lt;th&gt;Abundance&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;Phylum&lt;/th&gt;&lt;th&gt;Seq identity&lt;/th&gt;&lt;th&gt;Genome coverage&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Porphyromonas pasteri&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;8.5%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:100%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Bacteroidota&lt;/td&gt;&lt;td class='qc'&gt;97.4%&lt;/td&gt;&lt;td class='qc'&gt;93%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Rothia mucilaginosa&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;5.8%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:68%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Actinobacteriota&lt;/td&gt;&lt;td class='qc'&gt;98.4%&lt;/td&gt;&lt;td class='qc'&gt;79%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Rothia sp001808955&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;2.8%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:33%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Actinobacteriota&lt;/td&gt;&lt;td class='qc'&gt;98.1%&lt;/td&gt;&lt;td class='qc'&gt;56%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Alloprevotella sp015257125&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;2.6%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:31%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Bacteroidota&lt;/td&gt;&lt;td class='qc'&gt;97.8%&lt;/td&gt;&lt;td class='qc'&gt;89%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Prevotella melaninogenica&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;2.2%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:26%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Bacteroidota&lt;/td&gt;&lt;td class='qc'&gt;98.4%&lt;/td&gt;&lt;td class='qc'&gt;71%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Actinomyces graevenitzii&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;2.2%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:26%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Actinobacteriota&lt;/td&gt;&lt;td class='qc'&gt;97.1%&lt;/td&gt;&lt;td class='qc'&gt;78%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Rothia sp015265375&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;2.2%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:26%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Actinobacteriota&lt;/td&gt;&lt;td class='qc'&gt;98.2%&lt;/td&gt;&lt;td class='qc'&gt;47%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Rothia mucilaginosa_B&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;2.2%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:25%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Actinobacteriota&lt;/td&gt;&lt;td class='qc'&gt;98.2%&lt;/td&gt;&lt;td class='qc'&gt;47%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Capnocytophaga gingivalis&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;1.8%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:21%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Bacteroidota&lt;/td&gt;&lt;td class='qc'&gt;97.5%&lt;/td&gt;&lt;td class='qc'&gt;75%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Neisseria perflava&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;1.5%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:18%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Proteobacteria&lt;/td&gt;&lt;td class='qc'&gt;98.8%&lt;/td&gt;&lt;td class='qc'&gt;58%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Streptococcus mitis_BB&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;1.4%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:17%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Firmicutes&lt;/td&gt;&lt;td class='qc'&gt;99.0%&lt;/td&gt;&lt;td class='qc'&gt;51%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Alloprevotella sp900095835&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;1.4%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:17%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Bacteroidota&lt;/td&gt;&lt;td class='qc'&gt;98.3%&lt;/td&gt;&lt;td class='qc'&gt;79%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Bulleidia sp015256775&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;1.4%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:16%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Firmicutes&lt;/td&gt;&lt;td class='qc'&gt;98.1%&lt;/td&gt;&lt;td class='qc'&gt;84%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Rothia aeria&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;1.3%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:15%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Actinobacteriota&lt;/td&gt;&lt;td class='qc'&gt;98.3%&lt;/td&gt;&lt;td class='qc'&gt;86%&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;i&gt;Gemella sanguinis&lt;/i&gt;&lt;/td&gt;&lt;td class='pct'&gt;1.1%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:13%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;Firmicutes&lt;/td&gt;&lt;td class='qc'&gt;97.9%&lt;/td&gt;&lt;td class='qc'&gt;75%&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;

&lt;h3&gt;Top viral species&lt;/h3&gt;
&lt;table&gt;&lt;tr&gt;&lt;th&gt;Virus&lt;/th&gt;&lt;th&gt;Abundance&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;Note&lt;/th&gt;&lt;/tr&gt;
    &lt;tr&gt;&lt;td class='nm'&gt;Tomato brown rugose fruit virus&lt;/td&gt;&lt;td class='pct'&gt;64%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:100%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;dietary plant virus (tobamovirus)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;uncultured phage&lt;/td&gt;&lt;td class='pct'&gt;27%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:42%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;bacteriophage&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='nm'&gt;&lt;b&gt;Human metapneumovirus (HMPV)&lt;/b&gt;&lt;/td&gt;&lt;td class='pct'&gt;9%&lt;/td&gt;&lt;td&gt;&lt;div class='bar'&gt;&lt;div style="height:10px;border-radius:3px;width:14%;background:#2c7fb8"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='ph'&gt;real respiratory pathogen &amp;rarr; target&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;The tobamovirus hit is probably from recently eaten food.
There is only one human virus in the dataset: &lt;a href="https://en.wikipedia.org/wiki/Human_metapneumovirus"&gt;human metapneumovirus (HMPV)&lt;/a&gt;.
HMPV is a single-stranded RNA virus with a lipid coat that is one of the most common causes of the common cold. 
There is no antiviral treatment for HMPV. Like most viruses, the advice is to wait for your immune system to fight it off.&lt;/p&gt;
&lt;p&gt;HMPV is usually not serious in older children or adults,
but accounts for &lt;a href="https://pubmed.ncbi.nlm.nih.gov/40732017/"&gt;5% to 10% of hospitalizations among pediatric patients with acute respiratory tract infections&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_hmpv_diagram.png" width="100%" /&gt;
&lt;em&gt;Diagram of HMPV from &lt;a href="https://www.mdpi.com/2076-2607/13/7/1508"&gt;Lianou et al., 2025&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Virus sequence&lt;/h2&gt;
&lt;p&gt;The sequence of the genome is about 3% diverged from the closest reference
(&lt;a href="https://www.ncbi.nlm.nih.gov/nuccore/FJ168778"&gt;FJ168778.1&lt;/a&gt;), with 64 missense mutations.
It's not &lt;em&gt;that&lt;/em&gt; surprising that it all matches a reference sequence so well,
but it's still gratifying to see.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_hmpv_genome_diagram.svg" width="100%" /&gt;
&lt;em&gt;The sequence of my HMPV vs a &lt;a href="https://www.ncbi.nlm.nih.gov/nuccore/FJ168778"&gt;reference sequence&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Virus structure&lt;/h2&gt;
&lt;p&gt;The structure of the HMPV virus is way bigger and more complicated than you would think from the diagram above.&lt;/p&gt;
&lt;p&gt;I am used to thinking of viruses as small icosahedra, with a tightly coiled genome inside
(see this &lt;a href="https://www.asimov.press/p/viral-capsids"&gt;great article on icosahedral viruses from Asimov Press&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;HMPV is pretty different:
it's a coiled nucleoprotein, which requires around 1900 "N" proteins to cover the genome,
producing a massive structure of hundreds of megadaltons per virion. 
All of this is squished into a lipid sphere like a ball of yarn.&lt;/p&gt;
&lt;p&gt;I used &lt;a href="https://alphafoldserver.com"&gt;AlphaFold 3&lt;/a&gt; to fold ten nucleoproteins and some RNA from my virus.
As you'd expect, given there are &lt;a href="https://www.rcsb.org/search?request=%7B%22query%22%3A%7B%22type%22%3A%22group%22%2C%22logical_operator%22%3A%22and%22%2C%22nodes%22%3A%5B%7B%22type%22%3A%22group%22%2C%22label%22%3A%22text%22%2C%22logical_operator%22%3A%22and%22%2C%22nodes%22%3A%5B%7B%22type%22%3A%22terminal%22%2C%22service%22%3A%22full_text%22%2C%22parameters%22%3A%7B%22value%22%3A%22hmpv%20nucleoprotein%22%7D%7D%5D%7D%5D%7D%2C%22return_type%22%3A%22entry%22%2C%22request_options%22%3A%7B%22paginate%22%3A%7B%22start%22%3A0%2C%22rows%22%3A25%7D%2C%22results_content_type%22%3A%5B%22experimental%22%5D%2C%22sort%22%3A%5B%7B%22sort_by%22%3A%22score%22%2C%22direction%22%3A%22desc%22%7D%5D%2C%22scoring_strategy%22%3A%22combined%22%7D%2C%22request_info%22%3A%7B%22query_id%22%3A%224d7c6ac7e0bcdc79d01c7aa4480a2103%22%7D%7D"&gt;good reference structures in PDB&lt;/a&gt;,
AlphaFold 3 does a fine job folding the nucleoproteins into a coil.
In contrast, the RNA has formed a double-stranded hairpin and does not match the &lt;a href="https://www.rcsb.org/3d-view/8PDN"&gt;crystal structure&lt;/a&gt;.&lt;/p&gt;
&lt;div style="display: flex; justify-content: space-between; align-items: flex-start;"&gt;
  &lt;img class="blogimg" src="/images/nasal_spray_N.jpg" style="width: 49%; height: auto;" /&gt;
  &lt;img class="blogimg" src="/images/nasal_8pdn.jpg" style="width: 49%; height: auto;" /&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;(Left) Ten N proteins from my HMPV in a circular configuration (blue/yellow), with some RNA (orange) wound around.
(Right) Eleven N proteins in a spiral configuration (&lt;a href="https://www.rcsb.org/3d-view/8PDN"&gt;PDB:8PDN&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Viral target&lt;/h2&gt;
&lt;p&gt;The "F" (Fusion) protein is the obvious target for a therapeutic.
It is on the surface of the lipid envelope and mediates cell adhesion and membrane fusion.
It has two configurations: pre-fusion and post-fusion.
Pre-fusion is the unstable form. When it comes into contact with the host cell,
it snaps into the more stable "harpoon" that mediates membrane fusion.&lt;/p&gt;
&lt;!--
This is a bit challenging for therapeutic development
because if you make a recombinant F protein you get the stable (post-fusion) form,
which is probably not the target you want to bind.
--&gt;

&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_fusion.jpg" width="100%" /&gt;
&lt;em&gt;The &lt;a href="https://www.researchgate.net/profile/James-Crowe-3/publication/221886542_Structure_of_the_Human_Metapneumovirus_Fusion_Protein_with_Neutralizing_Antibody_Identifies_a_Pneumovirus_Antigenic_Site/links/0f317531e9ff40ef9e000000/Structure-of-the-Human-Metapneumovirus-Fusion-Protein-with-Neutralizing-Antibody-Identifies-a-Pneumovirus-Antigenic-Site.pdf"&gt;pre-fusion F protein&lt;/a&gt; is compact and the post-fusion F protein is elongated&lt;/em&gt;&lt;/p&gt;
&lt;!--
An alternative is to target a segment of the F protein that is the same pre- and post-fusion.
Luckily there is such an epitope, identified in [Wen et al., 2012](https://www.researchgate.net/profile/James-Crowe-3/publication/221886542_Structure_of_the_Human_Metapneumovirus_Fusion_Protein_with_Neutralizing_Antibody_Identifies_a_Pneumovirus_Antigenic_Site/links/0f317531e9ff40ef9e000000/Structure-of-the-Human-Metapneumovirus-Fusion-Protein-with-Neutralizing-Antibody-Identifies-a-Pneumovirus-Antigenic-Site.pdf).
This paper includes a PDB structure, [4DAG](https://www.rcsb.org/structure/4DAG), which has a Fab bound to the epitope.

It's "highly protective in vivo".

There is a PDB entry, `4DAG`, with a Fab bound to the Fusion trimer from a similar strain
(the Fusion sequence is 99% similar).
--&gt;

&lt;p&gt;Luckily, there is a paper (&lt;a href="https://www.researchgate.net/profile/James-Crowe-3/publication/221886542_Structure_of_the_Human_Metapneumovirus_Fusion_Protein_with_Neutralizing_Antibody_Identifies_a_Pneumovirus_Antigenic_Site/links/0f317531e9ff40ef9e000000/Structure-of-the-Human-Metapneumovirus-Fusion-Protein-with-Neutralizing-Antibody-Identifies-a-Pneumovirus-Antigenic-Site.pdf"&gt;Wen et al., 2012&lt;/a&gt;)
where the authors created a Fab ("DS7", &lt;a href="https://www.rcsb.org/structure/4DAG"&gt;PDB:4DAG&lt;/a&gt;) that binds both the pre-fusion and post-fusion forms.
This is the perfect example for us to use as a reference.
The sequence of their F protein is 99% similar to ours.&lt;/p&gt;
&lt;h1&gt;Making a peptide therapy&lt;/h1&gt;
&lt;p&gt;What if we could design a peptide that binds to the virus and neutralizes it?
How hard would that be?&lt;/p&gt;
&lt;p&gt;I hear binder design is all the rage these days, so I tried to design a peptide binder.
I happened to get some credits for the new &lt;a href="https://boltz.bio/api"&gt;BoltzGen API&lt;/a&gt;
so I decided to try that.&lt;/p&gt;
&lt;p&gt;Thanks to the Wen et al. paper, I had a good epitope to go after and a crystal structure of the pre-fusion F protein.&lt;/p&gt;
&lt;p&gt;I pointed Claude at the BoltzGen API and asked for a peptide binder of length 20-40, aimed at the DS7 epitope. 
I spent around $200 on the BoltzGen API, and came up with a length 28 peptide: &lt;code&gt;VKVYDTETPEGYEKWKELARESHGMADV&lt;/code&gt;.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Complex&lt;/th&gt;
&lt;th&gt;ipTM&lt;/th&gt;
&lt;th&gt;ipSAE&lt;/th&gt;
&lt;th&gt;iLIS&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Peptide binder + reference pre-fusion F&lt;/td&gt;
&lt;td&gt;0.898&lt;/td&gt;
&lt;td&gt;0.616&lt;/td&gt;
&lt;td&gt;0.563&lt;/td&gt;
&lt;td&gt;confident closed-state interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Peptide binder + sequenced pre-fusion F&lt;/td&gt;
&lt;td&gt;0.909&lt;/td&gt;
&lt;td&gt;0.635&lt;/td&gt;
&lt;td&gt;0.578&lt;/td&gt;
&lt;td&gt;confident closed-state interface&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Peptide binder + reference post-fusion F&lt;/td&gt;
&lt;td&gt;0.159&lt;/td&gt;
&lt;td&gt;0.000&lt;/td&gt;
&lt;td&gt;0.000&lt;/td&gt;
&lt;td&gt;no confident open-state interface&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The properties of the binder are pretty good, but not ideal.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://www.biorxiv.org/content/10.1101/2025.08.14.670059v1.full.pdf"&gt;ipTM&lt;/a&gt; is high;
the &lt;a href="https://www.biorxiv.org/content/10.1101/2025.02.10.637595v1"&gt;ipSAE&lt;/a&gt; is relatively high, given the size of the peptide;
the &lt;a href="https://flyark.github.io/LIVIA/universal.html"&gt;iLIS&lt;/a&gt; is far into the "confident" range (&amp;gt;0.223),
implying a low false positive rate.&lt;/p&gt;
&lt;p&gt;One potential limitation is that in theory the pre- and post-fusion forms of the F protein have the same epitope,
but when I refold with the post-fusion form it does not appear to bind.
In practice, we probably only care about binding the pre-fusion form (before adhesion has occurred).&lt;/p&gt;
&lt;p&gt;So I can't say it's definitely a binder, but I think it has a reasonably good shot of binding.
Usually, if there is a known binder in PDB, making another binder for the same epitope is not so difficult.&lt;/p&gt;
&lt;!--
### The binder
To test if it's likely to be a real binder,
I refolded with ESMFold 2 (arguably the best protein folding method, and an independent check from the FreeBindCraft methods)
and I used the new iLIS metric from [the LIVIA project](https://flyark.github.io/LIVIA/universal.html).

I get an ipTM of 0.89, and a iLIS of 0.527.
These are good metrics. An iLIS of 0.527 implies a ~2% false positive rate, according to their website.
I don't think this is certainly a binder, but it's pretty good for a quick design, and very plausibly could bind.
Ideally I'd do 
--&gt;

&lt;iframe src="/images/nasal_binder.html" width="100%" height="720" style="border:0; border-radius:8px;"&gt;&lt;/iframe&gt;

&lt;h2&gt;How to make the peptide&lt;/h2&gt;
&lt;p&gt;There are two main ways to make a peptide: with a ribosome or with chemistry (solid phase synthesis).
If you use a ribosome (i.e., translation in a cell or cell-free system),
then you need to purify the peptide.
For short peptides it's generally easier to synthesize chemically.
For example, you can order a peptide from GenScript for around $10-25 per amino acid.&lt;/p&gt;
&lt;p&gt;The main advantages of using chemical synthesis are
(a) purity: specifically, the lack of endotoxins you get with ribosomal production;
(b) the ability to go beyond the simple 20 proteinogenic amino acids.&lt;/p&gt;
&lt;p&gt;For this peptide, we may want to add an N-terminal &lt;a href="https://en.wikipedia.org/wiki/Palmitic_acid"&gt;Palmitic acid&lt;/a&gt; or a similar fatty acid,
which should anchor the peptide in the cell membrane,
and prevent it getting flushed as mucus refreshes.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_genscript.png" width="100%" /&gt;
&lt;em&gt;This peptide would cost around $600 and take around 20 business days to arrive&lt;/em&gt;&lt;/p&gt;
&lt;!--
It might have also made sense to design a cyclic peptide, which would have some potential advantages in potency and resilience to degradation.
--&gt;

&lt;p&gt;Note, I did not test the binder against the F protein!
Maybe I'll do it at Adaptyv at some point just for interest's sake.&lt;/p&gt;
&lt;h2&gt;Safety&lt;/h2&gt;
&lt;p&gt;One big open question is whether a peptide like this, sprayed into the nose, would be safe.
The main reasons I think it probably would be are that (a) it's extracellular;
(b) our noses are exposed to tons of peptides all day (e.g., pollen);
(c) if the user experienced irritation, they could stop using it—it doesn't persist.&lt;/p&gt;
&lt;p&gt;I did a quick review of the literature, and did not find much on the topic.&lt;/p&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;It's fun to sequence viruses and design peptide binders,
but how would a peptide therapeutic like this actually work in practice?&lt;/p&gt;
&lt;h2&gt;Detection&lt;/h2&gt;
&lt;p&gt;First we would need a rapid test that could tell us which virus is present.
In theory, sequencing would be best.
Oxford Nanopore could do it,
but it is still a bit impractical, especially since you'd need RNA, and ideally results within an hour or so.&lt;/p&gt;
&lt;p&gt;The most practical thing would probably be an ELISA, similar to the rapid COVID-19 tests.
Today you can buy a &lt;a href="https://www.amazon.com/Flowflex-Results-Minutes-At-Home-Children/dp/B0G26N96BK/"&gt;COVID-19 / Flu A/B / RSV test&lt;/a&gt; in the US for around $10.
Or, if you go on alibaba, you can buy a
&lt;a href="https://www.alibaba.com/product-detail/Hot-Sale-AfireGene-Respiratory-Combo-Self_1601695278673.html"&gt;10 in 1 test&lt;/a&gt;
that includes HMPV for $2.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/nasal_elisa.jpg" width="100%" /&gt;
&lt;em&gt;&lt;a href="https://www.alibaba.com/product-detail/Hot-Sale-AfireGene-Respiratory-Combo-Self_1601695278673.html"&gt;10 in 1 test kit&lt;/a&gt; for "cat, dog, human"(!)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Once you have identified HMPV as the virus, then you would spray the peptide in your nose.
Would this actually work post-infection?
That is very unclear,
though even "protective" sprays like carrageenan do appear to reduce the duration of infection.
It is much more likely it could prevent others from getting the virus.&lt;/p&gt;
&lt;p&gt;My original idea here was to see if it would make sense to sequence and make a personalized peptide per virus.
The answer is probably no, because, as we saw,
the viruses are usually not that different, and 
the steps currently take way too long when a virus can run its course within a week or less.&lt;/p&gt;
&lt;p&gt;Instead, we could make a cocktail of peptides to address the top ten common cold viruses.
Influenza may evolve too quickly to be included in the panel—it depends on whether we can design a binder to a slowly-evolving part of the virus.
Arguably this is all overkill when safe, protective nose sprays exist, but we should do it anyway!&lt;/p&gt;
&lt;div style="font-size:75%;font-style:italic"&gt;
Thanks to Darren Zhu and Saoirse N for helpful comments on this article.
&lt;/div&gt;</content><category term="biotech"/><category term="ai"/><category term="biotech"/><category term="proteindesign"/><category term="drugdelivery"/></entry><entry><title>VHH design competition results and easymosaic</title><link href="/vhh-competition-2025-results.html" rel="alternate"/><published>2026-04-01T11:00:00-07:00</published><updated>2026-04-01T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2026-04-01:/vhh-competition-2025-results.html</id><summary type="html">&lt;p&gt;VHH competition results and easymosaic&lt;/p&gt;</summary><content type="html">&lt;p&gt;A few months ago I launched a VHH binder design &lt;a href="https://blog.booleanbiotech.com/vhh-competition-2025"&gt;mini-competition&lt;/a&gt;.
The itch I wanted to scratch was to see how well binder design tools do when run without hand-holding by the developers themselves—i.e., 
when run the way a typical user would.&lt;/p&gt;
&lt;p&gt;There are more details in the &lt;a href="https://blog.booleanbiotech.com/vhh-competition-2025"&gt;original blogpost&lt;/a&gt;,
but the gist was that the competitor submits a script to generate designs, and I run that script on a target.&lt;/p&gt;
&lt;p&gt;If we had a "best script" for binder design, kind of like AlphaFold 3 is for folding, it would be hugely enabling for scientists.&lt;/p&gt;
&lt;p&gt;I ended up allowing $100 of compute per design, which I thought was just on the edge of possibly producing a binder.
It's also approximately the price of testing one design in the lab, which seems like a reasonable benchmark.
The consensus from experts I talked to was that this would be insufficient to generate a binder.
Turns out they were right! Nevertheless, here is the rundown.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/easymosaic_competition.jpg" width="100%" style="max-width:800px" /&gt;&lt;/p&gt;
&lt;h2&gt;Competitors&lt;/h2&gt;
&lt;p&gt;I convinced one person to enter this competition: &lt;a href="https://bsky.app/profile/nboyd.bsky.social"&gt;Nick Boyd&lt;/a&gt; from &lt;a href="escalante.bio"&gt;Escalante Bio&lt;/a&gt;.
Nick won the recent &lt;a href="https://blog.escalante.bio/winning-the-de-novo-portion-of-the-adaptyv-nipah-binder-competition/"&gt;Adaptyv Nipah G competition&lt;/a&gt;
using his own &lt;a href="https://github.com/escalante-bio/mosaic"&gt;Mosaic&lt;/a&gt; protein design library (and it wasn't close!)&lt;/p&gt;
&lt;p&gt;As you'd expect, Nick entered using
&lt;a href="https://github.com/hgbrian/boolean-biotech-vhh-competition-2025/blob/main/vhh_mosaic.py"&gt;a Mosaic script&lt;/a&gt;,
similar to his Nipah G script, but adapted to generate a VHH instead of a mini-binder.
While Mosaic is &lt;a href="https://blog.escalante.bio/minibinder-design-is-just-not-that-hard"&gt;well validated&lt;/a&gt; for mini-binders,
it has not really been tested for VHH designs,
which are generally believed to be more difficult.&lt;/p&gt;
&lt;p&gt;I entered using &lt;a href="https://github.com/hgbrian/boolean-biotech-vhh-competition-2025/blob/main/vhh_boltzgen.py"&gt;a BoltzGen script&lt;/a&gt;.
My reasoning was that BoltzGen showed very strong results for VHH designs in their &lt;a href="https://www.biorxiv.org/content/10.1101/2025.11.20.689494v1"&gt;preprint&lt;/a&gt;,
though they certainly used a lot more GPU hours than I did.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/easymosaic_boltzgen_vhh.jpg" width="100%" style="max-width:800px" /&gt;
&lt;em&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2025.11.20.689494v1"&gt;BoltzGen&lt;/a&gt; has arguably the strongest published VHH design results&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;p&gt;I tested the designs against MBP, part of Adaptyv's &lt;a href="https://start.adaptyvbio.com/benchbb"&gt;BenchBB benchmark&lt;/a&gt;,
which is a set of seven standardized targets designed to be used for benchmarking.
If you elect to make the results public, as I did, you get a discount.&lt;/p&gt;
&lt;p&gt;I posted the scripts and full results from Apaptyv on the
&lt;a href="https://github.com/hgbrian/boolean-biotech-vhh-competition-2025"&gt;competition github repo&lt;/a&gt;.
The results should also appear on &lt;a href="https://proteinbase.com"&gt;proteinbase.com&lt;/a&gt; in the near future.
Of course, there is not much to see here, since none of the designs bound!&lt;/p&gt;
&lt;h2&gt;EasyMosaic&lt;/h2&gt;
&lt;p&gt;One complication of Mosaic compared to other tools like &lt;a href="https://github.com/martinpacesa/BindCraft"&gt;BindCraft&lt;/a&gt;,
&lt;a href="https://github.com/HannesStark/boltzgen"&gt;BoltzGen&lt;/a&gt;, or &lt;a href="https://github.com/manifoldbio/mber-open"&gt;mBER&lt;/a&gt;
is that Mosaic is a library, so the user is expected to define their own optimization parameters and loss function.
For example, you could define a loss function as a weighted sum of ipTM, pLDDT, and distance to epitope.
Different binder design problems might require a different balance of weights.
This is a very powerful approach, and allows the user to tune Mosaic for different targets and use-cases,
but it can be difficult to know where to start.&lt;/p&gt;
&lt;p&gt;Part of the point of this competition was to see if Mosaic could be packaged into a user-friendly script.
Since its success in the Nipah G competition, there has been quite a bit of interest in this.&lt;/p&gt;
&lt;p&gt;With some advice from Nick on parameters,
I made a web-based interface to mosaic called &lt;a href="https://github.com/hgbrian/easymosaic"&gt;easymosaic&lt;/a&gt;.
As with most of my stuff, it runs on &lt;a href="https://modal.com"&gt;modal&lt;/a&gt;
and lets you run Mosaic with some reasonable default parameters for mini-binders or VHHs.
The minibinder parameters should match the parameters used by Nick in the Nipah G competition.&lt;/p&gt;
&lt;p&gt;Easymosaic is designed to do a decent job producing a binder without the need for parameter tuning.
Your mileage will certainly vary a lot based on your target!&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/easymosaic_screenshot.jpg" width="100%" style="max-width:800px" /&gt;
&lt;em&gt;Like protein folding tools, &lt;a href="https://github.com/hgbrian/easymosaic"&gt;easymosaic&lt;/a&gt;'s interface has almost no options&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Mosaic-TUI&lt;/h2&gt;
&lt;p&gt;Nick's own &lt;a href="https://github.com/escalante-bio/mosaic-tui"&gt;Mosaic-TUI&lt;/a&gt; is a similar idea, but is more suitable for power users.
It runs in the terminal, exposes all the relevant parameters, and has some nice features like the ability to use multiple GPUs. &lt;/p&gt;
&lt;p&gt;Both easymosaic and Mosaic-TUI use B200 GPUs by default, so it is very easy to spend hundreds of dollars for a few good designs.
Each design, &lt;em&gt;before&lt;/em&gt; filtering out the bad ones, can cost $1 or more.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/easymosaic_mosaic_tui_dashboard.svg" width="100%" style="max-width:800px" /&gt;
&lt;em&gt;Mosaic-TUI has a sweet retro-futuristic UI&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Sadly it's a bit too late to use either of these tools to enter the &lt;a href="https://proteinbase.com/competitions/gem-adaptyv-rbx1"&gt;Adaptyv RBX1 competition&lt;/a&gt;
but I'm sure there will be more competitions coming!&lt;/p&gt;
&lt;p&gt;Hopefully, binder design tools will make some advances and I can try this again in a year or so, with a better chance of success.
There are still plenty of things to try:
combining the strengths of &lt;a href="https://blog.escalante.bio/teaching-generative-models-to-hallucinate/"&gt;diffusion with hallucination&lt;/a&gt;; &lt;a href="https://www.blopig.com/blog/2026/01/what-molecular-ml-can-learn-from-the-vision-communitys-representation-revolution/"&gt;grounding designs in physics&lt;/a&gt;, etc.&lt;/p&gt;</content><category term="biotech"/><category term="ai"/><category term="biotech"/><category term="proteindesign"/><category term="competition"/></entry><entry><title>Oral microbiome sequencing after taking probiotics</title><link href="/oral-microbiome-biogaia.html" rel="alternate"/><published>2026-01-03T11:00:00-08:00</published><updated>2026-01-03T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2026-01-03:/oral-microbiome-biogaia.html</id><summary type="html">&lt;p&gt;Analysis of my oral microbiome after taking a probiotic.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Recently, a friend recommended &lt;a href="https://www.biogaia.com/products/biogaia-prodentis/"&gt;BioGaia Prodentis&lt;/a&gt; to me.
It is a DTC oral probiotic you can buy online that is supposedly good for oral health.
I thought it would be interesting to do some sequencing to see what, if anything, it did to my oral microbiome.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/oral_biogaia.jpg" width="100%" style="max-width:800px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;BioGaia Prodentis is &lt;a href="https://www.walmart.com/ip/BioGaia-Prodentis-Clinically-Proven-Dental-Probiotics-Teeth-Gums-Promotes-Good-Oral-Health-Gut-Too-30-Mint-Flavored-Lozenges-1-Pack/175541687"&gt;available online&lt;/a&gt; for $20 or less for a month's supply&lt;/em&gt;&lt;/p&gt;
&lt;h1&gt;BioGaia&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://www.biogaia.com/collections/all"&gt;BioGaia&lt;/a&gt; has a fascinating story.
They are a Swedish company, founded over 30 years ago, that exclusively sells probiotics DTC. 
They have developed multiple strains of &lt;em&gt;Limosilactobacillus reuteri&lt;/em&gt;, mainly for gut and oral health.
They apparently sell well! Their &lt;a href="https://www.nasdaq.com/european-market-activity/shares/biog-b?id=TX184"&gt;market cap&lt;/a&gt; is around $1B—impressive for a consumer biotech.&lt;/p&gt;
&lt;p&gt;Going in, I expected scant evidence for any real benefits to their probiotics, but the data (&lt;a href="https://www.biogaia.com/pages/probiotic-innovation"&gt;over 250 clinical studies&lt;/a&gt;) is much more complete than I expected.&lt;/p&gt;
&lt;!--
They have been involved in .
I asked [Edison](https://platform.edisonscientific.com/) to assess the BioGaia literature.
Edison said the results were "reasonable, legitimate, and generally trustworthy".
--&gt;

&lt;p&gt;Most notably, their gut probiotic, &lt;a href="https://www.biogaia.com/products/protectis-baby-drops"&gt;Protectis&lt;/a&gt;,
seems to have a significant effect on preventing
&lt;a href="https://my.clevelandclinic.org/health/diseases/10026-necrotizing-enterocolitis"&gt;Necrotizing Enterocolitis&lt;/a&gt; (NEC) in premature babies.
According to their &lt;a href="https://ibtherapeutics.com/ibt-is-addressing-urgent-medical-needs-in-the-premature-infant/"&gt;website&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;5-10% of the smallest premature infants develop NEC, a potentially lethal disorder in which portions of the bowel undergo tissue death.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In March 2025, the FDA granted Breakthrough Therapy Designation to &lt;a href="https://ibtherapeutics.com/press-releases/ibt-is-granted-breakthrough-therapy-designation-for-its-drug-candidate/"&gt;IBP-9414&lt;/a&gt;,
an &lt;em&gt;L. reuteri&lt;/em&gt; probiotic developed by BioGaia spinout &lt;a href="https://ibtherapeutics.com"&gt;IBT&lt;/a&gt;.&lt;/p&gt;
&lt;!--
From a recent [review](https://pmc.ncbi.nlm.nih.gov/articles/PMC8306447/):
&gt;Conclusion: Currently, probiotics are widely used to prevent and treat numerous gastrointestinal disorders. In our opinion, L. reuteri meets all the requirements to be considered a safe, well-tolerated, and efficacious probiotic that is able to contribute to the beneficial effects on gut-human health, preventing and treating many gastrointestinal symptoms, and speeding up the recovery and discharge of patients accessing the emergency department.
--&gt;

&lt;p&gt;This is not specifically for the oral health product, but it's for sure more science than I expected to see going in.&lt;/p&gt;
&lt;h3&gt;Prodentis&lt;/h3&gt;
&lt;p&gt;BioGaia Prodentis contains two strains of &lt;em&gt;L. reuteri&lt;/em&gt;: &lt;a href="https://www.ncbi.nlm.nih.gov/biosample/43393324"&gt;DSM 17938&lt;/a&gt;
and &lt;a href="https://www.ncbi.nlm.nih.gov/biosample/?term=ATCC%20PTA%205289"&gt;ATCC PTA 5289&lt;/a&gt;.
The claimed benefits include fresher breath, healthier gums, and outcompeting harmful bacteria.&lt;/p&gt;
&lt;h1&gt;Sequencing with Plasmidsaurus&lt;/h1&gt;
&lt;p&gt;Many readers will be familiar with &lt;a href="https://plasmidsaurus.com/"&gt;Plasmidsaurus&lt;/a&gt;.
Founded in 2021, the team took a relatively simple idea:
use massively multiplexed Oxford Nanopore (ONT) to offer complete plasmid sequencing with one day turnaround for $15,
and scaled it.
Plasmidsaurus quickly became part of biotech's core infrastructure, and spread like wildfire.
It also inspired multiple copycats.&lt;/p&gt;
&lt;p&gt;Compared to Illumina, ONT is faster and has much longer reads, but lower throughput and lower accuracy.
This profile is a great fit to many sequencing problems like plasmid QC, where you only need megabases of sequences, but want an answer within 24 hours.&lt;/p&gt;
&lt;p&gt;Over time, Plasmidsaurus has been adding services, including genome sequencing, RNA-Seq, and microbiome sequencing,
all based on ONT sequencing.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/oral_plasmidsaurus_list.png" width="100%" style="max-width:800px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Plasmidsaurus accepts many kinds of sample for microbiome sequencing&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I used their &lt;a href="https://plasmidsaurus.com/microbiome"&gt;16S sequencing product&lt;/a&gt;, which costs $45 for ~5000 reads, plus $15 for DNA extraction.
16S sequencing is an efficient way to amplify and sequence a small amount of DNA (the ubiquitous 16S region)
and be able to assign reads to specific species or even strains.&lt;/p&gt;
&lt;p&gt;This experiment cost me $240 for four samples, and I got data back in around a week.
It's very convenient that I no longer have to do my &lt;a href="https://blog.booleanbiotech.com/human-genome-at-home"&gt;own&lt;/a&gt; &lt;a href="https://blog.booleanbiotech.com/sequencing-at-home-with-flongle"&gt;sequencing&lt;/a&gt;.
As a side note, you can pay more for more than 5000 reads, but unless you want information on very rare strains (&amp;lt;&amp;lt;1% frequency),
this is a waste of money.&lt;/p&gt;
&lt;p&gt;Sample collection is simple: take 100-250 µL of saliva and mix with 500 µL of &lt;a href="https://www.zymoresearch.com/collections/dna-rna-shield"&gt;Zymo DNA/RNA Shield&lt;/a&gt;
(which I also had to buy for around $70.) You also need &lt;a href="https://www.amazon.com/dp/B09DYWX8Q2?ref=ppx_yo2ov_dt_b_fed_asin_title"&gt;2 mL screwtop tubes&lt;/a&gt; to ship in.&lt;/p&gt;
&lt;p&gt;The reads are high quality for nanopore sequencing, with a median Q score of 23 (99%+ accuracy).
This is more than sufficient accuracy for this experiment.
The read length is very tightly distributed around 1500 nt (the length of a typical 16S region).&lt;/p&gt;
&lt;p&gt;The results provided by Plasmidsaurus include taxonomy tables, per-read assignments, and some basic plots.
I include a download of the results at the end of this article, as well as the FASTQ files.&lt;/p&gt;
&lt;h1&gt;The experiment&lt;/h1&gt;
&lt;p&gt;The main idea of the experiment was to see if any &lt;em&gt;L. reuteri&lt;/em&gt; would colonize by the end of 30 days of probiotic use,
and if so, whether it would persist beyond that.
I collected four saliva samples:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sample&lt;/th&gt;
&lt;th&gt;Timing&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Baseline A&lt;/td&gt;
&lt;td&gt;Day -4&lt;/td&gt;
&lt;td&gt;A few days before starting BioGaia&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Baseline B&lt;/td&gt;
&lt;td&gt;Day -1&lt;/td&gt;
&lt;td&gt;The day before I started BioGaia&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Day 30&lt;/td&gt;
&lt;td&gt;Day 30&lt;/td&gt;
&lt;td&gt;The last day of the 30 day course&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Week after&lt;/td&gt;
&lt;td&gt;Day 37&lt;/td&gt;
&lt;td&gt;One week after completing the course&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/oral_heatmap.svg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Heatmap of the top 20 species. All species assignments were done by &lt;a href="https://plasmidsaurus.com/technical-documentation/microbiome"&gt;Plasmidsaurus&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Did &lt;em&gt;L. reuteri&lt;/em&gt; colonize?&lt;/h2&gt;
&lt;p&gt;There was no &lt;em&gt;L. reuteri&lt;/em&gt; found in any of the samples.
I did a manual analysis to check for any possible misassignments,
but the closest read was only 91% identical to either &lt;em&gt;L. reuteri&lt;/em&gt; strain.&lt;/p&gt;
&lt;p&gt;The probiotic either (a) didn't colonize the oral cavity;
(b) was present only transiently while actively taking the lozenges;
(c) was below the detection threshold.&lt;/p&gt;
&lt;p&gt;Probiotics are generally bad at colonizing, which is why you have to keep taking them.
Still, I was surprised not to see a single &lt;em&gt;L. reuteri&lt;/em&gt; read in there.&lt;/p&gt;
&lt;h2&gt;What actually changed?&lt;/h2&gt;
&lt;p&gt;Even though the probiotic itself didn't show up,
the oral microbiome did change quite a lot.&lt;/p&gt;
&lt;p&gt;The most striking change was a massive increase in &lt;em&gt;S. salivarius&lt;/em&gt;.
&lt;em&gt;S. salivarius&lt;/em&gt; went from essentially absent to ~20% of my oral microbiome on the last day.
However, this happened &lt;em&gt;one week after&lt;/em&gt; I stopped taking the probiotic,
so it's very unclear if it is related.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sample&lt;/th&gt;
&lt;th&gt;&lt;em&gt;S. mitis&lt;/em&gt;&lt;/th&gt;
&lt;th&gt;&lt;em&gt;S. salivarius&lt;/em&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Baseline A&lt;/td&gt;
&lt;td&gt;2.0%&lt;/td&gt;
&lt;td&gt;0.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Baseline B&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;15.9%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;0.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Day 30&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;10.2%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;0.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Week after&lt;/td&gt;
&lt;td&gt;1.0%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;19.3%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;We see &lt;em&gt;S. mitis&lt;/em&gt; decreasing as &lt;em&gt;S. salivarius&lt;/em&gt; increases, 
while the total Streptococcus fraction stayed roughly stable.
It's possible one species replaced the other within the same ecological niche.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;S. salivarius&lt;/em&gt; is itself a probiotic species.
The strain &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC1449041/"&gt;BLIS K12&lt;/a&gt;
was isolated from a healthy New Zealand child and is sold commercially for oral health.
It produces bacteriocins that kill &lt;em&gt;Streptococcus pyogenes&lt;/em&gt; (strep throat bacteria).&lt;/p&gt;
&lt;p&gt;At the same time, &lt;em&gt;V. tobetsuensis&lt;/em&gt; increased in abundance from 2.1% to 5.7%.
Veillonella bacteria can't eat sugar directly—they survive by consuming lactate that Streptococcus produces.
The &lt;em&gt;S. salivarius&lt;/em&gt; bloom is plausibly feeding them.&lt;/p&gt;
&lt;!--
## A bacterial friendship dissolved

*Haemophilus parainfluenzae* and *Streptococcus mitis* are known to
[live adjacent to each other](https://www.nature.com/articles/s41396-021-01141-3)
in oral biofilms — they're positively correlated in healthy mouths.

Both decreased together in my samples.
The Haemophilus species (*H. parainfluenzae*, *H. parahaemolyticus*, *H. haemolyticus*)
collectively dropped from ~14% to ~7%, with some species disappearing entirely.

Interestingly, *H. parainfluenzae* is
[associated with good oral health](https://pmc.ncbi.nlm.nih.gov/articles/PMC11406952/),
not bad — so losing it isn't necessarily a win.
The oral microbiome shifted from Proteobacteria (Haemophilus) toward Firmicutes (Streptococcus).
--&gt;

&lt;h2&gt;Are these changes real or intra-day variation?&lt;/h2&gt;
&lt;p&gt;There was a lot more variation in species than I expected, especially comparing the two baseline samples. 
In retrospect, I should have taken multiple samples on the same day, and mixed them to smooth it out.&lt;/p&gt;
&lt;p&gt;However, there is some light evidence that the variation I see is not just intra-day variation.
Specifically, there are several species that stay consistent in frequency across all samples:
e.g., &lt;em&gt;Neisseria subflava&lt;/em&gt;, &lt;em&gt;Streptococcus viridans&lt;/em&gt;, &lt;em&gt;Streptococcus oralis&lt;/em&gt;.&lt;/p&gt;
&lt;!--
The *S. salivarius* increase shows variability **6x beyond baseline noise**,
strongly suggesting this is a real biological change, not random fluctuation.

**Caveat:** *S. mitis* was already highly variable at baseline (2% vs 16%),
so some species are naturally dynamic in the oral microbiome.
But the *S. salivarius* signal (0% → 19%) is unambiguous.
--&gt;

&lt;h1&gt;Conclusions&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;L. reuteri&lt;/em&gt; didn't detectably colonize my mouth. Oral probiotics are surprisingly difficult to detect, even if you sample the same day as dosing.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;S. salivarius&lt;/em&gt; increased massively in abundance, but this increase happened after I stopped taking BioGaia&lt;/li&gt;
&lt;li&gt;Microbiome sequencing can be used to assess oral health. None of the &lt;a href="https://en.wikipedia.org/wiki/Red_complex"&gt;"red complex"&lt;/a&gt; bacteria (&lt;em&gt;P. gingivalis&lt;/em&gt;, &lt;em&gt;T. forsythia&lt;/em&gt;, &lt;em&gt;T. denticola&lt;/em&gt;) associated with gum disease were found in any sample.&lt;/li&gt;
&lt;li&gt;The oral microbiome is dynamic, with huge swings in species abundance over a timeframe of just weeks&lt;/li&gt;
&lt;li&gt;Microbiome sequencing is very easy and convenient these days thanks to Plasmidsaurus&lt;/li&gt;
&lt;li&gt;Prodentis tastes good, may help with oral health, and I'd consider taking it again&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://public.booleanbiotech.com/GVNLJW_fastq.zip"&gt;Download Raw FASTQ (50MB)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://public.booleanbiotech.com/GVNLJW_results.zip"&gt;Download Analysis Results (3MB)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><category term="health"/><category term="quantifiedself"/><category term="health"/><category term="nanopore"/><category term="sequencing"/></entry><entry><title>Using Claude Code for computational biology</title><link href="/claude-code-for-computational-biology.html" rel="alternate"/><published>2025-12-13T11:00:00-08:00</published><updated>2025-12-13T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2025-12-13:/claude-code-for-computational-biology.html</id><summary type="html">&lt;p&gt;A short case study of using Claude Code with Opus 4.5 for a computational biology task&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a href="https://x.com/search?q=opus%204.5&amp;amp;src=typed_query&amp;amp;f=top"&gt;People are very excited&lt;/a&gt; about Anthropic's new Opus 4.5 model,
and I am too.
It is arguably the first coding model that can code continuously for hours without hitting a wall,
or entering a &lt;a href="https://natesnewsletter.substack.com/p/how-to-escape-ai-doom-loops-a-practical"&gt;doom loop&lt;/a&gt;
(continually producing the same bugs over and over.)&lt;/p&gt;
&lt;p&gt;Opus 4.5 has crossed a threshold where it has led to what appears to be a permanent change in how I work,
so I wanted to write up a short article on this, with a real-world example.&lt;/p&gt;
&lt;p&gt;For software engineers, it's obvious how coding agents help: they write code for you.
For computational scientists, writing code is one step of many:
you read papers, download tools and data, log the steps and parameters of the experiment, plot results and write it all up.
This is where &lt;em&gt;agents&lt;/em&gt; like Claude Code shine.&lt;/p&gt;
&lt;h2&gt;Claude Code&lt;/h2&gt;
&lt;p&gt;There are two main ways to use Opus 4.5: in the &lt;a href="https://claude.ai"&gt;Claude chat interface&lt;/a&gt;, just like ChatGPT etc.,
or as an agent in &lt;a href="https://claude.com/product/claude-code"&gt;Claude Code&lt;/a&gt;.
The difference is that an agent is a program running on your computer:
it doesn't just produce text, it can run arbitrary commands in the terminal on your behalf.&lt;/p&gt;
&lt;p&gt;With Opus 4.5, Claude Code is good enough that it is starting to become my primary interface to the terminal,
not just my primary interface to code.
This is a little hard to explain, but I will show a real-life example from my own work that hopefully illustrates the point.&lt;/p&gt;
&lt;p&gt;You can categorize the eras kind of like self-driving cars.
The first era, with zero AI, ended just a few years back, and I now feel like I am now on era four.
Things are progressing quickly!&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Manual:&lt;/strong&gt; I write code; I run code; I review output (most of my career!)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Copilot:&lt;/strong&gt; I co-write code with AI (e.g., in an IDE like &lt;a href="https://cursor.com"&gt;Cursor&lt;/a&gt;); I run code; I review output&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Human-in-the-loop:&lt;/strong&gt; Claude Code (CC) writes code; I read code to check it; I run code; I review output&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agent:&lt;/strong&gt; CC writes code; CC runs code; CC and I review output&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Teams of agents:&lt;/strong&gt; A team of CC agents write code, run code and review output over multiple hours; they contact me when they need input&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Autonomous:&lt;/strong&gt; A team of CC agents work collaboratively and never need my input??&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Adding ipSAE to af2rank&lt;/h2&gt;
&lt;p&gt;The task here is to add the &lt;a href="https://www.biorxiv.org/content/10.1101/2025.02.10.637595v1"&gt;ipSAE&lt;/a&gt; statistic
to my &lt;code&gt;af2rank&lt;/code&gt; modal app in the &lt;a href="https://github.com/hgbrian/biomodals"&gt;biomodals repo&lt;/a&gt;.
The details don't matter too much, but ipSAE is a popular method of scoring protein–protein
interactions—for example it is used in the recent &lt;a href="https://proteinbase.com/competitions/adaptyv-nipah-competition"&gt;Nipah protein design competition&lt;/a&gt; from Adaptyv—and there is a &lt;a href="https://github.com/DunbrackLab/IPSAE"&gt;reference implementation on github&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Below are my two(!) prompts to Claude, abridged responses from Claude, and the final result. 
The full transcript is long so I have included it at the end of the post.
There you can see more of the warts and debugging, and how much the model does besides just write code.&lt;/p&gt;
&lt;pre&gt;
[Me] &gt;clone the https://github.com/DunbrackLab/IPSAE repo, extract the ipsae scoring function, and add it to the af2rank modal app

[Claude clones the IPSAE github repo, finds the relevant files, reads the code, finds my modal_af2rank.py file, reads it, and updates it]

[Me] &gt;ok test the repo to make sure it works using a test pdb file as in the docstring; then run ipsae and compare the results to make sure the calculation is correct

[Claude downloads a test pdb file, runs the modal app, learns how to run the reference IPSAE code, debugs several issues, and finally produces a working implementation, which it validates by checking the results against the reference. Finally it summarizes all it did.]

[Claude]
⏺ Now all scores match:

  Final Comparison:

  | Metric        | Our Implementation | Original IPSAE |
  |---------------|--------------------|----------------|
  | A→B ipSAE     | 0.2760             | 0.2760 ✅      |
  | B→A ipSAE     | 0.2862             | 0.2862 ✅      |
  | A-B_max ipSAE | 0.2862             | 0.2862 ✅      |
  | A→B LIS       | 0.2998             | 0.2998 ✅      |
  | B→A LIS       | 0.2206             | 0.2206 ✅      |
  | A-B_max LIS   | 0.2602             | 0.2602 ✅      |
  | pDockQ        | 0.1476             | 0.1476 ✅      |
  | A→B pDockQ2   | 0.1612             | 0.1612 ✅      |
  | B→A pDockQ2   | 0.1289             | 0.1289 ✅      |

⏺ All IPSAE scores now match exactly between our implementation and the original IPSAE script.

  Summary of changes made to modal_af2rank.py:

  1. Added IPSAE scoring functions (lines 66-260):
    - ptm_func() / ptm_func_vec() - PTM-like scoring
    - calc_d0() - TM-score d0 normalization
    - calc_ipsae_scores() - Computes ipSAE, pDockQ, pDockQ2, and LIS for all chain pairs
  2. Modified _get_score() to compute IPSAE scores for multimer models
  3. Added CLI parameters --pae-cutoff (default 10.0) and --dist-cutoff (default 8.0)
  4. Added PAE export for external comparison (af2_scores.json and *_predicted.pdb)
&lt;/pre&gt;

&lt;p&gt;Full disclosure, I have previously asked Claude Code to do this exact task before, just in a different codebase,
and that time it actually went smoother.
I posted that on &lt;a href="https://x.com/btnaughton/status/1996307988433568086"&gt;twitter&lt;/a&gt;,
and then thought it might make for an interesting post on the blog.&lt;/p&gt;
&lt;p&gt;This time it was not quite as slick,
but this represents a more realistic example of my typical Claude Code interactions.
The path was circuitous, but it got there in the end, with zero intervention on my part.
The final result is functional but overwrought.&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;I don't test all the models all the time, but Opus 4.5 is the first model I've used
that can keep context and make linear progress like this, and others seem to agree.
I should also note I pay $200 per month for Claude Code access, but there are lower tiers.
OpenAI and Gemini both have tools similar to Claude Code. There are also cheaper but workable &lt;a href="https://deepinfra.com/models"&gt;Chinese models like Qwen&lt;/a&gt;.
If these are not as good as Opus 4.5 today, they will be very soon.&lt;/p&gt;
&lt;p&gt;People are often concerned with AIs writing "slop" code, meaning poor quality or unmaintainable code.
Honestly I'm not totally sure I should care about that any more?
If it is maintainable by Claude, that might be all that matters.&lt;/p&gt;
&lt;p&gt;This workflow is powerful for software, but in software you probably have to care more about maintainability and consistency.
Specifically, the crux may be if a team of people is working on the same code.
There are definitely examples online of software teams trying out agents, but then reverting back to no AI for this reason.
Even fully AI-pilled experts like &lt;a href="https://www.dwarkesh.com/p/andrej-karpathy"&gt;Karpathy&lt;/a&gt; find full vibe-coding a poor fit for many kinds of code.&lt;/p&gt;
&lt;p&gt;I would argue these agents are a better fit for scientific code because it's usually not the code that matters but the insight.
If you can test ten hypotheses in a day instead of one, 
or if a scientist with no deep learning experience can now finetune a model themselves,
the maintainability of the code, or even the language the code is written in,
matters much less.&lt;/p&gt;
&lt;p&gt;The relationship here is more like PI–student, and in general a PI would not look at code,
but would ask questions to make sure it's working as intended.
You can talk to Claude in the same way ("did you check this?", "did you read this paper?").&lt;/p&gt;
&lt;p&gt;I have started doing projects from start to finish like this, never leaving Claude Code,
and that includes writing up all the steps (which is tedious work),
and detailing the results.
It's not always faster or better, screws up frequently, and you have to learn how to handle
"context"—i.e., not overloading Claude with too much information—but it is powerful in a very compelling way.
Even though it's only been a couple of weeks,
it's the way I now kickstart any new project and I can't see going back.&lt;/p&gt;
&lt;h2&gt;Claude Code transcript&lt;/h2&gt;
&lt;div style="height: 20em; overflow-y: auto; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';"&gt;
&lt;pre&gt;
&gt;clone the https://github.com/DunbrackLab/IPSAE repo, extract the ipsae scoring function, and add it to the af2rank modal app
⏺ Bash(git clone https://github.com/DunbrackLab/IPSAE.git)
⏺ Read(modal_af2rank.py)
⏺ Bash(ls -la IPSAE/)
⏺ Read(IPSAE/ipsae.py)
⏺ Now I understand both files. The IPSAE script is a comprehensive scoring function for protein-protein interactions that calculates ipSAE, pDockQ, pDockQ2, and LIS scores. I need to extract the core scoring logic and integrate it into the af2rank modal app.
⏺ Read(IPSAE/README.md)
⏺ Now I understand the IPSAE scoring. For AF2Rank, I need to extract the key calculations:
  - ipSAE: Interface predicted scoring using PAE with cutoff
  - pDockQ: Based on pLDDT and contact counts
  - pDockQ2: Based on PAE values at interface
  - LIS: Local Interaction Score
  The key insight is that AF2Rank already calculates PAE and pLDDT, so I can add IPSAE scoring using those values. Let me create a clean implementation that works with the ColabDesign output.
⏺ Update(modal_af2rank.py)
⏺ Now I need to update the _get_score method and the run_af2rank function to compute and include IPSAE scores. Let me first look at how to extract the necessary information from the ColabDesign model:
⏺ Read(modal_af2rank.py)
⏺ I see that the model has access to all_atom_positions which includes CA (index 1) and CB (index 3) positions. I also see that score["pae"] is scaled by 31.0 from the model output. To compute IPSAE scores, I need to:
  1. Get the PAE matrix (unscaled, as angstroms)
  2. Get pLDDT per residue
  3. Get CB coordinates
  4. Get chain assignments
  The challenge is getting chain information. For multimer models, this should be stored in the model. Let me modify _get_score to compute IPSAE when using multimer:

⏺ Now I need to update the predict method to pass through pae_cutoff and dist_cutoff parameters:
⏺ Now I need to update the call to _get_score() in the predict method to pass the cutoffs:
⏺ Now I need to update the run_af2rank function to add the pae_cutoff and dist_cutoff parameters and pass them through:
⏺ Now let me also update the local entrypoint to add these parameters:
⏺ Now I need to check if the pLDDT is stored as per-residue array in the model. Let me look at how pLDDT is handled in the af2rank class - I see it converts score["plddt"] to a scalar. For IPSAE we need the per-residue array. Let me check the ColabDesign aux output more carefully:
⏺ Now let me also add IPSAE scores to the print output:
⏺ The JSON serialization may have issues with numpy arrays in the score dictionary. Let me check the results saving and ensure the ipsae scores are properly serialized
⏺ I need to add a custom JSON encoder for numpy types:
⏺ Here's a summary of the changes made to modal_af2rank.py:

  Added IPSAE scoring to AF2Rank:

  1. New scoring functions (lines 66-260):
    - ptm_func() / ptm_func_vec() - PTM-like scoring function
    - calc_d0() - TM-score d0 normalization
    - calc_ipsae_scores() - Main function computing ipSAE, pDockQ, pDockQ2, and LIS scores for all chain pairs
  2. Modified _get_score() (lines 437-510):
    - Added pae_cutoff and dist_cutoff parameters
    - For multimer models, extracts per-residue pLDDT, PAE matrix, CB coordinates, and chain assignments
    - Calls calc_ipsae_scores() and adds results to score dict
  3. Modified predict() (lines 507-628):
    - Added pae_cutoff and dist_cutoff parameters
    - Prints IPSAE scores when verbose
  4. Modified run_af2rank() and main():
    - Added pae_cutoff (default 10.0) and dist_cutoff (default 8.0) CLI parameters
    - Added JSON serialization helper for numpy types

  Usage with multimer:
  uv run modal run modal_af2rank.py --input-pdb complex.pdb --model-name "model_1_multimer_v3" --chains "A,B"

  The IPSAE scores will be computed automatically for multimer models and included in the results.json output.

&gt; ok test the repo to make sure it works using a test pdb file as in the docstring; then run ipsae and compare the results to make sure the calculation is correct
⏺ Bash(wget -q https://files.rcsb.org/download/4KRL.pdb -O 4KRL.pdb &amp;&amp; head -50 4KRL.pdb)
⏺ Bash(uv run modal run modal_af2rank.py --input-pdb 4KRL.pdb --model-name "model_1_multimer_v3" --chains "A,B" --run-name test_ipsae 2&gt;&amp;1) timeout: 10m 0s
⏺ It ran successfully! The IPSAE scores show 0.0 which seems suspicious - all scores are zero. Let me check the results and also run the original IPSAE script to compare:
⏺ The PAE is 3.38 which is good (low is better), but the IPSAE scores are all zeros. The problem is likely that I'm computing IPSAE from the PAE matrix incorrectly - the PAE matrix values from ColabDesign might already be scaled differently, or the chain assignments might be wrong.
⏺ Read(modal_af2rank.py)
⏺ Let me look at the _get_score method where the IPSAE calculation happens:
⏺ Read(modal_af2rank.py)
⏺ The issue is that self.model.aux["pae"] might be a scalar (the mean PAE), not the full matrix. Let me add some debug output to understand what's happening:
⏺ Bash(uv run --with modal==1.2.1 modal run modal_af2rank.py --input-pdb 4KRL.pdb --model-name "model_1_multimer_v3" --chai…) timeout: 10m 0s
⏺ The PAE matrix values are way too high: min=23.25, max=893.24. This is way above any reasonable PAE cutoff. The issue is that I'm multiplying by 31 but the values are already in some other scale. The
  score["pae"] in the log shows 3.379 which is the mean - so the raw matrix values must already be in angstroms or a different scale.

  Looking at the original code in _get_score:
  score["pae"] = 31.0 * score["pae"]  # This converts the scalar log value

  But the raw self.model.aux["pae"] matrix might not need the 31x scaling. Let me check:

⏺ Bash(uv run --with modal==1.2.1 modal run modal_af2rank.py --input-pdb 4KRL.pdb --model-name "model_1_multimer_v3" --chai…) timeout: 10m 0s
⏺ Now we get non-zero IPSAE scores:
  - A-B: ipSAE=0.2760
  - B-A: ipSAE=0.2862
  - A-B_max: ipSAE=0.2862

  The PAE matrix now has reasonable values: min=0.75, max=28.81 angstroms. Let me remove the debug output and then run the original IPSAE script to compare:
⏺ Update(modal_af2rank.py)
⏺ Now let me run the original IPSAE script. First I need to save the PAE matrix from af2rank to a JSON file that IPSAE can read. But wait - the IPSAE script expects AlphaFold output files (PAE JSON + PDB). We're running AF2Rank which uses ColabDesign internally.

  Let me check what we can do - we need to either:
  1. Export the PAE matrix and pLDDT from af2rank to files IPSAE can read
  2. Or run an actual AlphaFold prediction on 4KRL and then compare

  Actually, the simplest approach is to save the PAE matrix and pLDDT from af2rank and run the IPSAE calculation on those. Let me modify the run_af2rank function to also save the PAE and pLDDT data:
⏺ Read(modal_af2rank.py)
⏺ Let me add PAE matrix export to the run_af2rank function so we can compare with the original IPSAE script:
⏺ Update(modal_af2rank.py)
⏺ Bash(uv run --with modal==1.2.1 modal run modal_af2rank.py --input-pdb 4KRL.pdb --model-name "model_1_multimer_v3" --chai…) timeout: 10m 0s
⏺ Bash(ls -la out/af2rank/test_ipsae_final/)
⏺ Now let me run the original IPSAE script with the exported data:
⏺ Bash(python IPSAE/ipsae.py out/af2rank/test_ipsae_final/af2_scores.json out/af2rank/test_ipsae_final/4KRL_af2rank.pdb 10 10 2&gt;&amp;1) timeout: 1m 0s
⏺ There's a mismatch in the number of residues. The PDB file has 331 residues but the distance matrix has 333. This is likely because the original 4KRL.pdb has different residues than what ColabDesign outputs. Let me check:
⏺ Bash(grep "^ATOM" 4KRL.pdb | grep " CA " | wc -l &amp;&amp; grep "^ATOM" out/af2rank/test_ipsae_final/4KRL_af2rank.pdb | grep " CA " | wc -l)
⏺ Both have 327 CA atoms which matches the PAE matrix size (327x327). Let me check what's happening in the IPSAE script:
⏺ Bash(python -c "...)
⏺ The data looks correct. The issue is that the IPSAE script is reading something else from the PDB. Let me check the original 4KRL.pdb vs the af2rank output:
⏺ Bash(grep "^ATOM" 4KRL.pdb | head -5 &amp;&amp; echo "---" &amp;&amp; grep "^ATOM" out/af2rank/test_ipsae_final/4KRL_af2rank.pdb | head -5)
⏺ The PDB files are identical. Let me check how IPSAE reads the PDB file - it might be counting something differently:
⏺ Bash(python -c "...)
⏺ Everything matches. The issue must be in how IPSAE is reading the file. Looking at the error more closely - it says shapes (331,) and (333,). Let me check what IPSAE is actually reading:
⏺ Bash(cd out/af2rank/test_ipsae_final &amp;&amp; python ../../../IPSAE/ipsae.py af2_scores.json 4KRL_af2rank.pdb 10 10 2&gt;&amp;1 | head -50)
⏺ Let me add some debug output to the IPSAE script to understand what's happening:
⏺ Bash(python -c "...)
⏺ Bash(pwd &amp;&amp; ls out/af2rank/)
⏺ Bash(ls out/af2rank/test_ipsae_final/)
⏺ It looks like IPSAE already ran successfully! There are output files. Let me check the IPSAE output:
⏺ Bash(cat out/af2rank/test_ipsae_final/4KRL_af2rank_10_10.txt)
⏺ Read(out/af2rank/test_ipsae_final/4KRL_af2rank_10_10.txt)
⏺ The file is empty. Let me run IPSAE fresh:
⏺ Bash(python IPSAE/ipsae.py out/af2rank/test_ipsae_final/af2_scores.json out/af2rank/test_ipsae_final/4KRL_af2rank.pdb 10 10 2&gt;&amp;1)
⏺ Let me look at what's happening in IPSAE around line 612. The issue is the mismatch between chains (331) and distances (333). Let me add debug output to understand:
⏺ Read(IPSAE/ipsae.py)
⏺ I see - chains is built from CA atoms (line 379, residues), but distances is built from coordinates which comes from cb_residues (line 378). The issue is that cb_residues has a different count because GLY residues add their CA to cb_residues too. Let me check the PDB more carefully:
⏺ Bash(python -c "...)
⏺ So our PDB should be fine (327 CA, 327 CB+GLY). The error mentions 331 and 333 which doesn't match our data. Let me check if there's something else going on - maybe the IPSAE script is reading a different file or the arrays are being built incorrectly for AF2 format:
⏺ Bash(python -c "...)
⏺ Now I see the problem! The PDB has 331 CA residues and 333 CB residues, but our PAE matrix is 327x327. The issue is that the original 4KRL.pdb has more residues than what ColabDesign processed. The 4KRL_af2rank.pdb file is just the original input - it wasn't updated by af2rank. Let me check if we're copying the wrong file:
⏺ Read(modal_af2rank.py)
⏺ Yes - the PDB being saved is pdb_str which is the original input, not the processed structure from ColabDesign. I need to save the predicted structure instead. Let me also save the output PDB from af2rank. But actually, for IPSAE comparison we need the original structure with the same residues as the PAE matrix.  The issue is that ColabDesign processes the input and may remove some residues. We should save the structure that ColabDesign actually used. Let me modify to save the model's output PDB:
⏺ Update(modal_af2rank.py)
⏺ Bash(uv run --with modal==1.2.1 modal run modal_af2rank.py --input-pdb 4KRL.pdb --model-name "model_1_multimer_v3" --chai…) timeout: 10m 0s
⏺ Bash(ls -la out/af2rank/test_ipsae_compare/)
⏺ Now let me check the predicted PDB size and run IPSAE on it:
⏺ Bash(grep "^ATOM" out/af2rank/test_ipsae_compare/4KRL_predicted.pdb | grep " CA " | wc -l)
⏺ 327 CA atoms - matches the PAE matrix. Now let me run IPSAE:
⏺ Bash(python IPSAE/ipsae.py out/af2rank/test_ipsae_compare/af2_scores.json out/af2rank/test_ipsae_compare/4KRL_predicted.pdb 10 10 2&gt;&amp;1)
⏺ Bash(cat out/af2rank/test_ipsae_compare/4KRL_predicted_10_10.txt)
⏺ IPSAE ran successfully. Now let me compare the results:
⏺ Comparison of Results:

  | Metric        | Our Implementation (af2rank) | Original IPSAE  |
  |---------------|------------------------------|-----------------|
  | A→B ipSAE     | 0.2760                       | 0.2760          |
  | B→A ipSAE     | 0.2862                       | 0.2862          |
  | A-B_max ipSAE | 0.2862                       | 0.2862          |
  | A→B LIS       | 0.2998                       | 0.2998          |
  | B→A LIS       | 0.2206                       | 0.2206          |
  | A-B_max LIS   | 0.2602                       | 0.2602          |
  | pDockQ        | 0.0183                       | 0.1476          |
  | pDockQ2       | 0.0074                       | 0.1612 / 0.1289 |

  The ipSAE and LIS scores match exactly! However, there's a significant difference in pDockQ and pDockQ2. Let me investigate the pDockQ calculation:
⏺ Read(modal_af2rank.py)
⏺ I see the issue. The pDockQ calculation uses dist_cutoff which we pass as a parameter (8.0 by default), but the original IPSAE uses a hardcoded 8.0 Å for pDockQ. More importantly, the pLDDT values are in
  different scales:
  - Our implementation uses ColabDesign's pLDDT which is 0-1 scale
  - IPSAE expects pLDDT in 0-100 scale

  Let me check the IPSAE code for pDockQ:
⏺ I see - IPSAE uses cb_plddt which comes from the JSON file. Let me check how it's loaded:
⏺ Read(IPSAE/ipsae.py)
⏺ The IPSAE script uses data['plddt'] directly. In our export, we multiply by 100:
  "plddt": (plddt_per_res * 100).tolist(),  # IPSAE expects 0-100 scale

  But in our internal calculation, we use the raw 0-1 pLDDT from ColabDesign. Let me fix the pDockQ calculation to use the 0-100 scale:
⏺ Update(modal_af2rank.py)
⏺ Bash(eval "$(uv run --with modal==1.2.1 modal run modal_af2rank.py --input-pdb 4KRL.pdb --model-name "model_1_multimer_v3" --chai…) timeout: 10m 0s
⏺ Now all scores match:

  Final Comparison:

  | Metric        | Our Implementation | Original IPSAE |
  |---------------|--------------------|----------------|
  | A→B ipSAE     | 0.2760             | 0.2760 ✅      |
  | B→A ipSAE     | 0.2862             | 0.2862 ✅      |
  | A-B_max ipSAE | 0.2862             | 0.2862 ✅      |
  | A→B LIS       | 0.2998             | 0.2998 ✅      |
  | B→A LIS       | 0.2206             | 0.2206 ✅      |
  | A-B_max LIS   | 0.2602             | 0.2602 ✅      |
  | pDockQ        | 0.1476             | 0.1476 ✅      |
  | A→B pDockQ2   | 0.1612             | 0.1612 ✅      |
  | B→A pDockQ2   | 0.1289             | 0.1289 ✅      |

⏺ All IPSAE scores now match exactly between our implementation and the original IPSAE script.

  Summary of changes made to modal_af2rank.py:

  1. Added IPSAE scoring functions (lines 66-260):
    - ptm_func() / ptm_func_vec() - PTM-like scoring
    - calc_d0() - TM-score d0 normalization
    - calc_ipsae_scores() - Computes ipSAE, pDockQ, pDockQ2, and LIS for all chain pairs
  2. Modified _get_score() to compute IPSAE scores for multimer models
  3. Added CLI parameters --pae-cutoff (default 10.0) and --dist-cutoff (default 8.0)
  4. Added PAE export for external comparison (af2_scores.json and *_predicted.pdb)
&lt;/pre&gt;
&lt;/div&gt;</content><category term="ai"/><category term="biotech"/><category term="ai"/></entry><entry><title>Boolean Biotech VHH Design Competition 2025</title><link href="/vhh-competition-2025.html" rel="alternate"/><published>2025-10-16T11:00:00-07:00</published><updated>2025-10-16T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2025-10-16:/vhh-competition-2025.html</id><summary type="html">&lt;p&gt;Boolean Biotech VHH Design Competition 2025&lt;/p&gt;</summary><content type="html">&lt;p&gt;This is quite a departure for this blog,
but I thought it might be fun to follow &lt;a href="https://design.adaptyvbio.com/"&gt;Adaptyv Bio&lt;/a&gt;,
&lt;a href="https://www.aintibody.org/the-challenges/"&gt;Specifica&lt;/a&gt;,
&lt;a href="https://huggingface.co/spaces/ginkgo-datapoints/abdev-leaderboard"&gt;Ginkgo&lt;/a&gt;, et al.
and run my own (tiny) protein design competition,
the "Boolean Biotech VHH Design Competition 2025"!&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_vhh_competition_banner.jpg" width="100%" style="max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;Why do this when there are other, larger competitions?
The twist is that instead of submitting a design tuned to the target, you submit a script that outputs designs for any target.
The goal is to see how good we are at making VHHs with open models, limited compute, and no manual supervision.
I am optimistic I'll get at least one submission!&lt;/p&gt;
&lt;!--
The goal is to design a VHH for a protein from Adaptyv Bio's [BenchBB set](https://beta.adaptyvbio.com/benchbb).
BenchBB is an effort to make evaluation of binder design methods straightforward.
They currently have seven targets available, and you can test a design there for $99,
if you agree to make the data public.
--&gt;

&lt;h2&gt;The rules&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;For simplicity, entrants should use the standard &lt;a href="https://www.rcsb.org/structure/3EAK"&gt;hNbBCII10&lt;/a&gt; VHH.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;hNbBCII10
QVQLVESGGGLVQPGGSLRLSCAASGGSEYSYSTFSLGWFRQAPGQGLEAVAAIASMGGLTYYADSVKGRFTISRDNSKNTLYLQMNSLRAEDTAVYYCAAVRGYFMRLPSSHNFRYWGQGTLVTVSS
&amp;gt;hNbBCII10_with_CDRs_Xd
QVQLVESGGGLVQPGGSLRLSCAASXXXXXXXXXXXLGWFRQAPGQGLEAVAAXXXXXXXXYYADSVKGRFTISRDNSKNTLYLQMNSLRAEDTAVYYCXXXXXXXXXXXXXXXXXXWGQGTLVTVSS
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;The target is Maltose-binding protein from &lt;a href="https://beta.adaptyvbio.com/benchbb"&gt;BenchBB&lt;/a&gt; (PDB code: &lt;a href="https://www.rcsb.org/structure/1PEB"&gt;1PEB&lt;/a&gt;).
BenchBB, an Adaptyv Bio project, has seven targets to choose from.
The alternatives are either too large (Cas9), arguably too small (BHRF1, BBF-14) or already well-trodden (EGFR, PD-L1 and IL-7Rα).&lt;/li&gt;
&lt;li&gt;You submit one Python script that I can run using the &lt;code&gt;uvx modal run&lt;/code&gt; command below (optionally using &lt;code&gt;--with PyYAML&lt;/code&gt; or other libraries.)
The script should use ideally use all the chains in the PDB file as the target.
For simplicity, if your design tool uses only sequence and not structure, extract the sequence from the PDB file.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;uvx&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;modal&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.2.0&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;your_pipeline_name&lt;span class="o"&gt;}&lt;/span&gt;.py&lt;span class="w"&gt; &lt;/span&gt;--input-pdb&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;pdb_name&lt;span class="o"&gt;}&lt;/span&gt;.pdb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;I will use $50 of compute on any GPU available on modal to produce a binder.
The modal script should output a file called &lt;code&gt;{your_pipeline_name}.faa&lt;/code&gt;
with a maximum of 10 designs that looks like this:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;{optional_info_1}
{binder_seq_1}
&amp;gt;{optional_info_2}
{binder_seq_2}
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;I can run non-open pipelines (e.g., pipelines that use PyRosetta), but the intention of the competition is to compare open pipelines,
e.g., &lt;a href="https://www.ariax.bio/resources/freebindcraft-open-source-unleashed"&gt;FreeBindCraft&lt;/a&gt; over &lt;a href="https://www.nature.com/articles/s41586-025-09429-6"&gt;BindCraft&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;To rank designs, I will fold with AF2-Multimer with 3 recycles and MSA, and take the designs with the maximum ipTM.
Of course, your script is free to do its own ranking and output a single result.&lt;/li&gt;
&lt;li&gt;I will submit the 10 best submissions to BenchBB, with a max of one per entrant (though if there are fewer than 10 entries, I'll run more than one per entrant.) I'll test more if i can! Ideally I would like to test multiple targets with the same pipeline.&lt;/li&gt;
&lt;li&gt;You have until Friday November 7th to submit. This is not that much time but the hope is that submissions should mostly run existing open pipelines, adapted to run as a single modal script, so there should not be a lot of target-specific tuning going on.&lt;/li&gt;
&lt;li&gt;Since I have no idea if I'll get any submissions within this timeframe, and it's a pretty casual competition, I reserve the right to change the rules above a bit. I think there is a good chance I'll end up just submitting some designs myself, but it's fun to let other people try if they like!&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The competition&lt;/h2&gt;
&lt;p&gt;Obviously, this will be a small competition,
so I won't be too strict if there are issues,
but I don't want to spend time on environments, jax, cuda, etc.
This is a very appealing aspect of forcing the competition to run on &lt;code&gt;uv&lt;/code&gt; and &lt;code&gt;modal&lt;/code&gt;:
one portable script should be able to do whatever you need.&lt;/p&gt;
&lt;p&gt;All the code, designs and stats will be made public,
and will appear on &lt;a href="proteinbase.com"&gt;ProteinBase&lt;/a&gt; (Adaptyv Bio's public database),
hopefully a few weeks after the competition ends.
Adaptyv Bio has its own &lt;a href="https://x.com/julian_englert/status/1972710251255214146"&gt;BenchBB stuff&lt;/a&gt; in the works too.&lt;/p&gt;
&lt;p&gt;The prize is even better than lucre: it's glory, and maybe a t-shirt?
A plausibly easy way to enter would be to use the &lt;a href="https://github.com/TencentAI4S/IgGM"&gt;IgGM&lt;/a&gt; modal app from the &lt;a href="https://github.com/hgbrian/biomodals/"&gt;biomodals repo&lt;/a&gt;,
which should be almost plug-and-play here.&lt;/p&gt;
&lt;p&gt;This competition is difficult, maybe way too difficult!
Even the best models today recommend testing 10s of designs for every target.
So it &lt;em&gt;might&lt;/em&gt; be impossible,
but I am struck that one submission from the &lt;a href="https://foundry.adaptyvbio.com/competition?design=6175acbc-8644-4c43-bc27-8ec0508caac1"&gt;BindCraft team&lt;/a&gt;
to the 2024 &lt;a href="https://www.adaptyvbio.com/blog/po104/"&gt;Adaptyv competition&lt;/a&gt; bound, and at 100nM too!&lt;/p&gt;
&lt;p&gt;If the expected outcome of everything failing comes to pass,
maybe I will try again when the technology has progressed a bit.&lt;/p&gt;
&lt;p&gt;(Thanks to Nick Boyd for help with figuring out the rules.)&lt;/p&gt;
&lt;!--
## Appendix: compute
Making a script use exactly $50 of compute is almost impossible,
so I'll allow some leeway here, but I'll put a hard cutoff of $70.
I think a fair way to do this is to give a small penalty in ipTM for increased compute time.
So, the score I'll use to rank will be `ipTM - 0.001*max(0, num_dollars_spent-50)`.
In other words, if you spend $70, your ipTM has to 0.02 higher than a $50 submission;
if you spend $51, it should all be negligible.
--&gt;</content><category term="biotech"/><category term="biotech"/><category term="ai"/><category term="competition"/></entry><entry><title>AI antibody design in 2025</title><link href="/ai-antibody-design-2025.html" rel="alternate"/><published>2025-09-28T11:00:00-07:00</published><updated>2025-09-28T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2025-09-28:/ai-antibody-design-2025.html</id><summary type="html">&lt;p&gt;A review of antibody design tools&lt;/p&gt;</summary><content type="html">&lt;p&gt;This is a continuation of my &lt;a href="https://blog.booleanbiotech.com/archives"&gt;past articles&lt;/a&gt; on protein binder design. Here I'll cover the state-of-the-art in AI antibody design.&lt;/p&gt;
&lt;p&gt;Antibodies and antibody fragments (e.g., Fab, scFv, VHH) are particularly important in biotech, because they are highly specific, adaptable to almost any target, and have a proven track record as therapeutics. Full antibodies also have &lt;a href="https://en.wikipedia.org/wiki/Fragment_crystallizable_region"&gt;Fc regions&lt;/a&gt;, so they can activate the immune system as well as bind. In this article I'll just use the term "antibody" but many of the design approaches discussed below generate these smaller antibody fragments.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_fragments.jpg" width="100%" style="max-width:800px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A menagerie of antibody fragments (&lt;a href="https://www.nature.com/articles/nbt1142"&gt;Engineered antibody fragments and the rise of single domains, Nature Biotech, 2005&lt;/a&gt;)&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Last year we saw a lot of progress in mini-binder design (especially &lt;a href="https://blog.booleanbiotech.com/protein-binder-design-revisited"&gt;BindCraft&lt;/a&gt;), but this year there has been a lot of activity in antibody and peptide design too, as it becomes clear that there are commercially important opportunities here. BindCraft 2 will likely include the ability to create antibody fragments; a fork called &lt;a href="https://github.com/KhondamirRustamov/FoldCraft"&gt;FoldCraft&lt;/a&gt; already enables this.&lt;/p&gt;
&lt;p&gt;Antibodies are proteins, so why is antibody design not just the same problem as mini-binder design? In most ways they are the same. The main difference is that the CDR loops that drive antibody binding are highly variable and do not benefit directly from evolutionary information the way other binding motifs do. Folding long CDR loops correctly is especially difficult.&lt;/p&gt;
&lt;p&gt;Here I'll review the latest antibody design tools. I'll also provide some &lt;a href="https://github.com/hgbrian/biomodals"&gt;biomodals&lt;/a&gt; code to run in case the reader wants to actually design their own antibodies!&lt;/p&gt;
&lt;h2&gt;RFantibody&lt;/h2&gt;
&lt;p&gt;While there were other antibody design tools before it, especially &lt;a href="https://academic.oup.com/bioinformaticsadvances/article/2/1/vbac046/6609807"&gt;antibody language models&lt;/a&gt;, &lt;a href="https://github.com/RosettaCommons/RFantibody"&gt;RFantibody&lt;/a&gt; was arguably the first successful &lt;em&gt;de novo&lt;/em&gt; antibody design model. It is a fine-tuned variant of &lt;a href="https://github.com/RosettaCommons/RFdiffusion"&gt;RFdiffusion&lt;/a&gt;, and like RFdiffusion it requires testing thousands of designs to have a good shot at producing a binder. The &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC10983868/"&gt;original RFantibody paper&lt;/a&gt; was originally published way back in March 2024, so as you'd expect, the performance—while remarkable for the time—has been surpassed, and Baker lab seems to have moved on to the next challenge. (Note, the preprint was first published in 2024 but the code was only released this year.)&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_rfantibody.jpg" width="100%" style="max-width:1000px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The diffusion process as illustrated in the &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC10983868/"&gt;RFantibody paper&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;IgGM&lt;/h2&gt;
&lt;p&gt;It's pretty interesting how many Chinese protein models there are now. Many of these models are from random internet companies just flexing their AI muscles.
&lt;a href="https://github.com/TencentAI4S/IgGM"&gt;IgGM&lt;/a&gt; is a brand new, comprehensive antibody design suite from Tencent (the giant internet conglomerate). It can do &lt;em&gt;de novo&lt;/em&gt; design, affinity maturation, and more.&lt;/p&gt;
&lt;p&gt;There are some troubling aspects to the &lt;a href="https://www.biorxiv.org/content/10.1101/2025.09.12.675771v1"&gt;IgGM paper&lt;/a&gt;. &lt;a href="https://bsky.app/profile/delalamo.xyz/post/3lz4tr25n6k2b"&gt;Diego del Alamo&lt;/a&gt; notes that the plots have unrealistically low variance (see the suspicious-looking plot below). When I run the code, I see what look like not-fully-folded structures. However, there is also strong empirical evidence it's a good model: a third place finish in the &lt;a href="https://www.aintibody.org"&gt;AIntibody competition&lt;/a&gt; (more information on that below).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_iggm.png" width="80%" style="max-width:800px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Suspiciously tight distributions in plots from the &lt;a href="https://www.biorxiv.org/content/10.1101/2025.09.12.675771v1"&gt;IgGM paper&lt;/a&gt;.
Sometimes this is due to plotting standard error vs standard deviation.&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;To run IgGM and generate a nanobody for PD-L1, run the following code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# get the PD-L1 model from the Chai-2 technical report, only the A chain&lt;/span&gt;
curl&lt;span class="w"&gt; &lt;/span&gt;-s&lt;span class="w"&gt; &lt;/span&gt;https://files.rcsb.org/download/5O45.pdb&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;grep&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^ATOM.\{17\}A"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;5O45_chainA.pdb
&lt;span class="c1"&gt;# get a nanobody sequence from 3EAK; replace CDR3 with Xs; tack on the sequence of 5O45 chain A&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;gt;H\nQVQLVESGGGLVQPGGSLRLSCAASGGSEYSYSTFSLGWFRQAPGQGLEAVAAIASMGGLTYYADSVKGRFTISRDNSKNTLYLQMNSLRAEDTAVYYCXXXXXXXXXWGQGTLVTVSSRGRHHHHHH\n&amp;gt;A\nNAFTVTVPKDLYVVEYGSNMTIECKFPVEKQLDLAALIVYWEMEDKNIIQFVHGEEDLKVQHSSYRQRARLLKDQLSLGNAALQITDVKLQDAGVYRCMISYGGADYKRITVKVNAPYAAALEHHHHHH"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;binder_X.fasta
&lt;span class="c1"&gt;# run IgGM; use the same hotspot from the Chai-2 technical report (add --relax for pyrosetta relaxation)&lt;/span&gt;
uvx&lt;span class="w"&gt; &lt;/span&gt;modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_iggm.py&lt;span class="w"&gt; &lt;/span&gt;--input-fasta&lt;span class="w"&gt; &lt;/span&gt;binder_X.fasta&lt;span class="w"&gt; &lt;/span&gt;--antigen&lt;span class="w"&gt; &lt;/span&gt;5O45_chainA.pdb&lt;span class="w"&gt; &lt;/span&gt;--epitope&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;56&lt;/span&gt;,115,123&lt;span class="w"&gt; &lt;/span&gt;--task&lt;span class="w"&gt; &lt;/span&gt;design&lt;span class="w"&gt; &lt;/span&gt;--run-name&lt;span class="w"&gt; &lt;/span&gt;5O45_r1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;IgGM has one closed library dependency, &lt;a href="https://www.pyrosetta.org"&gt;PyRosetta&lt;/a&gt;, but this is only used for relaxing the final design, so it is optional. There are other ways to relax the structure, like using &lt;a href="https://github.com/cytokineking/FreeBindCraft/tree/master/functions"&gt;pr_alternative_utils.py&lt;/a&gt; from &lt;a href="https://www.ariax.bio/resources/freebindcraft-open-source-unleashed"&gt;FreeBindCraft&lt;/a&gt; (a fork of BindCraft that does not depend on PyRosetta) or openmm via biomodals as shown below. FreeBindCraft's relax step has extra safeguards that likely make it work better than the code below.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;uvx&lt;span class="w"&gt; &lt;/span&gt;modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_md_protein_ligand.py&lt;span class="w"&gt; &lt;/span&gt;--pdb-id&lt;span class="w"&gt; &lt;/span&gt;out/iggm/5O45_r1/input_0.pdb&lt;span class="w"&gt; &lt;/span&gt;--num-steps&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;50000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;PXDesign&lt;/h3&gt;
&lt;p&gt;Speaking of Chinese models, there is also a new mini-binder design tool called &lt;a href="https://www.biorxiv.org/content/10.1101/2025.08.15.670450v1"&gt;PXDesign&lt;/a&gt; from ByteDance, which &lt;em&gt;is&lt;/em&gt; available for commercial use, but only via a &lt;a href="https://protenix-server.com"&gt;server&lt;/a&gt;. It came out of beta just this week. The claimed performance is excellent, comparable to Chai-2. (The related &lt;a href="https://github.com/bytedance/Protenix"&gt;Protenix protein structure model&lt;/a&gt;, "a trainable, open-source PyTorch reproduction of AlphaFold 3", is fully open.)&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_pxdesign.png" style="width:80%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2025.08.15.670450v1"&gt;PXDesign claims&lt;/a&gt; impressive performance, comparable to Chai-2&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Germinal&lt;/h2&gt;
&lt;p&gt;The &lt;a href="https://arcinstitute.org"&gt;Arc Institute&lt;/a&gt; has been on a tear for the past year or so, publishing all kinds of deep learning models, including the &lt;a href="https://arcinstitute.org/news/evo2"&gt;Evo 2&lt;/a&gt; DNA language model and &lt;a href="https://arcinstitute.org/news/virtual-cell-model-state"&gt;State&lt;/a&gt; virtual cell model.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://arcinstitute.org/news/building-germinal-for-ai-designed-antibody-molecules"&gt;Germinal&lt;/a&gt; is the latest model from the labs of &lt;a href="https://brianhie.com"&gt;Brian Hie&lt;/a&gt; and &lt;a href="https://cheme.stanford.edu/people/xiaojing-gao"&gt;Xiaojing Gao&lt;/a&gt;, and this time they are joining in on the binder design fun. Installing this one was &lt;a href="https://github.com/SantiagoMille/germinal/issues/2"&gt;not easy&lt;/a&gt;, but eventually Claude and I got the right combination of jax, colabdesign, spackle and tape to make it run.&lt;/p&gt;
&lt;p&gt;Unfortunately, there are also a couple of closed libraries required: &lt;a href="https://github.com/Graylab/IgLM"&gt;IgLM&lt;/a&gt;, the antibody language model, and &lt;a href="https://www.pyrosetta.org"&gt;PyRosetta&lt;/a&gt;, which both require a license. AlphaFold 3 weights, which are thankfully optional, require you to &lt;a href="https://docs.google.com/forms/d/e/1FAIpQLSfWZAgo1aYk0O4MuAXZj8xRQ8DafeFJnldNOnh_13qAx2ceZw/viewform"&gt;petition DeepMind&lt;/a&gt;, but don't even try if you are a filthy commercial entity!&lt;/p&gt;
&lt;p&gt;At some point all these tools need to follow Boltz and become fully open, or it will keep creating unnecessary friction and slowing everything down.&lt;/p&gt;
&lt;p&gt;The code below uses Germinal to attempt one design for PD-L1. It should take around 5 minutes and cost &amp;lt;$1 to run (using a H100).
Note, I have not gotten Germinal to ever pass all its filters, which may be a bug, but it does still output designs with reasonable metrics.
The code was only released this week and is still in flux, so I don't recommend any serious use of Germinal until it settles down a bit.
My code below &lt;em&gt;just barely&lt;/em&gt; works.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# Get the PD-L1 pdb from the Chai technical report&lt;/span&gt;
curl&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;https://files.rcsb.org/download/5O45.pdb
&lt;span class="c1"&gt;# Make a yaml for Germinal&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'target_name: "5O45"\ntarget_pdb_path: "5O45.pdb"\ntarget_chain: "A"\nbinder_chain: "C"\ntarget_hotspots: "56,115,123"\ndimer: false\nlength: 129'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;target_example.yaml
&lt;span class="c1"&gt;# Run Germinal; this is lightly tested, no guarantees of sensible output!&lt;/span&gt;
uvx&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;PyYAML&lt;span class="w"&gt; &lt;/span&gt;modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_germinal.py&lt;span class="w"&gt; &lt;/span&gt;--target-yaml&lt;span class="w"&gt; &lt;/span&gt;target_example.yaml&lt;span class="w"&gt; &lt;/span&gt;--max-trajectories&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--max-passing-designs&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h2&gt;Mosaic&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/escalante-bio/mosaic"&gt;Mosaic&lt;/a&gt; is a general protein design framework that is less plug-and-play than the others listed above, but enables the design of mini-binders, antibodies, or really any protein. It's essentially an interface to sequence optimization on top of three structure prediction models (AF2, Boltz, and Protenix.) You can construct an arbitrary loss function based on structural and sequence metrics, and let it optimize a sequence to that loss.&lt;/p&gt;
&lt;p&gt;While mosaic is not specifically for antibodies, it can be configured to design only parts of proteins (e.g., CDRs), and it can easily incorporate antibody language models in its loss (&lt;a href="https://github.com/oxpig/AbLang"&gt;AbLang&lt;/a&gt; is built in). The main author, Nick Boyd from &lt;a href="https://escalante.bio"&gt;Escalante Bio&lt;/a&gt;, wrote up a &lt;a href="https://blog.escalante.bio/minibinder-design-is-just-not-that-hard"&gt;recent blog post on mosaic&lt;/a&gt;, and showed results comparable to the current state-of-the-art models like BindCraft. Unlike some other tools listed here, it is completely open.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_mosaic.png" style="width:80%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Mosaic has &lt;a href="https://blog.escalante.bio/minibinder-design-is-just-not-that-hard"&gt;performance comparable to BindCraft&lt;/a&gt; on a small benchmark set (8/10 designs bound PD-L1 and 7/10 bound IL7Ra)&lt;/em&gt;&lt;/p&gt;
&lt;h1&gt;Commercial efforts&lt;/h1&gt;
&lt;h2&gt;Chai-2&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://www.chaidiscovery.com/news/introducing-chai-2"&gt;Chai-2&lt;/a&gt; was unveiled in June 2025, and the &lt;a href="https://www.biorxiv.org/content/10.1101/2025.07.05.663018v1"&gt;technical report&lt;/a&gt; included some very impressive results. They claim a "100-fold" improvement over previous methods (I think this is a reference to RFantibody, which advised testing thousands of designs, versus tens for Chai-2.)&lt;/p&gt;
&lt;p&gt;Chai-2 successfully created binding antibodies for 50% of targets tested, and some of these were even sub-nanomolar (i.e., potencies comparable to approved antibodies).
It is a bit dangerous to compare across approaches without a standardized benchmark—for example, some proteins like PD-L1 are easier to make binders for—but I think it's fair to say Chai-2 probably has the best overall performance stats of any model to date, mini-binder or antibody.
One criticism I have heard of these results is that the Chai team measured binding at &lt;a href="https://www.biorxiv.org/content/10.1101/2025.07.05.663018v1.full.pdf#page=14.08"&gt;5-10uM in BLI&lt;/a&gt;,
which is not recommended as it can &lt;a href="https://pubs.acs.org/doi/10.1021/acsomega.1c05659"&gt;include weak binders&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_chai2.png" style="width:100%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;h1&gt;Nabla Bio&lt;/h1&gt;
&lt;p&gt;Like Chai, Nabla Bio appear to be focused on &lt;a href="https://www.nabla.bio/partner"&gt;model licensing and partnering with pharma&lt;/a&gt;,
as opposed to their own drug programs.
This year they published a &lt;a href="https://nabla-public.s3.us-east-1.amazonaws.com/2025_nabla_de_novo_antibodies_gpcrs.pdf"&gt;technical report on their JAM platform&lt;/a&gt;
where they demonstrated the ability to generate low-nanomolar binders against GPCRs,
a difficult but therapeutically important class of targets.
This may be one of very few examples where an AI approach has shown &lt;em&gt;better performance&lt;/em&gt; than traditional methods,
rather than just faster results.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_nabla.png" style="width:100%;max-width:600px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Nabla Bio showing &lt;a href="https://nabla-public.s3.us-east-1.amazonaws.com/2025_nabla_de_novo_antibodies_gpcrs.pdf"&gt;impressive performance&lt;/a&gt; against two GPCRs&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Diffuse Bio&lt;/h2&gt;
&lt;p&gt;Diffuse Bio's &lt;a href="https://www.diffuse.bio/launch-dsg2mini-diffusesandbox#benchmarking-header"&gt;DSG2-mini&lt;/a&gt; model was also published in June 2025.
There is not too much information on performance apart from a claim that it "outperforms RFantibody on key metrics".
Like Chai-2, the Diffuse model is closed, though their &lt;a href="https://app.diffuse.bio"&gt;sandbox&lt;/a&gt; is accessible so it's probably a bit easier to take for a test drive than Chai-2.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_diffuse_sandbox.jpg" style="width:100%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Screenshot from the &lt;a href="https://app.diffuse.bio"&gt;Diffuse Bio sandbox&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Tamarind, Ariax, Neurosnap, Rowan&lt;/h2&gt;
&lt;p&gt;Every year there are more online services that make running these tools easier for biologists.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.tamarind.bio"&gt;Tamarind&lt;/a&gt; does not develop its own models, but allows anyone to easily run most of the open models.
Tamarind have been impressively fast at getting models onboarded and available for use.
They have a free tier, but realistically you need a subscription to do any real work, and I believe that costs tens of thousands per year.
&lt;a href="https://neurosnap.ai/services"&gt;Neurosnap&lt;/a&gt; looks like it has similar capabilities to Tamarind, but the pricing may be more suitable for academics or more casual users.
&lt;a href="https://www.ariax.bio"&gt;Ariax&lt;/a&gt; has done an incredible job making BindCraft (and &lt;a href="https://www.ariax.bio/resources/freebindcraft-open-source-unleashed"&gt;FreeBindCraft&lt;/a&gt;) available and super easy to run.
They don't generate antibodies yet, but they will once a suitably open model is released.
&lt;a href="https://www.rowansci.com"&gt;Rowan&lt;/a&gt; is more small molecule- and MD-focused than antibody-focused—they even release their &lt;a href="https://rowansci.com/blog/introducing-egret-1"&gt;own MD models&lt;/a&gt;—so although a fantastic toolkit, less relevant to antibody design.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_tamarind.png" style="width:100%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://www.tamarind.bio/features"&gt;Tamarind&lt;/a&gt; has over one hundred models, including all the major structure prediction and design models&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Xaira, Generate, Cradle, Profluent, Isomorphic, BigHat, etc&lt;/h2&gt;
&lt;p&gt;There are a gaggle of other actual drug companies working on computational antibody design, but these models will likely stay internal to those companies. Cradle is the outlier in this list since it is a service business, but I believe they do partnerships with pharma/biotech, rather than licensing their models.&lt;/p&gt;
&lt;p&gt;It will be interesting to see which of these companies figure out a unique approach to drug discovery, and which get overtaken by open source.
Most people in biotech will tell you that if you want a highly optimized antibody and can wait a few months, companies like &lt;a href="https://adimab.com"&gt;Adimab&lt;/a&gt;, &lt;a href="https://alloytx.com"&gt;Alloy&lt;/a&gt;, or &lt;a href="https://www.specifica.bio"&gt;Specifica&lt;/a&gt; can already reliably achieve that, and the price will be a small fraction of the total cost of the program anyway.&lt;/p&gt;
&lt;h1&gt;Benchmarks&lt;/h1&gt;
&lt;h2&gt;AIntibody&lt;/h2&gt;
&lt;p&gt;The &lt;a href="https://www.aintibody.org"&gt;AIntibody competition&lt;/a&gt;, run by the antibody discovery company &lt;a href="https://www.specifica.bio"&gt;Specifica&lt;/a&gt;, is similar to last year's &lt;a href="https://www.adaptyvbio.com/blog/po104"&gt;Adaptyv binder design competition&lt;/a&gt;, but focused on antibodies.&lt;/p&gt;
&lt;p&gt;The competition includes &lt;a href="https://www.aintibody.org/the-challenges"&gt;three challenges&lt;/a&gt;, but unlike the Adaptyv competition, none of the challenges is a simple "design a novel antibody for this target".
The techniques used in this competition ended up being quite complex workflows specific to the challenges: for example, a protein language model combined with a model fine-tuned on affinity data provided by Specifica.&lt;/p&gt;
&lt;p&gt;Interestingly, the "AI Biotech" listed as coming third is—according to &lt;a href="https://github.com/TencentAI4S/IgGM"&gt;their github&lt;/a&gt;—IgGM. The Specifica team has given a &lt;a href="https://www.aintibody.org/webinars"&gt;webinar&lt;/a&gt; on the results with some interesting conclusions, but the full write-up is still to come.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_aintibody.jpg" style="width:100%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Conclusions from the &lt;a href="https://www.aintibody.org/webinars"&gt;AIntibody webinar&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Ginkgo&lt;/h2&gt;
&lt;p&gt;Just this week,
&lt;a href="https://datapoints.ginkgo.bio/"&gt;Ginkgo Datapoints&lt;/a&gt;
launched a kaggle-style
&lt;a href="https://huggingface.co/blog/ginkgo-datapoints/making-antibody-embeddings-and-predictions"&gt;competition on huggingface&lt;/a&gt;
with a &lt;a href="https://huggingface.co/spaces/ginkgo-datapoints/abdev-leaderboard"&gt;public leaderboard&lt;/a&gt;.
This challenge is to predict developability properties (expression, stability, aggregation),
which is a vital step downstream of making a binder.
The competition deadline is November 1st.&lt;/p&gt;
&lt;h2&gt;BenchBB&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://beta.adaptyvbio.com/benchbb"&gt;BenchBB&lt;/a&gt; is Adaptyv Bio's new binder design benchmark.
While it's not specifically for antibodies,
if you did try to generate PD-L1 binders using the biomodals commands given above,
you could test your designs here for $99 each.&lt;/p&gt;
&lt;p&gt;We know we need a &lt;a href="https://www.nature.com/articles/s43588-025-00823-8"&gt;lot more affinity data&lt;/a&gt; to improve our antibody models,
and $99 is a phenomenal deal, so some crypto science thing should fund this instead of the nonsense they normally fund!&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_benchbb.jpg" style="width:100%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;There are seven currently available BenchBB targets&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I often seem to end these posts by saying things are getting pretty exciting. I think that's true, especially over the past few weeks with IgGM and Germinal being released, but there are also some gaps. RFantibody was published quite a while ago, and we still only have a few successors, most of which are not fully open. The models are improving, but large companies like Google (Isomorphic) are no longer releasing models, so progress has slowed somewhat. Mirroring the LLM world, it's left to academic labs like &lt;a href="https://www.linkedin.com/posts/martin-pacesa-5b6670100_i-am-super-excited-to-announce-that-i-will-activity-7354416535559438336-Reg6/"&gt;Martin Pacesa&lt;/a&gt;, &lt;a href="https://biology.mit.edu/profile/sergey-ovchinnikov/"&gt;Sergey Ovchinnikov&lt;/a&gt;, &lt;a href="https://people.epfl.ch/bruno.correia?lang=en"&gt;Bruno Correia&lt;/a&gt; and &lt;a href="https://brianhie.com"&gt;Brian Hie&lt;/a&gt;, and Chinese companies like Tencent to push the open models forward.&lt;/p&gt;
&lt;p&gt;I did not talk about antibody language models here even though there are a lot of interesting ones. It would be a big topic, and they are more applicable to downstream tasks, once you have a binder to improve upon.&lt;/p&gt;
&lt;p&gt;As with protein folding (see &lt;a href="https://github.com/apple/ml-simplefold"&gt;SimpleFold&lt;/a&gt; from this week!), there is not a ton of magic here, and many of the methods are converging on the same performance, governed by the available data. To improve upon that, we/someone probably needs to spend a few million dollars generating consistent binding and affinity data. In my opinion, Adaptyv Bio's BenchBB is a good place to focus efforts.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_ab_abrank.png" style="width:100%;max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Publicly available affinity data from the &lt;a href="https://arxiv.org/pdf/2506.17857"&gt;AbRank paper&lt;/a&gt;. Most of the data is from SARS-CoV-2 or HIV, so it's not nearly as much as it seems.&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h2&gt;Running the code&lt;/h2&gt;
&lt;p&gt;If you want to run the biomodals code above and design some antibodies for PD-L1 (or any target) you'll need to do a couple of things.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;1. &lt;a href="https://modal.com/signup?next=%2Fapps"&gt;Sign up for modal&lt;/a&gt;.
   They give you $30 a month on the free tier, more than enough to generate a few binders.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;2. &lt;a href="https://docs.astral.sh/uv/getting-started/installation/"&gt;Install uv&lt;/a&gt;. If you use Python you should do this anyway!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;3. Clone my biomodals repo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;git clone https://github.com/hgbrian/biomodals # or gh repo clone hgbrian/biomodals
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="biotech"/><category term="biotech"/><category term="ai"/></entry><entry><title>AI and protein patents</title><link href="/ai-protein-patents.html" rel="alternate"/><published>2025-05-05T11:00:00-07:00</published><updated>2025-05-05T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2025-05-05:/ai-protein-patents.html</id><summary type="html">&lt;p&gt;A review of protein patents and the impact of AI&lt;/p&gt;</summary><content type="html">&lt;p&gt;The new class of &lt;a href="https://blog.booleanbiotech.com/protein-binder-design-revisited"&gt;protein AI design tools&lt;/a&gt; are amazing, and could revolutionize many areas of science, including therapeutics, diagnostics, and biosensors.
Surprisingly, one important area that I haven't seen discussed too much is how these tools could impact patents.
I am not a lawyer, so obviously this post is just my basic understanding, and I'd be happy to hear corrections.
If there is a more expert critique I did not find it.&lt;/p&gt;
&lt;p&gt;Patents are wordy and convoluted by design.
For proteins, because a string of amino acids defines them, there are some common elements:
they often include the sequence(s) being patented,
and a threshold for how similar another sequence can be before infringing.
That means there is a target to hit, and AI is really good at hitting targets.&lt;/p&gt;
&lt;p&gt;There are two major categories of protein patents:
biologics (usually meaning antibodies) and enzymes.&lt;/p&gt;
&lt;h2&gt;Antibodies&lt;/h2&gt;
&lt;p&gt;According to the &lt;a href="https://information.patentepi.org/issue-1-2019/monoclonal-antibodies-and-sequence-identity-whats-the-epos-practice.html"&gt;European Patent Office&lt;/a&gt;,
there are two main ways to patent an antibody:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;"functional" claims, usually meaning the antibody's associated antigen or epitope;&lt;/li&gt;
&lt;li&gt;"structural" claims, usually meaning a sequence and sequence identity threshold, along with the epitope or some other support.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Over the past few years, the "functional" claim has been going away.
&lt;a href="https://www.vennershipley.com/insights-events/u-s-supreme-court-referral-diverging-approaches-to-antibody-epitope-claims-between-the-epo-and-uspto/"&gt;In the US&lt;/a&gt; it was killed off by the &lt;a href="https://en.wikipedia.org/wiki/Amgen_Inc_v._Sanofi"&gt;2023 Amgen vs Sanofi ruling&lt;/a&gt;, which essentially said you can't patent the concept of an antibody against PCSK9.
That means antibodies are now almost exclusively patented based on their structure (more specifically, a sequence plus some supporting functional information like epitope affinity.)&lt;/p&gt;
&lt;p&gt;For antibody sequences, it used to be common for claims to cover any sequence 80%+ identical in the heavy or light chains.
These days it seems like you have to be more specific,
with claims only covering 100% identity to all 6 CDRs.&lt;/p&gt;
&lt;p&gt;To take some real examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://patents.google.com/patent/US10000576B1/en"&gt;Zanidatamab&lt;/a&gt;, a HER2 bispecific approved in 2024, claims sequences with 100% sequence identity to its CDRs;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://patents.google.com/patent/US20220112287A1/en"&gt;Epcoritamab&lt;/a&gt;, a CD3/CD20 bispecific approved in 2024, also has claims sequences with 100% sequence identity to its CDRs;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://patents.google.com/patent/WO2013181571A2/en"&gt;Trastuzumab&lt;/a&gt;, the famous HER2 antibody approved in 1998 (filed in 2013), claims sequences with 85%+ sequence identity to the heavy and light chains, and does not mention CDRs at all.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;a href="https://information.patentepi.org/issue-1-2019/monoclonal-antibodies-and-sequence-identity-whats-the-epos-practice.html"&gt;EPO says&lt;/a&gt;:
"the slightest modification of the CDRs can affect the recognition of the target."
There is a nice breakdown of the differences between the &lt;a href="https://ktslaw.com/en/Blog/MEMO/2021/4/Navigating-Key-Differences-in-Therapeutic-Antibody-Patent-Protection-Strategies-Between-the-United-States-and-Europe"&gt;USPTO vs EPO approach to antibody patents here&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Enzymes&lt;/h2&gt;
&lt;p&gt;For enzymes, the patent landscape is more complicated,
or at least more varied.
Unlike antibodies,
where the patents are pretty uniformly focused on the sequence that binds an epitope,
enzymes can perform any number of functions.
Enzyme types include
&lt;a href="https://en.wikipedia.org/wiki/Enzyme_replacement_therapy"&gt;enzyme replacement therapies&lt;/a&gt;,
industrial enzymes like &lt;a href="https://en.wikipedia.org/wiki/Detergent_enzymes"&gt;detergents&lt;/a&gt;,
and molecular biology tools like &lt;a href="https://en.wikipedia.org/wiki/Cas9"&gt;CRISPR-Cas9&lt;/a&gt;.
It is still typical for these patents to include a sequence and supporting information.&lt;/p&gt;
&lt;p&gt;Some examples:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;this &lt;a href="https://patents.google.com/patent/EP2798053B1/en"&gt;detergent patent&lt;/a&gt;, granted in 2018, claims sequences with 60%+ sequence identity to the reference;&lt;/li&gt;
&lt;li&gt;this &lt;a href="https://patents.google.com/patent/US11390862B2/en"&gt;proteinase patent&lt;/a&gt;, granted in 2022, claims sequences with 90%+ sequence identity to the reference;&lt;/li&gt;
&lt;li&gt;this &lt;a href="https://patents.google.com/patent/JP7640606B2/en"&gt;novel Taq polymerase patent&lt;/a&gt;, granted in 2025, claims sequences with 95%+ sequence identity to the reference.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Cas9&lt;/h3&gt;
&lt;p&gt;The Cas9 patents are unusually diverse:
there are &lt;a href="https://patents.google.com/?q=(cas9)&amp;amp;oq=cas9"&gt;hundreds of them&lt;/a&gt;
and they mostly cover the many applications of the invention rather than the  sequences.
Since the &lt;a href="https://en.wikipedia.org/wiki/Association_for_Molecular_Pathology_v._Myriad_Genetics,_Inc."&gt;2013 ruling against Myriad Genetics&lt;/a&gt;, sequences from naturally occurring enzymes like Cas9 cannot be patented.
Engineered sequences can be patented with other supporting functional information.
You cannot take one of the &lt;a href="https://www.profluent.bio/media/editing-the-human-genome-with-ai"&gt;thousands of unique Cas9 sequences&lt;/a&gt; in GenBank and use that to circumvent the CRISPR-Cas9 patents.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_patents_cas9_patents.jpg" width="70%"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;There are &lt;a href="https://www.labiotech.eu/in-depth/crispr-patent-dispute-licensing/"&gt;hundreds of Cas9 patents&lt;/a&gt; covering everything anyone could think of&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;AI&lt;/h2&gt;
&lt;p&gt;Given that the amino acid sequence is so important in protein patents,
I am surprised that it is not bigger news that AI has effectively broken the direct connection between sequence and function.&lt;/p&gt;
&lt;p&gt;For patents where protein sequence identity is protected,
it is now relatively straightforward to generate new sequences that fold to the same structure but have 50% or lower sequence identity.&lt;/p&gt;
&lt;p&gt;For antibody patents where the CDR sequence is protected,
I believe it is also relatively straightforward to introduce a mutation that does not disrupt binding.
To be honest, I am not even sure AI is required here, since a mutation scan could perform the same function.
Perhaps for this reason, a recent paper called for &lt;a href="https://www.nature.com/articles/s41587-024-02549-w"&gt;"comprehensive CDR scanning"&lt;/a&gt; to protect a panel of CDR sequences instead of just one.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.science.org/doi/full/10.1126/science.add2187"&gt;ProteinMPNN&lt;/a&gt;,
published in 2022 by Baker lab,
is the most prominent tool for producing a new sequence that folds to a known structure.
ProteinMPNN is widely used as a step in many protein design workflows.
For example, methods like RFdiffusion generate backbone coordinates only,
and ProteinMPNN turns that into an amino acid sequence.&lt;/p&gt;
&lt;p&gt;In a &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC10811672/"&gt;follow-up ProteinMPNN paper&lt;/a&gt;,
the authors demonstrated that they could make a myoglobin and TEV protease with comparable or better function and greater stability than the natural versions, with sequence identities as low as 40%.
This is below the sequence identity threshold in any patent I have seen.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_patents_proteinmpnn.jpg" width="70%"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ProteinMPNN can be used to produce a new sequence for a protein while maintaining its function&lt;/em&gt;&lt;/p&gt;
&lt;!--
### Me-too AI antibodies

Traditionally, it has been difficult to make antibodies that have the same function but have different sequences,
and antibody patent protection has been difficult to circumvent.
There is even a handy [database of antibody sequences](
https://naturalantibody.com/patents-database/) (for non-commercial use).
If it is now straightforward to create an almost identically functioning antibody using software like ProteinMPNN, then what happens?
--&gt;

&lt;h3&gt;Sequence vs Structure&lt;/h3&gt;
&lt;p&gt;If this ability for AI to circumvent sequence-based patents is an issue,
maybe the obvious change here would be to base patent protection on structure.
This is a bit more complex than sequence identity,
but one way to do this would be with &lt;a href="https://academic.oup.com/nar/article/33/7/2302/2401364"&gt;TM-align&lt;/a&gt; or a similar tool.
TM-align has &amp;gt;3k citations so it is arguably the standard in the field.
A TM-score of above 0.8 indicates "the same topology"—in other words a very close structure.
I think this would work well for many proteins,
though it might need to be constrained to subdomains (akin to CDRs) in some cases.&lt;/p&gt;
&lt;p&gt;Interestingly, the only literature I found on patenting 3D structure
is from &lt;a href="https://scholar.google.com/scholar?hl=en&amp;amp;as_sdt=0%2C5&amp;amp;q=patent+structure+protein&amp;amp;btnG="&gt;20 years ago&lt;/a&gt;.
Maybe this has been debated already and rejected for some reason.
I suspect it was just easier to use sequence though.&lt;/p&gt;
&lt;h2&gt;OpenCRISPR-1&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2024.04.22.590591v1"&gt;OpenCRISPR-1&lt;/a&gt; was published in 2024 by the protein AI company &lt;a href="https://www.profluent.bio/"&gt;Profluent&lt;/a&gt;.
This is a &lt;em&gt;de novo&lt;/em&gt; Cas9 enzyme that is substantially different
in sequence to any known Cas9 (according to the abstract, "400 mutations away in sequence [from SpCas9]"—specifically 403/1380, or 71% identity).&lt;/p&gt;
&lt;p&gt;Cas9 is a &lt;a href="https://blog.addgene.org/a-needle-in-a-base-stack-cas9-structural-biology"&gt;bilobed enzyme&lt;/a&gt;, with a REC lobe (nucleotide recognition)
and a NUC lobe (DNA cleavage and PAM recognition.)
Broadly speaking, the REC lobe is the first half of the enzyme (amino acids 50–700), and the NUC lobe is the second (1–50 and 700–1350.)
These two lobes are connected by a "bridge helix".&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_patents_cas9.png" width="45%"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Cartoon representation of Cas9 from &lt;a href="https://blog.addgene.org/a-needle-in-a-base-stack-cas9-structural-biology"&gt;addgene&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The OpenCRISPR-1 enzyme is not as novel as it might seem.
In fact, I found it is actually &lt;a href="https://x.com/btnaughton/status/1783566980047671745"&gt;98% identical&lt;/a&gt; to a sequence constructed from three Cas9's spliced together from &lt;em&gt;Streptococcus cristatus&lt;/em&gt;, &lt;em&gt;Streptococcus pyogenes&lt;/em&gt; and &lt;em&gt;Streptococcus sanguinis&lt;/em&gt; (24 amino acids are unique to OpenCRISPR-1).&lt;/p&gt;
&lt;p&gt;This raises an interesting question, which is whether you could create
a "novel" Cas9 by simply stitching together the REC lobe from one species' Cas9 and the NUC lobe from another.
I believe this enzyme would work,
and this sequence would meet any sequence identity threshold requirements.&lt;/p&gt;
&lt;p&gt;The Profluent paper says the OpenCRISPR-1 enzyme was released
for "research and commercial applications", but there is a big caveat here.
Since CRISPR-Cas9 patents post-date the Myriad decision,
almost all are functional / method of use,
and naturally the most protected part is the use of Cas9 in "commercial applications" like therapeutics and diagnostics.&lt;/p&gt;
&lt;p&gt;It is commendable that Profluent tried to broaden the availability of Cas9,
so I appreciate the work behind this,
but as I understand it,
OpenCRISPR-1 is not really more available for commercial use than any Cas9.&lt;/p&gt;
&lt;p&gt;There is actually another "royalty-free" Cas,
a "Class 2 Type V" Cas nuclease called MAD7,
released by &lt;a href="https://www.inscripta.com/wp-content/uploads/2023/03/Rojek-et-al-2021-Authorea.pdf"&gt;Inscripta for commercial use in 2023&lt;/a&gt;.
I do not know how this enzyme intersects with the many Cas9 patents.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;One upshot of all this AI work is that &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7576625/"&gt;me-too and biosimilar&lt;/a&gt;
antibodies will be easier to make.
That saves some time and money,
but does not necessarily save on the major clinical trial costs,
although the probability of success could go up a lot if the antibody is functionally identical.&lt;/p&gt;
&lt;p&gt;While many enzyme patents will be affected,
patents like CRISPR-Cas9 that rely on functional or method of use claims do not seem to be impacted as much.
I don't know how many enzyme patents rely on sequence identity claims vs other claims these days.
It would be interesting to (get an AI to) do a proper survey.&lt;/p&gt;
&lt;p&gt;For internal research use,
it's unclear to me that using AI to reproduce a patented protein does a whole lot,
since at least in drug development,
the &lt;a href="https://en.wikipedia.org/wiki/Research_exemption"&gt;research exemption&lt;/a&gt;
seems to allow for the use of patented material quite broadly.&lt;/p&gt;</content><category term="biotech"/><category term="biotech"/><category term="ai"/><category term="ip"/></entry><entry><title>Protein binder design revisited</title><link href="/protein-binder-design-revisited.html" rel="alternate"/><published>2025-03-08T11:00:00-08:00</published><updated>2025-03-08T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2025-03-08:/protein-binder-design-revisited.html</id><summary type="html">&lt;p&gt;A review of protein binder design&lt;/p&gt;</summary><content type="html">&lt;p&gt;I have written about protein binder design a few times now
(&lt;a href="https://blog.booleanbiotech.com/adaptyv-binder-design-competition"&gt;the Adaptyv competition&lt;/a&gt;;
&lt;a href="https://blog.booleanbiotech.com/what-we-learned-adaptyv"&gt;a follow up&lt;/a&gt;).
Corin Wagen recently wrote a
&lt;a href="https://corinwagen.github.io/public/blog/20250303_achilles_and_the_tortoise.html"&gt;great piece&lt;/a&gt;
about protein–ligand binding.
This purpose of this post is to review how well protein binder design is working today,
and point out some interesting differences in model performance that I do not understand.&lt;/p&gt;
&lt;h2&gt;Protein design&lt;/h2&gt;
&lt;p&gt;There are two major types of protein design:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Design a &lt;strong&gt;sequence&lt;/strong&gt; to perform some task:
e.g., produce a sequence that improves upon some property of the protein&lt;/li&gt;
&lt;li&gt;Design a &lt;strong&gt;structure&lt;/strong&gt; to perform some task:
e.g., produce a protein structure that binds another protein&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;There is spillover between these two classes but I think it's useful to split this way.&lt;/p&gt;
&lt;h2&gt;Sequence models&lt;/h2&gt;
&lt;p&gt;Sequence models include open-source models like
the original &lt;a href="https://github.com/facebookresearch/esm"&gt;ESM2&lt;/a&gt;,
&lt;a href="https://github.com/ai4protein/ProSST"&gt;ProSST&lt;/a&gt;,
&lt;a href="https://github.com/westlake-repl/SaProt"&gt;SaProt&lt;/a&gt;,
and semi-open or fully proprietary models from
EvolutionaryScale
(&lt;a href="https://github.com/evolutionaryscale/esm"&gt;ESM3&lt;/a&gt;),
OpenProtein
(&lt;a href="https://www.openprotein.ai/a-multimodal-foundation-model-for-controllable-protein-generation-and-representation-learning"&gt;PoET-2&lt;/a&gt;),
and &lt;a href="https://www.cradle.bio"&gt;Cradle Bio&lt;/a&gt;.
The &lt;a href="https://proteingym.org/"&gt;ProteinGym benchmark&lt;/a&gt; puts ProSST, PoET-2 and SaProt up near the top.&lt;/p&gt;
&lt;p&gt;Many of the recent sequence-based models now also include structure information,
represented as a parallel sequence, with one "structure token" per amino acid.
This addition seems to improve performance quite a lot,
allows sequence models to make use of the PDB,
and — analogously to &lt;a href="https://proceedings.neurips.cc/paper/2021/file/c404a5adbf90e09631678b13b05d9d7a-Paper.pdf"&gt;Vision Transformers&lt;/a&gt; —
blurs the line between sequence and structure models.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_saprot.png" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;SaProt uses a FoldSeek-derived alphabet to encode structural information&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;The most basic use-case for sequence models is probably improving the stability of a protein.
You can take a protein sequence,
make whatever edits your model deems high likelihood,
and this should produce a sequence that retains the same fold,
but is more "canonical", and so may have improved stability too.&lt;/p&gt;
&lt;p&gt;An elaboration of this experiment is to find some data,
e.g.,
&lt;a href="https://huggingface.co/datasets/SaProtHub/Dataset-Thermostability-FLIP"&gt;thermostability for a few thousand proteins&lt;/a&gt;,
and fine-tune the original language model to be able to predict that property.
&lt;a href="https://colab.research.google.com/github/westlake-repl/SaprotHub/blob/main/colab/SaprotHub_v2.ipynb"&gt;SaProtHub&lt;/a&gt;
makes this essentially push-button.&lt;/p&gt;
&lt;p&gt;A further elaboration is doing active learning,
where you propose edits using your model,
generate empirical data for these edits (e.g., binding affinity),
and go back and forth, hopefully improving performance each iteration.
For example,
&lt;a href="https://github.com/mat10d/EvolvePro"&gt;EVOLVEpro&lt;/a&gt;,
&lt;a href="https://nabla-public.s3.us-east-1.amazonaws.com/2024_Nabla_JAM_de_novo_antibodies.pdf"&gt;Nabla Bio's JAM&lt;/a&gt; (which also uses structure),
and &lt;a href="https://www.biorxiv.org/content/10.1101/2025.02.19.639050v1.full.pdf"&gt;Prescient's Lab-in-the-loop&lt;/a&gt;.
These systems can be complex, but can also be as simple as running regressions on the output of the sequence models.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_evolvepro.png" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;EvolvePro's learning loop&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Sequence-based models are a natural fit to these kinds of problems,
since you can easily edit the sequence but maintain the same fold and function.
&lt;a href="https://www.profluent.bio/"&gt;Profluent&lt;/a&gt; and other companies make use of this ability
by producing patent-unencumbered sequences like
&lt;a href="https://github.com/Profluent-AI/OpenCRISPR"&gt;OpenCRISPR&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is especially enabling for the
&lt;a href="https://en.wikipedia.org/wiki/Biosimilar"&gt;biosimilars&lt;/a&gt;
industry.
Many biologics patents protect the sequence by setting amino acid identity thresholds.
For example, in the
&lt;a href="https://patents.google.com/patent/WO2013181571A2/en"&gt;Herceptin/trastuzumab patent&lt;/a&gt;
they protect any sequence &amp;gt;=85% identical to the heavy (SEQ ID NO: I) or light chain (SEQ ID NO: II).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_herceptin_patent.png" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Excerpt from the main trastuzumab patent&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Patent attorneys will layer as many other protections on top of this as they can think of,
but the sequence of the antibody is the primary IP.
(Tangentially, it is insane how patents always give examples of numbers greater than X.
Hopefully, the AIs that will soon be writing patents won't do this.)&lt;/p&gt;
&lt;p&gt;For binder design, sequence models appear to have limits.
Naively, since you do not know the positions of the atoms,
then unless you are apeing known interaction motifs,
you would assume binder design should be difficult?&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_diego_tweet.png" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Diego del Alamo &lt;a href="https://bsky.app/profile/ddelalamo.bsky.social/post/3ljhaojmt722j"&gt;points out&lt;/a&gt; apparent limits in the performance of sequence models for antibody design&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Structural models&lt;/h2&gt;
&lt;p&gt;Structural models include the original
&lt;a href="https://www.nature.com/articles/s41586-023-06415-8"&gt;RFdiffusion&lt;/a&gt;
and the recently released antibody variant
&lt;a href="https://github.com/RosettaCommons/RFantibody"&gt;RFantibody&lt;/a&gt;
from the Baker lab,
&lt;a href="https://github.com/sokrypton/ColabDesign"&gt;RSO&lt;/a&gt; from the ColabDesign team,
&lt;a href="https://github.com/martinpacesa/BindCraft"&gt;BindCraft&lt;/a&gt;,
&lt;a href="https://github.com/patrickbryant1/EvoBind"&gt;EvoBind2&lt;/a&gt;,
&lt;a href="https://github.com/microsoft/foldingdiff"&gt;foldingdiff&lt;/a&gt; from Microsoft,
and models from startups like
&lt;a href="https://generatebiomedicines.com"&gt;Generate Biomedicines&lt;/a&gt; (&lt;a href="https://github.com/generatebio/chroma"&gt;Chroma&lt;/a&gt;),
&lt;a href="https://www.chaidiscovery.com"&gt;Chai Discovery&lt;/a&gt;,
and &lt;a href="https://diffuse.bio"&gt;Diffuse Bio&lt;/a&gt;.
(Some of these tools are available on my &lt;a href="https://github.com/hgbrian/biomodals"&gt;biomodals repo&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Structural models are trained on both sequence data (e.g., UniRef) and structure data (PDB),
but they deal in atom co-ordinates instead of amino acid strings.
That difference means diffusion-style models dominate here over
the discrete-token–focused transformers.&lt;/p&gt;
&lt;p&gt;There are two major classes of structural models:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Diffusion models like RFdiffusion and RFantibody&lt;/li&gt;
&lt;li&gt;AlphaFold2-based models like BindCraft, RSO, and EvoBind2&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The success rates of RFdiffusion and RFantibody are not great.
For some targets they achieve a &amp;gt;1% success rate
(if we define success as finding a &amp;lt;1µM binder),
but in other cases they nominate thousands of designs and find no strong binder.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_rfantibody_paper.png" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;An example from the &lt;a href="https://www.biorxiv.org/content/10.1101/2024.03.14.585103v1"&gt;RFantibody paper&lt;/a&gt; showing a low success rate&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;BindCraft and RSO are two similar methods that produce minibinders
(small-ish non-antibody–based proteins)
and rely on inverting AlphaFold2 to turn structure into sequence.
EvoBind2 produces cyclic or linear peptides,
and also relies heavily on an AlphaFold confidence metric (pLDDT) as part of its loss.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_bindcraft_loss.jpg" width="70%" /&gt;
&lt;img class="blogimg" src="/images/2025_binders_evobind_loss.png" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;BindCraft (top) and EvoBind2 (bottom) have similar loss functions that rely on AF2's pLDDT and intermolecular contacts&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Even though these AF2-based models work very well,
one non-obvious catch is that you cannot take a binding pose and get AlphaFold2 to evaluate it.
These models can &lt;em&gt;generate&lt;/em&gt; binders, but not &lt;em&gt;discriminate&lt;/em&gt; binders from non-binders.
In the
&lt;a href="https://www.biorxiv.org/content/10.1101/2024.06.20.599739v2.full.pdf#page=9.04"&gt;EvoBind2 paper&lt;/a&gt;,
they found that "No &lt;em&gt;in silico&lt;/em&gt; metric separates true from false binders",
which means the problem is a bit more complex than just "ask AF2 if it looks good".&lt;/p&gt;
&lt;p&gt;According to the &lt;a href="https://www.biorxiv.org/content/10.1101/2022.03.11.484043v1"&gt;AF2Rank paper&lt;/a&gt;,
the AF2 model has a good model of the physics of protein folding,
but may not find the global minimum.
The MSAs' job is to help focus that search.
This was surprising to me!
The protein folding/binding problem is more of a search problem than I realized,
which means more compute should straightforwardly improve performance by simply doing more searching.
This is also evidenced by the &lt;a href="https://www.nature.com/articles/s41586-024-07487-w"&gt;AlphaFold 3 paper&lt;/a&gt;,
where re-folding antibodies 1000 times led to improved prediction quality.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_af2rank_paper.png" width="70%" /&gt;
&lt;img class="blogimg" src="/images/2025_binders_af2rank.png" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Excerpt from the AF2Rank paper (top), and a tweet from Sergey Ovchinnikov (bottom)
explaining the primacy of sequence data in structure prediction&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h2&gt;RFdiffusion/RFantibody vs BindCraft/EvoBind2&lt;/h2&gt;
&lt;p&gt;The main comparison I wanted to make in this post is between
RFdiffusion/RFantibody vs BindCraft and EvoBind2.&lt;/p&gt;
&lt;p&gt;These are all recently released, state-of-the-art models from top labs.
However, the difference in claimed performance is pretty striking.&lt;/p&gt;
&lt;p&gt;While the RFdiffusion and RFantibody papers caution that you may need to test hundreds
or even thousands of proteins to find one good binder,
the BindCraft and EvoBind2 papers appear to show very high success rates,
perhaps even as high as 50%.
(EvoBind2 only shows results for one ribonuclease target but BindCraft includes multiple).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_rfantibody.jpg" width="70%" /&gt;
&lt;img class="blogimg" src="/images/2025_binders_bindcraft_fig.jpg" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Words of caution from the &lt;a href="https://github.com/RosettaCommons/RFantibody"&gt;RFantibody github repo&lt;/a&gt; (top)
and BindCraft's impressive results for 10 targets (bottom)&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;There is no true benchmark to reference here, but I think under reasonable assumptions,
BindCraft (and arguably EvoBind2) achieve a &amp;gt;10X greater success rate than RFdiffusion or RFantibody.
The Baker lab is the leading and best resourced lab in this domain,
so what accounts for this large difference in performance?
I can think of a few possibilities:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;RoseTTAFold2 was &lt;a href="https://bsky.app/profile/ddelalamo.bsky.social/post/3ljhmt2kqfc2p"&gt;not the best filter&lt;/a&gt;
for RFantibody to use, and switching to AlphaFold3 would improve performance.&lt;/strong&gt;
This is plausible, but it is hard to believe that is a 10X improvement.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Antibodies are just harder than minibinders or cyclic peptides.&lt;/strong&gt;
Hypervariable regions are known to be difficult to fold, since
they do not have the advantage of evolutionary conservation.
However, RFdiffusion also produces minibinders, so this is not a satisfactory explanation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;BindCraft and EvoBind2 are testing on easier targets.&lt;/strong&gt;
There is likely some truth to this.
Most (but not all) examples in the BindCraft paper are for proteins with known binders;
EvoBind2 is only tested against a target with a known peptide binder.
However, most of RFantibody's targets also have known antibodies in PDB.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Diffusion currently just does not work as well as AlphaFold-based methods.&lt;/strong&gt;
AlphaFold2 (and its descendants, AF3, Boltz, Chai-1, etc.) have learned enough physics to recognize binding,
and by leaning on this ability heavily,
and filtering carefully, you get much better performance.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;What comes next?&lt;/h2&gt;
&lt;p&gt;RFdiffusion and RFantibody are arguably the first examples of
successful &lt;em&gt;de novo&lt;/em&gt; binder design and antibody design,
and for that reason are important papers.
BindCraft and EvoBind2 have proven they can produce one-shot nanomolar binders under
certain circumstances, which is technically extremely impressive.&lt;/p&gt;
&lt;p&gt;However, if we could get another 10X improvement in performance,
then I think these tools are being used in every biotech and research lab.
Some ideas for future directions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;More compute:&lt;/strong&gt;
One of the interesting things about BindCraft and EvoBind2 is how long they take to produce anything.
In BindCraft's case, it generates a lot of candidates, but has a long list of criteria that must be met.
One BindCraft run will screen hundreds or thousands of candidates and can easily cost $10+.
Similary, EvoBind2 can run for 5+ hours before producing anything, again easily costing $10+.
This approach of throwing compute at the problem may be generally applicable,
and may be analogous to the recently successful LLM reasoning approaches.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Combine diffusion and AlphaFold-based methods:&lt;/strong&gt;
I have no specific idea here, but since they are quite different approaches,
maybe integrating some ideas from RFdiffusion into EvoBind2 or BindCraft could help.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Combine sequence models and structure models:&lt;/strong&gt;
There is already a lot of work happening here, both from the sequence side and structure side.
In the simplest case,
the output of a sequence model like ESM2 could be an independent contributor to the loss of a structure model.
At the very least, this could help filter out structures that do not fold.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Neural Network Potentials:&lt;/strong&gt;
Neural Network Potentials are an exciting new tool for molecular dynamics
(see
&lt;a href="https://pubs.acs.org/doi/10.1021/acsphyschemau.4c00004"&gt;Duignan, 2024&lt;/a&gt; or
&lt;a href="https://www.liebertpub.com/doi/10.1089/genbio.2024.0011"&gt;Barnett, 2024&lt;/a&gt;).
&lt;a href="https://achira.ai"&gt;Achira&lt;/a&gt; just got funded to work on this,
and has several of the pioneers of the field on board.
Semi-open source models like
&lt;a href="https://github.com/orbital-materials/orb-models"&gt;orb-v2&lt;/a&gt;
from Orbital Materials are being actively developed too.
The amount of compute required is prohibitive right now,
but even a short trajectory could plausibly help with rank ordering binders,
and would be independent of the AF2 metrics.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_binders_duignan.jpg" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Tweet from &lt;a href="https://bsky.app/profile/timothyduignan.bsky.social/post/3liysxvb2522x"&gt;Tim Duignan at Orbital Materials&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;</content><category term="biotech"/><category term="biotech"/><category term="ai"/></entry><entry><title>A list of health-related products</title><link href="/health-related-products.html" rel="alternate"/><published>2025-02-09T11:00:00-08:00</published><updated>2025-02-09T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2025-02-09:/health-related-products.html</id><summary type="html">&lt;p&gt;A list of health-related products&lt;/p&gt;</summary><content type="html">&lt;p&gt;This post is a kind of brain dump of health-related product
information I have gathered over the past few years.
The major themes are
eliminating plastic, heavy metals, and other suspicious stuff,
and using stainless steel, cast iron, silicone, and glass where possible.
This post is really long, so I put a tl;dr list of all the products at the &lt;a href="#tl;dr"&gt;end of the article&lt;/a&gt;.
I may update this page if I think of more!&lt;/p&gt;
&lt;p&gt;There are a few resources that have useful information:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.consumerreports.org/"&gt;Consumer Reports&lt;/a&gt; actually does a decent amount of health stuff.
  It is behind a paywall, but accessible for free online through some libraries.
  Usually when they look into a subject, they do a pretty thorough job.
  For example, they tested
  &lt;a href="https://secure.consumerreports.org/ec/login?error"&gt;126 herbs and spices for heavy metals&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.consumerlab.com/"&gt;ConsumerLab's mission&lt;/a&gt; is
  "To help consumers and healthcare professionals find the best quality 
  health and nutrition products through independent testing and evaluation."
  ConsumerLab tests a lot of products,
  but all the information is behind a paywall.
  I bought a subscription to test it out, and I think it's decent.
  They seem quite careful in their testing,
  but the probability they have the specific information you are looking for is low.
  For example, their article on protein powders is extremely rambling,
  but for heavy metal testing they just link to a confusing
  &lt;a href="https://cleanlabelproject.org/the-best-worst-protein-powder-products/"&gt;Clean Labels Project page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.cochranelibrary.com/cdsr/reviews/topics"&gt;Cochrane collaboration&lt;/a&gt;
  is "a charitable organisation formed to synthesize
  medical research findings to facilitate evidence-based choices about health interventions". 
  This is much broader than product reviews,
  but if they cover your specific topic of interest it can be very informative.
  The reviews are rigorous to the point of being over-cautious.
  If there were no clinical trial for parachute use,
  they would have to say the data is inconclusive. This
  &lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC6298200/"&gt;humorous BMJ article&lt;/a&gt; agrees:&lt;blockquote&gt;
&lt;p&gt;Parachute use did not reduce death or major traumatic injury when jumping from aircraft in the first randomized evaluation of this intervention. However, the trial was only able to enroll participants on small stationary aircraft on the ground, suggesting cautious extrapolation to high altitude jumps.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/gp/product/B0BSDQMLHJ/"&gt;Elevate&lt;/a&gt; is a nice, short book
  that had some practical advice on the 80/20 of health interventions.
  Most memorably, the author recommends wearing natural fibers to limit skin exposure to plastics.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://plasticlist.org"&gt;plasticlist.org&lt;/a&gt; is a project funded by &lt;a href="https://x.com/natfriedman"&gt;Nat Friedman&lt;/a&gt;
  where they tested ~300 foods for plastic contamination and helpfully made the results publicly available.
  I believe they are supposed to continue to update the list over time.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.implasticfree.com/"&gt;implasticfree.com&lt;/a&gt; is
  "the easiest, fastest way to find plastic alternatives".
  They don't seem to do much independent testing but the information I have seen on there
  is quite well researched.
  For example, they have a good
  &lt;a href="https://www.implasticfree.com/plastic-free-electric-kettles/"&gt;list of plastic-free kettles&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Protein powder&lt;/h2&gt;
&lt;p&gt;For various reasons — e.g., edicts from health influencer
&lt;a href="https://peterattiamd.com/category/nutritional-biochemistry/protein/"&gt;Peter Attia&lt;/a&gt; —
many of us are eating more protein these days.
Whey, collagen, and creatine are probably the three major protein supplements,
and usually come in the form of concentrated powders.
Anything concentrated is a concern for toxins, especially heavy metals.&lt;/p&gt;
&lt;p&gt;When buying these, I am optimizing for these factors, in order of importance:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Third-party lab tests, preferably with results (since you can test and still get bad results!);&lt;/li&gt;
&lt;li&gt;Price;&lt;/li&gt;
&lt;li&gt;Form factor (I prefer bags to big tubs);&lt;/li&gt;
&lt;li&gt;Quality, including purity (sometimes ConsumerLab has
&lt;a href="https://www.consumerlab.com/reviews/protein-powders-shakes-drinks-sports/nutritiondrinks/"&gt;information on this&lt;/a&gt;).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;My current favorites from each category are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://agnroots.com/products/agn-roots-grass-fed-whey-3-lbs"&gt;AGN Roots Whey Isolate&lt;/a&gt;:&lt;!--(https://amazon.com/AGN-Roots-Protein-Powder-Isolate/dp/B0C3RKLMGH):--&gt;
    This whey is inexpensive and their literature has some reassuring information around heavy metal testing,
    including providing actual numbers.
    Whey isolate is generally considered
    &lt;a href="https://nakednutrition.com/blogs/protein/cholesterol-in-whey-protein"&gt;better than concentrate&lt;/a&gt;,
    with easier absorption and less cholesterol.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"AGN Roots Grassfed Whey heavy-metals test results will show a Lead Concentration of &amp;lt; .005 mg/kg (ppm). Our grassfed whey contains up to 100 times lower concentrations of heavy metals (Mercury, Arsenic, Lead, Cadmium) than the typical "grass-fed" whey supplier."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://naturalforce.com/products/grass-fed-collagen-peptides-protein-powder?variant=14848075595876"&gt;Natural Force Collagen&lt;/a&gt;:&lt;!--(https://amazon.com/Premium-Collagen-Peptides-Protein-Recovery/dp/B01LJWQ1C8):--&gt;
  This is a reasonably priced collagen that provides some specific test results.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"We test for Mercury (Hg), Lead (Pb), Arsenic (As), and Cadmium (Cd) on every batch.
Here are some recent test results:&lt;br&gt;
Unflavored&lt;br&gt;
Mercury 0.0029 mcg/g (µg)&lt;br&gt;
Lead 0.0039 mcg/g (µg)&lt;br&gt;
Arsenic &amp;lt;0.001 mcg/g (µg)&lt;br&gt;
Cadmium 0.0021 mcg/g (µg)"&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.amazon.com/gp/product/B0CCCNKD73"&gt;It's Just! Creatine&lt;/a&gt;:
  This is one of very few creatine brands that claim to test for heavy metals.
  (In fairness, heavy metal contamination is not believed to be a huge concern for creatine).
  &lt;a href="https://nakednutrition.com/products/creatine-monohydrate-powder?srsltid=AfmBOoqPjNEgqsOTv2XUqXw_Z2S5ZZQUhYZCA__CKk0ReIdFyzMe-kF-"&gt;Naked Nutrition Creatine&lt;/a&gt;&lt;!--(https://www.amazon.com/Pure-Creatine-Monohydrate-Artificial-Ingredients/dp/B00ULZF5HC)--&gt;
  also claims to test for heavy metals, though neither has
  &lt;a href="https://nakednutrition.com/pages/faq#general-product-questions-certifications-testing"&gt;specifics&lt;/a&gt;
  about their testing.
  It's Just! Creatine comes in a bag, which I happen to prefer, so I buy that.
  I used to buy from &lt;a href=""&gt;bulksupplements.com&lt;/a&gt;
  but there are some &lt;a href="https://illuminatelabs.org/blogs/health/bulk-supplements-review"&gt;concerns&lt;/a&gt;
  about their testing.
  &lt;a href="https://www.amazon.com/Creapure%C2%AE-SteelFit-Creatine-Monohydrate-Unflavored/dp/B07K5BPXPW"&gt;Creapure&lt;/a&gt;
  is more expensive, has
  &lt;a href="https://www.creapure.com/en/creapure/what-creapure"&gt;extensive testing&lt;/a&gt;
  (though no specific mention of heavy metals) and has also been recommended to me.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Cinnamon&lt;/h2&gt;
&lt;p&gt;Don't die guy Bryan Johnson recently
&lt;a href="https://x.com/bryan_johnson/status/1878538326795575565"&gt;tweeted&lt;/a&gt;
about the presence of heavy metals in cinnamon.
There are actually two kinds of cinnamon: Ceylon cinnamon ("true cinnamon") and Cassia cinnamon.
Johnson was referencing Ceylon cinnamon, which tastes better than Cassia and has less coumarin.
Coumarin is a 
&lt;a href="https://www.bfr.bund.de/en/faq_on_coumarin_in_cinnamon_and_other_foods-8487.html"&gt;liver toxin&lt;/a&gt;,
so in general best avoided.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Coumarin is a flavouring substance which is contained in relatively high concentrations in cinnamon varieties collectively known as "Cassia cinnamon". In especially sensitive persons, even comparatively small quantities of coumarin can cause liver damage, although the effect is usually reversible. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In 2024, Consumer Reports
&lt;a href="https://www.consumerreports.org/health/food-contaminants/high-lead-levels-in-cinnamon-powders-and-spice-mixtures-a4542246475/"&gt;tested 36 cinnamon powders&lt;/a&gt; for lead.
&lt;a href="https://www.amazon.com/365-Everyday-Value-Korintje-Cinnamon/dp/B00GB25R5Y"&gt;365 Whole Foods Organic Ground Cinnamon&lt;/a&gt;
came out on top at 0.02 ppm.
However — like all cinnamon that does not specifically say Ceylon — this is the cheaper Cassia variety.
The best Ceylon cinnamon tested was
&lt;a href="https://www.amazon.com/Ceylon-Cinnamon-Ground-Penzeys-Spices/dp/B08XK26GZG?gQT=1"&gt;Penzey's&lt;/a&gt; at 0.78 ppm.
Consumer Reports rated this "ok", but it is uncomfortably close to their "don't use" rating.
So, unfortunately, I do not know a great source of cinnamon.
According to Consumer Reports,
basil, oregano and thyme are also almost 
&lt;a href="https://www.consumerreports.org/health/food-safety/your-herbs-and-spices-might-contain-arsenic-cadmium-and-lead-a6246621494/"&gt;universally contaminated&lt;/a&gt;!&lt;/p&gt;
&lt;h2&gt;Peanut butter&lt;/h2&gt;
&lt;p&gt;Like cinnamon, peanut butter is a seemingly healthy food with some downsides.
For one thing, due to their longer growing cycle, nuts can
&lt;a href="https://www.sciencedirect.com/science/article/abs/pii/S0889157524007105#:~:text=Compared%20to%20grains%20and%20vegetables,strong%20toxicity%20to%20human%20body."&gt;concentrate heavy metals&lt;/a&gt;.
(Brazil nuts contain so much Selenium that you are only supposed to eat
&lt;a href="https://www.webmd.com/diet/health-benefits-brazil-nuts!"&gt;fewer than 5 per day&lt;/a&gt;).
Also, do not
&lt;a href="https://old.reddit.com/r/PeanutButter/comments/1fh8cic/a_cautionary_tale/"&gt;eat a pound a week of peanut butter&lt;/a&gt;
since that can cause liver damage.&lt;/p&gt;
&lt;p&gt;The real problem peculiar to peanut butter is a mold-derived natural product called aflatoxin,
a very potent toxin and carcinogen.
In 2004,
&lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC1855601/"&gt;125 Kenyans died&lt;/a&gt;
from aflatoxin poisoning after eating contaminated maize,
representing a fatality rate of 39%!&lt;/p&gt;
&lt;p&gt;Compared to whole peanuts,
I am told peanut butter is especially prone to aflatoxin contamination
because the mold that produces it can grow on the
lower quality peanut scraps and shavings used to make peanut butter.
This may or may not be true — I could not find a citation.&lt;/p&gt;
&lt;p&gt;There is also the unfortunate fact that the smaller,
higher quality peanut butter brands may actually have a higher probability
of contamination than the sugar and palm oil-laden Skippys and Jifs of the world,
simply because the larger players have enough scale to do frequent testing.
The &lt;a href="https://www.fda.gov/food/natural-toxins-food/mycotoxins#:~:text=Because%20of%20these%20health%20risks,of%20contamination%20in%20their%20products."&gt;FDA tests for aflatoxins&lt;/a&gt;,
so in general there should be no brands with a huge problem here.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Because of these health risks, the FDA has published action levels for aflatoxin and regularly tests foods for the presence of aflatoxins. By using modern agricultural and processing techniques, companies can reduce the possibility of contamination in their products.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There is a specific variety of peanut, Valencia peanuts,
that is
&lt;a href="https://eatbeautiful.net/aflatoxins-in-peanut-butter-how-much-do-the-leading-brands-have/"&gt;less prone to aflatoxin contamination&lt;/a&gt;.
Kirkland peanut butter is currently made with US Valencia peanuts.
Since we had been buying Kirkland peanut butter for a while,
I actually went as far as
&lt;a href="https://www.costco.com/kirkland-signature-organic-peanut-butter%2C-28-oz%2C-2-count.product.100334334.html"&gt;testing it for aflatoxin&lt;/a&gt; with the excellent &lt;a href="https://trilogylab.com"&gt;Trilogy Lab&lt;/a&gt;,
who graciously tolerated my tiny order. 
Kirkland had undetectable levels of aflatoxin, so that's what we exclusively buy now.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_aflatoxin.jpg" width="70%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Aflatoxin levels in Kirkland Valencia peanut butter were undetectable (results from Trilogy Lab)&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Turmeric&lt;/h2&gt;
&lt;p&gt;Turmeric is a popular supplement with pretty weak evidence for any positive effects,
but also weak evidence for any negative effects.
However, like cinnamon, and powders in general, there are concerns around heavy metal contamination.&lt;/p&gt;
&lt;p&gt;Despite the paucity of evidence, I do sometimes take turmeric. 
I buy it from
&lt;a href="https://www.amazon.com/Turmeric-Bioperine-Available-Standardized-Curcuminoids/dp/B01DBTFO98"&gt;BioSchwartz&lt;/a&gt;
because (a) it's turmeric &lt;em&gt;extract&lt;/em&gt;, which apparently removes some impurities;
(b) BioSchwarz does a lot of &lt;a href="https://bioschwartz.com/pages/about"&gt;testing&lt;/a&gt;
and is credible enough to be used in some 
&lt;a href="https://www.sciencedirect.com/science/article/pii/S073510972207125X?via%3Dihub"&gt;studies&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Interestingly, there is also evidence that curcumin may
&lt;a href="https://www.nature.com/articles/s41420-019-0234-y"&gt;chelate heavy metals&lt;/a&gt;,
and hence reduce the total heavy metal burden on the body.
On balance I find it worthwhile to take some turmeric, but I don't think it's an obvious win.&lt;/p&gt;
&lt;h2&gt;Sunscreen&lt;/h2&gt;
&lt;p&gt;For regulatory reasons
— basically, because sunscreen is regulated like a drug in the US —
it is difficult to buy good sunscreen in the US.
This used to be a niche concern,
but is now so mainstream that even
&lt;a href="https://www.nytimes.com/2023/08/12/style/sunscreen-fda-regulation-aoc.html"&gt;AOC talked about it&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Recently, I found a good source of sunscreen information, 
Lab Muffin Beauty
(e.g., her &lt;a href="https://www.youtube.com/watch?v=p5p72V3Jrg8&amp;amp;t=327s"&gt;Top Sunscreen Recommendations for 2024&lt;/a&gt;).
Lab Muffin Beauty is a PhD cosmetic chemist, and seems to have a ton of expertise on the topic.
One &lt;a href="https://www.youtube.com/watch?v=iK0FSmrR-gA"&gt;interesting point&lt;/a&gt;
she makes is that "physical" (Zinc or Titanium-based) sunblocks
are not really any safer than "chemical" sunscreens.
The basic argument is that both enter your bloodstream at low concentrations,
and both appear to have comparable, and negligible, health impacts.
She convinced me, for what it's worth.
(Note, usually "sunblock" refers to the physical kind and "sunscreen" the chemical kind.)&lt;/p&gt;
&lt;p&gt;Lab Muffin Beauty also had an
&lt;a href="https://youtu.be/wCPp8EJSG-Y?si=FNeqi-UtApgaz4j2&amp;amp;t=274"&gt;interesting video&lt;/a&gt; that references the
cancer-causing thymine dimer formation that can happen when UV damages DNA.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_thymidine.gif" style="max-width:20%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Thymine dimers resulting from UV radiation. These mutations can &lt;a href="https://academic.oup.com/mutage/article-abstract/28/3/249/1293260?redirectedFrom=fulltext"&gt;cause cancer&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;The sunscreens I currently buy are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/s?k=biore+watery+essence&amp;amp;i=beauty&amp;amp;crid=RUFKWJW34MJB&amp;amp;sprefix=biore+watery+essence%2Cbeauty%2C151&amp;amp;ref=nb_sb_noss_2"&gt;Biore UV Aqua Watery Essence SPF 50&lt;/a&gt;:
  This is a great sunscreen, even (surprisingly to me)
  doing well when
  &lt;a href="https://www.youtube.com/watch?v=JckfmlbU5C8"&gt;tested in water&lt;/a&gt;.
  However, there is a catch.
  If you live in the US, you may end up buying the US version,
  which is not as good.
  You have to either buy
  &lt;a href="https://www.amazon.com/Biore-Sunscreen-Essence-shokunin-3-55floz/dp/B0CJGY96XR"&gt;specific Asian-origin SKUs on Amazon&lt;/a&gt; (taking some risk on counterfeit or incorrect products),
  or buy from a non-US store like
  &lt;a href="https://www.stylevana.com/en_US/kao-biore-uv-aqua-rich-watery-essence-spf50-pa-70g-4pcs-set.html"&gt;StyleVana&lt;/a&gt;.
  If you buy four or more of these from StyleVana, as I did, the shipping is not bad,
  and thankfully sunscreen should
  &lt;a href="https://www.mayoclinic.org/healthy-lifestyle/adult-health/expert-answers/sunscreen-expire/faq-20057957"&gt;last three years&lt;/a&gt; or more.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/NIVEA-Protect-Super-Water-Pump/dp/B08YPCN6RL"&gt;NIVEA SUN Protect Super Water Gel&lt;/a&gt;:
  This one is less protective
  (it is only SPF30 and &lt;a href="https://www.thepinkfoundry.com/blogs/news/what-is-pa-in-sunscreen"&gt;PA+++&lt;/a&gt;),
  but it's a bit easier to
  &lt;a href="https://www.amazon.com/s?k=nivea+water+gell&amp;amp;i=beauty&amp;amp;crid=TO3712EF1Y0&amp;amp;sprefix=nivea+water+ge%2Cbeauty%2C207&amp;amp;ref=nb_sb_noss_2"&gt;buy online&lt;/a&gt; (though the price is all over the place),
  and the pump is convenient to use, especially for children.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These two sunscreens are "watery" style, which I prefer.
All of the "white" sunscreens I have ever used leave white deposits everywhere.
I don't have recommendations for non-watery sunscreens but
Lab Muffin Beauty also has plenty of recommendations in her
&lt;a href="https://www.youtube.com/watch?v=p5p72V3Jrg8&amp;amp;t=327s"&gt;video&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One thing to be aware of is that lots of brands have US versions of their sunscreens
where they use the exact same brand names (e.g., La Roche-Posay Anthelios),
so it's tricky to know what you are buying.&lt;/p&gt;
&lt;h2&gt;Toothpaste&lt;/h2&gt;
&lt;p&gt;Toothpaste has the same problem as sunscreen in that
it is regulated like a drug in the US.
Again, this means US toothpastes lag in technology by years.&lt;/p&gt;
&lt;p&gt;The most notable ingredient that is missing from US toothpaste is
&lt;a href="https://www.haleonhealthpartner.com/en-gb/oral-health/brands/sensodyne/science/novamin/"&gt;NovaMin&lt;/a&gt;,
a bioactive glass found, for example, in European Sensodyne but not US Sensodyne.
This is especially egregious to me because the European Sensodyne reduces sensitivity 
by 
&lt;a href="https://www.che.ufl.edu/PDF/ren/paper/1110.pdf"&gt;remineralizing teeth&lt;/a&gt;
while the US Sensodyne includes a numbing agent
(&lt;a href="https://www.sensodyne.com/en-us/about-sensodyne/ingredients/"&gt;potassium nitrate&lt;/a&gt;)
that just masks sensitivity!&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;(1) Bioactive glass (NovaMin) alone exhibited promising remineralization capabilities compared with a combination of fluoride and bioactive glass or just fluoride; (2) bioactive glass with fluoride seemed to potentiate the effect of fluoride alone&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There is actually an &lt;a href="https://medium.com/@ravenstine/the-curious-history-of-novamin-toothpaste-620c6bef8881"&gt;interesting story behind NovaMin&lt;/a&gt;.
To summarize, GSK bought the rights to NovaMin but the US trials were too expensive
given the size of the toothpaste market.
Realistically, not many people care enough to look into
what ingredients US Sensodyne has vs European Sensodyne.&lt;/p&gt;
&lt;p&gt;There is good news though.
I don't understand the regulatory story here
— it may be because they do not claim cavity prevention effects —
but Amazon now sells toothpastes containing nano-hydroxyapatite,
which seems to be
&lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC5121804/"&gt;as good as NovaMin&lt;/a&gt;
at remineralization.
For example,
&lt;a href="https://www.amazon.com/Davids-Hydroxyapatite-Toothpaste-Remineralizing-Antiplaque/dp/B0D1W289B2"&gt;Davids&lt;/a&gt;,
which does not have fluoride,
and
&lt;a href="https://www.amazon.com/Made-Dentists-Rebuilding-Professional-Toothpaste/dp/B0DM6QWLSH"&gt;Made by Dentists&lt;/a&gt;,
which does.
Note that fluoride also remineralizes, albeit via a different mechanism,
and I believe using
&lt;a href="https://betterbiom.com/blogs/learn/is-nano-hydroxyapatite-better-than-fluoride"&gt;both is recommended&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;While fluoride toothpastes work by depositing fluoride ions into your enamel, fluoride free toothpaste with hydroxyapatite works by depositing naturally beneficial materials like calcium and phosphate ions into your enamel.&lt;/p&gt;
&lt;p&gt;So, while fluoride is renowned for its strength, hydroxyapatite stands out for its natural affinity with the teeth and its potential to excel in specific oral health aspects. That's why many people suggest that both nano hydroxyapatite and hydroxyapatite are better than fluoride.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Unlike supplements and sunscreen,
the effects of NovaMin/nano-hydroxyapatite
are quite visible.
You can see the "dentine tubule occlusion" process with a
&lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC5121804/"&gt;Scanning Electron Microscope&lt;/a&gt;
within just a few days.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_SEM.jpg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Pre- and post-treatment with &lt;a href="https://www.amazon.com/Davids-Hydroxyapatite-Toothpaste-Remineralizing-Antiplaque/dp/B0D1W289B2"&gt;nano-hydroxyapatite&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Biomin F&lt;/h3&gt;
&lt;p&gt;The strongest remineralizing agent of all appears to be "Biomin F",
which deposits fluoroapatite, a bioglass claimed to be
&lt;a href="https://www.biomintoothpaste.com.au/biomin-alternative-to-apagard-toothpaste/"&gt;10 times more acid resistant than hydroxyapatite&lt;/a&gt;.
Of course, you cannot buy Biomin F in the US,
despite receiving
&lt;a href="https://www.nature.com/articles/s41415-021-2714-8"&gt;FDA clearance in 2021&lt;/a&gt; 
(note, not "FDA approval" as it says in the article!)
You can buy
&lt;a href="https://www.amazon.com/Dr-Collins-BioMin-Restore-Toothpaste/dp/B0CWWF5DFN"&gt;Biomin C&lt;/a&gt;,
but that is very similar to regular nano-hydroxyapatite.
Not only that, but stores worldwide are low on Biomin F inventory for some reason.
The 
&lt;a href="https://www.biomin-toothpaste.com/collections/biominf-collection"&gt;Biomin Canada store&lt;/a&gt;
is out of stock until "Q2 2025".
&lt;a href="https://www.burbel.ie/products/biomin-f"&gt;Burbel in Ireland&lt;/a&gt;
has it for the very reasonable price of €8 per tube, but it is out of stock until "next week",
and this &lt;a href="https://www.cutpricepharmacy.com.au/"&gt;Australian pharmacy&lt;/a&gt;
has it but with you'll pay $30 shipping to the US.&lt;/p&gt;
&lt;p&gt;The
&lt;a href="https://www.nature.com/articles/s41415-023-6147-4"&gt;British Dental Journal news article&lt;/a&gt;
on Biomin F includes this hilariously mercantile take.
Dentists really get away with some things doctors would not dare say:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;BioMin F delivers controlled fluoride release to strengthen teeth against acid attack and reduce dentine hypersensitivity including scaling and post-bleaching sensitivity, a problem that reduces patient acceptance of this highly profitable revenue stream.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Floss&lt;/h3&gt;
&lt;p&gt;Floss is likely a
&lt;a href="https://www.nature.com/articles/s41370-018-0109-y"&gt;significant source&lt;/a&gt;
of PFAS (the Teflon-related "forever chemicals" that don't break down)
and &lt;a href="https://pubmed.ncbi.nlm.nih.gov/38092338/"&gt;microplastics&lt;/a&gt;.
A &lt;a href="https://pubmed.ncbi.nlm.nih.gov/39797715/"&gt;recent NHANES report&lt;/a&gt;
found higher
&lt;a href="https://en.wikipedia.org/wiki/Perfluorooctanoic_acid"&gt;PFOAs&lt;/a&gt;
in dental floss users,
but, counterintuitively, lower levels of other PFAS.
(&lt;a href="https://www.cdc.gov/nchs/nhanes/index.html"&gt;NHANES&lt;/a&gt;
is a massive survey that forms the basis for many observational health studies.)&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Flossing with Oral-B Glide, having stain-resistant carpet or furniture, and living in a city served by a PFAS-contaminated water supply were also associated with higher levels of some PFASs. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;These are not great studies, and there is nothing all that concerning in these reports,
but since floss is something that can directly contact blood,
it still seems worth addressing.
Just last month,
&lt;a href="https://www.consumerreports.org/toxic-chemicals-substances/dental-floss-without-pfas-and-other-harmful-chemicals-a9722832754/"&gt;Consumer Reports reviewed PFAS-free flosses&lt;/a&gt;.
Of those recommended,
&lt;a href="https://treebirdeco.com/collections/floss/products/pure-silk-eco-floss-refills-5-pack"&gt;TreeBird&lt;/a&gt;
seems to have the best reviews, but you have to buy it directly from the manufacturer for some reason.
I have been using a very similar product,
&lt;a href="https://www.amazon.com/gp/product/B07WV798SM"&gt;Bambo Earth&lt;/a&gt;,
and it works ok.
However, it is quite thin and breaks quite easily.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_floss_table.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Flosses tested for the &lt;a href="https://www.nature.com/articles/s41370-018-0109-y"&gt;presence of fluorine&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Air filters&lt;/h2&gt;
&lt;p&gt;Despite the increase in awareness of air filtration due to recent forest fires (at least in the US),
I think air pollution is still underappreciated as a cause of disease.
In a large study published in &lt;a href="https://pubmed.ncbi.nlm.nih.gov/28657878/"&gt;NEJM in 2017&lt;/a&gt;,
they found a very strong correlation between PM2.5 and all-cause mortality.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Increases of 10 μg per cubic meter in PM2.5 [was] associated with increases in all-cause mortality of 7.3%&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Although this is an observational study, it was large and well-controlled.
There are many cities in the USA with an average PM2.5 of 10μg/m³ or greater,
and in India, some cities can even average &amp;gt;100μg/m³.
Within cities there is also a lot of variation,
with houses closer to freeways having much greater PM2.5 levels.
The air filtration company IQAir publishes an interesting
&lt;a href="https://www.iqair.com/us/world-most-polluted-cities"&gt;"most polluted cities" leaderboard&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_iqair.png" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;IQAir's most polluted cities in the US&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;The content of the pollution matters.
An estimated
&lt;a href="https://pubs.acs.org/doi/abs/10.1021/es101450t#afn2"&gt;30% of Bay Area pollution&lt;/a&gt;
blows in from China,
including a lot of lead from coal-fired power plants.&lt;/p&gt;
&lt;p&gt;Thankfully, there are plenty of good air filters around these days,
and the technology is very standard: essentially an air filter is just a fan and a HEPA filter
(the exception is
&lt;a href="https://www.consumerreports.org/appliances/air-purifiers/molekule-air-purifier-review-a6711172738/"&gt;Molekule&lt;/a&gt;,
which doesn't work well).
We have
&lt;a href="https://www.amazon.com/Purifier-Washable-Pre-Filters-Particle-Allergens/dp/B073WJL99W"&gt;BlueAir&lt;/a&gt;
and use
&lt;a href="https://www.amazon.com/s?k=BLUEAIR+211+filters&amp;amp;i=garden&amp;amp;crid=1EXBRDTRBDXPU&amp;amp;sprefix=blueair+211+filters%2Cgarden%2C159&amp;amp;ref=nb_sb_noss_2"&gt;cheaper third-party filters&lt;/a&gt;.
I have tested a few of these third-party filters with a particle counter,
and they all appear to work fine.
&lt;a href="https://www.amazon.com/Coway-AP-1512HH-Mighty-Purifier-White/dp/B01728NLRG"&gt;Coway&lt;/a&gt; and 
&lt;a href="https://www.amazon.com/Winix-5500-2-Purifier-PlasmaWave-Reducing/dp/B01D8DAYII"&gt;Winix&lt;/a&gt;
also work fine and are cheaper than BlueAir.
Winix even has its own air quality sensor built in, which is pretty amazing for a $180 device.
To really go all out,
IQAir will sell you a &lt;a href="https://www.iqair.com/us/products/air-purifiers/perfectpro-series?srsltid=AfmBOopWLLCu4wYwLoYpTMjTPjJrKXpGrL6gGzg_OGsHCC1XW5zuE8oM"&gt;whole-house HEPA filter&lt;/a&gt; for around $3000
(many houses already have air filters,
but these are usually around MERV 13, where HEPA is closer to &lt;a href="https://www.iso-aire.com/blog/what-are-the-differences-between-a-merv-13-and-a-hepa-filter"&gt;MERV 17&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_MERV.jpeg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;MERV vs HEPA ratings&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Although HEPA filters are most important because they catch PM2.5 particles,
you can also buy activated carbon filters.
Activated carbon captures VOCs like benzene (which a gas range will emit,
&lt;a href="https://www.npr.org/2023/06/16/1181299405/gas-stoves-pollute-homes-with-benzene-which-is-linked-to-cancer"&gt;even when off!&lt;/a&gt;)
Wildfires are also a major source of &lt;a href="https://cpo.noaa.gov/Understanding-Volatile-Organic-Compound-Emissions-from-Wildfires-in-the-Western-US-with-Modeling-Comparisons/"&gt;VOC pollution&lt;/a&gt;.
Combination HEPA–activated carbon filters are easy to buy for
&lt;a href="https://www.amazon.com/PUREBURG-Replacement-Activated-Compatible-Purifiers/dp/B08CRDQ18H"&gt;BlueAir&lt;/a&gt;,
&lt;a href="https://www.amazon.com/Nispira-Replacement-Compatible-Purifier-AP-1512HH/dp/B01N3A7XVA"&gt;Coway&lt;/a&gt;, and 
&lt;a href="https://www.amazon.com/Cabiclean-Replacement-Compatible-1712-0096-00-Activated/dp/B08MVL3BR8"&gt;Winix&lt;/a&gt;,
so I think it's worthwhile.&lt;/p&gt;
&lt;h2&gt;Nose sprays&lt;/h2&gt;
&lt;p&gt;Airborne infectious diseases mostly enter through the nose and mouth.
Generally, breathing through the nose is thought to be healthier,
since the nose has more active barriers than the mouth,
including a mucous layer and increased nitric oxide concentration (an 
&lt;a href="https://decisionsindentistry.com/2020/06/nasal-breathing-help-reduce-risk-covid/"&gt;antimicrobial&lt;/a&gt;).
The recent fitness influencer trend of taping your mouth shut at night
to improve sleep quality and reduce sleep apnea may also
&lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7200356/"&gt;prevent infection&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Studies indicate that NO may also help to reduce respiratory tract infection by inactivating viruses and inhibiting their replication in epithelial cells.&lt;/p&gt;
&lt;p&gt;Studies indicate that individuals who snore or breathe through the mouth during sleep—conditions which are highly prevalent in males—are more likely to develop respiratory tract infections. Our anecdotal observations also suggest that favoring nasal breathing during sleep by sealing the mouth with adhesive tape reduces common colds. This phenomenon may be due to the filtration and humidifying effects of the nose on inhaled air and to increased NO levels in the airways, which may decrease viral load during sleep and allow the immune system more time to mount an effective antiviral response.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You can also potentially prevent even more infections by augmenting the nose's defenses.
There are at least two products that claim to do this:&lt;/p&gt;
&lt;h3&gt;Carrageenan&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://www.amazon.com/LUCA-V-Defense-Protection-Airborne-Spraying/dp/B0C2237D1Q"&gt;Luca V-Defense&lt;/a&gt;
is a Korean nose spray that deposits a layer of type of carrageenan on the inside of the nose.
As a common food thickener, carrageenan seems to be quite safe.
There are several other carrageenan-based sprays on Amazon, like
&lt;a href="https://www.northernvitality.us/products/betadine-cold-defence-nasal-spray-20ml"&gt;Betadine&lt;/a&gt;.
Based on the ingredients I don't think there is too much to choose between them.&lt;/p&gt;
&lt;p&gt;Strangely, even though the putative mechanism of action is prevention,
the trials I found are for treatment post-infection 
(e.g., for the &lt;a href="https://respiratory-research.biomedcentral.com/articles/10.1186/1465-9921-14-124"&gt;common cold&lt;/a&gt;,
&lt;a href="https://bpspubs.onlinelibrary.wiley.com/doi/full/10.1002/prp2.810"&gt;influenza&lt;/a&gt;,
&lt;a href="https://www.mdpi.com/1661-3821/3/3/25"&gt;SARS-CoV-2&lt;/a&gt;).
This is probably because real prevention trials would have to be extremely large and expensive.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The biological effect of carrageenan appears to prevent the virus from binding to cell surfaces or penetrating the cells&lt;/p&gt;
&lt;p&gt;The antiviral effect of iota-carrageenan was previously shown in vitro for several other viruses, e.g., influenza A virus, human rhinovirus, endemic human coronaviruses and herpes simplex virus 2 &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;None of the claims or evidence here is amazingly strong,
but a physical barrier is a pretty simple and believable mechanism of action,
especially for prevention,
so I am inclined to believe some efficacy.
Also, a common mechanism for infection is simply
&lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC7872882/"&gt;dried out mucous membranes&lt;/a&gt;,
especially on airplanes,
so carrageenan could also help with that.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Low indoor [relative humidity], as experienced during winter months or inside airplanes, directly or indirectly influences several mechanisms that increase the transmission of respiratory diseases.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Nitric oxide&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://sanotize.com/technology/nasal-spray/faq/"&gt;Enovid&lt;/a&gt; (aka VirX)
is a nitric oxide spray that is
more expensive, more difficult to buy, and arguably less safe than carrageenan.
You cannot buy it on Amazon for a reasonable price.
Enovid has been tested in a
&lt;a href="https://www.thelancet.com/journals/lansea/article/PIIS2772-3682(22)00046-4/fulltext"&gt;Phase III in India for SARS-CoV-2&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Secondary endpoint assessments demonstrated a greater proportion of patients receiving [NO nasal spray] (82.8%) cleared SARS-CoV-2 (RT-PCR negative) by [end of treatment] compared to placebo (66.7%, p = 0.046), with no virus RNA detected a median of four days earlier compared to placebo (three vs seven days; p = 0.044).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The results for treatment are pretty good, if not amazing.
Like carrageenan, it is possible that the NO effect is more relevant for prevention than treatment.
It's honesly unclear to me why it helps at all post-infection.&lt;/p&gt;
&lt;p&gt;I use both of these products sometimes.
In particular, for airplane trips,
I generally try to use the Luca spray beforehand,
a mask (&lt;a href="https://www.amazon.com/3M-Aura-Particulate-Respirator-9205/dp/B095FJ36H2"&gt;3M Aura&lt;/a&gt;)
on the plane (which also helps with the dry air),
and maybe Enovid at some point after.
Airplanes are a &lt;a href="https://journals.asm.org/doi/10.1128/microbiolspec.iol5-0009-2015"&gt;major source of infections&lt;/a&gt;,
and anecdotally, this protocol helps.&lt;/p&gt;
&lt;p&gt;All told, I think the carrageenan sprays are probably a better bet than the NO sprays.
They are cheap, easy to buy,
have decent evidence for being protective against all airborne infection,
and seem very safe.&lt;/p&gt;
&lt;h2&gt;Gas and induction stoves&lt;/h2&gt;
&lt;p&gt;Gas stoves produce a lot of noxious fumes, including NO₂, benzene, and CO.
Like asbestos, lead, and other once-common toxins,
the ubiquity of gas stoves may hide how unhealthy they actually are.
By one estimate, gas stoves cause
&lt;a href="https://pubmed.ncbi.nlm.nih.gov/36612391/"&gt;12%&lt;/a&gt; of
&lt;a href="https://www.science.org/doi/10.1126/sciadv.adm8680"&gt;childhood asthma cases&lt;/a&gt;
in the US,
though honestly this is a weak observational study and the claim is
&lt;a href="https://www.sciencedirect.com/science/article/pii/S2590113324000269"&gt;heavily disputed&lt;/a&gt;
(12% is a number so high that it would require
&lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC3114207/#:~:text=%E2%80%9CExtraordinary%20claims%20require%20extraordinary%20evidence%E2%80%9D%20was%20a%20phrase%20made%20popular,et%20al.%2C%201999"&gt;extraordinary evidence&lt;/a&gt;).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This increased exposure likely causes ~50,000 cases of current pediatric asthma from long-term NO₂ exposure alone. Short-term NO₂ exposure from typical gas stove use frequently exceeds both World Health Organization and U.S. Environmental Protection Agency benchmarks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_gas.jpg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Even with the kitchen extractor hood turned on, NO₂ levels
&lt;a href="https://www.science.org/doi/10.1126/sciadv.adm8680"&gt;exceed health guidelines&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;As mentioned above,
&lt;a href="https://www.amazon.com/Particle-Carbon-Replacement-Filter-Foldable/dp/B073SKH39W"&gt;activated carbon filters&lt;/a&gt;
can remove some of these VOC pollutants, while regular HEPA filters cannot.
&lt;a href="https://marcumsnursery.com/nasa-approved-plants/"&gt;Indoor plants&lt;/a&gt; may also help a little bit!&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_plant.jpg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Some plants, like snake plants, remove a small amount of VOCs from the air&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Venting with an extractor fan helps a lot,
but the only real solution is replacing gas with electric,
which these days means induction.
&lt;a href="https://www.consumerreports.org/appliances/ranges/the-best-induction-ranges-a8524766309/"&gt;Consumer Reports&lt;/a&gt; recommends this
&lt;a href="https://www.lg.com/us/cooking-appliances/lg-lsis6338fe"&gt;LG Induction Stove&lt;/a&gt; ($2800)
or the cheaper
&lt;a href="https://www.ikea.com/us/en/p/tvaersaeker-range-with-induction-cooktop-stainless-steel-40466006/"&gt;IKEA TVARSAKER stove&lt;/a&gt; ($1400).
There are also new lithium battery-augmented stoves like the
&lt;a href="https://www.nytimes.com/wirecutter/reviews/copper-charlie-induction-stove-review/"&gt;Copper Charlie&lt;/a&gt; and
&lt;a href="https://www.youtube.com/watch?v=r0U3mTAiV-k!"&gt;Impulse Labs (cooktop only)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;These induction stoves are admittedly pretty expensive,
but as a stopgap, the
&lt;a href="https://www.nytimes.com/wirecutter/reviews/best-portable-induction-cooktop/"&gt;Wirecutter-recommended&lt;/a&gt; 
&lt;a href="https://www.amazon.com/Duxtop-1800-Watt-Induction-Countertop-9600LS/dp/B01FLR0ET8"&gt;Duxtop portable induction cooktop&lt;/a&gt;
is only around $120, and some alternatives are
&lt;a href="https://www.amazon.com/AmazonBasics-1800W-Portable-Induction-Cooktop/dp/B07S2628R9"&gt;half as much&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Electric kettles&lt;/h2&gt;
&lt;p&gt;Microplastics and other leached chemicals appear when you
&lt;a href="https://www.yongkeng.com/is-it-safe-to-boil-water-in-plastic-electric-kettle.html"&gt;add boiling water to plastic&lt;/a&gt;.
Since I drink a lot of tea,
I spent quite a bit of time looking for a kettle with no plastic parts exposed to water.
The more I read the more it seemed like every kettle has some small amount of plastic somewhere,
so I was not totally satisfied, but I ended up buying a
&lt;a href="https://www.amazon.com/COSORI-Electric-Gooseneck-Variable-Stainless/dp/B07T1CH2HH"&gt;Cosori gooseneck kettle&lt;/a&gt;,
and I like it.
This &lt;a href="https://www.implasticfree.com/plastic-free-electric-kettles/"&gt;recent roundup from implasticfree.com&lt;/a&gt;
recommends the Cosori, plus several other options if gooseneck does not suit.&lt;/p&gt;
&lt;h2&gt;Tea bags&lt;/h2&gt;
&lt;p&gt;Tea bags, especially the plasticky-looking ones, can also contain microplastics.
We buy Republic of Tea bags, which are made from wood pulp, and sell in
&lt;a href="https://www.amazon.com/Republic-Tea-Good-Hope-Vanilla/dp/B00KRI08OS"&gt;bulk bags of 250&lt;/a&gt;.
The company claims no plastics are used, though 
&lt;a href="https://old.reddit.com/r/tea/comments/1gi99pk/is_there_any_tea_bags_that_have_absolutely_no/"&gt;this reddit thread&lt;/a&gt; throws some doubt on that.
Apparently, "plant-based bioplastics" are commonly used to seal tea bags,
and there's no doubt many companies will refer to this as "plastic free".
&lt;a href="https://www.implasticfree.com/why-you-should-switch-to-plastic-free-tea-bags/"&gt;implasticfree.com also has a list&lt;/a&gt;
of approved tea bags.
Loose leaf tea is probably safest given the confusion here, but it's too inconvenient for me.&lt;/p&gt;
&lt;h2&gt;AeroPress&lt;/h2&gt;
&lt;p&gt;I have been using an Aeropress for many years, and it always bugged me that it's plastic.
As plastics go, polypropylene seems like a good one, but it's still not ideal.
There have been
&lt;a href="https://old.reddit.com/r/AeroPress/comments/j3vpxv/metal_aeropress_from_artisansmith/"&gt;handmade metal-and-glass versions&lt;/a&gt;
available online for a few years,
but I was never convinced that with welding etc. I wasn't trading plastic contamination for metal contamination.
This year, Aeropress finally released a
&lt;a href="https://aeropress.com/products/aeropress-coffee-maker-premium"&gt;stainless steel and borosilicate glass version&lt;/a&gt;,
which I bought.
It costs $150 and ships in May 2025.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_aeropress.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The new glass and stainless steel AeroPress is $150&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Travel mugs&lt;/h2&gt;
&lt;p&gt;In 2024, the giant Stanley travel mugs hydration enthusiasts were buying made the news when they were
&lt;a href="https://www.bbc.com/future/article/20240130-stanley-cups-contain-lead-should-consumers-worry"&gt;found to contain lead&lt;/a&gt;.
Since the lead is totally separated from the interior of the cup,
the risk turned out to be probably pretty negligible.
Separately,
&lt;a href="https://tamararubin.com"&gt;Lead Safe Mama&lt;/a&gt;,
a blogger who tests household items for lead and other contaminants,
investigated and noted that the interior is only
&lt;a href="https://tamararubin.com/2023/03/full-xrf-test-results-for-a-2023-purchased-stanley-40-oz-flowstate-quencher-h2-0-tumbler/"&gt;recommended for use with water&lt;/a&gt;,
which is kind of weird.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://www.amazon.com/Hydro-Flask-Around-Tumbler-Trillium/dp/B0C353845H"&gt;HydroFlask equivalent&lt;/a&gt;
is the same size as the Stanley cup and is all stainless steel,
so it's a pretty straightforward swap-in.
I bought a HydroFlask, and also ended up also swapping the hard plastic part of the HydroFlask straw for a
&lt;a href="https://www.amazon.com/gp/product/B0CBK7V4CV"&gt;silicone straw&lt;/a&gt;
since it comes in contact with hot liquid.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_hydroflask.jpg" style="min-width:30%; max-width:60%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The Hydroflask straw has two separate parts: silicone on top and hard plastic on the bottom&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Water filtration&lt;/h2&gt;
&lt;p&gt;There are two main ways to purify water: activated carbon filters and reverse osmosis.
At one point I looked into &lt;a href="https://myberkey.com/"&gt;Berkey water filters&lt;/a&gt;,
as the only stainless steel activated carbon filter I could find.
I decided against Berkey because it
&lt;a href="https://www.nytimes.com/wirecutter/reviews/big-berkey-water-filter-system/"&gt;lacks certification&lt;/a&gt;
and &lt;a href="https://www.youtube.com/watch?v=1QL3McV20YM"&gt;leached aluminum in at least one test&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We got &lt;a href="https://www.amazon.com/PUR-DS1811Z-Ultimate-Water-Dispenser/dp/B07CRSK5KX"&gt;PUR filters&lt;/a&gt;,
which are similar to Brita,
but with some minor performance improvements (when I checked 5+ years ago).
I tested our PUR-filtered water with a
&lt;a href="https://blog.booleanbiotech.com/water-purity-genequant"&gt;GeneQuant&lt;/a&gt;,
and in that test it removed a lot of impurities!
The good news is that activated carbon filters work well.
The bad news is they are annoying:
they need to be filled manually, changed regularly, they slow down over time, and everything is plastic.&lt;/p&gt;
&lt;p&gt;In retrospect, reverse osmosis filters are probably a better bet.
They are out of sight so they require some active maintenance to avoid bacterial and mold growth,
and since reverse osmosis removes minerals,
they require a separate remineralization filter to taste ok.
I have yet to install a reverse osmosis filter, so I don't have any particular recommendations.&lt;/p&gt;
&lt;p&gt;The best way to test your water is probably
&lt;a href="https://mytapscore.com/"&gt;TapScore&lt;/a&gt;
but it's quite expensive at $200-300.&lt;/p&gt;
&lt;h2&gt;KitchenAid attachments&lt;/h2&gt;
&lt;p&gt;Many people own the classic KitchenAid stand mixer.
In 2014, 
&lt;a href="https://tamararubin.com/2023/01/lead-safe-mama-llcs-cpsc-violation-report-lsm_01_2023-reporting-unsafe-levels-of-lead-found-in-kitchenaid-stand-mixer-aluminum-attachments/"&gt;Lead Safe Mama&lt;/a&gt;
found very high levels of lead in the standard KitchenAid attachments.
There is a
&lt;a href="https://tamararubin.com/2022/12/a-point-by-point-response-to-kitchenaids-public-statements-regarding-lead-safe-mama-llcs-findings-of-lead-contamination-in-their-standard-mixer-attachments/"&gt;long backstory&lt;/a&gt;
here and KitchenAid disagrees with the conclusion,
but I think overall it was convincing that there was a concerning amount of lead.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_kitchenaid.jpg" style="min-width:40%;max-width:80%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The KitchenAid stand mixer and stainless steel attachments&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;In 2018, KitchenAid started selling
&lt;a href="https://www.amazon.com/KitchenAid-Stainless-KitchenAid%C2%AE-Tilt-Head-Mixers/dp/B07SSHJTK9"&gt;stainless steel attachments&lt;/a&gt;
in response to this finding.
We own these and they work great.
We had the standard enamel-coated attachments before,
and these actually chipped a little bit due to misalignment,
so independent of the lead problem, this is a big improvement.
If you own this mixer, this is an upgrade I would highly recommend.&lt;/p&gt;
&lt;h2&gt;Food containers&lt;/h2&gt;
&lt;p&gt;Most paper and cardboard that touches food is lined with something.
It's a pretty complicated zoo of plasticky materials, and I don't understand it very well.
Some things are lined with PFAS (e.g., the paper in burger or sandwich wrappers, at least
&lt;a href="https://apnews.com/article/pfas-forever-chemicals-fast-food-wrappers-fda-234b4d2ebb9ee1eed30006c24ff6f450"&gt;up until recently&lt;/a&gt;),
some are lined with wax (e.g., the
&lt;a href="https://www.chowhound.com/1697734/what-is-paper-pizza-box/#:~:text=This%20paper%20is%20called%20dry,to%20do%20in%20the%20kitchen."&gt;dry wax paper under pizza&lt;/a&gt;),
some with silicone (e.g., &lt;a href="https://en.wikipedia.org/wiki/Parchment_paper"&gt;parchment paper&lt;/a&gt;),
some with polyethylene (e.g., &lt;a href="https://insights.basf.com/home/article/read/anatomy-of-a-cup"&gt;paper coffee cups&lt;/a&gt;, 
&lt;a href="https://www.oren-intl.com/blog/bid/330911/Wax-Coated-Butcher-Paper-is-a-Thing-of-The-Past"&gt;butcher's paper&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;There are plenty of exceptions to the above,
and it's difficult to figure out exactly what is lining what,
but I think it's pretty safe to say almost all paper and cardboard that could get soggy
has some kind of lining.
To my mind, dry wax and parchment paper are probably ok.
The other random plastics are things I'd prefer to avoid, given the choice.&lt;/p&gt;
&lt;p&gt;Since nothing is really labeled,
I am pretty suspicious that there is more PFAS here than advertised,
in the same way that BPA-free essentially means "contains something a lot like BPA", e.g.,
&lt;a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC4816743/"&gt;BPS&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The real issue is that the industry is replacing a toxic chemical with another, yet untested chemical, which will require large investments of research funds to carry out applicable studies&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Despite the recent
&lt;a href="https://apnews.com/article/pfas-forever-chemicals-fast-food-wrappers-fda-234b4d2ebb9ee1eed30006c24ff6f450"&gt;phase-outs of PFAS&lt;/a&gt;,
&lt;a href="https://www.consumerreports.org/health/food-contaminants/dangerous-pfas-chemicals-are-in-your-food-packaging-a3786252074/#allResults"&gt;Consumer Reports&lt;/a&gt;
did a review in 2022 and found a ton of PFAS.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Identifying the exact type of PFAS in a product is complex: There are more than 9,000 known PFAS, yet common testing methods can identify only a couple dozen.&lt;/p&gt;
&lt;p&gt;CR tested multiple samples of 118 products and calculated average organic fluorine levels for each. Overall, CR detected that element in more than half the food packaging tested. Almost a third—37 products—had organic fluorine levels above 20 ppm, and 22 were above 100 ppm. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In a &lt;a href="https://pubs.acs.org/doi/10.1021/acs.est.1c06768"&gt;2022 paper&lt;/a&gt;,
they found "trillions of sub-100 nm nanoparticles" being released into water
from plastic-lined single-use coffee cups.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;On a particle number density basis, particles released into water from a single 300 mL hot beverage cup equate to one particle for every seven cells in the human body in a size range available for cellular uptake.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_plastic_cup.jpg" style="max-width:35%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Plastic-lined paper cups leach plastics&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;SweetGreen&lt;/h3&gt;
&lt;p&gt;One interesting example is the "fiber bowls" you get from fancier fast food like SweetGreen.
Fiber bowls are those brown bowls that look like recycled cardboard,
and you'd be forgiven for thinking they are healthier than the classic plastic or styrofoam containers.
They used to be lined with PFAS, but in 2020
SweetGreen
&lt;a href="https://press.footprintus.com/en/fast-company-sweetgreen-and-footprint-partner-to-provide-pfas-free-compostable-bowls"&gt;partnered with FootPrint International&lt;/a&gt;
to remove PFAS from their bowls.&lt;/p&gt;
&lt;p&gt;There is not much information online, but FootPrint have several
&lt;a href="https://patents.google.com/patent/US11654600B2/en?assignee=%22Footprint+International%2c+LLC%22&amp;amp;oq=%22Footprint+International%2c+LLC%22"&gt;patents&lt;/a&gt;, for example:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Methods and apparatus for vacuum forming and subsequently applying topical coatings fiber-based food containers. The slurry includes an embedded moisture barrier and/or vapor barrier, and the topical coating comprises an oil barrier comprising acrylate, rice bran wax, pectin, and pea protein.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As far as I can tell, acrylate (also listed as acrylic in the patent)
is safer than PFAS, since it's harder and so less prone to leach.
However, though it might technically not be "plastic" for some reason, it's not far off.&lt;/p&gt;
&lt;p&gt;SweetGreen also scored very high for plastic contamination on &lt;a href="https://plasticlist.org"&gt;plasticlist.org&lt;/a&gt;, 
coming in at 4th highest for &lt;a href="https://en.wikipedia.org/wiki/Bis(2-ethylhexyl)_phthalate"&gt;DEHP&lt;/a&gt;
out of 300 foods tested.
My understanding is that this is more likely to come from the chicken than the bowl.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_plasticlist.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The &lt;a href=""&gt;plasticlist.org&lt;/a&gt; top 7 by DEHP content&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Mass spectrometry&lt;/h2&gt;
&lt;p&gt;One common theme here is that it's really hard to tell
what products are actually made from. In most cases the information does not exist,
and the manufacturers have little incentive to say anything.
If the product is manufactured in China, they may not even know for sure.
For example, is there "plastic" in Sweet Green bowls and Republic of Tea tea bags,
or just something very similar to plastic? I still don't know.&lt;/p&gt;
&lt;p&gt;There is a technology that can detect the constituent molecules of almost anything: mass spectrometry.
I really wish someone with a mass spec could review products and tell me what they are made from.
Unfortunately, mass specs are pretty expensive ($100k-$1M) and finicky to keep running,
and the data analysis is not all that straightforward
(as evidenced by the recent study claiming
&lt;a href="https://www.nature.com/articles/s41591-024-03453-1"&gt;massive amounts of microplastics in the brain&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/2025_products_mass_spec_brain.jpg" style="min-width:20%;max-width:500px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A &lt;a href="https://x.com/DusanMateric/status/1886730304859062773"&gt;rebuttal to the study&lt;/a&gt; claiming very large volume of microplastics in the brain&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Amazon&lt;/h2&gt;
&lt;p&gt;Even though the majority of the links above are from Amazon,
and I buy from there a lot, in general I prefer not to.
It's
&lt;a href="https://www.nytimes.com/wirecutter/blog/amazon-counterfeit-fake-products/"&gt;fairly common&lt;/a&gt;
for products on Amazon to be counterfeit,
mainly because random third-party sellers get mixed in with the official stores.
Supplements may be especially prone to counterfeiting, since they are so easy to fake.
If you are buying products specifically to avoid contaminants,
then the rampant counterfeiting might defeat the purpose.
Target, Costco, etc. do not appear to have this problem.&lt;/p&gt;
&lt;h2 id="tl;dr"&gt;tl;dr&lt;/h2&gt;
&lt;p&gt;Recommended product list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://agnroots.com/products/agn-roots-grass-fed-whey-3-lbs"&gt;Whey powder&lt;/a&gt;&lt;!--(https://amazon.com/AGN-Roots-Protein-Powder-Isolate/dp/B0C3RKLMGH)--&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://naturalforce.com/products/grass-fed-collagen-peptides-protein-powder?variant=14848075595876"&gt;Collagen powder&lt;/a&gt;&lt;!--(https://amazon.com/Premium-Collagen-Peptides-Protein-Recovery/dp/B01LJWQ1C8)--&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/gp/product/B0CCCNKD73"&gt;Creatine powder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.costco.com/kirkland-signature-organic-peanut-butter%2C-28-oz%2C-2-count.product.100334334.html"&gt;Peanut butter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Turmeric-Bioperine-Available-Standardized-Curcuminoids/dp/B01DBTFO98"&gt;Turmeric&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.stylevana.com/en_US/kao-biore-uv-aqua-rich-watery-essence-spf50-pa-70g-4pcs-set.html"&gt;Sunscreen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Made-Dentists-Rebuilding-Professional-Toothpaste/dp/B0DM6QWLSH"&gt;Toothpaste&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Biodegradable-Refillable-Candelilla-Compostable-Eco-Friendly/dp/B07FC4JBZZ"&gt;Floss&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/5510-Purifier-Generation-Deodorization-Allergies/dp/B0DJG1731C"&gt;Air filter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/LUCA-V-Defense-Protection-Airborne-Spraying/dp/B0C2237D1Q"&gt;Nose spray&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Duxtop-1800-Watt-Induction-Countertop-9600LS/dp/B01FLR0ET8"&gt;Induction burner&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/COSORI-Electric-Gooseneck-Variable-Stainless/dp/B07T1CH2HH"&gt;Electric kettle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Republic-Tea-Good-Hope-Vanilla/dp/B00KRI08OS"&gt;Tea bags&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aeropress.com/products/aeropress-coffee-maker-premium"&gt;AeroPress&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/Hydro-Flask-Around-Tumbler-Trillium/dp/B0C353845H"&gt;Travel mug&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazon.com/KitchenAid-Stainless-KitchenAid%C2%AE-Tilt-Head-Mixers/dp/B07SSHJTK9"&gt;Kitchenaid attachments&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thanks to Darren Zhu for comments on this post!&lt;/p&gt;</content><category term="health"/><category term="health"/></entry><entry><title>What we learned about binder design from the Adaptyv competition</title><link href="/what-we-learned-adaptyv.html" rel="alternate"/><published>2024-12-30T11:00:00-08:00</published><updated>2024-12-30T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2024-12-30:/what-we-learned-adaptyv.html</id><summary type="html">&lt;p&gt;What we learned about binder design from the Adaptyv competition&lt;/p&gt;</summary><content type="html">&lt;p&gt;This article is a deeper look at
&lt;a href="https://design.adaptyvbio.com/"&gt;Adaptyv's binder design competition&lt;/a&gt;,
and some thoughts on what we learned.
If you are unfamiliar with the competition,
there is background information on the &lt;a href="https://www.adaptyvbio.com/blog"&gt;Adaptyv blog&lt;/a&gt;
and &lt;a href="https://blog.booleanbiotech.com/adaptyv-binder-design-competition"&gt;my previous article&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;The data&lt;/h2&gt;
&lt;p&gt;Adaptyv did a really nice job of packaging up the data from the competition
(both &lt;a href="https://github.com/adaptyvbio/egfr_competition_1"&gt;round 1&lt;/a&gt;
and &lt;a href="https://github.com/adaptyvbio/egfr_competition_2"&gt;round 2&lt;/a&gt;).
The also did a comprehensive analysis of which metrics predicted successful binding
in &lt;a href="https://www.adaptyvbio.com/blog/po104"&gt;this blogpost&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The data from round 2 is more comprehensive than round 1
— it even includes Alphafolded structures —
so I downloaded the
&lt;a href="https://github.com/adaptyvbio/egfr_competition_2/blob/main/results/result_summary.csv"&gt;round 2 csv&lt;/a&gt;
and did some analysis.&lt;/p&gt;
&lt;h2&gt;Regressions&lt;/h2&gt;
&lt;p&gt;Unlike the &lt;a href="https://www.adaptyvbio.com/blog/po104"&gt;Adaptyv blogpost&lt;/a&gt;,
which does a deep dive on each metric in turn,
I just wanted to see how well I could predict binding affinity (&lt;code&gt;Kd&lt;/code&gt;)
using the following features provided in the csv: 
&lt;code&gt;pae_interaction&lt;/code&gt;, &lt;code&gt;esm_pll&lt;/code&gt;, &lt;code&gt;iptm&lt;/code&gt;, &lt;code&gt;plddt&lt;/code&gt;,
&lt;code&gt;design_models&lt;/code&gt; (converted to one-hot),
&lt;code&gt;seq_len&lt;/code&gt; (inferred from sequence).
Three of these metrics (&lt;code&gt;pae_interaction&lt;/code&gt;, &lt;code&gt;esm_pll&lt;/code&gt;, &lt;code&gt;iptm&lt;/code&gt;)
were used to determine each entry's rank in the competition's
&lt;a href="https://design.adaptyvbio.com"&gt;virtual leaderboard&lt;/a&gt;,
which was used to prioritize entries going into the binding assay.&lt;/p&gt;
&lt;p&gt;I also added one more feature, &lt;code&gt;prodigy_kd&lt;/code&gt;,
which I generated from the PDB files provided
using &lt;a href="https://github.com/haddocking/prodigy"&gt;prodigy&lt;/a&gt;.
Prodigy is an old-ish tool for predicting binding affinity
that identifies all the major contacts (polar–polar, charged–charged, etc.)
and reports a predicted Kd (&lt;code&gt;prodigy_Kd&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;I used the typical regression tools:
Random Forest,
&lt;a href="https://x.com/search?q=from%3Atunguz%20xgboost&amp;amp;src=typed_query"&gt;Kaggle favorite XGBoost&lt;/a&gt;,
SVR, linear regression,
as well as just using the mean &lt;code&gt;Kd&lt;/code&gt; as a baseline.
There is not a ton of data here for cross-validation,
especially if you split by submitter,
which I think is fairest.
If you do not split by submitter,
then you can end up with very similar proteins in different folds.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# get data and script&lt;/span&gt;
git&lt;span class="w"&gt; &lt;/span&gt;clone&lt;span class="w"&gt; &lt;/span&gt;https://github.com/adaptyvbio/egfr_competition_2
&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;egfr_competition_2/results
wget&lt;span class="w"&gt; &lt;/span&gt;https://gist.githubusercontent.com/hgbrian/1262066e680fc82dcb98e60449899ff9/raw/regress_adaptyv_round_2.py
&lt;span class="c1"&gt;# run prodigy on all pdbs, munge into a tsv&lt;/span&gt;
find&lt;span class="w"&gt; &lt;/span&gt;structure_predictions&lt;span class="w"&gt; &lt;/span&gt;-name&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*.pdb"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;xargs&lt;span class="w"&gt; &lt;/span&gt;-I&lt;span class="o"&gt;{}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;uv&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;prodigy-prot&lt;span class="w"&gt; &lt;/span&gt;prodigy&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;prodigy_kds.txt
&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-e&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"name\tprodigy_kd"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;rg&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Read.+\.pdb|25.0˚C"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;prodigy_kds.txt&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;sed&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'s/.*\///'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;sed&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'s/.*25.0˚C:  //'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;paste&lt;span class="w"&gt; &lt;/span&gt;-&lt;span class="w"&gt; &lt;/span&gt;-&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;sed&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'s/\.pdb//'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;prodigy_kds.tsv
&lt;span class="c1"&gt;# run regressions&lt;/span&gt;
uv&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;scikit-learn&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;polars&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;matplotlib&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;seaborn&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;pyarrow&lt;span class="w"&gt; &lt;/span&gt;--with&lt;span class="w"&gt; &lt;/span&gt;xgboost&lt;span class="w"&gt; &lt;/span&gt;regress_adaptyv_round_2.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The results are not great!
There are a few ways to slice the data
(including replicates or not; including &lt;code&gt;similarity_check&lt;/code&gt; or not; including non-binders or not).
There is a little signal, but I think it's fair to say nothing was strongly predictive.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;table style="font-size:90%" class="table table-bordered table-hover table-condensed"&gt;
&lt;thead style="background-color:#55c9ea;font-size:110%;" &gt;
&lt;tr&gt;
&lt;th&gt;&lt;b&gt;Model&lt;/b&gt;&lt;/th&gt;
&lt;th&gt;R²&lt;/th&gt;
&lt;th&gt;RMSE (log units)&lt;/th&gt;
&lt;th&gt;Median Fold Error&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Linear Regression&lt;/b&gt;&lt;/t&gt;
&lt;td&gt;0.150&lt;/td&gt;
&lt;td&gt;0.729&lt;/td&gt;
&lt;td&gt;1.8x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Random Forest Regression&lt;/b&gt;&lt;/t&gt;
&lt;td&gt;0.188&lt;/td&gt;
&lt;td&gt;0.712&lt;/td&gt;
&lt;td&gt;1.4x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;SVM Regression&lt;/b&gt;&lt;/t&gt;
&lt;td&gt;0.022&lt;/td&gt;
&lt;td&gt;0.781&lt;/td&gt;
&lt;td&gt;1.2x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;XGBoost&lt;/b&gt;&lt;/t&gt;
&lt;td&gt;0.061&lt;/td&gt;
&lt;td&gt;0.766&lt;/td&gt;
&lt;td&gt;1.2x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;Mean Kd only&lt;/b&gt;&lt;/t&gt;
&lt;td&gt;-0.009&lt;/td&gt;
&lt;td&gt;0.794&lt;/td&gt;
&lt;td&gt;1.9x&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;img class="blogimg" src="/images/prediction_performance_kd_xgb.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;XGBoost performance looks ok here but is not much more predictive than just taking the mean Kd&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/feature_importance_kd.png" width="100%" style="max-width:1200px"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Surprisingly, no one feature dominates in terms of predictive power&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Virtual leaderboard rank vs competition rank&lt;/h3&gt;
&lt;p&gt;If there &lt;em&gt;really&lt;/em&gt; is no predictive power in these computational metrics,
there should be no correlation between rank in the virtual leaderboard and rank in the competition.
In fact, there is a weak but significant correlation (Spearman correlation ~= 0.2).
However, if you constrain to the top 200 (of 400 total), there is no correlation.
My interpretation is that these metrics can discriminate no-hope-of-binding from
some-hope-of-binding, but not more than that.&lt;/p&gt;
&lt;p&gt;It may be too much to ask one set of metrics 
to work for antibodies (poor PLL, poor PAE?), &lt;em&gt;de novo&lt;/em&gt; binders (poor PLL),
and EGF/TNFa-derived binders (natural, so excellent PLL).
However, since I include &lt;code&gt;design_models&lt;/code&gt; as a covariate,
the regression models above can use different strategies for different design types,
so at the very least we know there is not a trivial separation that can be made.&lt;/p&gt;
&lt;h2&gt;BindCraft's scoring heuristics&lt;/h2&gt;
&lt;p&gt;So how can BindCraft work if it's mostly using these same metrics as heuristics?
I asked this on twitter and got an &lt;a href="https://x.com/jadolfbr/status/1869526559910207790"&gt;interesting response&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/bindcraft_twitter.png" width="100%" style="max-width:1200px;margin-bottom:20px"/&gt;
It is possible that PyRosetta's InterfaceAnalyzer is adding a lot of information.
However, if this were the case, you might expect Prodigy's Kd prediction to also help, which it does not.
It is also possible that by using AlphaFold2, the structures produced by BindCraft
are inherently biased towards natural binding modes.
Then a part of the binding heuristics are implicit in the weights of the model?&lt;/p&gt;
&lt;h2&gt;What did we learn?&lt;/h2&gt;
&lt;p&gt;I learned a couple of things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Some tools, specifically &lt;a href="https://github.com/martinpacesa/BindCraft"&gt;BindCraft&lt;/a&gt;,
can consistently generate decent binders,
at least against targets and binding pockets present in its training set (PDB).
(The &lt;a href="https://www.biorxiv.org/content/10.1101/2024.09.30.615802v1.full#:~:text=Targeting%20proteins%20in%20non%2Dnative%20binding%20sites"&gt;BindCraft paper&lt;/a&gt;
also shows success with at least one &lt;em&gt;de novo&lt;/em&gt; protein not present in the PDB.)&lt;/li&gt;
&lt;li&gt;We do not have a way to predict if a given protein will bind a given target.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I think this is pretty interesting, and a bit counterintuitive.
More evidence that we cannot predict binding comes from the
&lt;a href="https://www.dickinsonlab.uchicago.edu/ppi-challenge"&gt;Dickinson lab's Prediction Challenges&lt;/a&gt;,
where the goal is to match the binder to the target. Apparently no approach can (yet).
&lt;br/&gt;&lt;br/&gt;
&lt;img class="blogimg" src="/images/protein_binding_dickinson.png" width="100%" style="max-width:600px;margin-bottom:25px"/&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://www.adaptyvbio.com/blog/po104"&gt;Adaptyv blogpost&lt;/a&gt;
ends by stating that binder design has not been solved yet.
This is clearly true. So what comes next?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We could find computational metrics that work, based on the current sequence and structure data.
For example, BindCraft includes "number of unsatisfied hydrogen bonds at the interface" in its heuristics.
I am skeptical that we can do a lot better with this approach.
For one thing, Adaptyv has already iterated once on its ranking metrics,
with negligible improvement in prediction.&lt;/li&gt;
&lt;li&gt;We could get better at &lt;a href="https://blog.booleanbiotech.com/md-protein-ligand"&gt;Molecular Dynamics&lt;/a&gt;,
which probably contains some useful information today (at exorbitant computational cost),
and could soon be much better with &lt;a href="https://www.nature.com/articles/s41586-024-08127-z"&gt;deep learning approaches&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;We could develop an "AlphaFold for Kd prediction".
There are certainly attempts at this,
e.g., &lt;a href="https://pubs.acs.org/doi/abs/10.1021/acs.jcim.4c01850"&gt;ProAffinity-GNN&lt;/a&gt; and the &lt;a href="https://www.nature.com/articles/s41597-024-03997-4"&gt;PPB-Affinity&lt;/a&gt; dataset to pick two recent examples,
but I don't know if anything works that well.
The big problem here, as with many biology problems, is a lack of data;
&lt;a href="http://www.pdbbind.org.cn/index.php"&gt;PDBbind&lt;/a&gt; is not that big (currently ~2800 protein–protein affinities.)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Luckily, progress in this field is bewilderingly fast so I'm sure we'll see a ton of developments in 2025.
Kudos to Adaptyv for helping push things forward.&lt;/p&gt;</content><category term="ai"/><category term="ai"/><category term="biotech"/><category term="proteindesign"/></entry><entry><title>The ABCs of Alphafold 3, Boltz and Chai-1</title><link href="/alphafold3-boltz-chai1.html" rel="alternate"/><published>2024-11-30T11:00:00-08:00</published><updated>2024-11-30T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2024-11-30:/alphafold3-boltz-chai1.html</id><summary type="html">&lt;p&gt;Comparing Alphafold 3, Boltz and Chai-1&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a href="https://www.nature.com/articles/s41586-024-07487-w"&gt;Alphafold 3&lt;/a&gt; 
(AF3) came out in May 2024,
and included several major advances over &lt;a href="https://www.nature.com/articles/s41586-021-03819-2"&gt;Alphafold 2&lt;/a&gt; (AF2).
In this post I will give a brief review of Alphafold 3,
and compare the various open and less-open AF3-inspired models that have come out over the past six months.
Finally, I will show some results from folding antibody complexes.&lt;/p&gt;
&lt;h2&gt;Alphafold 3&lt;/h2&gt;
&lt;p&gt;AF3 has many new capabilities compared to AF2:
it can work with small molecules, nucleic acids, ions, and modified residues.
It also has arguably a streamlined architecture compared to AF2
(pairformer instead of evoformer, no rotation invariance).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://310.ai/"&gt;310.ai&lt;/a&gt; did a nice &lt;a href="https://310.ai/blog/alphafold2-alphafold-multimer-alphafold3"&gt;review and small benchmark of AlphaFold3&lt;/a&gt; that is worth reading.&lt;/p&gt;
&lt;!--
AF3 performs really well on many problem types:
protein–ligand co-folding (docking),
protein–nucleic acid folding,
proteins with modified bases.
--&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/af3_graph.png" width="100%" style="max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;The AF3 paper hardly shows any data comparing AF3 to AF2,
and is mainly focused on its new capabilities working with non-amino acids.
In all cases tested, it performed as well as or exceeded state-of-the-art.
For most regular protein folding problems,
AF3 and AF2 work comparably well 
(more specifically, 
&lt;a href="https://www.biorxiv.org/content/10.1101/2021.10.04.463034v2"&gt;Alphafold-Multimer&lt;/a&gt; (AF2-M), the AF2 revision that allowed for multiple protein chains)
though for antibodies there is a jump in performance.&lt;/p&gt;
&lt;p&gt;Still, despite being an excellent model, AF3 gets relatively little discussion. This is because the parameters are not available so nobody outside DeepMind/Isomorphic Labs really uses it. The open source AF2-M still dominates, especially when used via the amazing &lt;a href="https://github.com/sokrypton/ColabFold"&gt;colabfold&lt;/a&gt; project.&lt;/p&gt;
&lt;h2&gt;Alphafold-alikes&lt;/h2&gt;
&lt;p&gt;As soon as AF3 was published, the race was on to reimplement the core ideas.
The chronology so far:&lt;/p&gt;
&lt;table style="font-size:80%" class="table table-bordered table-hover table-condensed"&gt;
&lt;thead style="background-color:#55c9ea;font-size:110%;font-color:#111;" &gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Software&lt;/th&gt;
&lt;th&gt;Code available?&lt;/th&gt;
&lt;th&gt;Parameters available?&lt;/th&gt;
&lt;th&gt;Lines of Python code&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2024-05&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/google-deepmind/alphafold3"&gt;Alphafold 3&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;❌ (CC-BY-NC-SA 4.0)&lt;/td&gt;
&lt;td&gt;❌ (you must request access)&lt;/td&gt;
&lt;td&gt;32k&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;2024-08&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/PaddlePaddle/PaddleHelix"&gt;HelixFold3&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;❌ (CC-BY-NC-SA 4.0)&lt;/td&gt;
&lt;td&gt;❌ (CC-BY-NC-SA 4.0)&lt;/td&gt;
&lt;td&gt;17k&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;2024-10&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/chaidiscovery/chai-lab"&gt;Chai-1&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;❌ (Apache 2.0, inference only)&lt;/td&gt;
&lt;td&gt;✅ (Apache 2.0)&lt;/td&gt;
&lt;td&gt;10k&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;2024-11&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/bytedance/Protenix"&gt;Protenix&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;❌ (CC-BY-NC-SA 4.0)&lt;/td&gt;
&lt;td&gt;❌ (CC-BY-NC-SA 4.0)&lt;/td&gt;
&lt;td&gt;36k&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;2024-11&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/jwohlwend/boltz"&gt;Boltz&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;✅ (MIT)&lt;/td&gt;
&lt;td&gt;✅ (MIT)&lt;/td&gt;
&lt;td&gt;17k&lt;/td&gt;
&lt;/tr&gt;

&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;There are a few other models that are not yet of interest: &lt;a href="https://github.com/Ligo-Biosciences/AlphaFold3"&gt;Ligo's AF3 implementation&lt;/a&gt; is not finished and perhaps not under active development, &lt;a href="https://github.com/lucidrains/alphafold3-pytorch"&gt;LucidRains' AF3 implementation&lt;/a&gt; is not finished but is still under active development.&lt;/p&gt;
&lt;p&gt;It's been pretty incredible to see so many reimplementation attempts within the span of a few months,
even if most are not usable due to license issues.&lt;/p&gt;
&lt;h2&gt;Code and parameter availability&lt;/h2&gt;
&lt;p&gt;As a scientist who works in industry, it's always annoying to try to figure out which tools are ok to use or not. It causes a lot of friction and wastes a lot of time. For example, I started using &lt;a href="https://www.cgl.ucsf.edu/chimerax/"&gt;ChimeraX&lt;/a&gt; a while back, only to find out after sinking many hours into it that this was not allowed. &lt;/p&gt;
&lt;p&gt;There are many definitions of "open" software. When I say open I really mean you can use it without checking with a lawyer. For example, even if you are in academia, if the license says the code is not free for commercial use, then what happens if you start a collaboration with someone in industry? What if you later want to commercialize? These are common occurrences.&lt;/p&gt;
&lt;p&gt;In some cases (AF3, HelixFold3, Protenix, and Chai-1), they make a server available, which is nice for very perfunctory testing, but precludes testing anything proprietary or folding more than a few structures.
If you have the code and the training set, it would cost around $100k to train one of these models (specifically, the Chai-1 and Protenix papers give numbers in this range, though that is just the final run). So in theory there is no huge blocker to retraining. In practice it does not seem to happen, perhaps for license issues.&lt;/p&gt;
&lt;p&gt;The specific license matters.
Before today, I thought MIT was just a more open Apache 2.0, but apparently there is an
&lt;a href="https://snyk.io/learn/apache-license/"&gt;advantage to Apache 2.0 around patents&lt;/a&gt;!
My non-expert conclusion is that
&lt;a href="https://unlicense.org/"&gt;unlicense&lt;/a&gt;,
&lt;a href="https://en.wikipedia.org/wiki/MIT_License"&gt;MIT&lt;/a&gt; and 
&lt;a href="https://en.wikipedia.org/wiki/Apache_License"&gt;Apache&lt;/a&gt; are usable,
&lt;a href="https://www.gnu.org/licenses/gpl-3.0.en.html"&gt;GPL&lt;/a&gt; and 
&lt;a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en"&gt;CC-BY-NC-SA&lt;/a&gt; are not.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/Pasted image 20241127094258.png" width="100%"  maxWidth="400px" /&gt;&lt;/p&gt;
&lt;h2&gt;Which model to choose?&lt;/h2&gt;
&lt;p&gt;There are a few key considerations: availability; extensibility / support; performance.&lt;/p&gt;
&lt;h2&gt;1. Availability&lt;/h2&gt;
&lt;p&gt;In terms of availability, I think only Chai-1 and Boltz are in contention.
The other models are not viable for any commercial work, and would only be worth considering if their capabilities were truly differentiated.
As far as I know, they are not.&lt;/p&gt;
&lt;h2&gt;2. Extensibility and support&lt;/h2&gt;
&lt;p&gt;I think this one is maybe under-appreciated.
If an open source project is truly open and gains enough mindshare,
it can attract high quality bug reports, documentation, and improvements.
Over time, this effect can compound.
I think currently Boltz is the only model that can make this claim.&lt;/p&gt;
&lt;p&gt;A big difference between Bolt and Chai-1 is that Boltz includes the training code and neural network architecture, whereas Chai-1 only includes inference code and uses pre-compiled models. I only realized this when I noticed the Chai-1 codebase is half the size of the Boltz codebase.
Most users will not retrain or finetune the model,
but the ability for others to improve the code is important.&lt;/p&gt;
&lt;p&gt;To be clear, I am grateful to Chai for making their code and weights available for commercial purposes, and I intend to use the code, but from my perspective Boltz should be able to advance much quicker.
There is maybe an analogy to Linux or Blender vs proprietary software. &lt;/p&gt;
&lt;h2&gt;3. Performance&lt;/h2&gt;
&lt;p&gt;It's quite hard to tell from the literature who has the edge in performance.
You can squint at the graphs in each paper,
but fundamentally all of these models are AF3-derivatives trained on the same data,
so it's not surprising that performance is generally very similar.
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/Pasted image 20241128072421.png" width="100%" maxWidth="400px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2024.10.10.615955v1"&gt;Chai-1 and AF3&lt;/a&gt; perform almost identically&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/boltz_graph.jpg" width="100%" maxWidth="400px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2024.11.19.624167v1"&gt;Boltz and Chai-1&lt;/a&gt; perform almost identically&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/protenix_graph.jpg" width="100%" maxWidth="400px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/bytedance/Protenix/blob/main/Protenix_Technical_Report.pdf"&gt;Protenix and AF-3&lt;/a&gt; perform almost identically&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;Benchmarking performance&lt;/h3&gt;
&lt;p&gt;I decided to do my own mini-benchmark,
by taking 10 recent (i.e., not in any training data)
antibody-containing PDB entries and folding them using Boltz and Chai-1.&lt;/p&gt;
&lt;p&gt;Both models took around 10 minutes per antibody fold on a single A100 (80GB for Boltz, 40GB for Chai-1).
Chai-1 is a little faster, which is expected since it uses ESM embeddings instead of multiple sequence alignments (MSAs). (Note, I did not test Chai-1 in MSA mode, giving it a small disadvantage compared to Boltz.)&lt;/p&gt;
&lt;p&gt;Tangentially, I was surprised I could not find a "pdb to fasta"
tool that would output protein, nucleic acids, and ligands.
Maybe we need a new file format?
You can get protein and RNA/DNA from &lt;a href="https://www.rcsb.org/"&gt;pdb&lt;/a&gt;,
but it will be the complete sequence of the protein, not the sequence in the PDB file
(this may or may not be what you want).
Extracting ligands from PDB files is actually very painful since the necessary bond information is absent!
The best code I know of to do this is a pretty buried old
&lt;a href="https://gist.github.com/PatWalters/c046fee2760e6894ed13e19b8c99193b"&gt;Pat Walters gist&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Most of the PDBs I tested were protein-only,
&lt;a href="https://www.rcsb.org/structure/9DN4"&gt;one had RNA&lt;/a&gt;,
and I skipped one &lt;a href="https://www.rcsb.org/structure/9CJ8"&gt;glycoprotein&lt;/a&gt;.
I evaluated performance using &lt;a href="https://www.nature.com/articles/s41592-022-01585-1"&gt;USalign&lt;/a&gt;,
using either the average "local" subunit-by-subunit alignment (&lt;code&gt;USalign -mm 1&lt;/code&gt;)
or one "global" all-subunit alignment (&lt;code&gt;USalign -mm 2&lt;/code&gt;).
Both models do extremely well when judged on local subunit accuracy,
but much worse for global accuracy — sadly this is quite relevant for an antibody model!
It appears that these models well understand how antibodies fold, but not how they bind.&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;On my antibody benchmark, Boltz and Chai-1 perform eerily similar,
with a couple of cases where Boltz wins out.
That, combined with all the data from the literature,
makes the conclusion straightforward, at least for me.
Boltz performs as well as or better than any of the models,
has a clean, complete codebase with relatively little code,
is hackable,
and is by far the most open model.
I am excited to see how Boltz progresses in 2025!&lt;/p&gt;
&lt;h3&gt;Technical details&lt;/h3&gt;
&lt;p&gt;I ran Boltz and Chai-1 on modal using &lt;a href="https://github.com/hgbrian/biomodals"&gt;my biomodals repo&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_boltz.py&lt;span class="w"&gt; &lt;/span&gt;--input-faa&lt;span class="w"&gt; &lt;/span&gt;8zre.fasta&lt;span class="w"&gt; &lt;/span&gt;--run-name&lt;span class="w"&gt; &lt;/span&gt;8zre
modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_chai1.py&lt;span class="w"&gt; &lt;/span&gt;--input-faa&lt;span class="w"&gt; &lt;/span&gt;8zre.fasta&lt;span class="w"&gt; &lt;/span&gt;--run-name&lt;span class="w"&gt; &lt;/span&gt;8zre
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Here is a
&lt;a href="https://drive.google.com/drive/folders/1Iq_AEh2s2ZZtoCiQ9OAY1J8EoU36d0zC?usp=sharing"&gt;folder&lt;/a&gt;
with all the pdb files and images shown below.&lt;/p&gt;
&lt;h2&gt;Addendum&lt;/h2&gt;
&lt;p&gt;On BlueSky, &lt;a href="https://bsky.app/profile/ddelalamo.bsky.social/post/3lc72bypek22a"&gt;Diego del Alamo notes&lt;/a&gt;
that Chai-1 outperformed Boltz in a head-to-head of
&lt;a href="https://x.com/chaidiscovery/status/1859025154682347569"&gt;antibody–antigen modeling&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/chai1_antibody_graph.jpg" width="100%" maxWidth="400px" /&gt;&lt;/p&gt;
&lt;p&gt;On linkedin, &lt;a href="https://www.linkedin.com/feed/update/urn:li:activity:7268771404911677440?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7268771404911677440%2C7268822817574469632%29&amp;amp;dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287268822817574469632%2Curn%3Ali%(co3Aactivity%3A7268771404911677440%29)"&gt;Joshua Meier&lt;/a&gt;
(co-founder Chai Discovery) recommended running Chai-1 with &lt;code&gt;msa_server&lt;/code&gt; turned on,
to make for a fairer comparison.
I reran the benchmark with Chai-1 using MSAs, and it showed improvements
in 8ZRE (matching Boltz) and 9E6K (exceeding Boltz.)&lt;/p&gt;
&lt;p&gt;I think it is still fair to say that the results are very close.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;table style="font-size:110%" class="table table-bordered table-hover table-condensed"&gt;
&lt;thead style="background-color:#55c9ea;font-size:110%;font-color:#111;font-weight:bold;" &gt;
&lt;tr&gt;
&lt;th width="20%"&gt;Complex&lt;/th&gt;
&lt;th width="40%"&gt;Boltz&lt;/th&gt;
&lt;th width="40%"&gt;Chai-1&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;tbody&gt;

&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9CIA"&gt;9CIA&lt;/a&gt;:
T cell receptor complex&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9cia_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9449&lt;br/&gt;RMSD: 1.5783&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.3928&lt;br/&gt;RMSD: 6.6600&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt; &lt;/table&gt;
&lt;/td&gt;

&lt;td&gt;
&lt;img class="blogimg" src="/images/9cia_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9435&lt;br/&gt;RMSD: 1.3492&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.4200&lt;br/&gt;RMSD: 5.5000&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9411&lt;br/&gt;RMSD: 1.3858&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.3980&lt;br/&gt;RMSD: 7.3400&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt; &lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/8ZRE"&gt;8ZRE&lt;/a&gt;:
HBcAg-D4 Fab complex&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/8zre_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt; TM-Score: 0.9216&lt;br/&gt; RMSD: 1.4688 &lt;/td&gt; 
&lt;td&gt;Global&lt;br/&gt; TM-Score: 0.3468&lt;br/&gt; RMSD: 6.6200 &lt;/td&gt; 
&lt;/tr&gt; &lt;/table&gt; &lt;/td&gt;

&lt;td&gt;
&lt;img class="blogimg" src="/images/8zre_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa
&lt;td&gt;Local&lt;br/&gt; TM-Score: 0.5196&lt;br/&gt; RMSD: 2.3763 &lt;/td&gt; 
&lt;td&gt;Global&lt;br/&gt; TM-Score: 0.3428&lt;br/&gt; RMSD: 6.5700&lt;/td&gt; 
--&gt;
&lt;td&gt;Local&lt;br/&gt; TM-Score: 0.9070&lt;br/&gt; RMSD: 1.4062 &lt;/td&gt; 
&lt;td&gt;Global&lt;br/&gt; TM-Score: 0.2856&lt;br/&gt; RMSD: 6.1000 &lt;/td&gt; 
&lt;/tr&gt; &lt;/table&gt; &lt;/td&gt;

&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9DF0"&gt;9DF0&lt;/a&gt;:
PDCoV S RBD bound to PD41 Fab (local refinement)
&lt;/td&gt;
&lt;/td&gt;

&lt;td&gt;
&lt;img class="blogimg" src="/images/9df0_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.8733&lt;br/&gt;RMSD: 1.1500&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.7020&lt;br/&gt;RMSD: 2.7900&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9df0_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.2958&lt;br/&gt;RMSD: 2.2767&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.7064&lt;br/&gt;RMSD: 2.4000&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.2957&lt;br/&gt;RMSD: 2.2400&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.7022&lt;br/&gt;RMSD: 2.7100&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;

&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9CLP"&gt;9CLP&lt;/a&gt;:
Structure of ecarin from the venom of Kenyan saw-scaled viper in complex with the Fab of neutralizing antibody H11&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9clp_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9762&lt;br/&gt;RMSD: 0.9667&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.6545&lt;br/&gt;RMSD: 2.3700&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9clp_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9361&lt;br/&gt;RMSD: 1.3967&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.6584&lt;br/&gt;RMSD: 3.6100&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9607&lt;br/&gt;RMSD: 1.2233&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.6675&lt;br/&gt;RMSD: 3.2100&lt;br/&gt;&lt;/td&gt;

&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9C45"&gt;9C45&lt;/a&gt;:
SARS-CoV-2 S + S2L20 (local refinement of NTD and S2L20 Fab variable region)&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9c45_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9903&lt;br/&gt;RMSD: 1.3600&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.5288&lt;br/&gt;RMSD: 4.0900&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9c45_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9887&lt;br/&gt;RMSD: 2.6533&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.5294&lt;br/&gt;RMSD: 4.3900&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9912&lt;br/&gt;RMSD: 2.7033&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.5141&lt;br/&gt;RMSD: 4.3500&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9E6K"&gt;9E6K&lt;/a&gt;:
Fully human monoclonal antibody targeting the cysteine-rich substrate-interacting region of ADAM17 on cancer cells.
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9e6k_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.7462&lt;br/&gt;RMSD: 2.4400&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.7732&lt;br/&gt;RMSD: 4.2200&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9e6k_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!--no msa
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.6833&lt;br/&gt;RMSD: 2.9200&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.7475&lt;br/&gt;RMSD: 4.6700&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9676&lt;br/&gt;RMSD: 1.3633&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.8015&lt;br/&gt;RMSD: 2.7300&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9CMI"&gt;9CMI&lt;/a&gt;:
Cryo-EM structure of human claudin-4 complex with Clostridium perfringens enterotoxin, sFab COP-1, and Nanobody&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9cmi_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9307&lt;br/&gt;RMSD: 2.1680&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.4448&lt;br/&gt;RMSD: 5.6900&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9cmi_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9245&lt;br/&gt;RMSD: 2.1100&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.4550&lt;br/&gt;RMSD: 6.0700&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9307&lt;br/&gt;RMSD: 2.3560&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.4464&lt;br/&gt;RMSD: 4.4400&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9CX3"&gt;9CX3&lt;/a&gt;:
Structure of SH3 domain of Src in complex with beta-arrestin 1&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9cx3_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.8978&lt;br/&gt;RMSD: 1.3867&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.5045&lt;br/&gt;RMSD: 2.3200&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9cx3_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.8782&lt;br/&gt;RMSD: 1.3300&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.4690&lt;br/&gt;RMSD: 3.4400&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.8916&lt;br/&gt;RMSD: 1.2617&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.4487&lt;br/&gt;RMSD: 2.6700&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9DX6"&gt;9DX6&lt;/a&gt;:
Crystal structure of Plasmodium vivax (Palo Alto) PvAMA1 in complex with human Fab 826827
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9dx6_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.7870&lt;br/&gt;RMSD: 3.1400&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.5551&lt;br/&gt;RMSD: 5.6100&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9dx6_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.2941&lt;br/&gt;RMSD: 2.9833&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.5511&lt;br/&gt;RMSD: 4.1400&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.2757&lt;br/&gt;RMSD: 2.3067&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.5861&lt;br/&gt;RMSD: 4.7600&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;


&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.rcsb.org/structure/9DN4"&gt;9DN4&lt;/a&gt;:
Crystal structure of a SARS-CoV-2 20-mer RNA in complex with FAB BL3-6S97N
.&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9dn4_boltz-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9726&lt;br/&gt;RMSD: 0.8500&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.9850&lt;br/&gt;RMSD: 0.9300&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;img class="blogimg" src="/images/9dn4_chai1-fs8.png" width="100%" /&gt;
&lt;table style="width:100%"&gt; &lt;tr&gt; 
&lt;!-- no msa
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9577&lt;br/&gt;RMSD: 1.2450&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.9707&lt;br/&gt;RMSD: 1.3100&lt;br/&gt;&lt;/td&gt;
--&gt;
&lt;td&gt;Local&lt;br/&gt;TM-Score: 0.9938&lt;br/&gt;RMSD: 0.4550&lt;br/&gt;&lt;/td&gt;
&lt;td&gt;Global&lt;br/&gt;TM-Score: 0.9957&lt;br/&gt;RMSD: 0.4900&lt;br/&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;/tbody&gt;
&lt;/table&gt;</content><category term="ai"/><category term="ai"/><category term="biotech"/><category term="proteindesign"/></entry><entry><title>The Adaptyv binder design competition</title><link href="/adaptyv-binder-design-competition.html" rel="alternate"/><published>2024-09-07T11:00:00-07:00</published><updated>2024-09-07T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2024-09-07:/adaptyv-binder-design-competition.html</id><summary type="html">&lt;p&gt;Some notes on the Adaptyv binder design competition&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a href="https://www.adaptyvbio.com/"&gt;Adaptyv&lt;/a&gt; is a newish startup that sells high-throughput protein assays.
The major innovations are
(a) they tell you the price (a big innovation for biotech services!)
(b) you only have to upload protein sequences, and you get results in a couple of weeks.&lt;/p&gt;
&lt;p&gt;A typical Adaptyv workflow might look like the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Design N protein binders for a target of interest (Adaptyv has 50-100 pre-specified targets)&lt;/li&gt;
&lt;li&gt;Submit your binder sequences to Adaptyv&lt;/li&gt;
&lt;li&gt;Adaptyv synthesizes DNA, then protein, using your sequences&lt;/li&gt;
&lt;li&gt;In ~3 weeks you get affinity measurements for each design at a cost of $149 per data-point&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is an exciting development since it decouples "design" and "evaluation" in a way
that enables computation-only startups to get one more step towards a drug (or sensor, or tool).
There are plenty of steps after this one, but it's still great progress!&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_landing.png" width="50%" /&gt;&lt;/p&gt;
&lt;h2&gt;The Adaptyv binder design competition&lt;/h2&gt;
&lt;p&gt;A couple of months ago, Adaptyv launched a binder design competition,
where the goal was to design an EGFR binder.
There was quite a lot of excitement about the competition on Twitter,
and about 100 people ended up entering.
At around the same time,
&lt;a href="https://www.leash.bio/"&gt;Leash Bio&lt;/a&gt; launched a
&lt;a href="https://www.kaggle.com/competitions/leash-BELKA"&gt;small molecule competition on Kaggle&lt;/a&gt;,
so there was something in the air.
&lt;br/&gt;&lt;br/&gt;
&lt;a href="https://x.com/julian_englert/status/1813970990147272717"&gt;
&lt;img class="blogimg" src="/images/adaptyv_twitter.jpg" width="50%" /&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;PAE and iPAE&lt;/h2&gt;
&lt;p&gt;For this competition, Adaptyv ranked designs based on the "PAE interaction" (iPAE) of the binder with EGFR.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8728224/"&gt;PAE (Predicted Aligned Error)&lt;/a&gt;
"indicates the expected positional error at residue x if the predicted and actual structures are aligned on residue y".
iPAE is the average PAE for residues in the binder vs target.
In other words, how accurate do we expect the relative positioning of binder and target to be?
This is a metric that David Baker's lab seems to use quite a bit,
at least for thresholding binders worth screening.
It is straightforward to calculate using the PAE outputs from AlphaFold.&lt;/p&gt;
&lt;p&gt;Unusually, compared to, say, a Kaggle competition,
in this competition there are no held-out data that your model is evaluated on.
Instead, if you can calculate iPAE,
you know your expected position on the leaderboard before submitting.&lt;/p&gt;
&lt;p&gt;The original paper Adaptyv reference is
&lt;a href="https://www.nature.com/articles/s41467-023-38328-5"&gt;Improving de novo protein binder design with deep learning&lt;/a&gt;
and the &lt;a href="(https://github.com/nrbennet/dl_binder_design)"&gt;associated github repo&lt;/a&gt;
has an implementation of iPAE that
&lt;a href="https://github.com/hgbrian/biomodals/blob/main/modal_alphafold.py"&gt;I use&lt;/a&gt;
(and I assume the code Adaptyv use.)&lt;/p&gt;
&lt;p&gt;Confusingly, there is also a metric called "iPAE" mentioned in the paper &lt;a href="https://www.biorxiv.org/content/10.1101/2023.08.07.552219v1.full.pdf"&gt;Systematic discovery of protein interaction interfaces using AlphaFold and experimental validation&lt;/a&gt;.
It is different, but could actually be a more appropriate metric for binders?&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_ipae_text.png" width="100%" /&gt;&lt;/p&gt;
&lt;p&gt;At the end of last month (August 2024), there was a new
&lt;a href="https://www.biorxiv.org/content/10.1101/2024.08.29.610300v2.abstract"&gt;Baker lab paper on Ras binders&lt;/a&gt; that also used iPAE,
in combination with a few other metrics like
&lt;a href="https://www.ebi.ac.uk/training/online/courses/alphafold/inputs-and-outputs/evaluating-alphafolds-predicted-structures-using-confidence-scores/plddt-understanding-local-confidence/"&gt;pLDDT&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_ras_paper.jpg" width="100%" /&gt;&lt;/p&gt;
&lt;h2&gt;Experiments&lt;/h2&gt;
&lt;p&gt;A week or so after the competition ended,
I found some time to try a few experiments.&lt;/p&gt;
&lt;p&gt;Throughout these experiments, I include &lt;a href="https://modal.com"&gt;modal&lt;/a&gt; commands to run the relevant software.
If you clone the &lt;a href="https://github.com/hgbrian/biomodals"&gt;biomodals repo&lt;/a&gt; it should just work(?)&lt;/p&gt;
&lt;h3&gt;iPAE vs Kd&lt;/h3&gt;
&lt;p&gt;The consensus seems to be that &amp;lt;10 represents a decent iPAE,
but in order for iPAE to be useful, it should correlate with some physical measurement.
As a small experiment, I took 55 PDB entries from &lt;a href="http://www.pdbbind.org.cn/"&gt;PDBbind&lt;/a&gt;
(out of ~100 binders that were &amp;lt;100 aas long, had an associated Kd, and only two chains),
ran AlphaFold, calculated iPAE, and correlated this to the known Kd.
I don't know that I really expected iPAE to correlate strongly with Kd,
but it's pretty weak.
&lt;br/&gt;&lt;br/&gt;
&lt;img class="blogimg" src="/images/adaptyv_kd_ipae_correlation.png" width="100%" style="max-width:1200px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;PDBbind Kd vs iPAE correlation&lt;/em&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# download the PDBbind protein-protein dataset in a more convenient format and run AlphaFold on one example&lt;/span&gt;
wget&lt;span class="w"&gt; &lt;/span&gt;https://gist.githubusercontent.com/hgbrian/413dbb33bd98d75cc5ee6054a9561c54/raw&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;pdbbind_pp.tsv
tail&lt;span class="w"&gt; &lt;/span&gt;-1&lt;span class="w"&gt; &lt;/span&gt;pdbbind_pp.tsv
wget&lt;span class="w"&gt; &lt;/span&gt;https://www.rcsb.org/fasta/entry/6har/display&lt;span class="w"&gt; &lt;/span&gt;-O&lt;span class="w"&gt; &lt;/span&gt;6har.fasta
&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;gt;6HAR\nYVDYKDDDDKEFEVCSEQAETGPCRACFSRWYFDVTEGKCAPFCYGGCGGNRNNFDTEEYCMAVCGSAIPRHHHHHHAAA:IVGGYTCEENSLPYQVSLNSGSHFCGGSLISEQWVVSAAHCYKTRIQVRLGEHNIKVLEGNEQFINAAKIIRHPKYNRDTLDNDIMLIKLSSPAVINARVSTISLPTAPPAAGTECLISGWGNTLSFGADYPDELKCLDAPVLTQAECKASYPGKITNSMFCVGFLEGGKDSCQRDAGGPVVCNGQLQGVVSWGHGCAWKNRPGVYTKVYNYVDWIKDTIAANS"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;6har_m.fasta
modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_alphafold.py&lt;span class="w"&gt; &lt;/span&gt;--input-fasta&lt;span class="w"&gt; &lt;/span&gt;6har_m.fasta&lt;span class="w"&gt; &lt;/span&gt;--binder-len&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;80&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Greedy search&lt;/h3&gt;
&lt;p&gt;This is about the simplest approach possible.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start with EGF (53 amino acids)&lt;/li&gt;
&lt;li&gt;Mask every amino acid, and have ESM propose the most likely amino acid&lt;/li&gt;
&lt;li&gt;Fold and calculate iPAE for the top 30 options&lt;/li&gt;
&lt;li&gt;Take the best scoring iPAE and iterate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each round takes around 5-10 minutes and costs around $4 on an A10G on modal.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# predict one masked position in EGF using esm2&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;gt;EGF\nNSDSECPLSHDGYCL&amp;lt;mask&amp;gt;DGVCMYIEALDKYACNCVVGYIGERCQYRDLKWWELR"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;esm_masked.fasta
modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_esm2_predict_masked.py&lt;span class="w"&gt; &lt;/span&gt;--input-fasta&lt;span class="w"&gt; &lt;/span&gt;esm_masked.fasta
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# run AlphaFold on the EGF/EGFR complex and calculate iPAE&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;gt;EGF\nNSDSECPLSHDGYCLHDGVCMYIEALDKYACNCVVGYIGERCQYRDLKWWELR:LEEKKVCQGTSNKLTQLGTFEDHFLSLQRMFNNCEVVLGNLEITYVQRNYDLSFLKTIQEVAGYVLIALNTVERIPLENLQIIRGNMYYENSYALAVLSNYDANKTGLKELPMRNLQEILHGAVRFSNNPALCNVESIQWRDIVSSDFLSNMSMDFQNHLGSCQKCDPSCPNGSCWGAGEENCQKLTKIICAQQCSGRCRGKSPSDCCHNQCAAGCTGPRESDCLVCRKFRDEATCKDTCPPLMLYNPTTYQMDVNPEGKYSFGATCVKKCPRNYVVTDHGSCVRACGADSYEMEEDGVRKCKKCEGPCRKVCNGIGIGEFKDSLSINATNIKHFKNCTSISGDLHILPVAFRGDSFTHTPPLDPQELDILKTVKEITGFLLIQAWPENRTDLHAFENLEIIRGRTKQHGQFSLAVVSLNITSLGLRSLKEISDGDVIISGNKNLCYANTINWKKLFGTSGQKTKIISNRGENSCKATGQVCHALCSPEGCWGPEPRDCVSCRNVSRGRECVDKCNLLEGEPREFVENSECIQCHPECLPQAMNITCTGRGPDNCIQCAHYIDGPHCVKTCPAGVMGENNTLVWKYADAGHVCHLCHPNCTYGCTGPGLEGCPTNGPKIPSI"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;egf_01.fasta
modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_alphafold.py&lt;span class="w"&gt; &lt;/span&gt;--input-fasta&lt;span class="w"&gt; &lt;/span&gt;egf_01.fasta&lt;span class="w"&gt; &lt;/span&gt;--binder-len&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;53&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;One of the stipulations of the competition is that your design must be
at least 10 amino acids different to any known binder,
so you must run the loop above 10 or more times.
Of course, there is no guarantee that there is a single amino acid
change that will improve the score, so you can easily get stuck.&lt;/p&gt;
&lt;p&gt;After 12 iteratations (at a cost of around $50 in Alphafold compute),
the best score I got was 7.89, which would have been good enough to make the top 5.
(I can't be sure, but I think my iPAE calculation is identical!)
Still, this is really just brute-forcing EGF tweaks.
I think the score was asymptoting, but there were also jumps in iPAE with certain
substitutions, so who knows?&lt;/p&gt;
&lt;p&gt;Unfortunately, though the spirit of the competition was to find novel binders,
the way iPAE works means that the best scores are very likely to
come from EGF-like sequences (or other sequences in AlphaFold's training set).&lt;/p&gt;
&lt;p&gt;Adaptyv are attempting to mitigate this issue by
(a) testing the top 200 and
(b) taking the design process into account.
It is a bit of an impossible situation,
since the true wet lab evaluation happens only after the ranking step.&lt;/p&gt;
&lt;h3&gt;Bayesian optimization&lt;/h3&gt;
&lt;p&gt;Given an expensive black box like AlphaFold + iPAE,
some samples, and a desire to find better samples,
one appropriate method is Bayesian optimization.&lt;/p&gt;
&lt;p&gt;Basically, this method allows you, in a principled way,
to control how much "exploration" of new space is appropriate (looking for global minima)
vs "exploitation" of variations on the current best solutions (optimizing local minima).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_bayes.gif" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Bayesian optimization of a 1D function&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The input to a Bayesian optimization is of course not amino acids, but numbers,
so I thought reusing the ESM embeddings would be a decent, or at least convenient, idea here.&lt;/p&gt;
&lt;p&gt;I tried both the &lt;a href="https://bayesian-optimization.github.io/BayesianOptimization/index.html"&gt;Bayesian Optimization package&lt;/a&gt;
and a
&lt;a href="https://num.pyro.ai/en/0.7.0/examples/thompson_sampling.html"&gt;numpyro Thompson sampling implementation&lt;/a&gt;.
I saw some decent results at first
(i.e., the first suggestions seemed reasonable and scored well),
but I got stuck either proposing the same sequences over and over,
or proposing sequences so diverged that testing them would be a waste of time.
The total search space is gigantic, so testing random sequences will not help.
I think probably the ESM embeddings were not helping me here,
since there were a lot of near-zeros in there.&lt;/p&gt;
&lt;p&gt;This is an interesting approach, and not too difficult to get started with,
but I think it would work better with much deeper sampling of a smaller number of amino acids,
or perhaps a cruder, less expensive, evaluation function.&lt;/p&gt;
&lt;h3&gt;ProteinMPNN&lt;/h3&gt;
&lt;p&gt;ProteinMPNN (now part of the &lt;a href="https://github.com/dauparas/LigandMPNN"&gt;LigandMPNN&lt;/a&gt; package),
maps structure to sequence (i.e., the inverse of AlphaFold).
For example, you can input an EGF PDB file,
and it will return a sequence that should produce the same fold.&lt;/p&gt;
&lt;p&gt;I found that for this task ProteinMPNN generally produced sequences with low confidence
(as reported by ProteinMPNN), and as you'd expect, these resulted in low iPAEs.
Some folds are difficult for ProteinMPNN, and I think EGF falls into this category.
To run ProteinMPNN, I would recommend &lt;a href="https://x.com/simonduerr?lang=en"&gt;Simon Duerr&lt;/a&gt;'s
&lt;a href="https://huggingface.co/spaces/simonduerr/ProteinMPNN"&gt;huggingface space&lt;/a&gt;,
since it has a friendly interface and includes an AlphaFold validation step.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_huggingface.jpg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ProteinMPNN running on huggingface&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# download a EGF/EGFR crytal structure and try to infer a new sequence that folds to chain C (EGF)&lt;/span&gt;
wget&lt;span class="w"&gt; &lt;/span&gt;https://files.rcsb.org/download/1IVO.pdb
modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_ligandmpnn.py&lt;span class="w"&gt; &lt;/span&gt;--input-pdb&lt;span class="w"&gt; &lt;/span&gt;1IVO.pdb&lt;span class="w"&gt; &lt;/span&gt;--extract-chains&lt;span class="w"&gt; &lt;/span&gt;AC&lt;span class="w"&gt; &lt;/span&gt;--params-str&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'--seed 1 --checkpoint_protein_mpnn "/LigandMPNN/model_params/proteinmpnn_v_48_020.pt" --chains_to_design "C" --save_stats 1 --batch_size 5 --number_of_batches 100'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;RFdiffusion&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://github.com/RosettaCommons/RFdiffusion"&gt;RFdiffusion&lt;/a&gt; was the
&lt;a href="https://www.nature.com/articles/s41586-023-06415-8"&gt;first protein diffusion method&lt;/a&gt;
that showed really compelling results in generating &lt;em&gt;de novo&lt;/em&gt; binders.
I would recommend &lt;a href="https://github.com/sokrypton/ColabDesign"&gt;ColabDesign&lt;/a&gt;
as a convenient interface to this and other protein design tools.&lt;/p&gt;
&lt;p&gt;The input to RFdiffusion can be a protein fold to copy, or a target protein to bind to,
and the output is a PDB file with the correct backbone co-ordinates,
but with every amino acid labeled as Glycine.
To turn this output into a sequence, this PDB file must then be fed into ProteinMPNN or similar.
Finally, that ProteinMPNN output is typically folded with AlphaFold to see if the fold matches.&lt;/p&gt;
&lt;p&gt;Although RFdiffusion massively enriches for binders over random peptides,
you still have to screen many samples to find the really strong binders.
So, it's probably optimistic to think that a few RFdiffusion-derived binders
will show strong binding, even if you can somehow get a decent iPAE.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_ras_tweet.png" width="40%" /&gt;&lt;/p&gt;
&lt;p&gt;In my brief tests with RFdiffusion here,
I could not generate anything that looked reasonable.
I think in practice,
the process of using RFdiffusion successfully is quite a bit more elaborate and heuristic-driven
than anything I was going to attempt.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_ras_figure.jpg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Figure 1 from &lt;a href="https://www.biorxiv.org/content/10.1101/2024.08.29.610300v2.full.pdf"&gt;De novo design of Ras isoform selective binders&lt;/a&gt;, showing multiple methods for running RFdiffusion&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;# Run RFdiffusion on the EGF/EGFR crystal structure, and diffuse a 50-mer binder against chain A (EGFR)&lt;/span&gt;
modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_rfdiffusion.py&lt;span class="w"&gt; &lt;/span&gt;--contigs&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'A:50'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--pdb&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"1IVO"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Other things&lt;/h3&gt;
&lt;p&gt;A few other strategies I thought might be interesting:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Search &lt;a href="https://search.foldseek.com/search"&gt;FoldSeek&lt;/a&gt; for folds similar to EGF.
The idea here is that you might find a protein in another organism that wants to bind EGFR.
I do find some interesting human-parasitic nematode proteins in here, but decided these were unlikely to be EGFR binders.&lt;/li&gt;
&lt;li&gt;Search NCBI for EGF-like sequences with &lt;a href="https://blast.ncbi.nlm.nih.gov/Blast.cgi?PAGE=Proteins"&gt;blastp&lt;/a&gt;.
You can find mouse, rat, chimp, etc. but nothing too interesting.
The iPAEs are lower than human EGF, as expected.&lt;/li&gt;
&lt;li&gt;Search the &lt;a href="https://patents.google.com/?q=(EGFR+binder)&amp;amp;oq=EGFR+binder"&gt;patent literature&lt;/a&gt; for EGFR binders. I did find some antibody-based binders, but as expected for folds that AlphaFold cannot solve, the iPAE was low. &lt;/li&gt;
&lt;li&gt;Delete regions of the protein with low iPAE contributions to increase the average score.
I really thought this would work for at least one or two amino acids, but it did not seem to. I did not do this comprehensively, but perhaps there are no truly redundant parts of this small binder?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;All the top spots on the leaderboard went to &lt;a href="https://x.com/gottapatchemall"&gt;Alex Naka&lt;/a&gt;,
who helpfully detailed his methods in this
&lt;a href="https://x.com/gottapatchemall/status/1827386015713260019"&gt;thread&lt;/a&gt;.
(A lot of this is similar to what I did above, including using modal!)
&lt;a href="https://x.com/anthonygitter"&gt;Anthony Gitter&lt;/a&gt; also published an interesting thread
on &lt;a href="https://x.com/anthonygitter/status/1827760228122738689"&gt;his attempts&lt;/a&gt;.
I find these kinds of threads are very useful since they give a sense of the tools
people are using in practice,
including some I had never heard of,
like &lt;a href="https://github.com/programmablebio/pepmlm"&gt;pepmlm&lt;/a&gt;
and &lt;a href="https://www.biorxiv.org/content/10.1101/2024.05.30.596740v1"&gt;Protrek&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Finally, I made a tree of the 200 designs that Adaptyv is
&lt;a href="https://foundry.adaptyvbio.com/egfr_design_competition"&gt;screening&lt;/a&gt;
(with iPAE &amp;lt;10 in green, &amp;lt;20 in orange, and &amp;gt;20 in red).
All the top scoring sequences are EGF-like and cluster together.
(Thanks to &lt;a href="https://x.com/andrewwhite01"&gt;Andrew White&lt;/a&gt; for pointing me at the sequence data).
We can look forward to seeing the wet lab results published in a couple of weeks.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/adaptyv_tree.svg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Tree of Adaptyv binder designs&lt;/em&gt;&lt;/p&gt;</content><category term="biotech"/><category term="biotech"/><category term="ai"/><category term="llm"/></entry><entry><title>A simple evolution simulation</title><link href="/simple-evolution-simulation.html" rel="alternate"/><published>2024-07-27T11:00:00-07:00</published><updated>2024-07-27T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2024-07-27:/simple-evolution-simulation.html</id><summary type="html">&lt;p&gt;A simulation of evolution and predator–prey dynamics&lt;/p&gt;</summary><content type="html">&lt;p&gt;This is a simple experiment in simulating evolution and predator–prey dynamics,
where the predators and prey have simple brains that learn to sense their environment.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://htmlpreview.github.io/?https://github.com/hgbrian/predator_vs_prey/blob/main/predator_vs_prey.html"&gt;Click here to start the simulation&lt;/a&gt;.
&lt;br/&gt;&lt;br/&gt;
&lt;img class="blogimg" src="/images/predators2_poster.jpg" width="100%" /&gt;&lt;/p&gt;
&lt;h2&gt;The setup&lt;/h2&gt;
&lt;p&gt;There are three types in the simulation:
one static type (food, light green),
and two microbes that can evolve (predators, red, and prey, green).&lt;/p&gt;
&lt;p&gt;Food appears spontaneously (via photosynthesis?);
prey eat food, creating progeny prey;
predators eat prey, creating progeny predators.&lt;/p&gt;
&lt;p&gt;When microbes go off the top, bottom or sides of the screen, they loop around, like Pac-Man.
Interestingly, this means their &lt;a href="https://users.monash.edu.au/~normd/documents/MATH-348-lecture-33.pdf"&gt;world is a torus&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/predators_pacman.png" width="50%" /&gt;&lt;/p&gt;
&lt;h2&gt;Evolution&lt;/h2&gt;
&lt;p&gt;Every generation, the predators and prey have a few parameters that change a bit,
according to the mutation rate:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;1 speed parameter: generally, faster leads to greater fitness&lt;/li&gt;
&lt;li&gt;8 antenna length parameters: generally, longer antennae lead to greater fitness&lt;/li&gt;
&lt;li&gt;20 neural network parameters: these are connected to their antennae and dictate their actions&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Neural network&lt;/h3&gt;
&lt;p&gt;Predators and prey each have 8 equally spaced antennae that act as sensors.
Each of the 8 antennae can sense 4 things: Empty, Food, Prey, Predator.
So the input matrix to the neural network is a simple 8x4 &lt;a href="https://en.wikipedia.org/wiki/One-hot#Machine_learning_and_statistics"&gt;one-hot matrix&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The final output I want is a length 2 vector representing 
a decision for the microbe's next direction and speed.&lt;/p&gt;
&lt;p&gt;The simplest way to convert an 8x4 matrix to a 2x1 vector
is to multiply by an 8x2 matrix, to make a 4x2 matrix,
then multiply by a 4x1 matrix to make a 2x1 matrix.
Hence, there are 16 + 4 total weights to learn.&lt;/p&gt;
&lt;p&gt;This creates a feedforward neural network with one hidden layer,
but even simpler than most because there is no thresholding or activation function.
For this application, it just seemed to work better to allow the microbes to learn their speed and direction values directly, and cap their speed after the fact if necessary.&lt;/p&gt;
&lt;p&gt;&lt;img width="60%" src="/images/predators_nn.png" /&gt;&lt;/p&gt;
&lt;h2&gt;Balance&lt;/h2&gt;
&lt;p&gt;I have played a little with simulations like this before,
and it's surprisingly difficult to keep things balanced.
A minuscule advantage can snowball and lead to an extinction event almost immediately.&lt;/p&gt;
&lt;p&gt;The main thing keeping this simulation balanced is that there is a fixed
maximum of 256 objects (food, prey, predators) at any time.
I mainly did this because it fits well with numpy code and is fast,
but it turns out to really help with keeping the simulation in equipoise.&lt;/p&gt;
&lt;p&gt;I also set "endless mode" by default, which stops predators and prey dying if it looks like they are going extinct.&lt;/p&gt;
&lt;p&gt;As the predators and prey speed up, the swings in their population sizes become greater,
and you either see the &lt;a href="https://en.wikipedia.org/wiki/Lotka%E2%80%93Volterra_equations"&gt;expected predator–prey to and fro&lt;/a&gt;
or eventually the predators and prey become too fast for the world size,
and this seems to keep the prey at a low population size.&lt;/p&gt;
&lt;h2&gt;What do they learn?&lt;/h2&gt;
&lt;p&gt;Looking at the little guys, it's natural to ascribe agency to their actions and overinterpret,
so with that caveat, the prey do seem to consistently learn a few things.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They learn to use their front antennae to brake when they touch predators (change speed)&lt;/li&gt;
&lt;li&gt;They learn to use their left and right antennae to swerve predators (change direction)&lt;/li&gt;
&lt;li&gt;They learn to keep their front antennae long and may or may not lose their back antennae&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;They predators appear to learn much less.
They can thrive if they go fast, so in general they speed up,
but their brains don't seem to help them much at all!&lt;/p&gt;
&lt;p&gt;Anecdotally, prey brains and predator neuron weights look different,
but I haven't really checked how consistent these differences are yet.&lt;/p&gt;
&lt;video autoplay loop muted playsinline poster="/images/predators1_poster.jpg" style="max-width:100%"&gt;
  &lt;source src="/images/predators1.mp4" type="video/mp4"&gt;
  Your browser does not support the video tag.
&lt;/video&gt;

&lt;p&gt;&lt;em&gt;After ~100,000 iterations, prey learn to swerve and brake&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Claude&lt;/h2&gt;
&lt;p&gt;The original code was some numpy-heavy Python,
but I decided to see if Claude 3.5 could translate that to JS/HTML.
Overall it worked very well and saved a bunch of time,
but parts of the process were still painful.
I got best results when I asked it to transliterate Python line by line.
For adding HTML stuff like the graphs, it worked better.
The simulation is relatively slow to run and could be sped up a lot at the cost of some complexity.&lt;/p&gt;
&lt;p&gt;The code is quite simple (&lt;a href="https://github.com/hgbrian/predator_vs_prey"&gt;github&lt;/a&gt;),
but the simulation has enough emergent behavior that it is pretty mesmerizing to watch.
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;video autoplay loop muted playsinline poster="/images/predators2_poster.jpg" style="max-width:100%"&gt;
  &lt;source src="/images/predators2.mp4" type="video/mp4"&gt;
  Your browser does not support the video tag.
&lt;/video&gt;

&lt;p&gt;&lt;em&gt;Top left: the main play area; Bottom left: data and graphs; Right: neural network data with one row per microbe and 20 columns representing neuron weights&lt;/em&gt;&lt;/p&gt;</content><category term="datascience"/><category term="datascience"/><category term="ai"/><category term="evolution"/></entry><entry><title>Evaluating longevity drugs with LLMs</title><link href="/evaluating-longevity-drugs-with-llms.html" rel="alternate"/><published>2024-03-31T11:00:00-07:00</published><updated>2024-03-31T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2024-03-31:/evaluating-longevity-drugs-with-llms.html</id><summary type="html">&lt;p&gt;Using LLMs to search PubMed and summarize information on longevity drugs.&lt;/p&gt;</summary><content type="html">&lt;p&gt;There is an interesting project currently running at 
&lt;a href="https://orabiomedical.com/"&gt;Ora Biomedical&lt;/a&gt;, a longevity-focused biotech,
called the &lt;a href="https://orabiomedical.com/sponsor-mmc/"&gt;Million Molecule Challenge&lt;/a&gt;.
The idea is to test as many molecules as possible in a &lt;em&gt;C. elegans&lt;/em&gt; longevity assay
to look for something better than rapamycin.
Ora claims to have already found a better MTOR inhibitor in their initial screens.&lt;/p&gt;
&lt;p&gt;Individuals can &lt;a href="https://orabiomedical.com/product/single-compound-intervention/"&gt;sponsor testing one of 2720 FDA-approved compounds for $100&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/longevity_mmc.png" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The Million Molecule Challenge&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This seemed like a good application for the LLM code from my
&lt;a href="http://blog.booleanbiotech.com/progress-towards-parsing-publications-with-llms.html"&gt;previous blogpost&lt;/a&gt;.
The idea is as follows:
for each of the 2720 compounds, search PubMed for abstracts around longevity and aging;
assess the evidence with an LLM; give each a score from 0-10.&lt;/p&gt;
&lt;h2&gt;LLM&lt;/h2&gt;
&lt;p&gt;I decided to try Claude this time instead of GPT-4, having heard good things about Claude Haiku.
Haiku is extremely inexpensive at &lt;a href="https://www.anthropic.com/api"&gt;25c per million tokens&lt;/a&gt; input.
By comparison GPT-4 is &lt;a href="https://help.openai.com/en/articles/7127956-how-much-does-gpt-4-cost"&gt;$10 per million tokens&lt;/a&gt;.
Anthropic also has the more advanced Sonnet ($3/million) and Opus ($15/million) models.&lt;/p&gt;
&lt;p&gt;I wanted to try using Haiku, 
but also run enough compounds through Sonnet and Opus to validate they all
gave approximately the same quality answers.
In practice, I ran out of Haiku tokens too quickly (my limit was 1M tokens per day, or 25c of processing!)
so I ended up using a combination of Haiku and Sonnet.&lt;/p&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;p&gt;For example, here I search PubMed for the "Acarbose" and "longevity",
have the LLM read the returned abstracts, and
the results look like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;{
&lt;span class="s2"&gt;"Summary"&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"The evidence on whether the compound acarbose has a role in longevity is mixed. There are some promising results from cell-based and animal studies, but the overall evidence is not yet conclusive. More research, especially in human subjects, would be needed to establish a clear role for acarbose in longevity."&lt;/span&gt;,
&lt;span class="s2"&gt;"Compound"&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Acarbose"&lt;/span&gt;,
&lt;span class="s2"&gt;"Evidence"&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Acarbose was identified as one of several longevity-enhancing interventions in a proteomic study of mouse tissues (Burns et al., Geroscience, 2023). Cell-based assays also found that acarbose shared clinically relevant activities with other longevity-enhancing compounds like rapamycin (Venn-Watson et al., Nutrients, 2023). However, the review paper by Elliehausen et al. (BMC Biology, 2023) suggests the relationship between acarbose and exercise for longevity is complex and requires further study."&lt;/span&gt;,
&lt;span class="s2"&gt;"Score"&lt;/span&gt;:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;To get results formatted as json,
Anthropic recommends &lt;a href="https://docs.anthropic.com/claude/docs/control-output-format"&gt;just asking for json format&lt;/a&gt;.
In general, all models did a decent job outputting valid json, though Haiku was the worst.
Sonnet did a bit better at outputting valid json, and Opus was about the same as Sonnet.
As usual, I had to do a bit of semi-manual munging with sed to fix parsing issues.&lt;/p&gt;
&lt;p&gt;(As in previous experiments, the first "Summary" entry is a chance for the LLM to think aloud and can be discarded.)&lt;/p&gt;
&lt;h2&gt;Comparing Haiku and Sonnet&lt;/h2&gt;
&lt;div&gt;
&lt;img src="/images/longevity1.png" width="45%" /&gt;
&lt;img src="/images/longevity2.png" width="45%" /&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Violin plot and histogram of differences between Sonnet and Haiku for scores &amp;gt; 0&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Haiku and Sonnet produced similar scores across the board, with Haiku scores being a little higher.
I considered doing a correction to calibrate the scores,
or allowing Opus to refine results for the highest scorers,
but decided the scores were close enough and there is no gold standard anyway.&lt;/p&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;p&gt;I put all 2720 results in a &lt;a href="https://docs.google.com/spreadsheets/d/1FRUK0-2zQ9Dop_mHdgLr8UkZuscKc_XrIUXQ0x83Ef8/edit?usp=sharing"&gt;public Google Sheet&lt;/a&gt;.
11 compounds score 9/10, 97 score 8/10, 987 score 1-7/10, and 1625 score 0/10 — 
generally those with no identified literature evidence.
Arguably the most interesting stuff will be in the unknown,
but also it may make sense to test the drugs with the most evidence as longevity drugs first.&lt;/p&gt;
&lt;table style="font-size:73%" class="table table-bordered table-hover table-condensed"&gt;
&lt;thead style="background-color:#55c9ea;font-size:110%;font-color:#111;" &gt;&lt;tr&gt;&lt;th title="Field #1"&gt;Compound&lt;/th&gt;
&lt;th title="Field #2"&gt;Score&lt;/th&gt;
&lt;th title="Field #3"&gt;Evidence&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ramipril&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;1) A study in long-lived male mice found that the combination of Ramipril (an ACE inhibitor) and simvastatin (a statin) significantly increased mean and median lifespan by 9%, while the individual therapies were ineffective (Spindler et al., Age, 2016). 2) In a mouse model of Alport syndrome, Ramipril therapy tripled the lifespan when combined with a neutralizing antibody against IL-11, compared to untreated Alport mice (Madison et al., J Pathol, 2024). 3) Another study in Alport mice showed that Ramipril alone can delay the onset of renal failure and reduce renal fibrosis (Gross et al., Kidney Int, 2003).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sarcosine&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Glycine N-methyltransferase (GNMT), which produces sarcosine from glycine, has been shown to extend lifespan in Drosophila by regulating S-adenosylmethionine (SAM) levels (Obata and Miura, Nat Commun, 2015). Sarcosine levels decline with age in rodents and humans, while dietary restriction increases sarcosine levels (Walters et al., Cell Rep, 2018). Sarcosine has been found to induce autophagy, a cellular process associated with longevity (Walters et al., Cell Rep, 2018; Johnson and Cuellar, Ageing Res Rev, 2023).
Rilmenidine Phosphate   9   Rilmenidine extends lifespan and healthspan in Caenorhabditis elegans via a nischarin I1-imidazoline receptor (Bennett et al., Aging Cell, 2023)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fulvestrant&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Periodic fasting or a fasting-mimicking diet enhances the activity of the endocrine therapeutic fulvestrant by lowering circulating IGF1, insulin and leptin and inhibiting AKT-mTOR signaling in mouse models of hormone-receptor-positive breast cancer. When combined with palbociclib, adding fasting-mimicking diet cycles promotes long-lasting tumor regression and reverts acquired drug resistance (Caffa et al., Nature, 2020).
Betulinic acid  9   Betulinic acid increased lifespan of Drosophila via Sir2 and FoxO activation (Lee and Min, Nutrients, 2024). It mitigated oxidative stress and apoptosis, enhancing longevity in yeast (Sudharshan et al., Free Radic Res, 2022). In C. elegans, it increased lifespan and stress resistance via the insulin/IGF-1 signaling pathway (Chen et al., Front Nutr, 2022).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Trametinib (GSK1120212)&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Trametinib, an allosteric inhibitor of MEK in the Ras/MAPK pathway, robustly extends lifespan and reduces age-related gut pathology in Drosophila females by decreasing Pol III activity in intestinal stem cells (Ureña et al., Proc Natl Acad Sci USA, 2024). Trametinib, along with rapamycin and lithium, acts additively to increase longevity in Drosophila by targeting components of the nutrient-sensing network (Castillo-Quan et al., Proc Natl Acad Sci USA, 2019). Trametinib reduces translation errors, and its anti-aging effects are mediated through increased translational fidelity, a mechanism shared with rapamycin and Torin1 (Martinez-Miguel et al., Cell Metab, 2021). The Ras-Erk-ETS signaling pathway is identified as a drug target for longevity, with Trametinib extending lifespan in Drosophila (Slack et al., Cell, 2015).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GDC-0941&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Ortega-Molina et al. (Cell Metab, 2015) showed that pharmacological inhibition of PI3K with GDC-0941 reduced adiposity and metabolic syndrome in obese mice and rhesus monkeys. Bharill et al. (Front Genet, 2013) demonstrated that GDC-0941 extended lifespan and increased stress tolerance in C. elegans, potentially by inhibiting the insulin-like signaling pathway.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hydralazine HCl&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Hydralazine targets cAMP-dependent protein kinase leading to SIRT1/SIRT5 activation and lifespan extension in C. elegans (Dehghan et al., Nature Communications, 2019). Hydralazine induces stress resistance and extends C. elegans lifespan by activating the NRF2/SKN-1 signaling pathway (Dehghan et al., Nature Communications, 2017). Hydralazine might produce anti-aging activity via AMPK activation and help stabilize genomic integrity to prolong life expectancy (Thanapairoje et al., Journal of Basic and Clinical Physiology and Pharmacology, 2023).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Geniposide&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;1) Treatment with Gardenia jasminoides Ellis fruit extract (GFE) rich in Geniposide increased the lifespan of C. elegans by 27.1% and improved healthspan markers like pharyngeal pumping, muscle quality, and stress resistance (Choi et al., J Gerontol A Biol Sci Med Sci, 2023). 2) Treatment with 10 mM Geniposide alone increased lifespan by 18.55% and improved healthspan markers in C. elegans (Choi et al., J Gerontol A Biol Sci Med Sci, 2023). 3) Eucommia ulmoides male flower extract (EUFE) containing Geniposide, aucubin, and asperuloside increased C. elegans lifespan by 18.61% and improved healthspan indicators like pharyngeal pumping, mobility, muscle morphology, and stress resistance (Chen et al., Food Funct, 2023).&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ivacaftor (VX-770)&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Eur Respir J. (2024) reported that Ivacaftor, in combination with other CFTR modulators, significantly improved lung function (FEV1) and increased the number of adult cystic fibrosis patients, indicating improved longevity. Curr Opin Pulm Med. (2021) highlighted the potential of the triple combination of Ivacaftor, tezacaftor, and elexacaftor to improve lung function, weight, and quality of life in a significant portion of the cystic fibrosis population. J Acad Nutr Diet. (2021) found that Ivacaftor improved weight and BMI in specific CFTR mutation groups.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hesperidin&lt;/td&gt;&lt;td&gt;9&lt;/td&gt;&lt;td&gt;Two papers in the Journal of Biomedical Sciences (Yeh et al., 2022; Shen et al., 2024) reported that hesperidin activates the CISD2 gene, which is involved in longevity and healthspan. In naturally aged mice, hesperetin treatment late in life prolonged healthspan and lifespan, ameliorated age-related metabolic decline, and rejuvenated the transcriptome. In human keratinocytes and mouse skin, hesperetin activated CISD2 and attenuated senescence in a CISD2-dependent manner. The 2024 paper in J Biomed Sci also showed that hesperetin can rejuvenate naturally aged skin in mice.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;em&gt;All results scoring 9/10&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;There are also some baffling and wrong results.
For example, the evidence for Dimethyl Fumarate, which scored 8/10 by Sonnet, clearly points in the wrong direction:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"The paper (Harrison et al., Geroscience, 2024) states: "fisetin, SG1002 (hydrogen sulfide donor), dimethyl fumarate, mycophenolic acid, and 4-phenylbutyrate do not significantly affect lifespan in either sex at the doses and schedules used." It also notes that the amounts of dimethyl fumarate in the diet averaged 35% of the target dose, which may explain the absence of lifespan effects."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Still, overall, the results are good, and the super-cheap Haiku results are indistinguishable from Sonnet.
The whole project, even using Sonnet for half, cost less than $10.
Some obvious improvements would be widening the scope of the PubMed search beyond search results that
directly mention "longevity", or allowing the LLM to read the full text of the papers.&lt;/p&gt;
&lt;p&gt;I didn't decide on an intervention to sponsor yet, if any,
but I love the crowd-funded aspect of this project,
and I hope many more such projects spring up.&lt;/p&gt;
&lt;h2&gt;Script&lt;/h2&gt;
&lt;p&gt;The script is a lightly edited variant of the code in a &lt;a href="http://blog.booleanbiotech.com/progress-towards-parsing-publications-with-llms.html"&gt;previous blogpost&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;re&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pathlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;textwrap&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dedent&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;urllib.parse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;tqdm.auto&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;anthropic&lt;/span&gt;
&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;anthropic&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Anthropic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;# os.environ["ANTHROPIC_API_KEY"] = "sk-xxx"&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gpt_out_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"claude-3-opus-20240229"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"out_opus"&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gpt_out_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"claude-3-haiku-20240307"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"out_haiku"&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gpt_out_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"claude-3-sonnet-20240229"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"out_sonnet"&lt;/span&gt;

&lt;span class="n"&gt;SEARCH_PUBMED_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&amp;amp;term=&lt;/span&gt;&lt;span class="si"&gt;{params}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;retmax=&lt;/span&gt;&lt;span class="si"&gt;{max_abstracts}{api_key_param}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;GET_ABSTRACT_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&amp;amp;id=&lt;/span&gt;&lt;span class="si"&gt;{pmid}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;retmode=text&amp;amp;rettype=abstract&lt;/span&gt;&lt;span class="si"&gt;{api_key_param}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="c1"&gt;# https://www.ncbi.nlm.nih.gov/research/bionlp/APIs/BioC-PubMed/&lt;/span&gt;
&lt;span class="n"&gt;BIOC_PMCID_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://www.ncbi.nlm.nih.gov/research/bionlp/RESTful/pmcoa.cgi/BioC_json/&lt;/span&gt;&lt;span class="si"&gt;{pmcid}&lt;/span&gt;&lt;span class="s2"&gt;/unicode"&lt;/span&gt;

&lt;span class="n"&gt;DEFAULT_MAX_ABSTRACTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;

&lt;span class="c1"&gt;# NCBI recommends that users post no more than three URL requests per second and limit large jobs&lt;/span&gt;
&lt;span class="c1"&gt;# Failure to comply with this policy may result in an IP address being blocked from accessing NCBI.&lt;/span&gt;
&lt;span class="n"&gt;NCBI_API_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""&lt;/span&gt;
&lt;span class="sd"&gt;    Recursively traverse through the JSON object (dict or list) and:&lt;/span&gt;
&lt;span class="sd"&gt;    1. Remove any node if it or any of its nested structures contains a dict with 'section_type': 'REF'.&lt;/span&gt;
&lt;span class="sd"&gt;    2. Remove any key-value pairs where the value is an empty list or empty dictionary.&lt;/span&gt;
&lt;span class="sd"&gt;    3. Remove any key-value pairs where the key is 'offset'.&lt;/span&gt;
&lt;span class="sd"&gt;    """&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Check if any value of this dict is a nested dict with 'section_type': 'REF'&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'section_type'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'REF'&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# No nested dict with 'section_type': 'REF', recursively process each key-value pair&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'offset'&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt;
                       &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;{}}&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Recursively process each item in the list&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;{}]&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Return the item as is if it's not a dict or list&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;find_keywords&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"longevity"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="s2"&gt;"age"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="s2"&gt;"aging"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compounds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_abstracts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;DEFAULT_MAX_ABSTRACTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ncbi_api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;NCBI_API_KEY&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""Download abstracts and fulltext from pubmed, generate a prompt, query OpenAI.&lt;/span&gt;
&lt;span class="sd"&gt;    """&lt;/span&gt;
    &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"downloads"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exist_ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out_dir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exist_ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;api_key_param&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;amp;api_key=&lt;/span&gt;&lt;span class="si"&gt;{ncbi_api_key}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ncbi_api_key&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;compound&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compounds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Compounds"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;leave&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;abstracts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="n"&gt;fulltexts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

        &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'(&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;compound&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;) AND ("&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;")'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;pmtxt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SEARCH_PUBMED_URL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_abstracts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;max_abstracts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
        &lt;span class="n"&gt;pmids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;Id&amp;gt;(\d+)&amp;lt;/Id&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pmtxt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;pmid&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmids&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"pmids"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;leave&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/abstract.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                &lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/abstract.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/fulltext.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                    &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/fulltext.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;

            &lt;span class="n"&gt;abstract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GET_ABSTRACT_URL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
            &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/abstract.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="n"&gt;pmcid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"^PMCID:\s+(PMC\S+)$"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MULTILINE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"there should be max one PMCID per paper"&lt;/span&gt;
            &lt;span class="n"&gt;pmcid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pmcid&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;fulltext_request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BIOC_PMCID_URL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;fulltext_request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;fulltext_json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fulltext_request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fulltext_json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/fulltext.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fulltext_json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# If there are only a couple of papers then we can include the fulltext&lt;/span&gt;
        &lt;span class="c1"&gt;# 250k characters should be well below 100k tokens; 500k characters is too many&lt;/span&gt;
        &lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;find_keywords&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;abstract_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;fulltext_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;abstract_len&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;fulltext_len&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;250_000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;abstracts_txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;abstracts_txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# clip data to the first few abstracts&lt;/span&gt;
        &lt;span class="n"&gt;abstracts_txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;abstracts_txt&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;10_000&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

        &lt;span class="n"&gt;gpt_out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;gpt_out_dir&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;compound&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;".txt"&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts_txt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1_000&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;completion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;max_tokens&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;system&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dedent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"""&lt;/span&gt;
&lt;span class="s2"&gt;                You are an autoregressive language model that has been fine-tuned with instruction-tuning and RLHF.&lt;/span&gt;
&lt;span class="s2"&gt;                You carefully provide accurate, factual, thoughtful, nuanced answers, and are brilliant at reasoning. &lt;/span&gt;
&lt;span class="s2"&gt;                If you think there might not be a correct answer, you say so. &lt;/span&gt;
&lt;span class="s2"&gt;                Your users are experts in AI and ethics, so they already know you're a language model and your capabilities and limitations, so don't remind them of that. &lt;/span&gt;
&lt;span class="s2"&gt;                They're familiar with ethical issues in general so you don't need to remind them about those either. &lt;/span&gt;
&lt;span class="s2"&gt;                Don't be verbose in your answers, but do provide details and examples where it might help the explanation.&lt;/span&gt;

&lt;span class="s2"&gt;                Your users are also experts in science, and especially biology, medicine, statistics. &lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT add any details about how science or research works, tell me to ask my doctor or consult with a health professional.&lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT add any details that such an expert would already know.&lt;/span&gt;
&lt;span class="s2"&gt;                """&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dedent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"""&lt;/span&gt;
&lt;span class="s2"&gt;                Help me research whether this compound has the role of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;compound&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;
&lt;span class="s2"&gt;                Here are the top abstracts from pubmed, and any full text that will fit in context:&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;abstracts_txt&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;

&lt;span class="s2"&gt;                Read and synthesize all the evidence from these papers.&lt;/span&gt;
&lt;span class="s2"&gt;                Prefer evidence from good journals and highly cited papers, and papers that are recent.&lt;/span&gt;
&lt;span class="s2"&gt;                If there is one standout result in a top journal like Nature, Science or Cell, focus on that.&lt;/span&gt;
&lt;span class="s2"&gt;                There should usually be one primary result and most of the evidence should depend on that.&lt;/span&gt;

&lt;span class="s2"&gt;                Include a score out of 10, where 1 would be a single paper with weak evidence,&lt;/span&gt;
&lt;span class="s2"&gt;                5 would be a mid-tier journal with a single paper with believable evidence,&lt;/span&gt;
&lt;span class="s2"&gt;                and 10 would be multiple Nature, Science or Cell papers with very strong evidence.&lt;/span&gt;
&lt;span class="s2"&gt;                A score above 7 is exceptional, implying at least the result has been replicated and is trustworthy.&lt;/span&gt;

&lt;span class="s2"&gt;                Make sure the results are valid json with fields exactly as in the examples below.&lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT change the fields, change the order, or add any other fields.&lt;/span&gt;
&lt;span class="s2"&gt;                The "Compound" json entry MUST match the query compound. Here, &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;compound&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.                &lt;/span&gt;
&lt;span class="s2"&gt;                Include AT LEAST ONE reference for each entry on evidence (unless there is no evidence), e.g., (Smith et al., Nature, 2021). ALWAYS include the journal name.&lt;/span&gt;
&lt;span class="s2"&gt;                To help you think step-by-step about your response, use the FIRST "Summary" entry to summarize the question&lt;/span&gt;
&lt;span class="s2"&gt;                and the relevant available evidence in your own words, in one hundred words or fewer.&lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT output markdown, just raw json. The first character should be &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;&lt;span class="s2"&gt; and the last character should be &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;

&lt;span class="s2"&gt;                Here are some examples of json you might output:&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;
&lt;span class="s2"&gt;                "Summary": "Aspirin has no evidence of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. The experiments are not convincing. There is some evidence for a related compound, which may indicate something."; // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Compound": "Aspirin", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Evidence": "No evidence as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. No relevant papers found.", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Score": 0 // integer from 0-10&lt;/span&gt;
&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;
&lt;span class="s2"&gt;                "Summary": "There is some evidence for Abacavir, which may indicate something. The evidence is medium, e.g. a paper in a mid-tier journal" // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Compound": "Abacavir", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Evidence": "A C. elegans screen identified Abacavir as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; with a small effect (Jones et al., Nature Cancer, 2001)", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Score": 5 // integer from 0-10&lt;/span&gt;
&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;
&lt;span class="s2"&gt;                "Summary": "Rapamycin has been cited as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; many times. The experiments are convincing. The evidence is strong: many papers including a recent Nature paper and a Science paper" // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Compound": "Rapamycin" // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Evidence": "A cell-based assay identified Rapamycin as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; in longevity (Smith et al., Science, 2022, Thomson et al., Nature, 2019)", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Score": 10 // integer from 0-10&lt;/span&gt;
&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;
&lt;span class="s2"&gt;                """&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;completion&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="c1"&gt;# just log null results&lt;/span&gt;
            &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;compounds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"compound_list_fixed.txt"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;readlines&lt;/span&gt;&lt;span class="p"&gt;()]&lt;/span&gt;
    &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;compounds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;compounds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"longevity"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="datascience"/><category term="biotech"/><category term="datascience"/><category term="ai"/><category term="llm"/></entry><entry><title>Progress towards parsing publications with LLMs</title><link href="/progress-towards-parsing-publications-with-llms.html" rel="alternate"/><published>2024-01-14T11:00:00-08:00</published><updated>2024-01-14T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2024-01-14:/progress-towards-parsing-publications-with-llms.html</id><summary type="html">&lt;p&gt;Using LLMs to search pubmed and summarize information.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I wrote about
&lt;a href="http://blog.booleanbiotech.com/gpt3-as-biotech-knowledgebase.html"&gt;querying research papers with LLMs last February&lt;/a&gt;.
Since then things have progressed a lot, with significant new LLM results seemingly every week.
However, I think it's fair to say there is still no turnkey way to
search PubMed, load a corpus of PDFs into an LLM,
query, and get good quality results.
(If I've missed something great, let me know...)&lt;/p&gt;
&lt;p&gt;There are several options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The tools I used in my &lt;a href="http://blog.booleanbiotech.com/gpt3-as-biotech-knowledgebase.html"&gt;previous article&lt;/a&gt;, &lt;a href="https://github.com/whitead/paper-qa"&gt;Paper QA&lt;/a&gt; and &lt;a href="https://github.com/run-llama/llama_index"&gt;LlamaIndex&lt;/a&gt;, can work well if you already have a corpus of papers. Indexing papers with GPT-4 can get expensive though.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;New RAG (&lt;a href="https://blogs.nvidia.com/blog/what-is-retrieval-augmented-generation/"&gt;Retrieval Augmented Generation&lt;/a&gt;) tools like &lt;a href="https://github.com/bclavie/RAGatouille"&gt;RAGatouille&lt;/a&gt; (which uses the new &lt;a href="https://medium.com/@zz1409/colbert-a-late-interaction-model-for-semantic-search-da00f052d30e"&gt;ColBERT&lt;/a&gt; model, now built into &lt;a href="https://python.langchain.com/docs/integrations/retrievers/ragatouille"&gt;LangChain&lt;/a&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;All-in-one local LLM UIs like &lt;a href="https://ai.plainenglish.io/gpt4all-the-open-source-chatgpt-alternative-for-macos-690d0adc9736"&gt;gpt4all&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Web-based scientific services like &lt;a href="https://elicit.com"&gt;elicit.org&lt;/a&gt; and &lt;a href="https://scite.ai/"&gt;scite.ai&lt;/a&gt;.
I can't tell exactly which papers these tools have access to.
scite.ai seems to be focused on "citation statements" (what?) and elicit.org on abstracts.
I imagine it is difficult for these services to get access to all full text articles.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As of January 2024,
GPT-4 still dominates all open-source models in terms of reasoning performance,
but it is expensive for larger projects,
so for now I am still exploring and comparing approaches.
(For various reasons, I could get neither RAGatouille nor gpt4all to run on my mac!)&lt;/p&gt;
&lt;h2&gt;Long context&lt;/h2&gt;
&lt;p&gt;One really useful recent development in LLMs is long context (&amp;gt;100,000 tokens, or &amp;gt;100,000 words, approximately).
A few models now have long context: &lt;a href="https://help.openai.com/en/articles/8555510-gpt-4-turbo"&gt;GPT-4 Turbo&lt;/a&gt;, &lt;a href="https://www.anthropic.com/index/100k-context-windows"&gt;Claude&lt;/a&gt;, and some open-source models like &lt;a href="https://medium.com/@lyo.gavin/exciting-update-announcing-new-anima-llm-model-100k-context-window-fully-open-source-a9f3db0fea0d"&gt;Anima&lt;/a&gt;.
By comparision, GPT-3 launched with a context length of only 2,048 tokens — barely enough to hold a few abstracts.&lt;/p&gt;
&lt;p&gt;If you are trying to use an LLM to read and analyze documents, you have two main choices:
you can fine-tune the model with additional training on a comparatively set of documents,
or you can keep the default model and provide the document text directly in context.
Perhaps surprisingly, it seems like the latter actually works fine, often better!
Long context means you can directly load hundreds of pages of text into the model's memory.
Intuitively, it does seem cleaner to keep the reasoning engine (LLM) separate from the domain knowledge (papers).&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/llm_medpalm_gpt4.png" width="50%" /&gt;
&lt;br/&gt;
&lt;em&gt;A &lt;a href="https://twitter.com/DeanCarignan/status/1744751174748922322"&gt;recent post on twitter by @DeanCarignan&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Notably, smaller contexts can &lt;a href="https://arxiv.org/abs/2310.03025"&gt;work well with RAG&lt;/a&gt;,
I assume because RAG pulls out only relevant passages,
resulting in a better signal-to-noise ratio.&lt;/p&gt;
&lt;!--
Long contexts are good news for several reasons:

- you can now have the LLM "read" entire papers, or even multiple papers, instead of small extracts found via search
- fine-tuning is more work — and even more of a black art — than asking a good model a well-structured question
- you may not need RAG if your context is long enough
--&gt;

&lt;h2&gt;Text sources&lt;/h2&gt;
&lt;p&gt;For biomedical research, there are a few sources of text:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;abstracts, available free online via &lt;a href="https://pubmed.ncbi.nlm.nih.gov/"&gt;PubMed&lt;/a&gt; and &lt;a href="https://scholar.google.com/"&gt;Google Scholar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;full text papers (PDFs, HTML or JSON), some of which are available free via &lt;a href="https://www.ncbi.nlm.nih.gov/pmc/"&gt;PubMed Central&lt;/a&gt; (more and more thanks to the &lt;a href="https://www.nih.gov/health-information/nih-clinical-research-trials-you/what-is-nih-public-access-policy"&gt;NIH Public Access Policy&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;patents, available free via &lt;a href="https://ppubs.uspto.gov/pubwebapp/static/pages/ppubsbasic.html"&gt;USPTO&lt;/a&gt; or &lt;a href="https://patents.google.com"&gt;Google Patents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;internet forums and discords.
I have not actually looked into using this, but there is definitely a lot of high quality discourse on some discords.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;BioC&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://www.ncbi.nlm.nih.gov/research/bionlp/APIs/BioC-PubMed/"&gt;BioC&lt;/a&gt; is a very useful format that is new to me.
Essentially it's an NCBI-generated structured JSON file with annotated sections for "intro", "methods", etc. &lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/llm_bioc.png" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Example BioC JSON&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;One unfortunate caveat is that I found not all PMIDs are available in BioC,
even if the paper is available,
so I have to use PMCIDs (PubMed Central publications) instead.
No idea why, but I did email them about it.&lt;/p&gt;
&lt;h2&gt;Script&lt;/h2&gt;
&lt;p&gt;So here is a simple script that uses the PubMed and OpenAI APIs to
rank a set of genes for a given "role" (e.g., ["MAP2K1", "F5"] and "cancer driver").
It searches PubMed,
reads the abstracts to figure out if the gene has the specified role,
summarizes the results in a JSON object, including a score from 0-10 that can be used for ranking.
I found this script worked pretty well for me for ranking a few hundred genes
— a task that would have been way too laborious for me to do —
and it's a nice short script.
The LLM prompt is far from optimized though, so buyer beware!&lt;/p&gt;
&lt;p&gt;The long context model (GPT-4 Turbo) means I can simply include all the abstracts (I include the first 30)
in the text of my query, and not worry about fine-tuning or RAG.
The equivalent Paper QA script would have to additionally include an indexing and retrieval step,
but could include the full text where available.&lt;/p&gt;
&lt;p&gt;It feels strange to write these LLM scripts because most of the "code" is in English.
The prompt engineering part took inspiration from &lt;a href="https://twitter.com/jeremyphoward/status/1689464587077509120"&gt;Jeremy Howard from FastAI&lt;/a&gt; and this &lt;a href="https://finedataproducts.com/posts/2023-12-31-llm-based-metaanalysis/"&gt;article from finedataproducts&lt;/a&gt;, which covers a lot of the same topics as this one, but in more depth.&lt;/p&gt;
&lt;p&gt;Note that GPT-4 Turbo is still quite expensive,
so although the results are pretty good,
if you were attempting to search for all 20,000 genes in the human proteome,
it would get expensive.
Also, since you pay per token, the longer the context you provide,
the more expensive it gets — 
proper RAG is probably a better idea for bigger projects!&lt;/p&gt;
&lt;h3&gt;Example results&lt;/h3&gt;
&lt;p&gt;Here are some results from running the script for the role "cancer driver".
Note, the Summary field is an opportunity for the LLM to think "step-by-step".
Surprisingly, the phrase "cancer driver" is not that commonly found with specific genes so some genes return no result.&lt;/p&gt;
&lt;div style="max-width:100%;overflow-x:auto;"&gt;
&lt;table style="font-size:67%;" class="table table-bordered table-hover table-condensed"&gt;
&lt;thead style="background-color:#55c9ea;font-size:110%;font-color:#111;" &gt;&lt;tr&gt;&lt;th title="Field #1"&gt;Gene&lt;/th&gt;
&lt;th title="Field #2"&gt;Cancer type&lt;/th&gt;
&lt;th title="Field #3"&gt;Evidence&lt;/th&gt;
&lt;th title="Field #4"&gt;Summary&lt;/th&gt;
&lt;th title="Field #5"&gt;Score&lt;/th&gt;
&lt;/tr&gt;&lt;/thead&gt;
&lt;tbody&gt;&lt;tr&gt;
&lt;td&gt;MAT2A&lt;/td&gt;
&lt;td&gt;Leukemia, Glioma, Gastric Cancer&lt;/td&gt;
&lt;td&gt;MAT2A acts as an oncogenic driver by supporting methionine metabolism, crucial for MLLr leukemia (Fitzel et al. Neoplasia 2023), represents a vulnerability in H3K27M mutant glioma (Golbourn et al. Nat Cancer 2022), and protects cells from ferroptosis in gastric cancer via the MAT2A-ACSL3 pathway (Ma et al. Free Radic Biol Med 2022). Additionally, androgen-regulated alternative mRNA isoforms of MAT2A are linked with prostate cancer (Munkley et al. F1000Res 2018).&lt;/td&gt;
&lt;td&gt;MAT2A is implicated in various cancers through its roles in methionine metabolism and impact on epigenetic regulation. The evidence is derived from several recent studies focusing on the gene’s role in promoting oncogenesis and tumor survival, with one study published in Nat Cancer revealing MAT2A as a vulnerability in H3K27M gliomas.&lt;/td&gt;
&lt;td align="right"&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TOP1&lt;/td&gt;
&lt;td&gt;MYC-driven cancers&lt;/td&gt;
&lt;td&gt;A genome-wide CRISPR knockout screen in isogenic pairs of breast cancer cell lines reveals that TOP1 is a synthetic lethal vulnerability in MYC-driven cancers (Lin et al. Cancer Res 2023). Inhibition of TOP1 leads to accumulation of R-loops and reduced fitness of MYC-transformed tumors in vivo, and drug response to TOP1 inhibitors significantly correlates with MYC levels across several cancer cell lines and patient-derived organoids.&lt;/td&gt;
&lt;td&gt;There is strong evidence that TOP1 has a role as a cancer driver gene in MYC-driven cancers. The experiment used a genome-wide CRISPR knockout screen to identify synthetic lethal targets for MYC, finding that TOP1 is critical for the survival of cancers with high MYC activity.&lt;/td&gt;
&lt;td align="right"&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MAP2K1&lt;/td&gt;
&lt;td&gt;Lung adenocarcinoma, head and neck squamous cancer, pilocytic astrocytoma&lt;/td&gt;
&lt;td&gt;MAP2K1 mutations are associated with resistance to osimertinib in EGFR-mutated lung adenocarcinoma (Ito et al. 2023), and its expression is integrated into the APMHO prognostic score for head and neck squamous cancer (Zeng et al. 2023). MAP2K1 fusion has also been reported to activate the MAPK pathway in pilocytic astrocytoma (Yde et al. 2016).&lt;/td&gt;
&lt;td&gt;MAP2K1 has been implicated as playing a role in cancer, with evidence pointing to its involvement in drug resistance, tumor progression, and potentially as a predictive marker. The evidence is substantial but not overwhelming.&lt;/td&gt;
&lt;td align="right"&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BIRC2&lt;/td&gt;
&lt;td&gt;Cervical cancer&lt;/td&gt;
&lt;td&gt;Chr11q BFB event leading to YAP1/BIRC2/BIRC3 gene amplification is associated with earlier age of diagnosis in cervical cancer and is more common in African American women, suggesting potential for targeted therapy (Rodriguez et al., medRxiv, 2023)&lt;/td&gt;
&lt;td&gt;BIRC2 is implicated in cervical cancer, related to BFB cycles resulting in the gene&amp;#39;s amplification. The study from a preprint provides insight into a specific amplification event on chromosome 11, which includes the BIRC2 gene.&lt;/td&gt;
&lt;td align="right"&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FANCA&lt;/td&gt;
&lt;td&gt;Potentially implicated in general carcinogenesis&lt;/td&gt;
&lt;td&gt;FANCA was identified as one of the genes with BaP-induced mutations predicted to impact protein function in post-stasis HMEC. The mutated FANCA gene is cited as a high-confidence cancer driver gene. This was observed in human mammary epithelial cells exposed to the carcinogen BaP, which is known to produce mutations typical of human lung cancers in smokers (Severson et al., Mutat Res Genet Toxicol Environ Mutagen, 2014)&lt;/td&gt;
&lt;td&gt;FANCA has evidence of a role as a cancer driver gene from a single study that analyzed molecular changes in human mammary epithelial cells after carcinogen exposure. This is an indirect functional association, not a direct clinical demonstration&lt;/td&gt;
&lt;td align="right"&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MYB&lt;/td&gt;
&lt;td&gt;Breast cancer&lt;/td&gt;
&lt;td&gt;No evidence from the provided study links MYB as a cancer driver in breast cancer (Ping et al., Scientific Reports, 2016)&lt;/td&gt;
&lt;td&gt;MYB was not identified as a cancer driver gene in the provided study. The study focused on breast cancer and MYB was not listed among the significantly associated genetic abnormalities&lt;/td&gt;
&lt;td align="right"&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;Here are some other example use-cases for this script; in my experience, pretty common types of tasks in biotech:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Analyze a set of genes and rank them by their importance in cancer metabolism, immune response, lupus, etc.&lt;/li&gt;
&lt;li&gt;Analyze a set of compounds and rank them by their toxicity, potency, etc.&lt;/li&gt;
&lt;li&gt;Analyze a set of bacterial strains and rank them by their presence in human microbiome, potential use as probiotics, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With these kinds of queries, you'll likely get reasonable results,
with the obvious candidates at the top (and perhaps a few surprises),
comparable to what you might get from an inexperienced intern with unlimited time.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;
&lt;br/&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;re&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;requests&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pathlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;textwrap&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dedent&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;time&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sleep&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;urllib.parse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;openai&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;
&lt;span class="n"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# Requires OpenAI API Key: https://openai.com/blog/openai-api&lt;/span&gt;
&lt;span class="c1"&gt;# os.environ["OPENAI_API_KEY"] = "sk-xxx"&lt;/span&gt;

&lt;span class="n"&gt;SEARCH_PUBMED_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&amp;amp;term=&lt;/span&gt;&lt;span class="si"&gt;{params}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;retmax=&lt;/span&gt;&lt;span class="si"&gt;{max_abstracts}{api_key_param}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;GET_ABSTRACT_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&amp;amp;id=&lt;/span&gt;&lt;span class="si"&gt;{pmid}&lt;/span&gt;&lt;span class="s2"&gt;&amp;amp;retmode=text&amp;amp;rettype=abstract&lt;/span&gt;&lt;span class="si"&gt;{api_key_param}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="c1"&gt;# https://www.ncbi.nlm.nih.gov/research/bionlp/APIs/BioC-PubMed/&lt;/span&gt;
&lt;span class="n"&gt;BIOC_PMCID_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://www.ncbi.nlm.nih.gov/research/bionlp/RESTful/pmcoa.cgi/BioC_json/&lt;/span&gt;&lt;span class="si"&gt;{pmcid}&lt;/span&gt;&lt;span class="s2"&gt;/unicode"&lt;/span&gt;

&lt;span class="n"&gt;DEFAULT_MAX_ABSTRACTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;

&lt;span class="c1"&gt;# NCBI recommends that users post no more than three URL requests per second and limit large jobs&lt;/span&gt;
&lt;span class="c1"&gt;# Failure to comply with this policy may result in an IP address being blocked from accessing NCBI.&lt;/span&gt;
&lt;span class="c1"&gt;# Add an API key if you want to download faster&lt;/span&gt;
&lt;span class="n"&gt;NCBI_API_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""&lt;/span&gt;
&lt;span class="sd"&gt;    Recursively traverse through the JSON object (dict or list) and:&lt;/span&gt;
&lt;span class="sd"&gt;    1. Remove any node if it or any of its nested structures contains a dict with 'section_type': 'REF'.&lt;/span&gt;
&lt;span class="sd"&gt;    2. Remove any key-value pairs where the value is an empty list or empty dictionary.&lt;/span&gt;
&lt;span class="sd"&gt;    3. Remove any key-value pairs where the key is 'offset'.&lt;/span&gt;
&lt;span class="sd"&gt;    """&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Check if any value of this dict is a nested dict with 'section_type': 'REF'&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'section_type'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'REF'&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# No nested dict with 'section_type': 'REF', recursively process each key-value pair&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'offset'&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt;
                       &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;{}}&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Recursively process each item in the list&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="p"&gt;{}]&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Return the item as is if it's not a dict or list&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;genes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_abstracts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;DEFAULT_MAX_ABSTRACTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ncbi_api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;NCBI_API_KEY&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""Download abstracts and fulltext from pubmed, generate a prompt, query OpenAI.&lt;/span&gt;
&lt;span class="sd"&gt;    """&lt;/span&gt;
    &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"downloads"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exist_ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"gpt_output"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;exist_ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;api_key_param&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;amp;api_key=&lt;/span&gt;&lt;span class="si"&gt;{ncbi_api_key}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ncbi_api_key&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;gene&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;genes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;abstracts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="n"&gt;fulltexts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

        &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'(&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;gene&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;) AND ("&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;")'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;pmtxt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SEARCH_PUBMED_URL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_abstracts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;max_abstracts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
        &lt;span class="n"&gt;pmids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;Id&amp;gt;(\d+)&amp;lt;/Id&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pmtxt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;pmid&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pmids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/abstract.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                &lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/abstract.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/fulltext.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                    &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/fulltext.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;

            &lt;span class="n"&gt;abstract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GET_ABSTRACT_URL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api_key_param&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;
            &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/abstract.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="n"&gt;pmcid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"^PMCID:\s+(PMC\S+)$"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abstract&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MULTILINE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"there should be max one PMCID per paper"&lt;/span&gt;
            &lt;span class="n"&gt;pmcid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pmcid&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;fulltext_request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BIOC_PMCID_URL&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;pmcid&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;fulltext_request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;fulltext_json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;remove_ref_blank_entries_and_offsets&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fulltext_request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
                    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fulltext_json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"downloads/fulltext.pmid_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pmid&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fulltext_json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# If there are only a couple of papers then we can include the fulltext&lt;/span&gt;
        &lt;span class="c1"&gt;# 250k characters should be well below 100k tokens; 500k characters is too many&lt;/span&gt;
        &lt;span class="n"&gt;abstract_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;fulltext_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;abstract_len&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;fulltext_len&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;250_000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;abstracts_txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fulltexts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;abstracts_txt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;gpt_out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"gpt_output/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;gene&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.txt"&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abstracts_txt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1_000&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;completion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gpt-4-1106-preview"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"system"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dedent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"""&lt;/span&gt;
&lt;span class="s2"&gt;                You are an autoregressive language model that has been fine-tuned with instruction-tuning and RLHF.&lt;/span&gt;
&lt;span class="s2"&gt;                You carefully provide accurate, factual, thoughtful, nuanced answers, and are brilliant at reasoning. &lt;/span&gt;
&lt;span class="s2"&gt;                If you think there might not be a correct answer, you say so. &lt;/span&gt;
&lt;span class="s2"&gt;                Your users are experts in AI and ethics, so they already know you're a language model and your capabilities and limitations, so don't remind them of that. &lt;/span&gt;
&lt;span class="s2"&gt;                They're familiar with ethical issues in general so you don't need to remind them about those either. &lt;/span&gt;
&lt;span class="s2"&gt;                Don't be verbose in your answers, but do provide details and examples where it might help the explanation.&lt;/span&gt;

&lt;span class="s2"&gt;                Your users are also experts in science, and especially biology, medicine, statistics. &lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT add any details about how science or research works, tell me to ask my doctor or consult with a health professional.&lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT add any details that such an expert would already know.&lt;/span&gt;
&lt;span class="s2"&gt;                """&lt;/span&gt;&lt;span class="p"&gt;)},&lt;/span&gt;
                &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dedent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"""&lt;/span&gt;
&lt;span class="s2"&gt;                Help me research whether this gene has the role of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;gene&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;
&lt;span class="s2"&gt;                Here are the top abstracts from pubmed, and any full text that will fit in context:&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;abstracts_txt&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;

&lt;span class="s2"&gt;                Read and synthesize all the evidence from these papers.&lt;/span&gt;
&lt;span class="s2"&gt;                Prefer evidence from good journals and highly cited papers, and papers that are recent.&lt;/span&gt;
&lt;span class="s2"&gt;                If there is one standout result in a top journal like Nature, Science or Cell, focus on that.&lt;/span&gt;
&lt;span class="s2"&gt;                There should usually be one primary result and most of the evidence should depend on that.&lt;/span&gt;

&lt;span class="s2"&gt;                Include a score out of 10, where 1 would be a single paper with weak evidence,&lt;/span&gt;
&lt;span class="s2"&gt;                5 would be a mid-tier journal with a single paper with believable evidence,&lt;/span&gt;
&lt;span class="s2"&gt;                and 10 would be multiple Nature, Science or Cell papers with very strong evidence.&lt;/span&gt;
&lt;span class="s2"&gt;                A score above 7 is exceptional, implying at least the result has been replicated and is trustworthy.&lt;/span&gt;

&lt;span class="s2"&gt;                Make sure the results are valid json with fields exactly as in the examples below.&lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT change the fields, change the order, or add any other fields.&lt;/span&gt;
&lt;span class="s2"&gt;                The "Gene" json entry MUST match the query gene. Here, &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;gene&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.                &lt;/span&gt;
&lt;span class="s2"&gt;                Include AT LEAST ONE reference for each entry on evidence (unless there is no evidence), e.g., (Smith et al., Nature, 2021). ALWAYS include the journal name.&lt;/span&gt;
&lt;span class="s2"&gt;                To help you think step-by-step about your response, use the FIRST "Summary" entry to summarize the question&lt;/span&gt;
&lt;span class="s2"&gt;                and the relevant available evidence in your own words, in one hundred words or fewer.&lt;/span&gt;
&lt;span class="s2"&gt;                Do NOT output markdown, just raw json. The first character should be &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;&lt;span class="s2"&gt; and the last character should be &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;

&lt;span class="s2"&gt;                Here are some examples of json you might output:&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;
&lt;span class="s2"&gt;                "Summary": "ABC1 has no evidence of &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;. The experiments are not convincing. There is some evidence for ABC2, which may indicate something."; // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Gene": "ABC1", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Cancer type": "", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Evidence": "No evidence as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Score": 0 // integer from 0-10&lt;/span&gt;
&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;
&lt;span class="s2"&gt;                "Summary": "There is some evidence for ABC2, which may indicate something. The evidence is medium, e.g. a paper in a mid-tier journal" // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Gene": "DEF2", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Cancer type": "Bladder cancer", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Evidence": "A CRISPR screen identified DEF2 as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; in bladder cancer (Jones et al., Nature Cancer, 2001)", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Score": 5 // integer from 0-10&lt;/span&gt;
&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;

&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;{{&lt;/span&gt;
&lt;span class="s2"&gt;                "Summary": "GHI3 has been cited as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; many times. The experiments are convincing. The evidence is strong: a recent Nature paper and a Science paper" // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Gene": "GHI3" // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Cancer type": "Colorectal cancer" // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Evidence": "A cell-based assay using a small molecule inhibitor identified GHI3 as &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; in colorectal cancer (Smith et al., Science, 2022, Thomson et al., Nature, 2019)", // string&lt;/span&gt;
&lt;span class="s2"&gt;                "Score": 8 // integer from 0-10&lt;/span&gt;
&lt;span class="s2"&gt;                &lt;/span&gt;&lt;span class="se"&gt;}}&lt;/span&gt;
&lt;span class="s2"&gt;                """&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;completion&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="c1"&gt;# just log null results&lt;/span&gt;
            &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gpt_out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;genes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"MAP2K1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"F5"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"cancer driver"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="datascience"/><category term="datascience"/><category term="ai"/><category term="llm"/></entry><entry><title>Using modal for bioinformatics</title><link href="/modal-for-bioinformatics.html" rel="alternate"/><published>2023-11-26T11:00:00-08:00</published><updated>2023-11-26T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2023-11-26:/modal-for-bioinformatics.html</id><summary type="html">&lt;p&gt;An example and examination of using modal for bioinformatics&lt;/p&gt;</summary><content type="html">&lt;style&gt;
.blogimg {
    width:100%;
    min-width:60%;
    max-width:800px;
}
&lt;/style&gt;

&lt;p&gt;For a long time, the dream has been to be able to test code on your laptop
and transparently scale it to infinite compute on the cloud.
There are &lt;a href="http://blog.booleanbiotech.com/biotech-data-infrastructure.html"&gt;many, many tools&lt;/a&gt;
that can help you do this, but
&lt;a href="https://modal.com/"&gt;modal&lt;/a&gt;, a new startup, comes closer to a seamless experience than anything I've used before.&lt;/p&gt;
&lt;p&gt;There is a really nice quickstart, and they even include a generous $30/month to help get your feet wet.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;modal
python3&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;modal&lt;span class="w"&gt; &lt;/span&gt;setup
git&lt;span class="w"&gt; &lt;/span&gt;clone&lt;span class="w"&gt; &lt;/span&gt;https://github.com/hgbrian/biomodals
&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;biomodals
modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;modal_omegafold.py&lt;span class="w"&gt; &lt;/span&gt;--input-fasta&lt;span class="w"&gt; &lt;/span&gt;modal_in/omegafold/insulin.fasta
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;OmegaFold&lt;/h1&gt;
&lt;p&gt;Here's an example of how to use modal to run OmegaFold. 
OmegaFold is an AlphaFold/ESMFold/ColabFold-like algorithm.
It is much easier to run than AlphaFold (which needs 2TB+ of reference data!)
and it performs well according to a &lt;a href="https://310.ai/2023/05/17/benchmarking-machine-learning-methods-for-protein-folding-a-comparative-study-of-esmfold-omegafold-and-alphafold/"&gt;recent benchmark by 310.ai&lt;/a&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;glob&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;subprocess&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pathlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;modal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Mount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Stub&lt;/span&gt;

&lt;span class="n"&gt;FORCE_BUILD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
&lt;span class="n"&gt;MODAL_IN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"./modal_in"&lt;/span&gt;
&lt;span class="n"&gt;MODAL_OUT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"./modal_out"&lt;/span&gt;

&lt;span class="n"&gt;stub&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Stub&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Image&lt;/span&gt;
         &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;debian_slim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
         &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apt_install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"git"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
         &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pip_install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"git+https://github.com/HeliXonProtein/OmegaFold.git"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;force_build&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;FORCE_BUILD&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@stub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gpu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"T4"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;600&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="n"&gt;mounts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Mount&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;from_local_dir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MODAL_IN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remote_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/in"&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;omegafold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]]:&lt;/span&gt;
    &lt;span class="n"&gt;input_fasta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MODAL_IN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"wrong input_fasta dir &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suffix&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".faa"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;".fasta"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"not fasta file &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"mkdir"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-p"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MODAL_OUT&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"omegafold"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"--model"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"/in/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MODAL_OUT&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;pdb_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdb_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;pdb_file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;MODAL_OUT&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/**/*.pdb"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;recursive&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="nd"&gt;@stub&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;local_entrypoint&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;outputs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;omegafold&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;out_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;outputs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mkdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parents&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;exist_ok&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;out_content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wb'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hopefully the code is relatively self-explanatory.
It's just Python code with code to set up the docker image,
and some decorators to tell modal how to run the code on the cloud.&lt;/p&gt;
&lt;p&gt;There are only really two important lines:
installing OmegaFold with pip:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pip_install&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"git+https://github.com/HeliXonProtein/OmegaFold.git"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;force_build&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;FORCE_BUILD&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and running OmegaFold:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"omegafold"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"--model"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"/in/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;input_fasta&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MODAL_OUT&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The rest of the code could be left unchanged and reused for many bioinformatics tools.
For example, to run minimap2 I would just add:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run_commands&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"git clone https://github.com/lh3/minimap2 &amp;amp;&amp;amp; cd minimap2 &amp;amp;&amp;amp; make"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Finally, to run the code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;modal&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="n"&gt;modal_omegafold&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;fasta&lt;/span&gt; &lt;span class="n"&gt;modal_in&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;omegafold&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;insulin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fasta&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Outputs&lt;/h1&gt;
&lt;p&gt;Modal has extremely nice, almost real-time logging and billing.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/modal_omegafold.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;CPU and GPU usage for an OmegaFold run. Note how it tracks fractional CPU/GPU use.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/modal_billing_1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Billing information for the same run, split into CPU, GPU, RAM.&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;This OmegaFold run cost me 3c and took about 3 minutes.
So if I wanted to run OmegaFold on a thousand proteins
I could probably do the whole thing for ~$100 in minutes.
(I'm not sure since my test protein is short, and I don't know how many would run in parallel.)
In theory, someone reading this article could go from never having heard of modal or OmegaFold
to folding thousands proteins in well under an hour.
That is much faster than any alternative I can think of.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Modal vs Docker&lt;/h1&gt;
&lt;p&gt;Why not just use Docker?
Docker has been around forever and you can just make a container and run it the same way!
Modal even uses Docker under the hood!&lt;/p&gt;
&lt;p&gt;There are significant differences:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dockerfiles are weird, have their own awful syntax, and are hard to debug;&lt;/li&gt;
&lt;li&gt;you have to create and manage your own images;&lt;/li&gt;
&lt;li&gt;you have to manage running your containers and collecting the output.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I have a direct equivalent to the above OmegaFold modal script that uses Docker, and it includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a Dockerfile (30 lines);&lt;/li&gt;
&lt;li&gt;a Python script (80 lines, including copying files to and from buckets);&lt;/li&gt;
&lt;li&gt;a simple bash script to build and push the image (5 lines);&lt;/li&gt;
&lt;li&gt;and finally a script to run the Dockerfile on GCP (40 lines, specifying machine types, GPUs, RAM, etc).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also, Docker can be slow to initialize, at least when I run my Docker containers on GCP.
Modal has some impressive optimizations and cacheing (which I do not understand).
I find I am rarely waiting more than a minute or two for scripts to start.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Modal vs snakemake, nextflow, etc&lt;/h1&gt;
&lt;p&gt;There is some overlap here, but in general the audience is different.
&lt;a href="https://cloud.tower.nf/"&gt;Nextflow Tower&lt;/a&gt; may be a sort-of competitor, I have not tried to use it.&lt;/p&gt;
&lt;p&gt;The advantages of these workflow systems over modal / Python scripts are mainly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;you can separate your process into many atomic steps;&lt;/li&gt;
&lt;li&gt;you can parameterize different runs and keep track of parameters;&lt;/li&gt;
&lt;li&gt;you can cache steps and restart after a failure (a major advantage of e.g., &lt;a href="https://github.com/insitro/redun"&gt;redun&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;However, for many common tasks like protein folding (OmegaFold, ColabFold),
genome assembly (SPAdes), read mapping (minimap2, bwa),
there is one major step — executing a binary —
and it's unclear if you need to package the process in a workflow.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Pricing&lt;/h1&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/modal_pricing.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Modal is priced per second so you don't pay for more than you use.&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Modal runs (transparently) on AWS, GCP, and Oracle.
&lt;a href="https://fikisipi.substack.com/p/doing-cheap-pytorch-inference-with"&gt;Another blogpost&lt;/a&gt;
claims that Modal adds around a 12% margin.
However, since Modal charges per cycle, I think it's possible you could end up saving quite a bit of money?
If you run your own Docker image on a VM, you may end up paying a lot for idle time;
for example, if your GPU is utilized for a fraction of the time (as with AlphaFold).
It's very unclear to me how modal makes this work (or if I am misunderstanding something),
but it's really nice to not have to worry about maximizing utilization.&lt;/p&gt;
&lt;p&gt;One challenge with modal — and all cloud compute — for bioinformatics
is having to push large files around (e.g., TB of sequencing reads).
If you want to do that efficiently you may have to look into the
&lt;a href="https://modal.com/docs/guide/volumes"&gt;modal's Volumes feature&lt;/a&gt;
so larger files only get uploaded once.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Not too long ago, I felt I had to do almost everything on a linux server,
since my laptop did not have enough RAM, or any kind of GPU.
Now with the M-series MacBook Pros, you get a GPU and as much RAM as high end server (128GB!)
I still need access to hundreds of cores and powerful GPUs, but only for defined jobs.&lt;/p&gt;
&lt;p&gt;I am pretty excited about modal's vision of "serverless" compute.
I think it's a big step forward in how to manage compute.
Their &lt;a href="https://modal.com/docs/examples/slack-finetune"&gt;many examples&lt;/a&gt; are illustrative.
Never having to think about VMs or even having to choose a cloud is a big deal,
especially these days when GPUs are so hard to find (rumor has it Oracle has spare A100's, etc!)
Although it's an early startup, there is almost no lock-in with modal since everything is just decorated Python.&lt;/p&gt;
&lt;p&gt;I made a basic &lt;a href="https://github.com/hgbrian/biomodals"&gt;biomodals repo&lt;/a&gt; and added some examples.&lt;/p&gt;</content><category term="datascience"/><category term="datascience"/><category term="modal"/><category term="workflow"/><category term="machine learning"/><category term="ai"/></entry><entry><title>A simple way to simulate protein–ligand interactions (that does not work)</title><link href="/md-protein-ligand.html" rel="alternate"/><published>2023-09-04T11:00:00-07:00</published><updated>2023-09-04T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2023-09-04:/md-protein-ligand.html</id><summary type="html">&lt;p&gt;Molecular dynamics code for protein–ligand interactions&lt;/p&gt;</summary><content type="html">&lt;style&gt;
.blogimg {
    width:100%;
    min-width:60%;
    max-width:800px;
}
&lt;/style&gt;

&lt;!-------------------------------------------------------------------------------------------------

Intro

--------------------------------------------------------------------------------------------------&gt;

&lt;p&gt;Molecular dynamics (MD) means simulating the forces acting on atoms.
In drug discovery, MD usually means simulating protein–ligand interactions.
This is clearly a crucial step in modern drug discovery,
yet MD remains a pretty arcane corner of computational science.&lt;/p&gt;
&lt;p&gt;This is a different problem to docking,
where molecules are for the most part treated as rigid,
and the problem is finding the right ligand orientation and the right pocket.
Since in MD simulations the atoms can move,
there are many more degrees of freedom,
and so a lot more computation is required.
For a great primer on this topic, see
&lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6209097/"&gt;Molecular dynamics simulation for all (Hollingsworth, 2018)&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;What about deep learning?&lt;/h2&gt;
&lt;p&gt;Quantum chemical calculations, though accurate, are too computationally expensive to use for MD simulation.
Instead, "force fields" are used, which enable computationally efficient calculation of the major forces.
As &lt;a href="https://www.deep-mind.org/2023/03/26/the-universal-approximation-theorem/#Universal_Approximation_Theorem"&gt;universal function approximators&lt;/a&gt;,
deep nets are potentially a good way to get closer to ground truth.&lt;/p&gt;
&lt;p&gt;Analogously, fluid mechanics calculations are very computationally expensive,
but deep nets appear to do a good job of
&lt;a href="https://www.technologyreview.com/2020/10/30/1011435/ai-fourier-neural-network-cracks-navier-stokes-and-partial-differential-equations/"&gt;approximating these expensive functions&lt;/a&gt;.&lt;/p&gt;
&lt;!--AlphaFold2 could even be characterized as learning to approximate the folding process.--&gt;

&lt;p&gt;&lt;img class="blogimg" src="/images/md_navier_stokes.gif" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A deep net approximating Navier-Stokes&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Recently, the &lt;a href="https://www.nature.com/articles/s41597-022-01882-6"&gt;SPICE dataset (Eastman, 2023)&lt;/a&gt;
was published, which is a reference dataset that can be used to train deep nets for MD.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We describe the SPICE dataset, a new quantum chemistry dataset for training potentials relevant to simulating drug-like small molecules interacting with proteins. It contains over 1.1 million conformations for a diverse set of small molecules, dimers, dipeptides, and solvated amino acids.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This dataset has enabled new ML force fields like &lt;a href="https://arxiv.org/abs/2307.07085"&gt;Espaloma (Takaba, 2023)&lt;/a&gt;
and the recent &lt;a href="https://arxiv.org/pdf/2304.10061.pdf"&gt;Allegro paper (Musaelian, 2023)&lt;/a&gt;,
where they simulated a 44 million atom system of a HIV capsid.
Interestingly, they scaled their system as high as 5120 A100's (which would cost $10k an hour to run!)&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_allegro.jpg" style="max-width:1000px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;There are also 
&lt;a href="https://www.biorxiv.org/content/10.1101/2020.07.29.227959v1.full"&gt;hybrid ML/MM approaches (Rufa, 2020)&lt;/a&gt;
based on the &lt;a href="https://pubs.acs.org/doi/10.1021/acs.jctc.0c00121"&gt;ANI2x ML force field (Devereux, 2020)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;All of this work is very recent, and as I understand it,
runs too slowly to replace regular force fields any time soon.
Despite MD being a key step in drug development,
only a small number of labs (e.g., &lt;a href="https://www.choderalab.org/"&gt;Chodera lab&lt;/a&gt;)
appear to work on &lt;a href="https://openmm.org/"&gt;OpenMM&lt;/a&gt;, &lt;a href="https://openforcefield.org/"&gt;OpenFF&lt;/a&gt;,
and the other core technologies here.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Doing an MD simulation&lt;/h1&gt;
&lt;p&gt;I have only a couple of use-cases in mind:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;does this ligand bind this protein in a human cell?&lt;/li&gt;
&lt;li&gt;does this mutation affect ligand binding in a human cell?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Doing these MD simulations is tricky since a lot of background is expected of the user.
There are many parameter choices to be made, and sensible options are not obvious.
For example, you may need to choose force fields, ion concentrations, temperature, timesteps, and more.&lt;/p&gt;
&lt;p&gt;By comparison, with AlphaFold you don't need to know how many recycles to run,
or specify how the relaxation step works.
You can just paste in a sequence and get a structure.
As far as I can tell, there is no equivalent "default" for MD simulations.&lt;/p&gt;
&lt;p&gt;A lot of MD tutorials I have found are geared towards simulating the trajectory of a system for inspection.
However, with no specific numerical output, I don't know what to do with these results.&lt;/p&gt;
&lt;h2&gt;Choosing an approach&lt;/h2&gt;
&lt;p&gt;There are several MD tools out there for doing protein–ligand simulations,
and calculating binding affinities:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.schrodinger.com/"&gt;Schrodinger&lt;/a&gt; is the main player in computational drug discovery,
and a mature suite of tools.
It's not really suitable for me, since it's expensive, geared toward chemists,
designed for interactive use over scripting, and not even necessarily cutting-edge.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.eyesopen.com/"&gt;OpenEye&lt;/a&gt; also appears to be used a lot, and has close ties to open-source.
Like Schrodinger, the tools are high quality, mostly interactive and designed for chemists.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://software.acellera.com/htmd/index.html"&gt;HTMD&lt;/a&gt; from Acellera is not open-source,
but it has a nice quickstart and
&lt;a href="https://software.acellera.com/htmd/tutorials/system-building-protein-ligand.html"&gt;tutorials&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gromacs.org/"&gt;GROMACS&lt;/a&gt; is open-source, actively maintained, and has &lt;a href="https://tutorials.gromacs.org/free-energy-of-solvation.html"&gt;tutorials&lt;/a&gt;,
but is still a bit &lt;a href="https://tutorials.gromacs.org/docs/md-intro-tutorial.html"&gt;overwhelming&lt;/a&gt;
with a lot of boilerplate.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ambermd.org/index.php"&gt;Amber&lt;/a&gt;, like GROMACS, has been around for decades.
It gets plenty of use (e.g., AlphaFold uses it as a final "relaxation" step),
but is not especially &lt;a href="https://ambermd.org/tutorials/"&gt;user-friendly&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://openmm.org/"&gt;OpenMM&lt;/a&gt; seems to be where most of the open-source effort has been over the past
five years or so, and is the &lt;em&gt;de facto&lt;/em&gt; interface for a lot of the recent ML work in MD
(e.g., Espaloma). A lot of tools are built on top or OpenMM:&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/choderalab/yank"&gt;yank&lt;/a&gt; is a tool for free energy binding calculations.
  Simulations are parameterized by a &lt;a href="https://github.com/choderalab/yank/blob/master/docs/examples/host-guest-implicit.rst"&gt;yaml file&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/choderalab/perses"&gt;perses&lt;/a&gt; is also used for free energy calculation. It is pre-alpha software but under active development — e.g., this &lt;a href="https://www.biorxiv.org/content/10.1101/2023.03.07.530278v1"&gt;recent paper on protein–protein interaction&lt;/a&gt;. (Note, I will not claim to understand the differences between yank and perses!)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/seekrcentral/seekr2"&gt;SEEKR2&lt;/a&gt; is a tool that enables free energy calculation, among other things.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pablo-arantes/making-it-rain"&gt;Making it rain&lt;/a&gt; is a suite of tools and colabs.
  It is a very well organized repo that guides you through running simulations on the cloud.
  For example, they include a &lt;a href="https://colab.research.google.com/github/pablo-arantes/making-it-rain/blob/main/Protein_ligand.ipynb"&gt;friendly colab&lt;/a&gt; to run protein–ligand simulations.
  The authors did a great job and I'd recommend this repo broadly.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/GHeinzelmann/BAT.py"&gt;BAT&lt;/a&gt;, the Binding Affinity Tool, calculates binding affinity using MD (also see the related &lt;a href="https://github.com/GHeinzelmann/GHOAT.py"&gt;GHOAT&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_openmm_quickstart.png" style="max-width:800px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;OpenMM quickstart for protein simulation&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Since I am not a chemist, I am really looking for a system with reasonable defaults
for typical drug development scenarios.
I found a nice &lt;a href="https://github.com/tdudgeon/simple-simulate-complex"&gt;repo by tdudgeon&lt;/a&gt;
that appears to have the same goal.
It uses OpenMM, and importantly has
&lt;a href="https://github.com/openmm/openmm/issues/2688"&gt;input from experts&lt;/a&gt;
on parameters and settings.
For example, I'm not sure I would have guessed you can multiply the mass of &lt;a href="http://docs.openmm.org/latest/userguide/application/02_running_sims.html"&gt;Hydrogen by 4&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;This keeps their total mass constant while slowing down the fast motions of hydrogens. When combined with constraints (typically constraints=AllBonds), this often allows a further increase in integration step size.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I &lt;a href="https://github.com/hgbrian/MD_protein_ligand"&gt;forked the repo&lt;/a&gt;,
with the idea that I could keep the simulation parameters intact
but change the interface a bit to make it focused on the problems I am interested in.&lt;/p&gt;
&lt;h2&gt;Calculating affinity&lt;/h2&gt;
&lt;p&gt;I am interested in calculating ligand–protein affinity (or binding free energy) —
in other words, how well does the ligand bind the protein.
There's a lot here I do not understand, but here is my basic understanding of how to calculate affinity:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Using MD:&lt;/strong&gt; This is the most accurate way to measure affinity, but the techniques are challenging.
There are "end-point" approaches (e.g., &lt;a href="https://pubs.acs.org/doi/10.1021/ct300418h"&gt;MM/PBSA&lt;/a&gt;) and &lt;a href="https://pubs.acs.org/doi/10.1021/acs.jctc.1c00194"&gt;Free Energy Perturbation (FEP)&lt;/a&gt; / alchemical approaches.
Alchemical free energy approaches are more accurate, and have been
&lt;a href="https://www.biorxiv.org/content/10.1101/2020.07.29.227959v1.full.pdf"&gt;widely used for years&lt;/a&gt;.
(I believe Schrodinger were the first to show accurate results
&lt;a href="https://pubmed.ncbi.nlm.nih.gov/25625324/"&gt;(Wang, 2015)&lt;/a&gt;.) 
Still, I found it difficult to figure out a straightforward way to do these calculations.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Using a scoring function:&lt;/strong&gt; This is how most docking programs like vina or gnina work.
Docking requires a very fast, but precise, score to optimize.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Using a deep net:&lt;/strong&gt; Recently, several deep nets trained to predict affinity have been published. 
For example, &lt;a href="https://pubs.acs.org/doi/10.1021/acs.jcim.3c00251"&gt;HAC-Net&lt;/a&gt;
is a CNN trained on PDBbind.
This is a very direct way to estimate binding affinity,
and should be accurate if there is enough training data.
&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;
&lt;img class="blogimg" src="/images/md_sqm.png" style="max-width:400px" /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;The SQM/COSMO docking scoring function &lt;a href="https://pubs.acs.org/doi/10.1021/acsomega.7b00503"&gt;(Ajani, 2017)&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Unfortunately, I do know know of a benchmark comparing all the above approaches,
so I just tried out a few things.
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Predicting cancer drug resistance&lt;/h1&gt;
&lt;p&gt;One interesting but tractable problem is figuring out if a mutation in a protein will affect ligand binding.
For example, let's say we sequence a cancer genome, and see a mutation in a drug target,
do we expect that drug will still bind?&lt;/p&gt;
&lt;p&gt;There are many examples of resistance mutations evolving in cancer.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_cancer_resistance.png" style="max-width:1000px" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Common cancer resistance mutations &lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7226513/"&gt;(Hamid, 2020)&lt;/a&gt;&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h2&gt;Experiments&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/V600E"&gt;BRAF V600E&lt;/a&gt; is a famous cancer target.
Vemurafenib is a drug that targets V600E, and L505H is known to be a resistance mutation.
There is a crystal structure of &lt;a href="https://www.rcsb.org/structure/3og7"&gt;BRAF V600E bound to Vemurafenib (PDB:3OG7)&lt;/a&gt;.
Can I see any evidence of reduced binding of Vemurafenib if I introduce an L505H mutation?&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_3OG7_pymol.jpg" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;PDB:3OG7, showing the distance between vemurafenib (cyan) and L505 (yellow)&lt;/em&gt;
&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;I ran a simple simulation:
starting with the crystal structure, introduce each possible mutation at position 505,
allow the protein–ligand system to relax,
and check to see if the new protein–ligand interactions
are less favorable according to some measure of affinity.&lt;/p&gt;
&lt;p&gt;I first used gnina's scoring function, which is fast and should be relatively precise (in order for gnina to work!)
The rationale here was that the "obstruction" due to the resistance mutation would be detectable
as the new atom positions of the amino acid and ligand would lead to a lower affinity.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_3OG7.png" width="50%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Estimated affinity given mutations at position 505 in 3OG7&lt;/em&gt;
&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Nope. The resistance mutation has higher affinity
(realistically, there are no distinguishable differences for any mutation).&lt;/p&gt;
&lt;p&gt;We also know that MEK1 V215E acts as a resistance mutation to PD0325901,
and the PDB has a crystal structure of
&lt;a href="https://www.rcsb.org/structure/7M0X"&gt;MEK1 bound to PD0325901 (PDB:70MX)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_70MX.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Estimated affinity given mutations at position 215 in 70MX&lt;/em&gt;
&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;Again, I can't detect any difference in affinity due to the resistance mutation.&lt;/p&gt;
&lt;h3&gt;HAC-Net&lt;/h3&gt;
&lt;p&gt;I also tried a deep-learning based affinity calculator, HAC-Net.
HAC-Net has a nice &lt;a href="https://colab.research.google.com/github/gregory-kyro/HAC-Net/blob/main/HACNet.ipynb"&gt;colab&lt;/a&gt;
and is relatively easy to run Dockerized.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_3og7_hacnet_colab.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The HAC-Net colab gives me a pKd of 8.873 for 3OG7 (wild-type)&lt;/em&gt;
&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/md_3OG7_HACNet.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Estimated pKd given mutations at position 505 in 3OG7 using HAC-Net&lt;/em&gt;
&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;I still see no difference in affinity with HAC-Net.&lt;/p&gt;
&lt;p&gt;Each of these simulations (relaxing a protein–ligand system with solvent present)
took a few minutes on a single CPU.
If I wanted to simulate a full trajectory, which could be 50 nanoseconds or longer,
it would take hundreds or thousands of times as long.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Conclusions&lt;/h1&gt;
&lt;p&gt;On the one hand, I can run state-of-the-art MD simulations pretty easily with this system.
On the other hand, I could not discriminate cancer resistance mutations from neutral mutations.&lt;/p&gt;
&lt;p&gt;There are several possible reasons.
Most likely, the short relaxation I am doing is insufficient and I need longer simulations.
The simulations may also be insufficiently accurate, either intrinsically or due to poor parameterization.
It's difficult to feel confident in these kinds of simulations,
since there's no simple way to verify anything.&lt;/p&gt;
&lt;p&gt;If anyone knows of any obvious fix for the approach here, let me know!
Probably the next thing I would try would be adapting the
&lt;a href="https://colab.research.google.com/github/pablo-arantes/making-it-rain/blob/main/Protein_ligand.ipynb"&gt;Making It Rain&lt;/a&gt; tools,
which include (non-alchemical) free energy calculation. 
For some reason the Making It Rain colab specifies
"This notebook is NOT a standard protocol for MD simulations!
It is just simple MD pipeline illustrating each step of a simulation protocol."
which begs the questions, why not and where is such a notebook?&lt;/p&gt;
&lt;p&gt;I do think that enabling anyone to run such simulations
— specifically, with default parameters blessed by experts for common use-cases —
would be a very good thing.&lt;/p&gt;
&lt;p&gt;There are already several cancer drug selection companies like &lt;a href="https://oncobox.com/materials/obx_sample_report_en.pdf"&gt;Oncobox&lt;/a&gt;, 
so maybe there should be a company doing this kind of MD for predicting cancer resistance.
Maybe there is and I just have not heard of it?&lt;/p&gt;
&lt;h2&gt;Addendum: modal labs&lt;/h2&gt;
&lt;p&gt;I have been experimenting with &lt;a href="https://modal.com/"&gt;modal labs&lt;/a&gt; for running code like this,
where there are very specific environment requirements (i.e., painful to install libraries)
and heavy CPU/GPU load.
Previously, I would have used Docker, which is fundamentally awkward,
and still requires manually provisioning compute.
Modal can be a &lt;a href="https://twitter.com/btnaughton/status/1691527757921198080"&gt;joy to use&lt;/a&gt;
and I'll probably write up a separate blogpost on it.&lt;/p&gt;
&lt;p&gt;To do your own simulation (bearing in mind all the failed experiments above!),
you can either use my &lt;a href="https://colab.research.google.com/github/hgbrian/biocolabs/blob/master/MD_protein_ligand.ipynb"&gt;MD_protein_ligand colab&lt;/a&gt;
or if you have a modal account, clone the &lt;a href="https://github.com/hgbrian/MD_protein_ligand"&gt;MD_protein_ligand repo&lt;/a&gt;
and run&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mkdir&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;input&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;modal&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;run_simulation_modal.py&lt;span class="w"&gt; &lt;/span&gt;--pdb-id&lt;span class="w"&gt; &lt;/span&gt;3OG7&lt;span class="w"&gt; &lt;/span&gt;--ligand-id&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;032&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--ligand-chain&lt;span class="w"&gt; &lt;/span&gt;A
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This basic simulation (including solvent) should cost around 10c on modal.
That means we could relax all
&lt;a href="http://www.pdbbind.org.cn/download/pdbbind_2020_intro.pdf"&gt;5000 protein–ligand complexes in the PDB&lt;/a&gt;
for around $500, perhaps in just a day or two (depending on how many machines modal allows in parallel).
I'm not sure if there's any point to that, but pretty cool that things can scale up so easily these days!&lt;/p&gt;
&lt;!--
# Plot
import io
import numpy as np
import pandas as pd
import seaborn as sns

from matplotlib import pyplot as plt
%config InlineBackend.figure_formats = ['retina', 'svg']

data = """
70MX VAL 211 ALA -8.6272
70MX VAL 211 ARG -8.4621
70MX VAL 211 ASN -8.1769
70MX VAL 211 ASP -8.6157
70MX VAL 211 CYS -8.4681
70MX VAL 211 GLN -8.7507
70MX VAL 211 GLU -8.3820
70MX VAL 211 GLY -8.6018
70MX VAL 211 HIS -8.6542
70MX VAL 211 ILE -8.8038
70MX VAL 211 LEU -8.4474
70MX VAL 211 LYS -8.1814
70MX VAL 211 MET -8.1044
70MX VAL 211 PHE -8.3340
70MX VAL 211 PRO -8.4526
70MX VAL 211 SER -8.7002
70MX VAL 211 THR -8.6477
70MX VAL 211 TRP -8.2937
70MX VAL 211 TYR -7.9141
70MX VAL 211 VAL -8.7205
3OG7 LEU 505 ALA -10.4426
3OG7 LEU 505 ARG -10.6635
3OG7 LEU 505 ASN -10.9827
3OG7 LEU 505 ASP -11.0866
3OG7 LEU 505 CYS -10.4699
3OG7 LEU 505 GLN -10.6861
3OG7 LEU 505 GLU -10.6732
3OG7 LEU 505 GLY -10.5070
3OG7 LEU 505 HIS -11.1227
3OG7 LEU 505 ILE -10.8774
3OG7 LEU 505 LEU -10.8205
3OG7 LEU 505 LYS -11.0363
3OG7 LEU 505 MET -10.6005
3OG7 LEU 505 PHE -12.1097
3OG7 LEU 505 PRO -10.8538
3OG7 LEU 505 SER -10.4651
3OG7 LEU 505 THR -10.6024
3OG7 LEU 505 TRP -10.5765
3OG7 LEU 505 TYR -11.5313
3OG7 LEU 505 VAL -10.7121
"""

df = pd.read_csv(io.StringIO(data), names=["pdb", "from_aa", "resn", "mutation", "affinity"], sep=' ')

f, ax = plt.subplots(figsize=(12,5))
g = sns.barplot(data=df.loc[lambda df: df.pdb == "70MX"].assign(affinity = lambda df: -df.affinity), x="mutation", y="affinity")
for bar in g.patches: bar.set_color('#aaaaaa')
g.patches[19].set_color('#77aaff') # 10th bar
g.patches[6].set_color('#ffaa99')  # 8th bar
ax.annotate("wild-type", (18.9, 7.2), rotation=90);
ax.annotate("resistance", (5.9, 7.2), rotation=90);
ax.set_title("70MX");
ax.set_ylim(7, 10);

f, ax = plt.subplots(figsize=(12,5))
g = sns.barplot(data=df.loc[lambda df: df.pdb == "3OG7"].assign(affinity = lambda df: -df.affinity), x="mutation", y="affinity")
# Color all bars grey
for bar in g.patches: bar.set_color('#aaaaaa')
g.patches[10].set_color('#77aaff') # 10th bar
g.patches[8].set_color('#ffaa99')  # 8th bar

ax.annotate("wild-type", (9.9, 10.2), rotation=90);
ax.annotate("resistance", (7.9, 10.2), rotation=90);
ax.set_title("3OG7");
ax.set_ylim(10, 13);

--&gt;</content><category term="biotech"/><category term="biotech"/><category term="machine learning"/><category term="ai"/></entry><entry><title>Colab and computational tools for drug design</title><link href="/colab-computational-drug-design-2023.html" rel="alternate"/><published>2023-06-25T11:00:00-07:00</published><updated>2023-06-25T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2023-06-25:/colab-computational-drug-design-2023.html</id><summary type="html">&lt;p&gt;Using colab to chain computational drug design tools&lt;/p&gt;</summary><content type="html">&lt;style&gt;
.blogimg {
    width:100%;
    min-width:60%;
    max-width:600px;
}
&lt;/style&gt;

&lt;p&gt;Last year I wrote a post about &lt;a href="http://blog.booleanbiotech.com/computational-tools-2022.html"&gt;computational tools for drug development&lt;/a&gt;.
Since then quite a lot has happened,
especially the appearance of several generative models
based on &lt;a href="https://dmol.pub/dl/Equivariant.html"&gt;equivariant neural networks&lt;/a&gt;
for drug design.
This article is a sort of update to that post,
and also a collection of &lt;a href="https://colab.research.google.com/?utm_source=scs-index"&gt;colabs&lt;/a&gt;
I have found or developed over the past year or so
that can be stitched together to design drugs.&lt;/p&gt;
&lt;p&gt;The tools listed here are focused on the earliest stages of drug development.
Specifically:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Generate a new molecule or use a virtual screen to find one&lt;/li&gt;
&lt;li&gt;Evaluate the molecule's potential as a drug&lt;/li&gt;
&lt;li&gt;Synthesize or purchase the molecule&lt;/li&gt;
&lt;/ol&gt;
&lt;!-------------------------------------------------------------------------------------------------

Generate

--------------------------------------------------------------------------------------------------&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;1a. Generate a new molecule&lt;/h1&gt;
&lt;h2&gt;&lt;a href="https://github.com/pengxingang/Pocket2Mol"&gt;Pocket2Mol&lt;/a&gt;: Protein structure → small molecules&lt;/h2&gt;
&lt;p&gt;Pocket2Mol is one of a new crop of generative models that
start with a binding pocket and generate molecules that fit in the pocket.
&lt;a href="https://twitter.com/guolin_ke/status/1653786131367071744"&gt;VD-Gen&lt;/a&gt; (with animation below)
is similar to Pocket2Mol but since it has no code available so I cannot tell if it works.&lt;/p&gt;
&lt;video class="blogimg" autoplay loop muted playsinline&gt;
  &lt;source src="/images/cdd_generate.mp4" type="video/mp4"&gt;
&lt;/video&gt;

&lt;p&gt;I created a
&lt;a href="https://colab.research.google.com/drive/113NKjh6wBZhOYEy6VZwd03zD3cJffogL"&gt;Pocket2Mol colab&lt;/a&gt;
that enables easy molecule generation.
The input is a PDB file and 3D coordinates to search around.
The centroid of a bound ligand in the PDB file can serve as the coordinates.
The output is a list of generated molecules.
I rank the generated molecules with &lt;a href="https://github.com/gnina/gnina"&gt;gnina&lt;/a&gt;,
a fast, easy to install, and relatively accurate way to measure binding affinity.&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://github.com/sokrypton/ColabDesign"&gt;ColabDesign&lt;/a&gt;: Protein structure → peptide binders&lt;/h2&gt;
&lt;p&gt;ColabDesign is an extremely impressive project that democratizes a lot of the
recent work in generative protein models.
As you may guess from the name, ColabDesign — and sister project &lt;a href="https://github.com/sokrypton/ColabFold"&gt;ColabFold&lt;/a&gt; —
allow anyone to run them via colab.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_colabdesign.png" /&gt;&lt;/p&gt;
&lt;p&gt;For example, even the recent state-of-the-art
&lt;a href="https://www.bakerlab.org/2023/03/30/rf-diffusion-now-free-and-open-source/"&gt;RFDiffusion&lt;/a&gt;
algorithm from the Baker lab has been
incorporated and made available as an
&lt;a href="https://colab.research.google.com/github/sokrypton/ColabDesign/blob/v1.1.1/rf/examples/diffusion.ipynb"&gt;RFDiffusion colab&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;ColabDesign can generate proteins that conform to a specific shape or reference protein backbone
(structure → sequence, i.e., AlphaFold in reverse).
It can also generate peptides that can bind to a specific protein.&lt;/p&gt;
&lt;p&gt;The same group also developed
&lt;a href="https://www.biorxiv.org/content/10.1101/2023.02.25.529956v1.full"&gt;AfCycDesign&lt;/a&gt;,
which uses a &lt;a href="https://twitter.com/sokrypton/status/1630053980096086016"&gt;nice trick&lt;/a&gt; to get Alphafold to fold 
&lt;a href="https://en.wikipedia.org/wiki/Cyclic_peptide"&gt;cyclic peptides&lt;/a&gt; —
an increasingly important drug type, and often an alternative to antibodies.
There is an
&lt;a href="https://colab.research.google.com/github/sokrypton/ColabDesign/blob/v1.1.1/af/examples/af_cyc_design.ipynb"&gt;AfCycDesign colab&lt;/a&gt; too!&lt;/p&gt;
&lt;p&gt;In this animation it is attempting to generate a cyclic peptide covid spike protein binder,
as &lt;a href="https://www.biorxiv.org/content/10.1101/2022.11.11.516114v1.full.pdf"&gt;published recently&lt;/a&gt;.&lt;/p&gt;
&lt;video class="blogimg" autoplay loop muted playsinline&gt;
  &lt;source src="/images/cdd_cyclic_peptide.mp4" type="video/mp4"&gt;
&lt;/video&gt;

&lt;!-------------------------------------------------------------------------------------------------

Virtual Screen

--------------------------------------------------------------------------------------------------&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;1b. Run a virtual screen&lt;/h1&gt;
&lt;h2&gt;&lt;a href="https://github.com/gnina/gnina"&gt;gnina&lt;/a&gt;: PDB structure + ligand → posed ligand + binding affinity&lt;/h2&gt;
&lt;p&gt;gnina is the deep-learning–based successor to the extremely popular smina, itself an
&lt;a href="https://en.wikipedia.org/wiki/AutoDock"&gt;AutoDock Vina&lt;/a&gt; fork.
There is a minimal implementation available as a &lt;a href="https://colab.research.google.com/drive/1QYo5QLUE80N_G28PlpYs6OKGddhhd931?usp=sharing"&gt;gnina colab&lt;/a&gt;.
gnina is a successor to smina and appears to be strictly better.
gnina can be used for 
&lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8659095/"&gt;virtual screening&lt;/a&gt;
and &lt;a href="https://pubs.acs.org/doi/10.1021/acs.jcim.3c00322"&gt;performs very well&lt;/a&gt;
at that.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/oxpig/PointVS"&gt;PointVS&lt;/a&gt; is a new, deep-learning approach.
Like many recent methods, it uses an EGNN (equivariant graph neural network).
PointVS's performance is impressive, comparable to gnina,
but it's unclear which method runs faster.
&lt;a href="https://github.com/dptech-corp/Uni-Dock"&gt;Uni-Dock&lt;/a&gt;
is a new GPU-accelerated Autodock Vina that claims impressive speed
but unfortunately there is no open code.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_pointvs_vs_gnina.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;PointVS and gnina perform comparably&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://github.com/gcorso/DiffDock"&gt;DiffDock&lt;/a&gt;: protein structure + ligand → posed ligand&lt;/h2&gt;
&lt;p&gt;DiffDock is a generative diffusion model with
&lt;a href="https://twitter.com/GabriCorso/status/1577543690255409152?s=20"&gt;impressive performance&lt;/a&gt;.
Given a protein and a ligand,
DiffDock can try to find the best pose for that ligand.
I created a
&lt;a href="https://colab.research.google.com/drive/1CTtUGg05-2MtlWmfJhqzLTtkDDaxCDOQ"&gt;DiffDock colab&lt;/a&gt;
that runs DiffDock and again ranks the results using gnina.&lt;/p&gt;
&lt;p&gt;DiffDock is a pose prediction method and is not designed to do virtual screening per se.
It returns a "confidence" score that correlates with smina/gnina affinity.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" style="width:100%;min-width:60%;max-width:600px;" src="/images/cdd_diffdock_vs_smina.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;DiffDock confidence and smina/gnina binding affinities correlate fairly well&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;As for which algorithm produces superior results, it's unclear,
but according to a &lt;a href="https://arxiv.org/pdf/2303.09916.pdf"&gt;recent review&lt;/a&gt;,
gnina comes out ahead.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_diffdock_results.png" /&gt;&lt;/p&gt;
&lt;!-------------------------------------------------------------------------------------------------

Evaluate

--------------------------------------------------------------------------------------------------&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;2. Evaluate molecule properties&lt;/h1&gt;
&lt;h2&gt;&lt;a href="(https://colab.research.google.com/drive/1rTlkzvImvyPh_gz_W6y3ipFWFh_6MnIm)"&gt;SMILES property predictor&lt;/a&gt;: molecule → predicted properties&lt;/h2&gt;
&lt;p&gt;A molecule the binds to a protein has one property necessary to become a drug,
but that is far from the only thing that matters.
We can also predict a molecule's intrinsic properties using machine learning.&lt;/p&gt;
&lt;p&gt;I created a &lt;a href="https://colab.research.google.com/drive/1rTlkzvImvyPh_gz_W6y3ipFWFh_6MnIm"&gt;Smiles to properties colab&lt;/a&gt; based on
&lt;a href="https://github.com/chemprop/chemprop"&gt;chemprop&lt;/a&gt;, &lt;a href="https://github.com/gnina/SolTranNet"&gt;soltrannet&lt;/a&gt;, and &lt;a href="https://github.com/blender-nlp/MolT5"&gt;SMILES2Caption&lt;/a&gt;.
Most of the training data is from &lt;a href="https://moleculenet.org/full-results"&gt;MoleculeNet&lt;/a&gt;.
For some reason there was no pre-trained network available so I had to retrain from scratch.&lt;/p&gt;
&lt;p&gt;The graphs generated show the predicted properties of your SMILES
as compared to FDA-approved drugs (grey bounds).
In the example below, acetaminophen appears as the most toxic of the group, as expected.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_smiles_to_properties.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://swissadme.ch"&gt;SwissADME&lt;/a&gt; also provides an excellent property prediction service,
though anecdotally analyzing proprietary molecules on someone else's
server is not commonly done in drug development.&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://github.com/choderalab/espaloma_charge"&gt;Espaloma Charge&lt;/a&gt;: molecule → charge&lt;/h2&gt;
&lt;p&gt;Espaloma Charge is a standalone part of Chodera lab's
&lt;a href="https://github.com/choderalab/espaloma"&gt;Espaloma&lt;/a&gt; system.
I include it here as they make available a very simple
&lt;a href="https://colab.research.google.com/drive/1NVxt2HdZ5cIO-bQLLJ9vDqLlizZUOVwG"&gt;Espaloma Charge colab&lt;/a&gt;
that will assign charges for your molecule.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_espaloma_charge.png"&gt;&lt;/p&gt;
&lt;!--
## Perses: PDB structure + posed ligand -&gt; binding energy??
--&gt;

&lt;h2&gt;&lt;a href="https://github.com/gregory-kyro/HAC-Net/"&gt;HAC-Net&lt;/a&gt;: Protein structure + posed ligand → binding affinity&lt;/h2&gt;
&lt;p&gt;HAC-Net is a new deep learning method specifically designed to estimate protein–ligand binding affinity.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://colab.research.google.com/github/gregory-kyro/HAC-Net/blob/main/HACNet.ipynb"&gt;HAC-Net colab&lt;/a&gt;
takes as input a protein and posed ligand and returns a dissociation constant (pKd)
and a nice pymol image.
This method may or may not be more accurate than gnina — I have not attempted to benchmark.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_HACnet_2HYY_STI.png"&gt;&lt;/p&gt;
&lt;!-------------------------------------------------------------------------------------------------

Synthesize or Purchase

--------------------------------------------------------------------------------------------------&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;3. Synthesize or purchase molecule&lt;/h1&gt;
&lt;h2&gt;&lt;a href="https://app.postera.ai/"&gt;Postera Manifold&lt;/a&gt;: SMILES → molecule or building blocks&lt;/h2&gt;
&lt;p&gt;Postera Manifold is a machine learning tool that helps figure out how to synthesize small molecules.
It can supply the building blocks and reactions necessary for synthesis,
or there is a "Have PostEra make it for you" button
(at least according to their documentation, but I could not find it!)
However, usually synthesis of a new small molecule is a custom, CRO-driven process,
that could be expensive and take a long time depending on the molecule's complexity.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_manifold.png"&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://www.biomatik.com/services/peptide-synthesis.html"&gt;Biomatik&lt;/a&gt;: SMILES → purchasable molecule&lt;/h2&gt;
&lt;p&gt;For peptides — which are linear, modular molecules — synthesis is much easier.
A service like Biomatik (or &lt;a href="https://www.genscript.com/peptide.html"&gt;GenScript&lt;/a&gt;, or many others)
can supply peptides for as little as $80 per.
They can use proteinogenic or non-proteinogenic amino acids, and can cyclize the peptide too.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_biomatik.png"&gt;&lt;/p&gt;
&lt;h2&gt;&lt;a href="https://sw.docking.org/search.html"&gt;Small World&lt;/a&gt;: SMILES → purchasable molecule&lt;/h2&gt;
&lt;p&gt;Small world allows you to search for molecules in the largest
compound databases: ZINC, Mcule, Enamine REAL...
There is also a nice, unofficial
&lt;a href="https://github.com/matteoferla/Python_SmallWorld_API"&gt;Small World Python API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you find a close match to your designed molecule,
you could evaluaate it to see if it works as a binder,
or use it as a starting point for modification.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_small_world.png"&gt;&lt;/p&gt;
&lt;!--

Orforglipron

CC1CC1(C2=NOC(=O)N2)N3C4=C(C=C(C=C4)C5CCOC(C5)(C)C)C=C3C(=O)N6CCC7=NN(C(=C7C6C)N8C=CN(C8=O)C9=C(C1=C(C=C9)N(N=C1)C)F)C1=CC(=C(C(=C1)C)F)C

--&gt;

&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Orforglipron&lt;/h1&gt;
&lt;p&gt;As an example of using these tools,
I'll use a new GLP-1 agonist, 
&lt;a href="https://pubchem.ncbi.nlm.nih.gov/compound/137319706"&gt;orforglipron&lt;/a&gt;,
that showed promising results in a
&lt;a href="https://www.nejm.org/doi/full/10.1056/NEJMoa2302392?query=featured_home"&gt;phase 2 study published in NEJM&lt;/a&gt;
just this week.&lt;/p&gt;
&lt;p&gt;First, I can generate an image of the protein GLP-1 with a different bound ligand using my
&lt;a href="https://colab.research.google.com/drive/1yLs8827nWu1_NYjkSx1ulBif3Xdni50N"&gt;pdb2png colab&lt;/a&gt;.
(PDB:&lt;a href="https://www.rcsb.org/structure/7S15"&gt;7S15&lt;/a&gt;, "Pfizer small molecule bound to GLP-1").&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_pdb2png.png"&gt;&lt;/p&gt;
&lt;p&gt;I can look at the molecule and its charges using the
&lt;a href="https://colab.research.google.com/drive/1NVxt2HdZ5cIO-bQLLJ9vDqLlizZUOVwG#scrollTo=OYpSlNwCoC5i"&gt;Espaloma Charge colab&lt;/a&gt;.
(Nice image, but to be honest this doesn't mean much to me!)&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_orf_espaloma_charge.png"&gt;&lt;/p&gt;
&lt;p&gt;I can get the molecule's SMILES from
&lt;a href="https://pubchem.ncbi.nlm.nih.gov/compound/137319706"&gt;pubchem&lt;/a&gt;,
and search for it using &lt;a href="https://sw.docking.org/search.html"&gt;Small World&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_orf_sw.svg"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;orforglipron in Small World: dark green is a match; light green is a mismatch&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;A little surprisingly,
I &lt;a href="https://zinc20.docking.org/substances/ZINC001772572717/"&gt;find a matching molecule&lt;/a&gt;
that is only two edits from orforglipron
in the ZINC20 "for sale" set.
It is &lt;a href="https://www.medchemexpress.com/GLP-1_receptor_agonist_1.html"&gt;labeled as orforglipron in MCE&lt;/a&gt;
and interestingly the text says it was "extracted from a patent".
It's unclear to me why it's not an exact match.
Most sources charge &amp;dollar;2k for 1mg, but there is one source that charges
&lt;a href="https://www.molport.com/shop/moleculelink/USUWIEBBBWHKNI-KHIFEHGGSA-N/46683270"&gt;$1k for 5mg&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I can evaluate its properties with SwissADME,
and it's interesting to note how far outside the ideal orforglipron is,
in terms of size (883 Da!) and predicted solubility.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_swissadme.png"&gt;&lt;/p&gt;
&lt;p&gt;I can use the &lt;a href="https://colab.research.google.com/drive/1CTtUGg05-2MtlWmfJhqzLTtkDDaxCDOQ"&gt;DiffDock colab&lt;/a&gt;
to see how well it might bind to GLP-1&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_orf_diffdock.png" /&gt;&lt;/p&gt;
&lt;p&gt;The best binding score I could get after three attempts
was a DiffDock confidence of -2 (very unconfident) and a
gnina affinity of -6 (poor-to-mediocre affinity).
Because this molecule is so large, there are many possible conformers
and it may be impossible to adequately sample them adequately.
It does at least bind to the same place as the Pfizer small molecule.&lt;/p&gt;
&lt;p&gt;When I feed this top pose from DiffDock into the
&lt;a href="https://colab.research.google.com/github/gregory-kyro/HAC-Net/blob/main/HACNet.ipynb"&gt;HAC-Net colab&lt;/a&gt;,
I get a pKd of 11, which is very high affinity.&lt;/p&gt;
&lt;p&gt;&lt;img class="blogimg" src="/images/cdd_orf_hacnet.png" /&gt;&lt;/p&gt;
&lt;p&gt;The tools for drug design are getting very powerful, and
colab is a fantastic way to make them widely available and easy to run.
Even when I have a command-line equivalent set up,
I often find running the colab to be quicker and easier.
In theory, Docker provides the same kind of advantages,
but it's never quite so easy, as you still have to provision compute, disk, etc.
Having easy access to A100's (on the extremely affordable
&lt;a href="https://colab.research.google.com/signup"&gt;Colab Pro&lt;/a&gt;) is not bad either.&lt;/p&gt;
&lt;!-- AF2Rank https://colab.research.google.com/github/sokrypton/ColabDesign/blob/main/af/examples/AF2Rank.ipynb --&gt;</content><category term="biotech"/><category term="biotech"/><category term="machine learning"/><category term="ai"/></entry><entry><title>Using GPT-3 as a knowledge-base in biotech</title><link href="/gpt3-as-biotech-knowledgebase.html" rel="alternate"/><published>2023-02-25T11:00:00-08:00</published><updated>2023-02-25T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2023-02-25:/gpt3-as-biotech-knowledgebase.html</id><summary type="html">&lt;p&gt;Using GPT-3 as a knowledge-base for a biotech&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;br/&gt;
By now most people have seen what Chat-GPT / GPT-3 can do.
It's an amazing tool, but it has a loose affiliation with the truth.
This makes it great for anything creative like generating ideas or filler text,
but less useful if you are trying to search for information.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;
&lt;img width="47%" style="vertical-align:top" src="/images/chatgpt_1A00_1.png" /&gt;
&lt;img width="47%" style="vertical-align:top" src="/images/chatgpt_1A00_3.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;(left) What Chat-GPT thinks PDB id 1A00 is (right) What PDB id 1A00 actually is&lt;/figcaption&gt;

&lt;p&gt;Tools like &lt;a href="(https://github.com/jerryjliu/gpt_index)"&gt;GPT Index&lt;/a&gt; (now LlamaIndex)
allow you to add additional text to augment GPT-3.
This leads to the obvious idea: what if you could create a custom
&lt;a href="https://en.wikipedia.org/wiki/Knowledge_base"&gt;knowledge-base&lt;/a&gt; for your lab or biotech,
indexing all scientific papers, assay results, and written communications.
This could be an extremely powerful tool for scientists to access insitutional knowledge,
find buried information, etc.&lt;/p&gt;
&lt;p&gt;You can get GPT Index running very quickly by following the &lt;a href="https://github.com/jerryjliu/gpt_index"&gt;quickstart&lt;/a&gt;.
However, for me, trained on scientific papers, it performed worse than vanilla Chat-GPT,
even for facts directly addressed in the corpus.&lt;/p&gt;
&lt;h2&gt;Paper QA&lt;/h2&gt;
&lt;p&gt;GPT Index is a powerful, but general tool.
For our purposes,
&lt;a href="https://twitter.com/andrewwhite01"&gt;Andrew White&lt;/a&gt;'s &lt;a href="https://github.com/whitead/paper-qa"&gt;Paper QA&lt;/a&gt;
improves upon it by adding the important concept of citations.
Citations turn out to be extremely useful for keeping the model honest,
and identifying the source of the information for follow-up or verification.&lt;/p&gt;
&lt;p&gt;There are two main ways of using this tool:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Automatically search for papers relevant to your question (e.g., on Google Scholar), index those papers, and respond (as &lt;a href="https://twitter.com/andrewwhite01/status/1629346569756483584"&gt;Andrew White does&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Index a large corpus of all papers relevant to your lab or biotech once, and respond referencing that corpus&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here, I attempt to get option 2 working.
I took a set of 200 scientific papers, indexed them, and tested the answers compared to Chat-GPT.&lt;/p&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;p&gt;It's difficult to quantify the results here, but compared to Chat-GPT,
Paper QA was less verbose (sometimes good, sometimes bad), less prone to invention, and had explicit citations.
Sometimes Paper QA even usefully responds with "I cannot answer".&lt;/p&gt;
&lt;p&gt;Trained on &lt;a href="http://book.bionumbers.org/"&gt;Cell Biology By The Numbers&lt;/a&gt;, it does a pretty good job of answering,
and giving the relevant page numbers.
However, the answers are far from perfect, and include some incorrect statements like "3 million genes in the human genome".
(Maybe it is dividing the size of the human genome by the size of the "typical protein"?)
Chat-GPT gives more detailed answers, but some of the details are strange,
and though the formulas are right, the calculations are off by an order of magnitude (twice!).&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img width="47%" style="vertical-align:top" src="/images/paperqa_prots.png" /&gt;
&lt;img width="47%" style="vertical-align:top" src="/images/chatgpt_prots.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;(left) Paper QA vs (right) Chat-GPT&lt;/figcaption&gt;

&lt;p&gt;&lt;img width="55%" src="/images/chatgpt_prots_milo.jpeg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Answer from &lt;a href="http://book.bionumbers.org/how-many-proteins-are-in-a-cell/"&gt;book.bionumbers.org&lt;/a&gt;&lt;/figcaption&gt;

&lt;p&gt;&lt;br/&gt;
&lt;img width="47%" style="vertical-align:top" src="/images/paperqa_nM.png" /&gt;
&lt;img width="47%" style="vertical-align:top" src="/images/chatgpt_nM.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;(left) Paper QA vs (right) Chat-GPT&lt;/figcaption&gt;

&lt;p&gt;&lt;img width="55%" src="/images/chatgpt_nM_milo.jpeg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Answer from &lt;a href="http://book.bionumbers.org/"&gt;book.bionumbers.org&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figcaption&gt;
&lt;h2&gt;Issues&lt;/h2&gt;
&lt;p&gt;All of this stuff is very new, so there are limitations.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The system as implemented costs around 15c per query.
Not terrible, but if you had hundreds of users you'd have to pay attention to costs.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Even with the addition of citations, it is still prone to fabulation, just like Chat-GPT.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Chat-GPT can often produce results that feel more complete, depending on the type of question. 
Additionally, you can correspond with Chat-GPT, asking follow-on questions or clarifications.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You cannot index e.g., your Slack history or your proprietary databases yet,
since OpenAI will retain access to all uploaded text.
Once an open-source language model emerges
(actually open, not pretend open like &lt;a href="https://twitter.com/sergeykarayev/status/1629168994136760322?s=20"&gt;LlaMa&lt;/a&gt;),
the addition of this kind of data could make the search really interesting though —
we could even ask questions about results stored in the &lt;a href="https://langchain.readthedocs.io/en/latest/modules/chains/examples/sqlite.html"&gt;database&lt;/a&gt;!&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;The system works well on certain types of tasks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you read something a while back, and want to remind yourself what it was and where you read it&lt;/li&gt;
&lt;li&gt;If you want a very short summary / answer on some topic referenced in the corpus,
and you are willing to check the reference to validate&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Overall, this seems like a great tool for searching a library of PDFs,
though anecdotally, the performance may degrade somewhat as you add papers
(e.g., to get a summary of one paper, it may be better to index only that paper.)
I can see using the tool routinely,
but the next stage,
where we index everything anyone has typed, read, or generated in an organization
could be where things get very exciting.
Or maybe we just go full multimodal and learn a 
&lt;a href="https://hyperparameter.space/blog/what-if-we-just-learn-a-language-model-for-all-of-life/"&gt;language model for all of life&lt;/a&gt;!&lt;/p&gt;
&lt;h2&gt;Code&lt;/h2&gt;
&lt;p&gt;You can easily create your own scientific paper knowledge-base with the following code.&lt;/p&gt;
&lt;p&gt;For simplicity, I make the citation derive from the filename of the PDF,
with all PDFs ending in &lt;code&gt;_[Authorname]_[Year].pdf&lt;/code&gt;.
(Note &lt;code&gt;Authorname&lt;/code&gt; must be capitalized for Paper QA!)
You could also use Zotero's bibliography output or similar.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;index_pdfs.py&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="sd"&gt;'''&lt;/span&gt;
&lt;span class="sd"&gt;Script to index a directory of PDFs for GPT queries&lt;/span&gt;
&lt;span class="sd"&gt;You need an OpenAI API key to run it.&lt;/span&gt;
&lt;span class="sd"&gt;Register and get a key at https://platform.openai.com/account/api-keys&lt;/span&gt;

&lt;span class="sd"&gt;Uses https://github.com/whitead/paper-qa&lt;/span&gt;
&lt;span class="sd"&gt;Before running the script, install paper-qa:&lt;/span&gt;
&lt;span class="sd"&gt;```pip install paper-qa```&lt;/span&gt;

&lt;span class="sd"&gt;Then run:&lt;/span&gt;
&lt;span class="sd"&gt;```python index_pdfs.py $PDF_DIR```&lt;/span&gt;

&lt;span class="sd"&gt;The cost to build the index should be around ~1c per paper. It cost me &amp;lt;$2 to index 200 papers.&lt;/span&gt;

&lt;span class="sd"&gt;The code indexes 30 papers at a time by default, since otherwise you may hit usage limits.&lt;/span&gt;
&lt;span class="sd"&gt;You can add to the index by just running `python index_pdfs.py` multiple times,&lt;/span&gt;
&lt;span class="sd"&gt;or just changing the limit.&lt;/span&gt;
&lt;span class="sd"&gt;Please check https://platform.openai.com/account/usage to monitor costs!&lt;/span&gt;
&lt;span class="sd"&gt;'''&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;paperqa&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Docs&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;os&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pickle&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"OPENAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ADD_OPENAI_API_KEY_HERE&lt;/span&gt;
&lt;span class="n"&gt;PKL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"pdf_index.pkl"&lt;/span&gt;
&lt;span class="n"&gt;MAX_PAPERS_PER_RUN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;

&lt;span class="n"&gt;pdfs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/*.pdf"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PKL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getsize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PKL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PKL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;docs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pickle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;docs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Docs&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="n"&gt;papers_added&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pdfs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;citation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'.'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()]:&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;

    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Indexing &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;citation&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;citation&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;papers_added&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;papers_added&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;MAX_PAPERS_PER_RUN&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;break&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="ne"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ERR"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PKL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"wb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;pickle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;query_pdfs.py&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="sd"&gt;'''&lt;/span&gt;
&lt;span class="sd"&gt;Script to ask questions of your indexed PDFs using GPT.&lt;/span&gt;

&lt;span class="sd"&gt;Run, e.g.:&lt;/span&gt;
&lt;span class="sd"&gt;```python query_pdfs.py What is the largest mammal?```&lt;/span&gt;
&lt;span class="sd"&gt;'''&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;paperqa&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Docs&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;os&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pickle&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sys&lt;/span&gt;

&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"OPENAI_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ADD_OPENAI_API_KEY_HERE&lt;/span&gt;
&lt;span class="n"&gt;PKL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"pdf_index.pkl"&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;PKL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"rb"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;docs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pickle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;question&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;

&lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="biotech"/><category term="biotech"/><category term="machine learning"/><category term="ai"/></entry><entry><title>Computational tools for drug development</title><link href="/computational-tools-2022.html" rel="alternate"/><published>2022-07-02T11:00:00-07:00</published><updated>2022-07-02T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2022-07-02:/computational-tools-2022.html</id><summary type="html">&lt;p&gt;Computational tools for drug development&lt;/p&gt;</summary><content type="html">&lt;!-- -------------------------

INTRO / about virtual biotech

--------------------------- --&gt;

&lt;p&gt;The minimal drug development pipeline is some computational tools and a full-stack CRO.
I wrote about &lt;a href="http://blog.booleanbiotech.com/virtual_biotech.html"&gt;tools for virtual biotech&lt;/a&gt; a few years ago.
Since then, quite a few new tools have emerged.&lt;/p&gt;
&lt;!--
By my definition, a virtual biotech is just a biotech that does not have its own physical infrastructure.
Almost all biotechs are partially virtual, in the sense that almost all use Contract Research Organizations (CROs) for some experiments. 
Specifically, CROs often perform animal experiments since most biotechs don't have a vivarium,
or medicinal chemistry since those skills are more readily available in China.
--&gt;

&lt;!--
Biotechs are usually tech-centric (aka "platform biotechs"), or asset-centric.
As with any company,
you want to keep your unique abilities in-house
and out-source anything else.
--&gt;

&lt;!--
There are two main kinds of virtual biotech:

- **Asset- or target-centric**:
  You provide some IP, which could be a new target or a licensed compound. CROs perform the wet-lab experiments.
- **Computational**:
  You do the computational work in-house
  (for example, designing a small molecule or antibody). CROs perform the wet-lab experiments.
--&gt;

&lt;!--
If you are developing a new technology or platform, 
then outsourcing is probably infeasible,
but if you are primarily focused on one asset or target,
or if your tech is purely computational,
then you can be a virtual biotech.
--&gt;

&lt;p&gt;Surprisingly,
since there is a pleasing analogy with cloud computing,
virtual biotech has waned in popularity in recent years.
It's possible that the term is just being retired,
as the lines between virtual and regular biotech blur — 
or, it may be that a purely virtual model proves too restrictive
given the laborious nature of drug development.&lt;/p&gt;
&lt;!-- link: https://books.google.com/ngrams/graph?content=virtual+biotech&amp;year_start=1800&amp;year_end=2019&amp;corpus=26&amp;smoothing=3&amp;direct_url=t1%3B%2Cvirtual%20biotech%3B%2Cc0 --&gt;

&lt;p&gt;&lt;img src="./images/virtual_biotech_ngrams.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://atlasventure.com"&gt;Atlas Venture&lt;/a&gt; was one of the early advocates of virtual biotech,
and Atlas' &lt;a href="https://lifescivc.com/2014/06/biotechs-virtual-reality/"&gt;Nimbus Therapeutics&lt;/a&gt;
is one of few big successes I know of in the space.
Nimbus used novel computational tools (&lt;a href="https://www.schrodinger.com/"&gt;Schrödinger&lt;/a&gt;'s &lt;a href="https://lifescivc.com/2019/05/a-decade-of-discovery/"&gt;WaterMap&lt;/a&gt;) and CROs to develop drugs against "intractable targets".
In 2016, Nimbus sold its &lt;a href="https://www.businesswire.com/news/home/20160404005324/en/Gilead-Sciences-Announces-Acquisition-of-Nimbus-Therapeutics%E2%80%99-Acetyl-CoA-Carboxlyase-ACC-Program-for-NASH-and-Other-Liver-Diseases"&gt;NASH drug to Gilead for $400M upfront&lt;/a&gt;.&lt;/p&gt;
&lt;!--
&gt;Nimbus conducts drug design and computational chemistry itself but has no in-house laboratories.
--&gt;

&lt;!--
## Why are there so few virtual biotechs?
Anecdotally, people are doing less virtual biotech over the past five or so years.
This is a mystery to me.
Either it's a bad idea because to do science you need greater control over experiments
(perhaps the company with the tightest loop will win),
or it's just difficult, because of communication issues.
--&gt;

&lt;!--
# 2. Manage several CROs
This is the most typical model for virtual biotech.
You can get a lot of services via CROs.

Here are some examples:

- Buy CRISPR cell-lines from Synthego


The main catch with this approach is that sometimes it's more convenient
to just do some of the work yourself.
For example, shipping cell-lines from CRO to CRO can be challening.
And shipping to China is also difficult.
--&gt;

&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h2&gt;Tools&lt;/h2&gt;
&lt;p&gt;There have been exciting developments in tooling
due to machine learning (especially deep learning),
and the increasing importance of outsourced services in all industries.&lt;/p&gt;
&lt;h3&gt;&lt;a href="https://www.opentargets.org/"&gt;OpenTargets&lt;/a&gt;: disease → protein target&lt;/h3&gt;
&lt;p&gt;Target identification has traditionally been an unstructured problem.
If a target has some high-profile papers, and a clear tie to a disease, it can be blessed as a drug target.
OpenTargets is an impressive effort to collate, in an unbiased way,
all relevant disease–target data into one interface.
On the cancer side, &lt;a href="https://depmap.org/portal/"&gt;depmap&lt;/a&gt; and &lt;a href="https://score.depmap.sanger.ac.uk/"&gt;Project Score&lt;/a&gt;
provide similarly impressive, and totally free, data based on CRISPR screens.&lt;/p&gt;
&lt;p&gt;&lt;img src="./images/virtual_biotech_opentargets.png" /&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a href="https://alphafold.ebi.ac.uk/"&gt;AlphaFold&lt;/a&gt; / &lt;a href="https://github.com/aqlaboratory/openfold"&gt;OpenFold&lt;/a&gt;: sequence → protein structure&lt;/h3&gt;
&lt;p&gt;AlphaFold needs no introduction.
It was a huge leap forward in protein structure prediction,
but also a bellwether for applications of deep learning in biology.&lt;/p&gt;
&lt;p&gt;Perhaps surprisingly, classical protein structure prediction has a mostly
indirect application to drug discovery,
since there are already experimental structures for most protein targets of interest
(or easy-to-fold close homologs).
Still, AlphaFold's influence has been immense, extending to many
&lt;a href="https://media.nature.com/original/magazine-assets/d41586-022-00997-5/d41586-022-00997-5.pdf"&gt;related areas&lt;/a&gt;,
like &lt;a href="https://www.biorxiv.org/content/10.1101/2022.05.21.492907v1.abstract"&gt;antibody binding&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;&lt;a href="https://www.biorxiv.org/content/10.1101/2022.06.03.494563v1"&gt;ProteinMPNN&lt;/a&gt;: protein structure → sequence&lt;/h3&gt;
&lt;p&gt;ProteinMPNN is the inverse of AlphaFold: given a structure, it can derive an amino acid sequence.&lt;/p&gt;
&lt;p&gt;Amazingly, it only takes a few seconds to run, and the
&lt;a href="https://huggingface.co/spaces/simonduerr/ProteinMPNN"&gt;huggingface implementation&lt;/a&gt;
includes a minimal AlphaFold implementation(!) to help validate the results.
One of the proposed use-cases is to generate target-binding proteins.&lt;/p&gt;
&lt;p&gt;&lt;img src="./images/virtual_biotech_pmpnn.png" width="100%"&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a href="https://openmm.org"&gt;OpenMM&lt;/a&gt;: protein structure → protein dynamics&lt;/h3&gt;
&lt;p&gt;OpenMM and &lt;a href="https://software.acellera.com/docs/latest/htmd/tutorials/md-protocols.html"&gt;HTMD&lt;/a&gt;
are remarkably user-friendly molecular dynamics packages.
With just a few lines of code, you can turn a PDB file into a full simulation of protein dynamics.
&lt;a href="https://www.mdanalysis.org/pages/learning_MDAnalysis/"&gt;MDAnalysis&lt;/a&gt; is a numpy-based tool for analyzing
the resulting trajectories.&lt;/p&gt;
&lt;!--Though in alpha, [Perses](https://perses.readthedocs.io/en/latest/) also looks interesting.--&gt;
&lt;!--&lt;img src="./images/virtual_biotech_openmm.png" width="100%"&gt;--&gt;

&lt;h3&gt;&lt;a href="https://github.com/HannesStark/EquiBind"&gt;EquiBind&lt;/a&gt;: protein + ligand → docked ligand&lt;/h3&gt;
&lt;p&gt;EquiBind is a very fast, deep-learning–based ligand docking algorithm.
Its performance appears to exceed the current state-of-the-art
(perhaps excluding commercial tools),
and because it is so fast, it's feasible to use it for virtual screening, 
evaluating thousands of ligands (or proteins).
Docking has not had its AlphaFold moment yet,
but the momentum is building,
especially with developments in &lt;a href="https://pubs.acs.org/doi/10.1021/acs.chemrev.0c01111"&gt;machine learning forcefields&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="./images/virtual_biotech_equibind.png" width="100%"&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a href="https://pharmit.csb.pitt.edu/"&gt;Pharmit&lt;/a&gt;: protein + bound ligand → alternative ligands&lt;/h3&gt;
&lt;p&gt;Pharmit, from the &lt;a href="https://bits.csb.pitt.edu/"&gt;Koes lab&lt;/a&gt;,
is one of my favorite drug development tools for its simple but powerful interface.
You just paste in a PDB id, select a ligand of interest, and it will find similar ligands in multiple databases.&lt;/p&gt;
&lt;!-- VX7 is Ivacaftor --&gt;
&lt;p&gt;For example, searching PDB for Ivacaftor brings up this
&lt;a href="https://www.rcsb.org/structure/6O2P"&gt;crystal structure&lt;/a&gt;
of the drug bound to CFTR.
Then pharmit allows you to find other, similar compounds that could bind at the same location.&lt;/p&gt;
&lt;p&gt;&lt;img src="./images/virtual_biotech_pharmit1.png" width="49%" min-width="400px"&gt;
&lt;img src="./images/virtual_biotech_pharmit2.png" width="49%" min-width="400px"&gt;
&lt;em&gt;Ivacaftor (left) vs a similar molecule found in the &lt;a href="https://www.molport.com"&gt;molport&lt;/a&gt; database (right)&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;&lt;a href="https://deepchem.io/"&gt;DeepChem&lt;/a&gt; / &lt;a href="https://pubs.acs.org/doi/abs/10.1021/acs.jcim.0c00915"&gt;REINVENT&lt;/a&gt; / &lt;a href="https://torchdrug.ai/"&gt;TorchDrug&lt;/a&gt; : protein structure → drug design&lt;/h3&gt;
&lt;p&gt;DeepChem, REINVENT, and TorchDrug are among the most comprehensive tools for &lt;em&gt;de novo&lt;/em&gt; drug design.
Because there are many features to optimize for a drug
(logP, toxicity, etc.; see &lt;a href="https://moleculenet.org/full-results"&gt;MoleculeNet&lt;/a&gt; for examples)
these tools are really computational frameworks with many abilities.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.schrodinger.com/"&gt;Schrödinger&lt;/a&gt;, &lt;a href="https://www.eyesopen.com/"&gt;OpenEye&lt;/a&gt; and &lt;a href="https://www.acellera.com"&gt;Acellera&lt;/a&gt; are more established commercial offerings in the same vein.
&lt;a href="https://deepchain.bio"&gt;DeepChain&lt;/a&gt; is a new startup providing a suite of deep learning tools, focused on protein design.&lt;/p&gt;
&lt;!--You can predict the effect of protein mutations on [protein–protein interactions](https://deepchain.bio/2021/11/22/assess-how-single-point-mutations-affect-protein-protein-interactions-with-deepchain/),
and predict [antibody binding](https://deepchain.bio/2022/02/03/deepchain-app-heroes-cdr-influenza-binding-app/).
--&gt;
&lt;p&gt;&lt;img src="./images/virtual_biotech_acellera.png" width="100%"&gt;
&lt;em&gt;&lt;a href="https://www.acellera.com"&gt;Acellera&lt;/a&gt; provides some browser-based tools via &lt;a href="https://playmolecule.com/"&gt;playmolecule.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;!--
https://colab.research.google.com/drive/1JEMiMvSBuqCuzzREYpviNZZRVOYsgivA?usp=sharing#forceEdit=true&amp;sandboxMode=true&amp;scrollTo=o1LaHntdgJ1w
ANI / torchani
openmm / perses / qmlify
--&gt;

&lt;!--
Here I will go through a specific workflow for this.
As a simple project, let's say we want to create a small molecule
that targets a well-known drug target.

Arbitrarily, I'll pick MEK, a protein with several drugs on the market,
and several drugs in development.
--&gt;

&lt;h3&gt;&lt;a href="https://postera.ai"&gt;PostEra&lt;/a&gt;: drug design → molecule&lt;/h3&gt;
&lt;p&gt;Designing a drug is not particularly useful unless you can synthesize and assay it.
PostEra calls their service "Medicinal Chemistry powered by Machine Learning".
They have a nice &lt;a href="https://postera.ai/library/guide"&gt;video&lt;/a&gt; explaining how it works.&lt;/p&gt;
&lt;p&gt;&lt;img src="./images/virtual_biotech_postera1.png" width="49%" min-width="900px"&gt;
&lt;img src="./images/virtual_biotech_postera2.png" width="49%" min-width="400px"&gt;
&lt;em&gt;PostEra calculates a synthetic route, and enables you to have the compound synthesized.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I have not used PostEra, but in theory, once you have designed your small molecule of interest,
PostEra can synthesize it and have it delivered to your CRO.
In the example above, the lead time is 6 weeks.
This service could become one of the biggest enablers for virtual biotech.&lt;/p&gt;
&lt;!--
## DeepChem
DeepChem is the major chemistry-related deep learning library.
The library focuses on general tools, and is a terrific learning resource.
For example, they have many [tutorials](https://github.com/deepchem/deepchem/tree/master/examples/tutorials)
including basic deep learning tutorials.

You can use DeepChem to develop a model, but 
it's not clear if inventing your own model is necessary.

There are lots of already-tested deep learning-driven tools being released.
For example:
- [ABlooper](https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac016/6517780) to fold antibody CDR loops;
- ????
--&gt;

&lt;h3&gt;&lt;a href="https://www.criver.com/"&gt;CRL&lt;/a&gt;: molecule → assays&lt;/h3&gt;
&lt;p&gt;The easiest way to make a therapeutic is to get a CRO to do it for you.
This is not as strange as it sounds.
CROs employ all the kinds of people you would need to do this,
and have enviable infrastructure compared to most biotechs.
If you have a target, or if you have a starting point for your drug,
then you could use an integrated drug discovery service for all downstream wet-lab tasks,
almost completely hands-off.&lt;/p&gt;
&lt;p&gt;Perhaps the most respected large CRO,
Charles River Labs (CRL), offers such
&lt;a href="https://www.drugdiscoverytrends.com/the-new-age-of-drug-development/"&gt;fully integrated services&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/virtual_biotech_subway.png" width="100%"&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The industry standard timeline from hit identification to preclinical candidate nomination is on average 33-36 months. As a full service preclinical drug development CRO with an integrated approach to development, Charles River can reduce this timeline to as little as 24 months.&lt;/p&gt;
&lt;p&gt;In the last 15 years Charles River has delivered 79 preclinical candidates, with over 30 of these molecules progressing to Phase I and beyond.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;CRL has a range of capabilities,
assembled via purchases and licensing.
For example, they have deals with several cutting-edge startups, including
&lt;a href="https://www.bit.bio/news/charles-river-announces-strategic-partnership-with-bit-bio-increasing-portfolio-of-translational-drug-discovery-technologies/"&gt;Bit Bio&lt;/a&gt; for stem cell reprogramming,
&lt;a href="https://www.atomwise.com/2019/01/11/charles-river-laboratories-and-atomwise-form-a-strategic-alliance-to-provide-integrated-artificial-intelligence-driven-drug-discovery/"&gt;Atomwise&lt;/a&gt; for computational chemistry,
and &lt;a href="https://www.scienceboard.net/index.aspx?sec=ser&amp;amp;sub=def&amp;amp;pag=dis&amp;amp;ItemID=3843"&gt;SAMDI&lt;/a&gt;
for mass spectrometry.&lt;/p&gt;
&lt;p&gt;Of course, you can also try to use a different CRO for each area, with the obvious benefits and drawbacks.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/virtual_biotech_logica.png" width="60%" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Charles River Labs offers sophisticated &lt;a href="https://www.criver.com/products-services/discovery-services/logica-transformative-drug-design"&gt;"AI-powered" computational chemistry services&lt;/a&gt; from a partnership with &lt;a href="https://www.valohealth.com/"&gt;Valo&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Joining the dots&lt;/h2&gt;
&lt;p&gt;Using the tools listed above, you could imagine the following simplified process:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Identify a novel drug target using a database like OpenTargets.&lt;/li&gt;
&lt;li&gt;Derive a &lt;a href="https://alphafold.ebi.ac.uk"&gt;structure&lt;/a&gt; for the protein target if it does not exist.&lt;/li&gt;
&lt;li&gt;Examine the protein's possible conformations with OpenMM or &lt;a href="https://deepchain.bio/2021/03/10/facilitating-powerful-molecular-dynamics-simulations-to-accelerate-protein-research/"&gt;DeepChain&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Search for potential drugs that bind the target with Pharmit,
  or generate novel drugs with &lt;a href="https://github.com/MolecularAI/ReinventCommunity/blob/master/notebooks/Complete_Use-Case-DRD2_Demo.ipynb"&gt;REINVENT&lt;/a&gt;.
  Refine the drug's molecular properties with DeepChem.
  Alternatively, design a short peptide that could act as a drug using ProteinMPNN and AlphaFold.&lt;/li&gt;
&lt;li&gt;Synthesize the compound with PostEra, or the peptide with &lt;a href="https://www.biomatik.com/services/peptide-synthesis.html"&gt;Biomatik&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Ship the compound directly to CRL for a specific &lt;a href="https://www.criver.com/products-services/biologics-testing-solutions/bioactivity-potency-testing/vitro-bioassays?region=3601"&gt;bioassay&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Iterate.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The success of the above scheme relies on a few things: 
a well-chosen drug target;
computational techniques that work reasonably well;
a reliable bioassay that translates well to clinical readouts.
Given the right disease, target and computational approach,
there is a lot of potential.
This &lt;a href="https://twitter.com/GahbauerStefan/status/1541924168785993729"&gt;public COVID project&lt;/a&gt;,
and the &lt;a href="https://twitter.com/covid_moonshot"&gt;COVID moonshot&lt;/a&gt; (collaborating with PostEra),
serve as great examples of what is possible today.&lt;/p&gt;
&lt;!-- https://sci-hub.se/https://pubs.acs.org/doi/10.1021/acsmedchemlett.9b00582 --&gt;

&lt;!--
### Design

Here I'll enumerate some options for molecule design.

### Small molecules
To design small molecules you can either
design from scratch, or do
[virtual screening](https://en.wikipedia.org/wiki/Virtual_screening#:~:text=Virtual%20screening%20(VS)%20is%20a,a%20protein%20receptor%20or%20enzyme.)

Virtual screening is appealing because it is straightforward to implement,
and if you find a good candidate,
you can often purchase it.
--&gt;
&lt;!--
### Designing proteins is also an option.
Designing proteins usually means antibodies (or nanobodies).
You can find antibodies
(or ["natural antibodies"](https://en.wikipedia.org/wiki/Antibody#Natural_antibodies))
with sequencing, and
[phage display screening](https://www.creative-biolabs.com/phage-display-service.html).
Designing antibodies is more difficult than sequencing though there is
[recent work](https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac016/6517780),
and unfortunately AlphaFold2 

Any large CRO like WuXi will help with all aspects of antibody development.

[A Review of Deep Learning Methods for Antibodies](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7344881/)
[ABlooper](https://academic.oup.com/bioinformatics/advance-article/doi/10.1093/bioinformatics/btac016/6517780)
--&gt;

&lt;!--
# Case study
## gnina
Like pharmit, [gnina](https://github.com/gnina/gnina) is also from [David Koes' lab](http://bits.csb.pitt.edu/).
It's a molecular docking tool that is based on autodock vina
but also uses [CNNs](https://jcheminf.biomedcentral.com/articles/10.1186/s13321-021-00522-2) based 

Gnina can be used for virtual screening,
and a recent [paper](https://www.mdpi.com/1420-3049/26/23/7369)
found that it performs well at this task.

For more complex simulations there is also software like [htmd](https://github.com/Acellera/htmd).

[Acellera](https://www.acellera.com/) has tools for computational drug discovery, including docking and simulation.
including [PlayMolecule](https://www.acellera.com/products/playmolecule/)

I know of Acellera because

[Schrodinger](https://www.schrodinger.com/platform/drug-discovery)
--&gt;

&lt;!--
# About biotech costs?
Biotech is [famously expensive](https://refoundable.com/research/life-after-erooms-law-interview-with-jack-scannell.html). 
For early stage biotech,
I think the major expense comes from lab space, employees, tools and reagents.
But the real driver of drug development costs is clinical trials.

Because of the rising costs, biotechs have had to raise more and more cash.
According to [Bay Bridge Bio](https://www.baybridgebio.com/blog/ipo_2018_q12019.html)
the median series A was $58M and the median series B was $83M.
Series A and B companies are not spending money on clinical trials,
which shows how expensive this process is.

Even though most of this expense is due failure rates in expensive clinical trials,
it's still useful to think about how early stage biotech could 
be made cheaper and better.
Any improvements obviously carry forward.
--&gt;

&lt;!--
### What are platforms now?
How many platforms do we need?
Ten years ago, we had basically two modalities: small molecules and antibodies.
Now we have approved
[aptamers (2004)](https://www.nature.com/articles/nrd3141#:~:text=The%20first%20aptamer%20approved%20for,Drug%20Administration%20for%20macular%20degeneration.),
[ASOs (1998, later withdrawn)](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7355792/#:~:text=Fomivirsen%20(VitraveneTM),AIDS%20patients%20(Table%202).), then 2013,
non-natural peptides (i.e., excluding insulin),
[PROTACs (2019)](https://www.nature.com/articles/d41573-021-00052-4#:~:text=In%202019%2C%20ARV%2D110%20became,degradation%20of%2070%E2%80%9390%25.),
[cell-based gene therapy (2021)](https://asgct.org/research/news/april-2021/abecma-cart-multiple-myeloma#:~:text=Idecabtagene%20vicleucel%20(ide%2Dcel),maturation%20antigen%20(BCMA)%20class.)
--&gt;

&lt;!--
## What about DAOs?
There's a lot of activity around bio / science DAOs recently.
Example include: [vitaDAO](https://www.vitadao.com/),
[labDAO](https://www.labdao.com/), 
[Vibe Bio](https://www.vibebio.com/),
[OSS DAO](https://www.ossdao.xyz/).
--&gt;</content><category term="biotech"/><category term="biotech"/><category term="virtualbiotech"/><category term="drugdevelopment"/></entry><entry><title>The baffling COR</title><link href="/the-baffling-cor.html" rel="alternate"/><published>2022-01-17T11:00:00-08:00</published><updated>2021-01-17T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2022-01-17:/the-baffling-cor.html</id><summary type="html">&lt;p&gt;Trying out The COR, a home blood diagnostic device.&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a href="https://thecor.com/"&gt;The COR&lt;/a&gt; is a new consumer device that uses infrared spectroscopy to measure
"how your body responds to food and fitness practices over 21 day cycles" 
using a prick of blood from a lancet.
It usually costs $400
(I bought mine for half-off in a recent launch sale),
and includes 28 blood-collection capillary tube cartridges (six months worth at weekly use).
At the time of writing it is sold out.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;
&lt;img src="/images/cor_device.jpeg" width="40%"&gt;&lt;/p&gt;
&lt;figcaption&gt;The COR device and blood-collection capillary tube cartridge.&lt;/figcaption&gt;

&lt;p&gt;The device has an interesting background.
The founder is an ex-Apple director who worked on the Apple Watch,
and it's funded by
&lt;a href="https://foundersfund.com/portfolio/"&gt;Founder's Fund&lt;/a&gt; (not on their portfolio page though!)
and
&lt;a href="https://www.khoslaventures.com/portfolio/cor"&gt;Khosla Ventures&lt;/a&gt;.
I think these guys would probably have vetted the technology pretty well
(especially post-Theranos, VCs are skeptical of devices like this).
However, it does seem to have had a &lt;a href="https://www.indiegogo.com/projects/cor#/comments"&gt;difficult development path on Indiegogo&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;How does it work?&lt;/h2&gt;
&lt;p&gt;The COR is an infrared spectrometer
with a "wavelength range of 1600-2450nm (resolution of 7-8nm)".
The name COR refers to the "correlations" that can be made with these spectroscopic readings.
Basically, they cannot derive readings for specific analytes (like glucose or cholesterol), 
but looking at the spectral data in aggregate ("ensemble spectral changes"),
they can see trends that correlate with certain health outcomes ("blood response patterns").&lt;/p&gt;
&lt;p&gt;This is interesting enough, though some of their
&lt;a href="https://patents.google.com/patent/WO2019213166A1/en?assignee=nueon&amp;amp;oq=nueon"&gt;patents&lt;/a&gt;
(ascribed to "nueon") promise a lot more,
and were part of what intrigued me about the device.
For example, according to some of the data in their patents,
they can measure glucose and cholesterol accurately.
As far as I know, this would be a big breakthrough for infrared spectroscopy.
The usual problem with replicating results like these is calibration —
some technologies can achieve great results,
but only if you have an accurate baseline to start off with.
It reminds me a bit of the almost-non-invasive
glucose-tracking &lt;a href="http://www.mendosa.com/glucowatch.htm"&gt;GlucoWatch&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/cor_patent1.jpeg" width="50%" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Patent diagram showing performance on various blood analytes&lt;/figcaption&gt;

&lt;p&gt;&lt;img src="/images/cor_patent2.jpeg" width="50%" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Patent diagram showing performance on glucose measurement&lt;/figcaption&gt;

&lt;p&gt;The COR website has a very informative &lt;a href="https://thecor.com/blog/blog_technology-research-and-innovation-at-cor-the-science"&gt;blogpost&lt;/a&gt;
that explains a lot more about the device and the study they are running to validate it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Despite IR’s incredible capabilities, it is not used in today’s central blood laboratories. The reason is sensitivity. IR cannot model the trace components of blood very well, and so the labs need to use various types of fluidics, derivatization and wet chemistry to get answers.  Once you have this type of equipment for the low concentration things (cancer biomarkers, hormones, etc.) you might as well use it for the high concentration biomarkers as well. Accordingly, there’s no clear place for IR in a central blood lab.&lt;/p&gt;
&lt;p&gt;Let’s circle back to the mission stated above. We want to give people the ability to see how lifestyle changes impact their blood in real time. To achieve that, IR is a perfect technology. Instead of prospectively looking for individual biomarkers in people with essentially no insight into their lifestyle changes, we look for and analyze overarching, subtle IR pattern changes in groups of people who are all performing the same lifestyle program. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;Spectroscopy&lt;/h2&gt;
&lt;p&gt;Spectroscopy is a technology that seems to be perennially almost there.
The appeal of a cheap, non-invasive tool for general molecular analysis is too appealing.
In particular, &lt;a href="https://pubmed.ncbi.nlm.nih.gov/?term=raman+spectroscopy"&gt;Raman spectroscopy&lt;/a&gt;
has been vaunted many times over the years as a way to measure analytes of all kinds.&lt;/p&gt;
&lt;p&gt;You can actually buy a &lt;a href="https://www.agilent.com/en/product/molecular-spectroscopy/raman-spectroscopy/raman-pharmaceutical-analysis-systems/vaya-handheld-raman-spectrometer-for-raw-material-identification"&gt;handheld Raman spectroscope&lt;/a&gt;
for raw material identification.
It is very cool technology, but the examples show identification
of bulk ingredients (e.g., a vial of lactose), 
which you expect to have a consistent spectroscopic pattern.
Picking out specific analytes from a complex mixture is much harder.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/cor_raman.jpeg" width="50%" /&gt;&lt;/p&gt;
&lt;h2&gt;Baffling things about the COR&lt;/h2&gt;
&lt;h3&gt;The programs&lt;/h3&gt;
&lt;p&gt;The programs suggested by COR are... unusual.
For example, "The Sardinia":&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/cor_sardinia.jpg" width="50%" max-width="400px" /&gt;&lt;/p&gt;
&lt;!--
- ten minutes of exercise
- two tablespoons of olive oil
- no meat
- 20 minutes outdoors
- one serving of sheep's cheese
- one glass of red
- 7+ hours of sleeping well
--&gt;
&lt;p&gt;I get that Sardinians do the things listed more than other populations,
and are regarded as having a healthy diet and lifestyle,
but it is a strange mix of things.&lt;/p&gt;
&lt;p&gt;The "Okinawa" program includes "10 minutes &lt;a href="https://en.wikipedia.org/wiki/Radio_calisthenics"&gt;rajio taiso&lt;/a&gt;",
and "one cup of reishi tea".
The Pro Athlete program includes a "Polar plunge" every day(!)
I think I would have to be much more dedicated to the programs to do all these things.&lt;/p&gt;
&lt;h3&gt;The time it takes&lt;/h3&gt;
&lt;p&gt;The COR takes 90 minutes to read out, continually measuring as the blood separates.
By the time it's done, the capillary tube is dry and empty.
It's not like I need results quickly or anything,
but I am not used to a consumer device taking this long.&lt;/p&gt;
&lt;h3&gt;The lack of outputs&lt;/h3&gt;
&lt;p&gt;When you process a sample on a device, generally you expect a result?
The COR seems to be very coy about results.
You are supposed to get a score from 0-100, 
representing some measure of blood health,
but I have yet to get a number.
I am assuming at some point I will get something,
but for now it really feels like the device
is an unnecessary part of the experience.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The ideas behind the COR are solid.
I believe ensemble patterns with spectroscopy will correlate with relevant blood markers.
I believe that lifestyle interventions can change blood chemistry.
I do find the product very strange though!&lt;/p&gt;
&lt;p&gt;I find it difficult to know what I am supposed to do with a number that may or 
may correlate with omega 3, or glucose, or cholesterol. 
It could mean one is up and the other two are down, it's just difficult to know.
The patents promise a lot more than the COR currently offers,
so maybe this is the start of a big effort to figure out more specific results using crowd-sourced data.&lt;/p&gt;
&lt;p&gt;I hope the COR succeeds and the product continues to improve.
If not, I think it would be interesting to hack the machine to get access to raw spectroscopic data,
though I suspect that will be tough.&lt;/p&gt;</content><category term="quantifiedself"/><category term="quantifiedself"/></entry><entry><title>Modern biotech data infrastructure</title><link href="/biotech-data-infrastructure.html" rel="alternate"/><published>2021-10-30T11:00:00-07:00</published><updated>2021-10-30T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2021-10-30:/biotech-data-infrastructure.html</id><summary type="html">&lt;p&gt;Some notes on setting up data infrastructure for a new biotech.&lt;/p&gt;</summary><content type="html">&lt;p&gt;So you are starting a biotech,
and because it's 2021, you intend to generate a good amount of data.
Maybe some genomics, proteomics, microscopy images, even video.
You want to set up data infrastructure you will not regret later.
This article has some thoughts on how to start.&lt;/p&gt;
&lt;h2&gt;Use Google Workspace or Office 365&lt;/h2&gt;
&lt;p&gt;OK this is pretty basic these days,
but I think the important thing here is to exclude desktop applications as much as possible.
The alternative choice of using desktop versions of Powerpoint, Excel, etc. still happens frequently in biotech,
but it seems crazy not to be able to reliably store documents past the tenure of a single employee,
back them up easily, and search them.
If someone leaves the company, they may well have some files you need on their hard drive!
The hard part is not so much having the online versions of these tools,
which is almost the default, but stopping people using the desktop versions. &lt;/p&gt;
&lt;p&gt;I haven't actually tried &lt;a href="https://www.office.com/"&gt;Office 365&lt;/a&gt;,
but I believe that the browser-based Powerpoint, Excel, etc. are pretty good.
I have used &lt;a href="https://workspace.google.com/"&gt;Google Workspace&lt;/a&gt; (previously called gsuite) for many years,
so I am pretty used to the tools and for me that is a pretty natural choice.&lt;/p&gt;
&lt;p&gt;I especially like Workspace's integration with the rest of Google Cloud.
For example, if you create an email address for a new employee,
then that email address can be automatically authenticated for any internal tools you have.
You hardly have to think about authentication — a not-fun security problem — at all.
(AWS also has &lt;a href="https://aws.amazon.com/single-sign-on/"&gt;single sign-on&lt;/a&gt; and it's probably not so hard to set up.)&lt;/p&gt;
&lt;h2&gt;Use the cloud (AWS or GCP) for everything&lt;/h2&gt;
&lt;p&gt;There are three major cloud providers: Amazon (AWS), Google (GCP), and Microsoft (Azure).
Unless you are closely tied to the Microsoft ecosystem,
I don't know of a good reason to use Azure.&lt;/p&gt;
&lt;h3&gt;GCP&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;great support for compute / ML, with TPUs and colab&lt;/li&gt;
&lt;li&gt;integrates very nicely with Google Workspace&lt;/li&gt;
&lt;li&gt;more modern and consistent API than AWS&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;AWS&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;more capabilities and tools than GCP&lt;/li&gt;
&lt;li&gt;better support from the AWS team&lt;/li&gt;
&lt;li&gt;the "default" cloud, so more tools support it or require it&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;GCP and AWS are both fine choices, and have more similarities than differences. 
In general, you do have to choose just one though,
both for simplicity and because "egress" (moving data out)
is one of the most expensive parts of using the cloud.&lt;/p&gt;
&lt;h2&gt;Put everything in buckets&lt;/h2&gt;
&lt;p&gt;I love buckets (&lt;a href="https://aws.amazon.com/s3/"&gt;s3&lt;/a&gt; on AWS, &lt;a href="https://cloud.google.com/storage"&gt;cloud storage&lt;/a&gt; on GCP).
In fact, this blog is served straight out of an s3 bucket.&lt;/p&gt;
&lt;p&gt;Apart from managing servers,
one of the most annoying things about scaling up data is when you run out of disk space.
Once your data no longer fits on a disk,
everything gets 10 times more complicated:
you have to think about how to distribute data across disks
and it's a huge administative overhead.
If you have ever had to &lt;a href="https://en.wikipedia.org/wiki/Shard_(database_architecture)"&gt;shard data&lt;/a&gt;, I am sorry.&lt;/p&gt;
&lt;p&gt;By comparison, buckets:
scale to infinity,
are at least 10X cheaper than disks (&lt;a href="https://aws.amazon.com/s3/pricing/?p=pm&amp;amp;c=s3&amp;amp;z=4"&gt;$0.001 to $0.02 per GB per month&lt;/a&gt;),
have many more 9s of uptime than anything else in your stack,
and basically just sit there serving data and never complaining.&lt;/p&gt;
&lt;p&gt;There are two main downsides:
accessing data over the network is never going to compete with a local disk,
and becuase buckets are basically a simple key–value store,
they are only searchable by one thing,
which is the name of the file
(for example, the ID of an experiment).
For many use-cases, this is good enough, but if you want to search for other data
within the file, you'll likely need a database too.&lt;/p&gt;
&lt;p&gt;Tools like &lt;a href="https://aws.amazon.com/athena/?whats-new-cards.sort-by=item.additionalFields.postDateTime&amp;amp;whats-new-cards.sort-order=desc"&gt;AWS's Athena&lt;/a&gt;
or &lt;a href="https://cloud.google.com/bigquery/docs/hive-partitioned-queries-gcs"&gt;Google's BigQuery&lt;/a&gt;
(essentially an SQL interface on top of files in buckets) may help, at least as a stop-gap,
but they still have to read in &lt;strong&gt;every&lt;/strong&gt; file for every search you do,
so they are not a substitute for indexed/searchable data.&lt;/p&gt;
&lt;p&gt;Even though you almost certainly need a database eventually,
depending on &lt;em&gt;how&lt;/em&gt; you are accessing data,
buckets could take you a long way.
For biotechs, accessing files by the ID of an experiment is pretty natural.
Later, when you want to layer a database on top,
it should be a natural progression to store the index-worthy data and the bucket URLs in the database.&lt;/p&gt;
&lt;p&gt;&lt;img display="block" width="100%" src="/images/biotech_infra_sqlite.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Comparison of data storage options by
&lt;a href="https://twitter.com/tsuname/status/1374527635036901387"&gt;@tsuname&lt;/a&gt;&lt;/figcaption&gt;

&lt;p&gt;Most files you store will either be raw data or tabular.
For tabular data, &lt;a href="https://www.snowflake.com/guides/what-parquet"&gt;parquet&lt;/a&gt; seems to be the safe choice these days.
It has native support in pandas, Athena, BigQuery, and can be optimized for space or speed. 
SQLite files are likely much bulkier than parquet, but may shine when you have more complex queries.
You can even do &lt;a href="https://phiresky.github.io/blog/2021/hosting-sqlite-databases-on-github-pages/"&gt;HTTP range requests&lt;/a&gt; on SQLite files in buckets!
This method could be a huge win for some use-cases.&lt;/p&gt;
&lt;p&gt;Which brings us on to "big data".&lt;/p&gt;
&lt;!--
### Local data vs bucket data
The data you can actually use is a small fraction fo the data you collect.
Sequencing reads become variants, microscopy images become feature vectors,
transcriptomes become transcript counts.
--&gt;

&lt;h2&gt;Big data: tech vs biotech&lt;/h2&gt;
&lt;p&gt;"Big data" as a term was a big thing for a while,
and it still lingers as a concept.
What is big though?
"Big data" has famously been described as data that
&lt;a href="https://shkspr.mobi/blog/2021/04/whats-the-origin-of-the-phrase-big-data-doesnt-fit-in-excel/"&gt;will not fit in an excel file&lt;/a&gt;,
which could be anything larger than a gigabyte.&lt;/p&gt;
&lt;!--
Interestingly, there are 9 orders of magnitude from a gigabyte to an exabyte (Google / Apple / Facebook-level big data)
--&gt;

&lt;!--
(a span of 9 orders of magnitude.)
--&gt;

&lt;p&gt;Biotechs use all these data-heavy instruments like sequencers, so surely modern biotech requires big data?
As a simple example, we can compare a hypothetical consumer-focused tech company to a data-driven biotech.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;One key difference between a biotech and almost any tech company
— even if they have the same amount of data —
is how many people are accessing the data.
It could be up to millions (or billions!) of users accessing data on a website,
but at a biotech it can never be more than thousands of users, and more likely, tens.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A consumer website or app may need to respond to a request in a &lt;a href="https://blog.uptrends.com/technology/surprising-ways-page-loading-time-affects-your-bottom-line/"&gt;couple of seconds&lt;/a&gt; to retain a user,
  while a scientist at a biotech may be willing to wait much longer for a batch of results.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Another important difference is how much the data can be compressed.
Usually, at a biotech you are trying to make some inference based on data.
For example, how are certain molecular features (gene expression, metabolism, cell structure) correlated with a treatment?
The actual sequencing reads or pixels are usually not relevant.
In contrast, for any website with text communication, you will need to retrieve the specific text written.
A biotech can throw away (or archive) the raw reads from a sequencing run and keep the variants,
but a tech company cannot throw away the raw text from a chat and keep the gist.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These differences have a big impact on how difficult it is to manage the data.&lt;/p&gt;
&lt;!--
So, two key differences: size of data, and relevance of uncompressed data?????

There are some differences between your biotech's data and FAAMG:

- Google and Facebook can't do lossy compression on their data. Uh, except images.
  It's not enough to know that "the chats between these two people were friendly" and throw away the text.
  Although, maybe eventually they'll encode older chat data in a deep learning model...
- All the data relates to other data, especially on facebook.
  So, you will obviously need database-like tools to quickly traverse these relationships.
  It sounds like something you'd want to do in biotech too, but I think I'd say not really.
--&gt;

&lt;h3&gt;How many hard disks is that?&lt;/h3&gt;
&lt;p&gt;One thing that is pretty counter-intuitive to me is how big hard disks are these days.
For example, a 16 TB hard drive now costs around &lt;a href="https://www.newegg.com/p/pl?N=100167523%20601334339"&gt;$500&lt;/a&gt;.
If you are like me, this doesn't really register as 1000 times bigger than a 16 GB hard drive.&lt;/p&gt;
&lt;p&gt;So how big is 16 TB really?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Genomes&lt;/strong&gt;: a human genome is 3GB naively uncompressed,
but &lt;a href="https://www.nature.com/articles/srep11565"&gt;less than 1MB compressed&lt;/a&gt;;
so you can theoretically store tens of millions of complete human genomes on one consumer hard disk.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sequencing reads&lt;/strong&gt;: a sequncing run from a large Illumina machine like a NovaSeq can produce terabytes of data,
but these essentially always get collapsed into much smaller derived files (assemblies, variant files, transcript counts).
The raw, archived reads can sit in a bucket (at a cost of $1 per TB per month),
or in most cases you could just delete the reads (nobody actually does this!)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Images&lt;/strong&gt;:
obviously this depends on the instrument producing the images, and how much lossy compression is ok for your inference.
Your images could be much larger than 1 MB, but trivially, you can store 16 million 1 MB images. That is a lot of experiments!
I'm not an expert here, but I have not seen deep learning applied to really high resolution images, I think for practical reasons.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Assays&lt;/strong&gt;:
this includes biochemical assays, cytotoxicity assays, any &lt;em&gt;in vivo&lt;/em&gt; assays, etc.
These are neglibible in size and will never fill a hard disk.&lt;/li&gt;
&lt;/ul&gt;
&lt;!--
If you want to keep every byte accessible locally on a disk, then you have Google-like problems.
--&gt;

&lt;p&gt;It may be useful to differentiate between the amount of data you need locally (e.g., in memory),
and the amount of data you need to be able to access at short notice.
If you want to access summary statistics, or derived data, instantly,
but also be able to access the raw data from an experiment in a reasonable timeframe of seconds to hours
(downloading from a fast or slow bucket),
then you may not have big data problems at all.
This is good news! It means you may not need a cluster, expensive RAID (NetApp, Isilon), IT staff, etc.&lt;/p&gt;
&lt;!--
SVG!!
--&gt;
&lt;div style="max-width:100%"&gt;
&lt;svg width="100%" height="71.43%" viewBox="0 0 3500 2500"&gt;

&lt;g transform="translate(400 2300)"&gt;
  &lt;polygon points="1,0 2,1 1,2 0,1"
   style="fill:rgba(150,75,75,1);stroke-width:0" /&gt;
  &lt;polygon points="0,1 1,2 1,3 0,2"
   style="fill:rgba(100,50,50,1);stroke-width:0" /&gt;
  &lt;polygon points="2,1 2,2 1,3 1,2"
   style="fill:rgba(60,30,30,1);stroke-width:0" /&gt;
  &lt;text x="10" y="-50" text-anchor="middle" fill="black" font-size="64"&gt;GB&lt;/text&gt;
&lt;/g&gt;

&lt;g transform="translate(700 2200)"&gt;
  &lt;polygon points="10,0 20,8 10,16 0,8"
   style="fill:rgba(150,75,75,1);stroke-width:0" /&gt;
  &lt;polygon points="0,8 10,16 10,24 0,16"
   style="fill:rgba(100,50,50,1);stroke-width:0" /&gt;
  &lt;polygon points="20,8 20,16 10,24 10,16"
   style="fill:rgba(60,30,30,1);stroke-width:0" /&gt;
  &lt;text x="10" y="-20" text-anchor="middle" fill="black" font-size="64"&gt;TB&lt;/text&gt;
&lt;/g&gt;

&lt;g transform="translate(1000 1900)"&gt;
  &lt;polygon points="100,0 200,80 100,160 0,80"
   style="fill:rgba(150,75,75,1);stroke-width:0" /&gt;
  &lt;polygon points="0,80 100,160 100,240 0,160"
   style="fill:rgba(100,50,50,1);stroke-width:0" /&gt;
  &lt;polygon points="200,80 200,160 100,240 100,160"
   style="fill:rgba(60,30,30,1);stroke-width:0" /&gt;
  &lt;text x="100" y="-20" text-anchor="middle" fill="black" font-size="64"&gt;PB&lt;/text&gt;
&lt;/g&gt;

&lt;g transform="translate(1320 0)"&gt;
  &lt;polygon points="1000,0 2000,800 1000,1600 0,800"
   style="fill:rgba(150,75,75,1);stroke-width:0" /&gt;
  &lt;polygon points="0,800 1000,1600 1000,2400 0,1600"
   style="fill:rgba(100,50,50,1);stroke-width:0" /&gt;
  &lt;polygon points="2000,800 2000,1600 1000,2400 1000,1600"
   style="fill:rgba(60,30,30,1);stroke-width:0" /&gt;
  &lt;text x="1000" y="800" text-anchor="middle" fill="black" font-size="64"&gt;EB&lt;/text&gt;
&lt;/g&gt;

&lt;/svg&gt;
&lt;/div&gt;

&lt;figcaption&gt;If you can see the GB, congrats, your monitor is very large or very clean.  &lt;/figcaption&gt;

&lt;!--
Under what circumstances would you want access to all raw data, vs summary statistics?
For example, images can be processed into features by deep learning methods;
sequencing reads get processed to assemblies or variants;
--&gt;

&lt;!--
CRAM file format https://www.ga4gh.org/news/cram-compression-for-genomics/
--&gt;

&lt;h3&gt;Example data costs for biotechs&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.recursion.com/news/the-subtle-art-of-really-big-data-recursion-pharma-maps-the-body"&gt;An old Recursion Tx blogpost&lt;/a&gt;
states that they gather "65 terabytes of data per month".
This would cost $650/month to store in a bucket for fast access (retrieval in &lt;a href="https://aws.amazon.com/s3/pricing/"&gt;milliseconds&lt;/a&gt;),
or $65/month for archival access (retrieval &lt;a href="https://aws.amazon.com/s3/pricing/"&gt;"within 12 hours"&lt;/a&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A &lt;a href="https://medium.com/hof-capital/why-we-invested-insitro-ec3ce3ed1d5e"&gt;2020 blogpost on insitro&lt;/a&gt;
says they "generate hundreds of terabytes (and eventually petabytes) of proprietary data specifically for training machine learning models".
A hundred terabytes is 10 hard disks (&amp;dollar;5000 worth),
or &amp;dollar;1-&amp;dollar;10k/month in bucket storage.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The numbers above oversimplify the complex data problems I am sure these companies have,
but these are also among the most data-hungry biotechs out there.
For most biotechs, the numbers will be a tiny fraction of this.&lt;/p&gt;
&lt;!--
I don't know the access patterns here, but arguably derived statistics are what is important.
The number of people accessing data (say, 100 scientists) is profoundly different to a Facebook or Google.
Even if each of 100 scientists were looking at 1000 images a day,
it's still the case that almost all the data is unaccessed.
--&gt;

&lt;p&gt;The main point here is just to translate "65 terabytes" into dollars and cents,
and put in a good word for buckets.
For an unfair contrast, &lt;a href="https://9to5mac.com/2021/06/29/apple-reportedly-increases-spending-on-google-cloud-by-50-year-over-year-exceeds-8-exabytes-of-storage/"&gt;Apple stores "8 exabytes"&lt;/a&gt;
of data with Google.
That is eight million terabytes.
I think it's useful to recognize the difference in scale.&lt;/p&gt;
&lt;h2&gt;Run your compute on the cloud&lt;/h2&gt;
&lt;p&gt;Running compute on the cloud is almost certainly the right way to start,
since it takes very little time to set up, and can scale up and down very quickly.
However, it can be shockingly expensive compared to just buying computers.&lt;/p&gt;
&lt;p&gt;For example, a hard disk you can buy for &amp;dollar;500 costs &amp;gt;&amp;dollar;600 a month to rent on the cloud!
(assuming &lt;a href="https://cloud.google.com/compute/disks-image-pricing#disk"&gt;$0.04 per GB per month&lt;/a&gt;
and a &lt;a href="https://www.newegg.com/seagate-ironwolf-pro-st16000ne000-16tb/p/N82E16822184804?quicklink=true"&gt;16 TB disk&lt;/a&gt;).
That is not even an SSD!&lt;/p&gt;
&lt;p&gt;GPU boxes are also extremely expensive,
which can be limiting if you need to do a lot of deep learning.
The counterargument here is that if you later need to train on 100 GPUs or TPUs,
the cloud is the only practical way to do this.&lt;/p&gt;
&lt;p&gt;Building a cluster of computers on site is a big task,
requiring at least one IT person to administer,
and it severely limits your ability to scale compute up and down.
Depending on the location of your company, 
one IT person could cost &amp;gt;$300k a year in salary, benefits, etc.
At a certain scale it may make sense to build a cluster,
like Recursion's &lt;a href="https://www.top500.org/system/179939/"&gt;BioHive supercomputer&lt;/a&gt;,
but not to start.&lt;/p&gt;
&lt;p&gt;If you want to save money on cloud costs,
one untested idea that I find very appealing is to just buy powerful desktop PCs for employees —
a &lt;a href="https://www.dell.com/en-us/shop/desktop-computers/alienware-aurora-r12-gaming-desktop/spd/alienware-aurora-r12-desktop/wdr12_cec_40s"&gt;&amp;dollar;3k gaming PC&lt;/a&gt;,
a monster &lt;a href="https://lambdalabs.com/gpu-workstations/vector"&gt;&amp;dollar;20k deep learning box&lt;/a&gt;,
or other &lt;a href="http://jermdemo.blogspot.com/2011/06/big-ass-servers-and-myths-of-clusters.html"&gt;Big Ass Server&lt;/a&gt; —
and access them like a distributed cloud via &lt;a href="https://developers.cloudflare.com/cloudflare-one/tutorials/ssh"&gt;cloudflare tunnels&lt;/a&gt;. 
Obviously shuttling data between machines can be difficult,
but in some situations this could save six figures and this may suit, say, a lean deep-learning startup.
Depending on how much data you have — and it could be a lot! —
you could still plausibly rsync &lt;em&gt;all&lt;/em&gt; the company's data to your local disk.&lt;/p&gt;
&lt;!--
## Types of data: instrument data

There are a few major filetypes you'll store in buckets:

- unprocessed data:
basically, anything a machine generates directly: images, sequencing reads, etc.
These are big files, and very well suited to buckets since you'll almost always want to access them by their IDs.
- processed data:
here parquet seems to be a nice alternative to csv (and increasingly supported, e.g. by both Athena and BigQuery),
though storing sqlite files can be very handy too (though the files will be bigger).
- inputted data:
this would include data typed in by scientists.
Anything you are reading and writing would very probably not go in a bucket.
There are lots of ways these data could be handled???

Pablo comparing tabular data:


Depending on the setup of your biotech,
it is plausible you can just live with buckets for quite a long time.
--&gt;

&lt;h3&gt;Tools for computation on the cloud&lt;/h3&gt;
&lt;p&gt;In the olden days,
you would run computations with &lt;a href="https://en.wikipedia.org/wiki/Message_Passing_Interface"&gt;MPI&lt;/a&gt;
and &lt;a href="https://en.wikipedia.org/wiki/Oracle_Grid_Engine"&gt;SGE&lt;/a&gt;
or &lt;a href="https://en.wikipedia.org/wiki/Slurm_Workload_Manager"&gt;slurm&lt;/a&gt; on a local cluster.
Many (most?) universities still use these systems,
because they still own their own clusters.
For cost reasons, it could be a good idea for large institutions to do this.
For startups it's neither realistic nor desirable.&lt;/p&gt;
&lt;p&gt;Then there was an awkward intermediate stage with cloud computing.
You could spin up clusters on the cloud, and tear them down when you were done,
but you still had to manage a bunch of stuff with the servers yourself.
For example, you might have to know how to set up &lt;a href="https://hadoop.apache.org/"&gt;hadoop&lt;/a&gt;,
or later &lt;a href="https://kubernetes.io/"&gt;kubernetes&lt;/a&gt;.
These are devops tasks, and really fiddly and annoying.&lt;/p&gt;
&lt;p&gt;Things have thankfully changed pretty fast,
and now you don't need to know much about the nuts and bolts of clusters and Docker pods to do distributed computing.&lt;/p&gt;
&lt;p&gt;The options for scaling compute on the cloud today include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/batch/"&gt;AWS Batch&lt;/a&gt;:
    Basic parallel batch jobs in the cloud, probably in combination with Docker.
    Part of &lt;a href="https://aws.amazon.com/blogs/aws/new-amazon-genomics-cli-is-now-open-source-and-generally-available/"&gt;AWS Genomics&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/databiosphere/dsub"&gt;dsub&lt;/a&gt;:
  Google's equivalent of AWS Batch (for now at least — it has already moved out of Google).
  Originally part of &lt;a href="https://cloud.google.com/life-sciences"&gt;Google Cloud Life Sciences&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nextflow.io/"&gt;Nextflow&lt;/a&gt;:
    The current favorite for running bioinformatics workflows.
    Nextflow now has good &lt;a href="https://www.nextflow.io/docs/latest/google.html"&gt;integration with AWS, GCP and Azure&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://snakemake.readthedocs.io/en/stable/"&gt;Snakemake&lt;/a&gt;:
    Similar to nextflow.
    Snakemake now uses the cloud via kubernetes.
    I am told it's quite easy to set up.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/grailbio/reflow"&gt;Reflow&lt;/a&gt;:
    Another workflow system, but designed almost exclusively for AWS spot instances
    (see a &lt;a href="http://blog.booleanbiotech.com/nextflow-snakemake-reflow.html"&gt;previous article&lt;/a&gt; for why I mention Reflow here!)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/meirwah/awesome-workflow-engines"&gt;Tons of other workflow languages&lt;/a&gt;:
    These include non-bioinformatics systems like &lt;a href="https://github.com/spotify/luigi"&gt;Luigi&lt;/a&gt;, &lt;a href="https://github.com/apache/airflow"&gt;Airflow&lt;/a&gt;, etc.
    Snakemake and Nextflow have most of the bioinformatics &lt;a href="https://mobile.twitter.com/albertvilella/status/1428309747313295366"&gt;mindshare today&lt;/a&gt;
    so probably just go with one of those.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img display="block" width="80%" src="/images/biotech_infra_piechart.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Results of a twitter poll by &lt;a href="https://mobile.twitter.com/albertvilella/status/1428309747313295366"&gt;@AlbertVilella&lt;/a&gt;&lt;/figcaption&gt;

&lt;h3&gt;Next-gen tools&lt;/h3&gt;
&lt;p&gt;The next generation of tools should require even less experience with the command-line, server provisioning, and explicit scaling.
Here are some examples of new models of hands-off cloud computing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://colab.research.google.com/?utm_source=scs-index"&gt;Google colab&lt;/a&gt;:
    These Google-managed jupyter notebooks are an amazing deal if you need access to a GPU or TPU every now and then.
    In particular, the &lt;a href="https://colab.research.google.com/signup"&gt;pro tier&lt;/a&gt; is a fantastic deal at $10/mo.
    (They must lose so much money on this.)
    There is zero setup and installation,
    so colabs are mainly a great way to deploy a tool to the community
    without setting up a server.
    A lean startup or &lt;a href="https://twitter.com/andrewwhite01/status/1454183018994847746"&gt;lab&lt;/a&gt; could get amazing value here.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.dominodatalab.com/"&gt;Domino Data Lab&lt;/a&gt;:
    Domino Data Lab is a very simple way to get access to compute on-demand,
    and it's good for analyzing and experimenting with data via jupyter.
    It is not designed for running routine workflows.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://github.com/Vaishaal/numpywren"&gt;numpywren&lt;/a&gt;:
    This is a defunct project, built on &lt;a href="https://pywren.io/"&gt;pywren&lt;/a&gt; and limited in many ways,
    but very interesting, and maybe an indication of where things are going.
    The serverless compute concept got a boost recently now that
    &lt;a href="https://aws.amazon.com/blogs/aws/new-a-shared-file-system-for-your-lambda-functions/"&gt;lambda can mount EFS&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://www.anyscale.com/"&gt;anyscale&lt;/a&gt;:
    This project looks very promising.
    The tagline here is "program your cluster as easily as your laptop". I think that captures it!
    It uses &lt;a href="https://docs.ray.io/en/latest/index.html"&gt;Ray&lt;/a&gt; on the backend, which is a good sign, I think.
    (If you are a pandas user, also check out &lt;a href="https://docs.ray.io/en/latest/data/modin/index.html"&gt;Modin&lt;/a&gt;, aka Pandas on Ray.)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://cloudprovider.dask.org/en/latest/"&gt;Dask Cloud Provider&lt;/a&gt;
    "This package provides classes for constructing and managing ephemeral Dask clusters on various cloud platforms".
    I have not tried this, but Dask is probably the most popular parallelization tool for Python/pandas.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://erikbern.com"&gt;polytope&lt;/a&gt;:
    The name of the project is no longer polytope, but I believe the plan is still hands-off compute on the cloud.
    The author, &lt;a href="https://twitter.com/bernhardsson"&gt;Erik Bernhardsson&lt;/a&gt;,
    also wrote an interesting blogpost on &lt;a href="https://erikbern.com/2021/07/23/what-is-the-right-level-of-specialization.html"&gt;data tools and organization&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://temporal.io/"&gt;Temporal&lt;/a&gt;:
    "The open source microservice orchestration platform for writing durable workflows as code".
    I don't really know anything about this one, and it's not aimed at biotech data, but its focus on robust workflows seems interesting.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/blogs/big-data/interactive-analysis-of-genomic-datasets-using-amazon-athena/"&gt;Athena for Genomics&lt;/a&gt;:
    There are a few next-gen projects like this from both Google and Amazon, but I'm not sure these use-cases make sense.
    In particular, this one will likely be very expensive for any routine tasks.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://latch.bio/"&gt;LatchBio&lt;/a&gt;:
    "Find and launch dozens of cloud workflows and visualize your biological data all within your browser"
    Latch is a new startup in the space,
    trying to accelerate data/ML infrastructure adoption for biotechs.
    It's currently no-code, so even more hands-off than the other tools listed here.
    (I am an investor in Latch).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!--
The workflows I am familiar with in bio generally map onto:
- generate a statistic, or perform a tranformation, on on one file at a time (embarrassingly parallel)
    - turn file A into file B (e.g., assemble reads, embarrassingly parallel)
    - do some compute on one file at a time (e.g., test for differences in 1000s of transcripts or cell-types)
    - running a deep learning model on a set of images to identify features
- load everything into RAM and run some inference: by far easiest with one high memory / large GPU server
    - load a lot of data into memory and generate some summary statistics (e.g., run a GWAS)
    - build a deep learning model (e.g., cell shape)
These two workflows map pretty well onto
(a) simple batch jobs on spot instances and
(b) using one big server (rent or buy), which is not really that different to using a home computer.

You can also distribute to e.g. hundreds of GPUs or TPUs,
but that should also be abstracted away by the cloud.
You can do quite a lot of deep learning with 4 $1k GPUs in a box.
--&gt;

&lt;h2&gt;Experimental lab data: ELN and LIMS&lt;/h2&gt;
&lt;p&gt;Up to now, I've mainly used the output of instruments like sequencers as my examples,
since these are the largest source of raw data.&lt;/p&gt;
&lt;p&gt;Apart from raw instrument data, 
there is also "experimental lab" data.
This is usually a small amount of data,
but more heterogeneous, interconnected, and difficult to organize.
The world of lab data software is not well-defined,
but at least two types of systems that come up are ELNs and LIMSs.&lt;/p&gt;
&lt;p&gt;An &lt;strong&gt;ELN&lt;/strong&gt; (electronic lab notebooks) is just what it sounds like:
semi-structured data-stores for experimental data.
They may also include common helper tools that scientists find useful in the lab (e.g., unit conversions).&lt;/p&gt;
&lt;p&gt;A &lt;strong&gt;LIMS&lt;/strong&gt; (laboratory information management system) is similar to an ELN,
in that it helps log experimental data,
but it's less of a personal notebook,
and more like the software that runs lab operations.
At a certain scale — and not very large — a biotech will need a LIMS to
(a) manage the instrument data they are generating;
(b) manage all the inventory in the lab;
(c) manage lab workflows ("after process A, queue up for process B").&lt;/p&gt;
&lt;p&gt;Despite how important LIMS are to biotech,
I don't know how a biotech is supposed to get one up and running.
Most of the modern LIMS I am aware of were developed in-house,
despite the large amount of redundancy in functionality.
Even today, &lt;a href="https://www.limswiki.org/index.php/LIMS_vendor"&gt;most LIMS&lt;/a&gt;
are developed by small companies with small software teams.
Unfortunately, I don't know of any specific LIMS that works well for general use.&lt;/p&gt;
&lt;h3&gt;Modern experimental lab data tools&lt;/h3&gt;
&lt;p&gt;The modern tools I am aware of that overlap with ELNs and/or LIMSs include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.benchling.com/"&gt;Benchling&lt;/a&gt;: a "life sciences R&amp;amp;D cloud".
  Benchling began as an ELN, and has gradually added LIMS functionality. 
  It is the most popular tool listed here, probably by a wide margin.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.radix.bio/"&gt;Radix&lt;/a&gt;: an "operating system for your lab".
  Radix appears to have a hardware focus that sounds promising ("connect all hardware and software together").
  I do worry that you need also boots on the ground, working directly with your machines, to make this integration work properly.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.synthace.com/"&gt;Synthace&lt;/a&gt;: an "R&amp;amp;D cloud" with a focus on experimental design and automation.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tetrascience.com/"&gt;TetraScience&lt;/a&gt;: an "R&amp;amp;D Data Cloud for life sciences" with instrument integrations.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://scicord.com/scicord-eln-or-lims/"&gt;SciCord&lt;/a&gt;: "combines the compliance and structured aspects of a Laboratory Information Management System (LIMS) with the flexibility of an Electronic Laboratory Notebook (ELN)". &lt;/li&gt;
&lt;li&gt;&lt;a href="https://elementalmachines.com/"&gt;Elemental Machines&lt;/a&gt;: "Distills a lab full of data onto a single dashboard".
  Elemental Machines is more focused on sensors and data monitoring than the others on this list, and hence may complement an ELN or LIMS.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you are wondering how these tools fit into your biotech,
and what problems they specifically solve, well I am too.
My impression is that most of these tools want to be a solution for data management and analysis,
but without promising specific LIMS functionality,
reflecting the breadth of the problem.
LIMS means interfacing with devices,
and that is often slow, custom work.
You may need to just custom build your system,
perhaps with help from a consulting group like &lt;a href="https://www.monomerbio.com/"&gt;Monomer Bio&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This &lt;a href="https://www.nature.com/articles/d41586-019-02875-z"&gt;2019 Nature news item&lt;/a&gt;
also discusses this topic — including remarks from Radix and Synthace — but from the perspective of cloud labs,
which is a whole &lt;a href="http://blog.booleanbiotech.com/genetic_engineering_pipeline_python.html"&gt;separate topic&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Compliance, traceability, etc.&lt;/h3&gt;
&lt;p&gt;There are also tools like &lt;a href="https://www.veeva.com/"&gt;Veeva&lt;/a&gt;
that are more focused on later stage biotech problems like compliance, traceability, manufacturing, marketing, etc.
These tools are out of scope for early-stage biotechs.&lt;/p&gt;
&lt;h2&gt;This is getting pretty long&lt;/h2&gt;
&lt;p&gt;The point of this post was supposed to be listing some technology choices
I think would make sense for a new, data-driven biotech startup.
So, here are a few loose conclusions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Start out with all your data in one place on the cloud, and disallow storing files on laptops.&lt;/li&gt;
&lt;li&gt;Use the cloud for all compute and storage, especially buckets where possible.&lt;/li&gt;
&lt;li&gt;Put off doing anything with servers, databases — and especially multiples of these — as long as you can.&lt;/li&gt;
&lt;li&gt;One big hard drive and a big CPU can store and process more data than you might think, possibly even &lt;em&gt;all&lt;/em&gt; of your data.
It's unlikely you have more than terabytes of locally-useful data. (Raw data should live in buckets!)&lt;/li&gt;
&lt;li&gt;Try out all the available data tools and platforms before building anything yourself — maintenance asymptotes at 100% of the total work required.&lt;/li&gt;
&lt;li&gt;It's easy to trial a couple of ELNs and pick your favorite but I have no idea what you are supposed to do about LIMS.
If anyone figures this out I'd love to know.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It would be useful to have some best practices out there for biotech data (or even more generally, hard tech data).
Unfortunately, the tech end of biotech is much smaller and more insular (read, IP-focused) than regular tech,
so there is much less material around on what's going on inside companies in the space.
In general, everyone is building their own thing, and mostly starting from scratch, incurring huge inefficiencies.
I hope that the rapidly increasing number of "techbio" companies will improve this 
(e.g., &lt;a href="https://www.youtube.com/watch?v=SF_Khx2IqVg"&gt;EQRx&lt;/a&gt; had a recent video on their data stack),
and we'll soon commoditize the nuts-and-bolts data problems and put the focus back on the biological problems.&lt;/p&gt;</content><category term="biotech"/><category term="biotech"/></entry><entry><title>Permutation tests are good</title><link href="/permutation-tests-are-good.html" rel="alternate"/><published>2021-10-03T11:00:00-07:00</published><updated>2021-10-03T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2021-10-03:/permutation-tests-are-good.html</id><summary type="html">&lt;p&gt;Some examples of permutation tests being applied to t-test-like problems.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I really like &lt;a href="https://en.wikipedia.org/wiki/Resampling_(statistics)"&gt;resampling methods&lt;/a&gt;
for data analysis, and I think they are under-utilized.
The main thing these techniques have in common is that instead of an analytical solution,
they make a computer repeatedly analyze variations of the data.
Examples of resampling methods include permutation tests, the bootstrap, and cross-validation. &lt;/p&gt;
&lt;p&gt;Cross-validation in particular seems to have really taken over model selection over the last ten years or so
(e.g., compared to the more "statistical" &lt;a href="https://en.wikipedia.org/wiki/Akaike_information_criterion"&gt;AIC&lt;/a&gt;
or &lt;a href="https://en.wikipedia.org/wiki/Bayesian_information_criterion"&gt;BIC&lt;/a&gt;).
There may be an argument here that this is due to non-statisticians needing statistical tests (e.g., in machine learning)
so they naturally gravitate to using computational power instead of statistical expertise.&lt;/p&gt;
&lt;p&gt;In biology, there are a few tests than come up a lot,
but the main one is probably testing if distribution A is different to distribution B (e.g., experiment vs control).
This is usually done with a t-test, but can also be done — with some advantages — by a permutation test.
I looked for a post on this topic but could not find one that exactly covered what I was interested in,
so this article will show some data on this.&lt;/p&gt;
&lt;p&gt;Here are a few related articles that may be of interest:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.jwilber.me/permutationtest/"&gt;The Permutation Test&lt;/a&gt;: some nice animations showing the basics of permutation tests&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.lreding.com/nonstandard_deviations/2017/10/26/mc_t_test/"&gt;tidy resampling&lt;/a&gt;: using a permutation test to replace a t-test, in tidy R&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.jstor.org/stable/2685470"&gt;Why Permutation Tests are Superior to t and F Tests in Biomedical Research&lt;/a&gt;: "Because randomization rather than random sampling is the norm in biomedical research and because group sizes are usually small, exact permutation or randomization tests for differences in location should be preferred to t or F tests."&lt;/li&gt;
&lt;li&gt;&lt;a href="https://lindeloev.github.io/tests-as-linear/"&gt;Common statistical tests are linear models&lt;/a&gt;: only related in theme, but has t-tests in there, and worth reading&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- 
The elaboration on a t-test is [ANOVA](https://en.wikipedia.org/wiki/Analysis_of_variance), but this technique has never come up for me.
The elaboration on this would be ANOVA, but I don't have any real experience with that.
This blogpost was memorable for pointing out flaws in how ANOVA gets used: http://deevybee.blogspot.com/2013/06/interpreting-unexpected-significant.html
--&gt;

&lt;h2&gt;The t-test&lt;/h2&gt;
&lt;p&gt;I would guess most biologists use t-tests occasionally, as the simplest way to check if an experimental result differs from a control.
I would also argue that most people who use the t-test don't really know the main assumptions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the distributions are normal&lt;/li&gt;
&lt;li&gt;the variances of the distributions are equal&lt;/li&gt;
&lt;li&gt;the sample size is large&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you violate any of these assumptions, you are supposed to  consider another test.&lt;/p&gt;
&lt;h3&gt;If distributions are not normal&lt;/h3&gt;
&lt;p&gt;We usually assume if a distribution is not normal then it's some unknown distribution.
In this case you could use a non-parametric test, like the &lt;a href="https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test"&gt;Mann–Whitney U test&lt;/a&gt;.
Of course, there's no such thing as a completely normal distribution, so it's a bit unclear where to draw the line here.&lt;/p&gt;
&lt;h3&gt;If variances are unequal&lt;/h3&gt;
&lt;p&gt;If the variances are unequal, &lt;a href="https://en.wikipedia.org/wiki/Welch%27s_t-test"&gt;Welch's t-test&lt;/a&gt; is recommended.
Welch's t-test is "an adaptation of Student's t-test, 
and is more reliable when the two samples have unequal variances and/or unequal sample sizes."
I'm not sure I've ever seen this test used in a biology paper, though variances are very often unequal.
For example, any time you are counting things (colonies, etc) it's likely a Poisson distribution where the variance equals the mean.&lt;/p&gt;
&lt;h3&gt;If sample size is small&lt;/h3&gt;
&lt;p&gt;It's a bit of a grey area how few samples count as "small", but some sources say below 30.
That is actually a pretty large number for many biological experiments!&lt;/p&gt;
&lt;p&gt;For example, if I do a quick review of the first four papers that pop up for the search &lt;a href="https://scholar.google.com/scholar?hl=en&amp;amp;as_sdt=0%2C5&amp;amp;q=mouse+xenograft+tumor+treatment+t-test&amp;amp;btnG="&gt;"xenograft tumor treatment t-test"&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=""&gt;https://acsjournals.onlinelibrary.wiley.com/doi/full/10.1002/cncr.22441&lt;/a&gt;: &amp;lt;=20 mice&lt;/li&gt;
&lt;li&gt;&lt;a href=""&gt;https://cancerres.aacrjournals.org/content/61/20/7669.full-text.pdf&lt;/a&gt;: "Data (n = 3) were compared with VEGF controls using t test analysis"&lt;/li&gt;
&lt;li&gt;&lt;a href=""&gt;https://cancerres.aacrjournals.org/content/67/8/3560.full-text.pdf&lt;/a&gt;: 7 groups of 7 mice&lt;/li&gt;
&lt;li&gt;&lt;a href=""&gt;https://link.springer.com/article/10.1007/s10585-010-9321-4&lt;/a&gt;: 10 mice&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In order to publish, the authors of these papers need to be able to report a p-value,
and the t-test is the most convenient, and accepted tool.&lt;/p&gt;
&lt;h3&gt;Violations&lt;/h3&gt;
&lt;p&gt;It's possible that the above violations in assumptions are just fine, and the stats work out fine.
Still, the lack of clarity on what counts as a violation here seems to defeat the purpose of having the rules,
and a permutation test might offer a safer approach.&lt;/p&gt;
&lt;h2&gt;Permutation Test&lt;/h2&gt;
&lt;p&gt;The general problem below will be to determine if two distributions with mean of &lt;code&gt;0&lt;/code&gt; (red) and &lt;code&gt;diff&lt;/code&gt; (yellow), are different.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scipy.stats&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;laplace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;median_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mannwhitneyu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pearsonr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linregress&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;SVG&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;tqdm.auto&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;
&lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pandas&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;dist1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;dist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;histplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;histplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'y'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bins&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/pt_output_4_0.png"&gt;&lt;/p&gt;
&lt;p&gt;This is the code for a permutation test, for use in place of a one- or two-sided t-test, Welch's t-test, etc.
In all examples below I will use a two-sided t-test, since this is more commonly used than one-sided.
(Although to me, one-sided makes more sense most the time!)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;ptest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""permutation test, matching scipy.ttest_ind syntax"""&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;collections&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;namedtuple&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;warnings&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;warn&lt;/span&gt;

    &lt;span class="n"&gt;PTResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;namedtuple&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"PTResult"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"stat"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pvalue"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="n"&gt;new_dists&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;concatenate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shuffle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_dists&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;ndist1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_dists&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
        &lt;span class="n"&gt;ndist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_dists&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;):]&lt;/span&gt;
        &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ndist1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ndist2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;stat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"less"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;pvalue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stat&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"greater"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;pvalue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;stat&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;pvalue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;stat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="ne"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="si"&gt;=}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pvalue&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"permutation test sample limit reached: &amp;lt;1/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;pvalue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;PTResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pvalue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_xy&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="sd"&gt;"""Plot the correlation between two tests, and report Pearson's r"""&lt;/span&gt;
    &lt;span class="n"&gt;lx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ly&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"log_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"log_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nan&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dropna&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;lx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;ly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;)}))&lt;/span&gt;

    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;linregress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ly&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lx&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scatterplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;lx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ly&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lineplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_xy&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;intercept&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slope&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_xy&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'r'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_xlim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min_xy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_ylim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min_xy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;axline&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;min_xy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_xy&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'g'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvalue&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;t-test with normal distributions&lt;/h3&gt;
&lt;p&gt;This is the simplest case: comparing two equal variance, high sample size, normal distributions. 
Here we see an almost perfect correspondence between the results of the t-test and permutation test.
This is good, since it shows the permutation test is not reporting biased (e.g., too low) p-values.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;

&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.02&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="n"&gt;dist1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;tt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;
    &lt;span class="n"&gt;pt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ptest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;

    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;tt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;df_rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'t-test vs permutation r: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;t-test vs permutation r: 1.000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/pt_output_9_2.png"&gt;&lt;/p&gt;
&lt;h3&gt;t-test with normal distributions, but low sample size&lt;/h3&gt;
&lt;p&gt;What happens to the results of a t-test when the number of samples is low?
Here, the low sample size results in some noise that decreases the correlation,
but it still seems to work very similarly to the permutation test, even with just 3 samples
(despite the regression line below).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;

&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.03&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="n"&gt;dist1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;tt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;
    &lt;span class="n"&gt;pt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ptest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;

    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;tt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;df_rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'t-test vs permutation r: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/tmp/ipykernel_2790/1233266942.py:30: UserWarning: permutation test sample limit reached: &amp;lt;1/30000
  warn(f"permutation test sample limit reached: &amp;lt;1/{N}")


t-test vs permutation r: 0.760
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/pt_output_11_3.png"&gt;&lt;/p&gt;
&lt;h3&gt;t-test with normal distributions, but unequal variances&lt;/h3&gt;
&lt;p&gt;scipy's &lt;code&gt;ttest_ind&lt;/code&gt; has an option to use &lt;a href="https://en.wikipedia.org/wiki/Welch%27s_t-test"&gt;Welch's t-test&lt;/a&gt; instead of a t-test.
Again, the results are almost identical between Welch's t-test and the permutation test.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;

&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.075&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="n"&gt;dist1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;tt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'two-sided'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;equal_var&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;
    &lt;span class="n"&gt;pt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ptest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;

    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;tt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;df_rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'t-test vs permutation r: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;/tmp/ipykernel_2790/1233266942.py:30: UserWarning: permutation test sample limit reached: &amp;lt;1/30000
  warn(f"permutation test sample limit reached: &amp;lt;1/{N}")


t-test vs permutation r: 0.967
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/pt_output_13_3.png"&gt;&lt;/p&gt;
&lt;h3&gt;t-test with non-normal distributions&lt;/h3&gt;
&lt;p&gt;In this case, the &lt;a href="https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test"&gt;Mann-Whitney U test&lt;/a&gt; is usually recommended instead of the t-test.
The Mann-Whitney U test "is a nonparametric test of the null hypothesis that, for randomly selected values X and Y from two populations, the probability of X being greater than Y is equal to the probability of Y being greater than X."
However, two distributions can have equal medians, but different distributions, and Mann-Whitney may return a significant p-value.&lt;/p&gt;
&lt;p&gt;Another option is to directly test for a difference in medians, with &lt;a href="https://en.wikipedia.org/wiki/Median_test"&gt;Mood's median test&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I'm not sure why the permutation test and median test results don't match more closely here, though the median test only produces a few possible p-values.
Still, the results are quite close, and appear unbiased. The correlation between the permutation tests and Mann-Whitney U test is also very high.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;

&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.025&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="n"&gt;dist1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;laplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;laplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;mt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;median_test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ties&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ignore"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# ugh, inconsistent scipy syntax&lt;/span&gt;
    &lt;span class="n"&gt;ut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mannwhitneyu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# ugh, inconsistent scipy syntax&lt;/span&gt;
    &lt;span class="n"&gt;pt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ptest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;median&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;

    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;mt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ut&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;df_rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ut"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'median test vs permutation r:  &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"mt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'mann-whitney vs permutation r: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ut"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'mann-whitney vs median test r: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ut"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"mt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;median test vs permutation r:  0.863
mann-whitney vs permutation r: 0.920
mann-whitney vs median test r: 0.873
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/pt_output_15_2.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="png" src="/images/pt_output_15_3.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="png" src="/images/pt_output_15_4.png"&gt;&lt;/p&gt;
&lt;h3&gt;t-test with normal distributions, but one outlier sample&lt;/h3&gt;
&lt;p&gt;A common problem with real-world datasets is outlier datapoints that greatly skew the distribution and hence skew p-values.
Removing or accounting for outliers will increase the robustness of a test (e.g., how sensitive the result is to an erroneous reading).&lt;/p&gt;
&lt;p&gt;It's interesting that the t-test is reasonably well correlated with the other two tests, but way off the diagonal.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;

&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.025&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
    &lt;span class="n"&gt;dist1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;concatenate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])])&lt;/span&gt;
    &lt;span class="n"&gt;dist2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;concatenate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rvs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sample_size&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;])])&lt;/span&gt;

    &lt;span class="n"&gt;mt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mannwhitneyu&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'two-sided'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;
    &lt;span class="n"&gt;tt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;
    &lt;span class="n"&gt;pt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ptest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dist1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;median&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alternative&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"two-sided"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pvalue&lt;/span&gt;

    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;mt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;df_rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"mt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'mann-whitney vs permutation r: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"mt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'t-test vs mann-whitney r:      &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"mt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'t-test vs permutation r:       &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;plot_corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pt"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;.3f&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;mann-whitney vs permutation r: 0.923
t-test vs mann-whitney r:      0.926
t-test vs permutation r:       0.835
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/pt_output_17_2.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="png" src="/images/pt_output_17_3.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="png" src="/images/pt_output_17_4.png"&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;In general, the permutation test gives you the same answer you would get if you chose the "right" test for your task.
But, you have to exert less effort in figuring out what the right test is.&lt;/p&gt;
&lt;p&gt;There is a very direct connection between the test you want and the calculation performed.
For example, with the Mann-Whitney U test, it's confusing what is actually being tested, apart from "the non-parametric alternative to a t-test".&lt;/p&gt;
&lt;p&gt;The permutation test is also robust in a way that serves most use-cases.
Outliers are handled conservatively, and there are few or no assumptions to violate.&lt;/p&gt;
&lt;h3&gt;Disadvantages&lt;/h3&gt;
&lt;p&gt;There are some disadvantages too, but relatively minor I think.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Regular t-tests do pretty well in my tests above, even with only 3 samples! The only major problem is with outliers, which can imply extremely wide distributions if taken at face-value.&lt;/li&gt;
&lt;li&gt;Permutation tests can be slow, so if you are doing thousands of tests, or you need precise, very low p-values, then they will likely not be suitable.&lt;/li&gt;
&lt;li&gt;You have to know precisely what you are testing. For example, "are the medians of these two distributions identical?". This is mostly an advantage in that it's more explicit.&lt;/li&gt;
&lt;li&gt;You get more statistical power if you use the test that includes the correct assumptions. This seems to be a very minor effect in my tests above. &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Overall, you can't go too far wrong with permutation tests since they are so simple.
If nothing else, they are a good way to sanity check results from other tests with more assumptions.&lt;/p&gt;</content><category term="datascience"/><category term="statistics"/><category term="datascience"/></entry><entry><title>Sequencing a human genome at home</title><link href="/human-genome-at-home.html" rel="alternate"/><published>2021-02-15T11:00:00-08:00</published><updated>2021-02-15T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2021-02-15:/human-genome-at-home.html</id><summary type="html">&lt;p&gt;Sequencing a human genome at home, using a nanopore sequencer.&lt;/p&gt;</summary><content type="html">&lt;!-- to make dataframes pretty --&gt;

&lt;!--
&lt;video loop autoplay muted width="800" height="600"&gt;
  &lt;source src="http://blog.booleanbiotech.com.s3.amazonaws.com/temp.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;
&lt;video loop autoplay muted width="800" height="600"&gt;
  &lt;source src="/images/seq2020_mp4.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;
&lt;video loop autoplay muted width="800" height="600"&gt;
  &lt;source src="/images/lab_step_1.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;
&lt;video loop autoplay muted width="800" height="600"&gt;
  &lt;source src="/images/lab_step_1.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;
&lt;img src="/images/seq2020_lab.webp" /&gt;
&lt;video loop autoplay width="800" height="600" controls&gt;
  &lt;source src="http://blog.booleanbiotech.com.s3.amazonaws.com/temp2.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;
--&gt;

&lt;p&gt;In this post I'll describe how to sequence a human genome at home,
something that's only recently become possible.&lt;/p&gt;
&lt;!--If you want to do this, it will cost about two thousand dollars in lab equipment.--&gt;
&lt;!--It takes about two hours to run the experiment, then 24-48 hours for the sequencing.--&gt;
&lt;p&gt;The protocol described here is not necessarily the best way to do this, but it's what has worked best for me.
It costs a few thousand dollars in equipment to get started,
but the (low-coverage) sequencing itself requires only $150, a couple of hours of work, and almost no lab skills.&lt;/p&gt;
&lt;!--
# Why would I want to do this?
There is no good reason to do this, except that it's possible.
Nanopore sequencing at home is more suited to identifying species.

# How do I do this?
Though it's not cheap to set everything up, it's still pretty amazing that this can be done at home.
Given the correct equipment, this protocol requires no special skills.
--&gt;

&lt;h1&gt;What does it mean to sequence a human genome?&lt;/h1&gt;
&lt;!--There are a few ways to sequence a human genome.--&gt;

&lt;p&gt;First, it's useful to explain some terms:
specifically, to differentiate a regular &lt;a href="https://en.wikipedia.org/wiki/Sequence_assembly#De-novo_vs._mapping_assembly"&gt;reference-based&lt;/a&gt; genome assembly from a &lt;i&gt;de novo&lt;/i&gt; genome assembly.&lt;/p&gt;
&lt;p&gt;Twenty years or so ago, the &lt;a href="https://en.wikipedia.org/wiki/Human_Genome_Project"&gt;Human Genome Project&lt;/a&gt;
resulted in one complete human genome sequence (actually combining data from several humans).
Since all humans are 99.9%+ identical genetically, this &lt;strong&gt;reference genome&lt;/strong&gt; can be used as a template for any human.
The easiest way to sequence a human genome is to generate millions of short reads (100-300 base-pairs)
and aligning them to this reference.&lt;/p&gt;
&lt;p&gt;The alternative to this reference-based assembly is a &lt;i&gt;de novo&lt;/i&gt; assembly,
where you figure out the genome sequence without using the reference,
by stitching together overlapping sequencing reads.
This is much more difficult computationally (and actually impossible if your reads are too short),
but the advantage is that you can potentially see large differences compared to the reference.
For example, it's not uncommon to have some sequence in a genome that is not present in the reference genome,
so-called &lt;a href="https://en.wikipedia.org/wiki/Structural_variation_in_the_human_genome"&gt;structural variants&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are also gaps in the reference genome, especially at the &lt;a href="https://en.wikipedia.org/wiki/Heterochromatin#:~:text=Heterochromatin%20is%20a%20tightly%20packed,in%20the%20expression%20of%20genes."&gt;ends and middle of chromosomes&lt;/a&gt;,
due to highly repetitive sequence.
In fact, the first &lt;a href="https://www.nature.com/articles/s41586-020-2547-7"&gt;full end-to-end human chromosome&lt;/a&gt;
was only sequenced last year, thanks to ultra-long nanopore reads.&lt;/p&gt;
&lt;p&gt;For non-human species, genome assembly is usually &lt;i&gt;de novo&lt;/i&gt;,
either because the genomes are small and non-repetitive (bacteria),
or there is no reference (newly sequenced species).&lt;/p&gt;
&lt;h2&gt;SNP chip&lt;/h2&gt;
&lt;p&gt;The cheapest way to get human genome sequence data is with a SNP chip,
like the &lt;a href="https://www.23andme.com/dna-health-ancestry"&gt;23andMe chip&lt;/a&gt;.
These chips work by measuring variation at specific, pre-determined positions in the genome.
Since we know the positions that commonly vary in the human genome,
we can just examine a few hundred thousand of those positions to see most of the variation.
You can also accurately &lt;a href="https://en.wikipedia.org/wiki/Imputation_(genetics)"&gt;impute&lt;/a&gt; tons of additional variants not on the chip.
The reason this is "genotyping" and not "sequencing" is that you don't get a contiguous sequence of As, Cs, Gs, and Ts.
The major disadvantage of SNP chips is that you cannot directly measure variants not on the chip,
so you miss things, especially rare and novel variants.
On the other hand, the accuracy for a specific variant of interest
(e.g., a recessive disease variant like cystic fibrosis ΔF508) is probably higher than from a sequenced genome.&lt;/p&gt;
&lt;h2&gt;Short-read sequencing&lt;/h2&gt;
&lt;p&gt;Short-read sequencing is almost always done with &lt;a href="https://www.illumina.com/systems/sequencing-platforms.html"&gt;Illumina sequencers&lt;/a&gt;,
though other &lt;a href="http://omicsomics.blogspot.com/2020/02/a-lazy-look-at-field-of-sequencing.html"&gt;short-read technologies are emerging&lt;/a&gt;.
These machines output millions or billions of 100-300 base-pair reads that you can align to the reference human genome.
Generally, people like to have on average 30X coverage of the human genome (~100 gigabases) to ensure high accuracy across the genome.&lt;/p&gt;
&lt;p&gt;Although you can read variants not present on a SNP chip, this is still not a complete genome:
coverage is not equal across the genome, so some regions will likely have too low coverage to call variants;
the reference genome is incomplete;
some structural variants (insertions, inversions, repetitive regions) cannot be detected with short reads.&lt;/p&gt;
&lt;!-- de novo?? --&gt;

&lt;h2&gt;Long-read sequencing&lt;/h2&gt;
&lt;p&gt;The past few years have seen single-molecule long-read sequencing develop into an essential complement
and sometimes credible alternative to Illumina.
The two players, &lt;a href="https://www.pacb.com/"&gt;Pacific Biosciences&lt;/a&gt; and &lt;a href="https://nanoporetech.com/"&gt;Oxford Nanopore&lt;/a&gt; (ONT) are now mature technologies.&lt;/p&gt;
&lt;!--(mainly because you are reading one molecule and not an aggregate of thousands of molecules).--&gt;
&lt;p&gt;The big advantage of these technologies is that you get reads much longer than 300bp
— from low thousands up to megabases on ONT in extreme examples —
so assembly is much easier.
This enables &lt;em&gt;de novo&lt;/em&gt; assembly, and is especially helpful with repetitive sequence.
For this reason, long-read sequencing is almost essential for sequencing new species,
especially highly repetitive plant genomes.&lt;/p&gt;
&lt;p&gt;Sounds great! Why do people still use Illumina then?
The per-base accuracy and per-base cost of Illumina is still considerably better than these competitors
(though &lt;a href="https://nanoporetech.com/products/promethion"&gt;ONT's PromethION&lt;/a&gt; is getting close on price).&lt;/p&gt;
&lt;p&gt;One huge advantage that ONT has over competitors is that the instrument is a fairly simple
solid-state device that reads electrical signals from the nanopores.
Since most of the technology is in the consumable "flow-cell" of pores,
the instruments can be tiny and almost free to buy.&lt;/p&gt;
&lt;p&gt;Instead of spending &amp;dollar;50k-1M on a complex machine that requires a service contract, etc.,
you can get a stapler-sized MinION sequencer for almost nothing, and you can use it almost anywhere.
ONT have also done a great job driving the cost per experiment down,
especially by releasing a lower-output flow-cell adaptor called the flongle.
Flongle flow-cells only cost $90 per flow-cell, and produce 100 megabases to &amp;gt;1 gigabase of sequence.&lt;/p&gt;
&lt;p&gt;There is a great primer on how nanopore sequencing works at &lt;a href="https://nanoporetech.com/how-it-works"&gt;nanoporetech.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Nanopore Sequencing Equipment&lt;/h1&gt;
&lt;p&gt;(Note, to make this article stand alone, I copied text from my previous &lt;a href="http://blog.booleanbiotech.com/sequencing-at-home-with-flongle.html"&gt;home lab blogpost&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;Surprisingly, you don't actually need much expensive equipment to do nanopore sequencing.&lt;/p&gt;
&lt;p&gt;In my home lab, I have the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.the-odin.com/pipette/"&gt;Three calibrated pipettes&lt;/a&gt; for $45 each and &lt;a href="http://www.the-odin.com/pipette-tips-1-200ul-box-of-96/"&gt;boxes of three sizes of pipette tips&lt;/a&gt; for $15 each from &lt;a href="https://www.the-odin.com"&gt;the-odin.com&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;An &lt;a href="https://www.nist.gov/laboratories/tools-instruments/eppendorf-5415c-centrifuge"&gt;Eppendorf 5415C&lt;/a&gt; centrifuge from &lt;a href="https://www.ebay.com/sch/i.html?_nkw=eppendorf+5415C"&gt;ebay&lt;/a&gt; for around $300. DNA extraction requires a centrifuge that can spin at &amp;gt;=12k rpm, which means a large-ish lab-grade centrifuge.&lt;/li&gt;
&lt;li&gt;A &lt;a href="http://www.the-odin.com/mini-4k-centrifuge/"&gt;mini-centrifuge&lt;/a&gt; for $45 from &lt;a href="https://www.the-odin.com"&gt;the-odin.com&lt;/a&gt;.
They also sell a nice &lt;a href="http://www.the-odin.com/10k-mini-centrifuge/"&gt;10k rpm version&lt;/a&gt; for $125.&lt;/li&gt;
&lt;li&gt;Two sous vides for water baths, e.g. this &lt;a href="https://www.amazon.com/Anova-Culinary-Precision-Bluetooth-Included/dp/B07C7PW3PC"&gt;Anova sous vide&lt;/a&gt; for $99 from amazon.&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.amazon.com/dp/B01CLLBZ6S/"&gt;vortex mixer&lt;/a&gt; for $80 from amazon.&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://nanoporetech.com/products/minion"&gt;MinION nanopore sequencer&lt;/a&gt;.
Unfortunately, you do not get a MinION with a &lt;a href="https://store.nanoporetech.com/flongle.html"&gt;flongle starter pack&lt;/a&gt; ($1,460).
The only way I know of to get a new one is in a &lt;a href="https://store.nanoporetech.com/configure-minion-basic"&gt;MinION starter pack&lt;/a&gt; for $1,000, which includes one MinION flow-cell, worth approximately $1000.&lt;/li&gt;
&lt;li&gt;A refrigerator that does not have a defrost cycle.
I bought a &lt;a href="https://www.amazon.com/BLACK-DECKER-BCRK17V-Compact-Refrigerator/dp/B01DZQI732/"&gt;small mini-fridge&lt;/a&gt;
from amazon for $150 so my lab stuff would not be in the kitchen fridge.&lt;/li&gt;
&lt;li&gt;I already had a chest freezer that does not have a &lt;a href="https://en.wikipedia.org/wiki/Auto-defrost"&gt;defrost cycle&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Optional equipment:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;a href="https://smile.amazon.com/gp/product/B0813744FY/"&gt;wireless fridge thermometer&lt;/a&gt;.
This was only $25 and it works great!
It's useful to be able to keep track of temperatures in your fridge or freezer.
Some fridges can get cold enough to freeze, which is deadly for flow-cells.&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://biochromspectros.com/spectrophotometers/genequant-1300-cat/genequant-1300-spectrophotometer.html"&gt;GeneQuant&lt;/a&gt;
to check the quality of DNA extractions.
A 20 year old machine cost me about $150 on ebay.
It's a useful tool, but does require quite a lot of sample (I use 200 µl).
I wrote a bit more about it &lt;a href="http://blog.booleanbiotech.com/water-purity-genequant.html"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="/images/home_lab_desk.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;*The lab during a sequencing run. MinION running and used flow-cell on the desk in front*&lt;/figcaption&gt;

&lt;p&gt;&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_centrifuge.jpg" /&gt;
&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_sous_vide.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;*(a) Eppendorf 5415C centrifuge. (b) Anova sous vide in a Costco coffee can*&lt;/figcaption&gt;

&lt;!--
I don't usually do anything with video, but I made an attempt to document the process below.
I thought it would help demystify the process, if nothing else.
I include the [moviepy](https://pypi.org/project/moviepy/) code I used to edit it at the end of the post.
--&gt;

&lt;h1&gt;Protocol Part One: extracting DNA&lt;/h1&gt;
&lt;p&gt;The first step in sequencing is DNA extraction (i.e., isolating DNA from biological material).
I use a &lt;a href="https://www.zymoresearch.com/collections/quick-dna-kits/products/quick-dna-microprep-plus-kit"&gt;Zymo Quick-DNA Microprep Plus Kit&lt;/a&gt;, costing $132.
It's 50 preps, so a little under $3 per prep.
There are other kits out there,
like &lt;a href="https://www.neb.com/products/t3010-monarch-genomic-dna-purification-kit#Product%20Information"&gt;NEB's Monarch&lt;/a&gt;,
but these are harder to buy (requiring a P.O., or business address).&lt;/p&gt;
&lt;p&gt;The Zymo kit takes "20 minutes" (it takes me about 40 minutes including setting up).
It is very versatile: it can work with "cell culture, solid tissue, saliva, and any biological fluid sample".
This prep is pretty easy to do, and all the reagents except Proteinase k are just stored at room temperature.
They claim it can recover &amp;gt;50kb fragments, and anecdotally, this is the maximum length I have seen.
That is far from the megabase-long &lt;a href="https://lab.loman.net/2017/03/09/ultrareads-for-nanopore/"&gt;"whale" reads&lt;/a&gt;
some labs can achieve,
but those preps are much more complex and time-consuming.
Generally speaking, 10kb fragments are more than long enough for most use-cases.&lt;/p&gt;
&lt;!--

## Step one: get 50ul of saliva
I start by just spitting in a tube, then collecting 50µl of that material.
DNA in saliva is actually mostly from
[white blood cells](https://en.wikipedia.org/wiki/White_blood_cell)
([up to 74%](https://blog.dnagenotek.com/blogdnagenotekcom/bid/35944/Rinse-Swab-or-Spit-What-s-the-Real-Source-of-DNA-in-Saliva)),
not epithelial cells. (Cheek swabs are mostly epithelial cells.)
For most use-cases, saliva is as good as blood, and much easier to acquire.

&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/step_1_saliva.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;

## Step two: add proteinase k
[Proteinase k](https://en.wikipedia.org/wiki/Proteinase_K)
is the only component of the DNA extraction that needs to be stored in the freezer.
It [degrades protein](https://en.wikipedia.org/wiki/Proteinase_K),
which can itself degrade DNA, as well as just get in the way.

&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/step_2_proteinase_k.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;

## Step three: add cell buffer
The cell buffer is [guanidinium thiocyanate](https://en.wikipedia.org/wiki/Guanidinium_thiocyanate),
It lyses cells, while denaturing the DNase that might cause.

&lt;!--Like all lab materials, it should be [handled with care](http://fscimage.fishersci.com/msds/01933.htm).

&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/step_3_buffer.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;


## Step four: add genomic binding buffer
Add an equal volume (105µl) of genomic binding buffer.

&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/step_4_genomic_binding_buffer.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;

## Step five: transfer to centrifuge

&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/step_5_transfer_to_centrifuge_tube.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;

## Step six: transfer to centrifuge tube

&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/step_6_transfer_to_centrifuge_tube.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;

# --&gt;

&lt;h1&gt;Protocol Part Two: library prep&lt;/h1&gt;
&lt;p&gt;Library prep is the process of preparing the DNA for sequencing,
for example by attaching the &lt;a href="https://nanoporetech.com/how-it-works"&gt;"motor protein"&lt;/a&gt;
that ratchets the DNA through the pore one base at a time.
The rapid library prep (&lt;a href="https://store.nanoporetech.com/us/sample-prep/rapid-sequencing-kit.html"&gt;RAD-004&lt;/a&gt;)
is the simplest and quickest library prep method available,
at &amp;dollar;600 for 12 preps (&amp;dollar;50 per prep).&lt;/p&gt;
&lt;p&gt;Library prep is about as difficult as DNA extraction, and takes around 30 minutes.
There are some very low volumes involved (down to 0.5µl, which is as low as my pipettes go),
and you need two to use two water bath temperatures, but overall it's pretty straightforward.&lt;/p&gt;
&lt;p&gt;The total time from acquiring a sample to beginning sequencing could be as little as 60-90 minutes.
You do pay for this convenience in lower read lengths and lower throughput though.&lt;/p&gt;
&lt;h1&gt;The Data&lt;/h1&gt;
&lt;p&gt;The amount of data you can get from ONT/nanopore varies quite a lot.
There is a fundamental difference between Illumina and nanopore
in that nanopore is single-molecule sequencing.
With nanopore, each read represents a single DNA molecule traversing the pore.
With Illumina, a read is an aggegated signal from many DNA molecules (which contributes to the accuracy).&lt;/p&gt;
&lt;p&gt;So, nanopore is really working with the raw material you put in.
If there are contaminants, then they can jam up the pores.
If there are mostly short DNA fragments in the sample, you will get mostly short reads.
Over time, the pores degrade, so you won't get as much data from a months-old flow-cell as a new one.&lt;/p&gt;
&lt;p&gt;Using the protocol above, I have been able to get around 100-200 megabases of data from one flongle ($1 per megabase!).
There are probably a few factors contributing to this relatively low throughput:
the rapid kit does not work as well as the more complex
&lt;a href="https://store.nanoporetech.com/us/catalog/product/view/id/488/s/ligation-sequencing-kit110/category/28/"&gt;ligation kit&lt;/a&gt;;
I don't do a lot of sequencing, so the protocol is certainly executed imperfectly;
my flow-cells are not always fresh.&lt;/p&gt;
&lt;p&gt;For a human sample, 100 megabases is less than a 0.1X genome,
which raises the fair question of why you would want to do that?
Today, the answer is mainly just because you can.
You could definitely do some interesting ancestry analyses,
but it would be difficult to validate without a reference database.
&lt;a href="https://gencove.com/data/gencove_product_sheet_human.pdf"&gt;gencove&lt;/a&gt;
also has several good population-level use-cases for low-pass sequencing.&lt;/p&gt;
&lt;p&gt;The next step up from a flongle is a full-size MinION flow-cell,
which runs on the same equipment and uses the same protocol,
but costs around $900, and in theory can produce up to 42 gigabases of sequence.
This would be a "thousand dollar genome",
though the accuracy is probably below what you would want for diagnosic purposes.
In a year or two, I may be able to generate a diagnostic-quality human genome at home for around $1000,
perhaps even a decent &lt;em&gt;de novo&lt;/em&gt; assembly.&lt;/p&gt;
&lt;!--
## Step x: add FRA
&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/add_FRA.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;


## Step x: install flongle
&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/install_flongle.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;


## Step x: incubate at 55C
&lt;video loop autoplay muted width="640" height="480"&gt;
  &lt;source src="/images/human_genome_three_hours/step_y_incubate_55.mp4" type="video/mp4"&gt;
Your browser does not support the video tag.
&lt;/video&gt;

--&gt;</content><category term="genomics"/><category term="sequencing"/><category term="genomics"/><category term="nanopore"/><category term="protocol"/></entry><entry><title>Modeling EV range with a multilevel model</title><link href="/ev-range-multilevel-model.html" rel="alternate"/><published>2021-01-02T11:00:00-08:00</published><updated>2021-01-02T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2021-01-02:/ev-range-multilevel-model.html</id><summary type="html">&lt;p&gt;Using Bambi and brms to estimate the efficiency of electric cars.&lt;/p&gt;</summary><content type="html">&lt;div&gt;
&lt;style scoped&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
    .dataframe tbody tr th {
        vertical-align: top;
    }
    .dataframe thead th {
        text-align: right;
    }
    .dataframe {
        font-size: 11pt;
        font-family: Arial;
        border-collapse: collapse;
        border: 1px solid silver;
    }
    .dataframe td, th {
        padding: 5px;
    }
    .dataframe tr:nth-child(even) {
        background: #E0E0E0;
    }
    .dataframe tr:hover {
        background: silver;
        cursor: pointer;
    }
    .dataframe th {
      background:#d5ddf5;
    }
&lt;/style&gt;
&lt;/div&gt;

&lt;p&gt;Youtuber &lt;a href="https://www.youtube.com/user/bjornnyland"&gt;Tesla Bjorn&lt;/a&gt; has a great channel reviewing electric cars.
Unusually, he tests the range of the cars in a consistent and rigorous way,
and posts all his results to a nicely-organized &lt;a href="https://docs.google.com/spreadsheets/d/1V6ucyFGKWuSQzvI8lMzvvWJHrBS82echMVJH37kwgjE/edit#gid=735351678"&gt;Google Sheet&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One interesting thing I picked up from his channel is that the
Porsche Taycan has much worse range than Tesla with its stock tires,
but &lt;a href="https://www.youtube.com/watch?v=VB24iJbusgQ"&gt;excellent range of 360mi/580km&lt;/a&gt;
with smaller, more efficient tires (and better weather).
One obvious question I had was, how much does tire size and temperature affect range?
Since the data was all there, I decided to take a look.&lt;/p&gt;
&lt;p&gt;This was also a good excuse to play with &lt;a href="https://cran.r-project.org/web/packages/brms/index.html"&gt;brms&lt;/a&gt;,
a Bayesian multilevel modeling tool for R.
I won't explain &lt;a href="https://en.wikipedia.org/wiki/Multilevel_model"&gt;multilevel modeling&lt;/a&gt; here
— others have done a much better job at this than I could (see various links below) —
but at least in my mind, it's like regular regression, but can incorporate information on subgroups and subgroup relationships.
&lt;a href="https://elevanth.org/blog/2017/08/24/multilevel-regression-as-default/"&gt;McElreath argues&lt;/a&gt;
it should just be the default way to do regression, since the downsides are minimal.
&lt;a href="http://babieslearninglanguage.blogspot.com/2018/02/mixed-effects-models-is-it-time-to-go.html"&gt;This blogpost&lt;/a&gt;
makes a similar case, and helpfully notes that there is evidence that you should generally
"use the "maximal" random effects structure supported by the design of the experiment".
I take this to mean we should not worry too much about overfitting the model.&lt;/p&gt;
&lt;p&gt;Other resources I like include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;McElreath's &lt;a href="https://xcelab.net/rm/statistical-rethinking/"&gt;Statistical Rethinking book&lt;/a&gt; and &lt;a href="https://www.youtube.com/playlist?list=PLDcUM9US4XdNM4Edgs7weiyIguLSToZRI"&gt;lectures&lt;/a&gt; — also available as &lt;a href="https://bookdown.org/content/3890/"&gt;brms code&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twiecki.io/blog/2014/03/17/bayesian-glms-3/"&gt;Thomas Wiecki&lt;/a&gt; and &lt;a href="https://mc-stan.org/users/documentation/case-studies/radon.html"&gt;Chris Fonnesbeck&lt;/a&gt; running the classic radon measurement example.&lt;/li&gt;
&lt;li&gt;Though not technically multilevel, I think a lot about
  Andrew Gelman's &lt;a href="https://mc-stan.org/users/documentation/case-studies/golf.html"&gt;model of golf putts&lt;/a&gt;.
  It's a great example of modeling a real-life process, and incorporating prior information in a useful way.
  I wish more science worked like this blogpost...&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Bambi vs brms&lt;/h2&gt;
&lt;p&gt;Even though this exercise was an excuse to try brms, I ended up mostly using &lt;a href="https://github.com/bambinos/bambi"&gt;Bambi&lt;/a&gt;.
They are very similar tools, except Bambi is built on Python/PyMC3 and brms is built on R/Stan
(&lt;a href="https://github.com/adamhaber/pybrms"&gt;pybrms&lt;/a&gt; also exists but I could not get it to work).
I am assuming Bambi was influenced by brms too.&lt;/p&gt;
&lt;p&gt;They both follow very similar syntax to widely-used R regression tools
like &lt;a href="https://cran.r-project.org/web/packages/lme4/index.html"&gt;lme4&lt;/a&gt;.
Using Bambi also lets me use the excellent &lt;a href="https://arviz-devs.github.io/arviz/index.html"&gt;Arviz plotting package&lt;/a&gt;,
and I can still use the more battle-tested brms to confirm my results.&lt;/p&gt;
&lt;h2&gt;Simulating data&lt;/h2&gt;
&lt;p&gt;Simulated data is always useful for these models.
It really helps get comfortable with the process generating the data,
and make sure the model can produce reasonable results under ideal conditions.&lt;/p&gt;
&lt;p&gt;My model is an attempt to find the "base efficiency" of each car.
Each car has a total tested efficiency, measured in Wh/km,
which you can easily calculate based on the range (km) and the battery size (Wh).&lt;/p&gt;
&lt;p&gt;In my model, a car's measured Wh/km (&lt;code&gt;Whk&lt;/code&gt;) is the sum of effects due to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the car's base efficiency (&lt;code&gt;car&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the weight of the car in tons (&lt;code&gt;ton&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the ambient temperature (&lt;code&gt;dgC&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the tire size in inches (&lt;code&gt;tir&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the surface being wet or dry (&lt;code&gt;wet&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;the tested speed (&lt;code&gt;spd&lt;/code&gt; — Tesla Bjorn tests every vehicle at 90km/h and 120km/h).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The simulated data below match the real data pretty well.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;

&lt;span class="n"&gt;num_cars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="n"&gt;mu_Whk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="n"&gt;mu_dgC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="n"&gt;mu_wet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="n"&gt;mu_tir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="n"&gt;mu_spd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;
&lt;span class="n"&gt;mu_wgt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="n"&gt;mu_ton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;

&lt;span class="c1"&gt;# parameters of each car&lt;/span&gt;
&lt;span class="n"&gt;has_Whk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;has_ton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_wgt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu_wgt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_wgt&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;per_ton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_ton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu_ton&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_ton&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;per_dgC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_dgC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu_dgC&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_dgC&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="n"&gt;per_wet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_wet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu_wet&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_wet&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;per_tir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_tir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu_tir&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_tir&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;per_spd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_spd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu_spd&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mu_spd&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;num_samples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_samples&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;dgC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;wet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;spd&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="n"&gt;Whk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;has_Whk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;per_ton&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;has_ton&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;per_tir&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;tir&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
               &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;per_spd&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;spd&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;per_wet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;wet&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="si"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;02d&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;has_ton&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;dgC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;spd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Whk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;has_Whk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;]])&lt;/span&gt;

&lt;span class="n"&gt;df_sim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'car'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ton'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'dgC'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wet'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'tir'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'spd'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Whk'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'has_Whk'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_sim&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;num_cars&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"unlucky sample"&lt;/span&gt;
&lt;span class="n"&gt;df_sim&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/df_ev_range_sim.csv"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df_sim&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;    car ton         dgC         wet tir spd Whk         has_Whk
0   12  2.386572    15.096731   0   2   0   229.106858  110.0
1   12  2.386572    15.096731   0   2   1   293.139807  110.0
2   10  2.083366    12.632114   0   1   0   162.626350  100.0
3   10  2.083366    12.632114   0   1   1   221.408095  100.0
4   19  1.848348    13.203525   0   2   0   256.221089  145.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now I can build my model.
The model is pretty simple:
all priors are just &lt;a href="https://discourse.mc-stan.org/t/why-studentt-3-0-1-for-prior/8102/2"&gt;T distributions&lt;/a&gt;
(a bit fatter-tailed than normal).
I originally bounded some of the priors (since e.g., a car cannot use &amp;lt;0 Wh/km),
but since I couldn't get that to work with brms,
I removed the bounds to make comparisons easier.
(The bounds did not materially change the results).&lt;/p&gt;
&lt;p&gt;I have an group per car &lt;code&gt;(1|car)&lt;/code&gt;,
and although I could also have groups for &lt;code&gt;(1|spd)&lt;/code&gt; and &lt;code&gt;(1|wet)&lt;/code&gt;,
I opted not to do that since it didn't change the results,
but made the interpretation a little messier.
I set the intercept to &lt;code&gt;0&lt;/code&gt; so that the &lt;code&gt;1|car&lt;/code&gt; intercept can represent the base efficiency by itself.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;arviz&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;az&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;bambi&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;

&lt;span class="n"&gt;prior_car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_ton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_dgC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_wet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_tir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_spd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model_sim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_sim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_sim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; samples"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;res_sim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model_sim&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s1"&gt;'Whk ~ 0 + ton + dgC + tir + spd + wet'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;group_specific&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"1|car"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;categorical&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'car'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;priors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'car'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_car&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ton"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_ton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"dgC"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_dgC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s2"&gt;"wet"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_wet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_tir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"spd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_spd&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;draws&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chains&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;az&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot_trace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;az&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res_sim&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The graph below shows that I can recover the base efficiency fairly well,
though obviously there are limits to what can be done.&lt;/p&gt;
&lt;p&gt;&lt;img width="50%" src="/images/ev_range_simulated.png" /&gt;&lt;/p&gt;
&lt;h2&gt;Real data&lt;/h2&gt;
&lt;p&gt;Now that this all looks good, I can try to model the real data.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;get_car&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;carstr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;carstr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'model'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;carstr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Tesla '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;carstr&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;carstr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'tesla'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;carstr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="p"&gt;)[:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'_'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;carstr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="p"&gt;)[:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;# using google sheets data downloaded to tsv&lt;/span&gt;
&lt;span class="n"&gt;df_wt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/ev_weight.tsv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;df_real&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/ev_range.tsv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_wt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Car'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'Total'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'weight'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tire_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Wheel front"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'\-(\d\d)'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dropna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Wh/km'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'tire_size'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'weight'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tire_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tire_size&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Temp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Temp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;u&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\u2212&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'-'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
          &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;df_clean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;df_real&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get_car&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Whk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Wh/km'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;weight&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Surface&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="s2"&gt;"Wet"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dgC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Temp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tire_size&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Speed&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mitsubishi'&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'maxus'&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="s2"&gt;"Whk"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"car"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tir"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ton"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"wet"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"spd"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"dgC"&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
    &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dropna&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/df_ev_range.csv"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df_clean&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/tmp/df_ev_range_clean.csv"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;prior_car&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_ton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_dgC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_wet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_tir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prior_spd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'StudentT'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigma&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;model_clean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_clean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_clean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; samples"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;res_clean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;model_clean&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s1"&gt;'Whk ~ 0 + ton + dgC + tir + spd + wet'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;group_specific&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"1|car"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;categorical&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'car'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wet'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'spd'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;priors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'car'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_car&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"ton"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_ton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"dgC"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_dgC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="s2"&gt;"wet"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_wet&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_tir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"spd"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prior_spd&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;draws&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chains&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;car_means&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res_clean&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;posterior&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'1|car'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dim&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"chain"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"draw"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;res_clean&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;posterior&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;res_clean&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;posterior&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sortby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;car_means&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;g&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;az&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot_forest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res_clean&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;posterior&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'ridgeplot'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;var_names&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'1|car'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;combined&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                   &lt;span class="n"&gt;colors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#eeeeee'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hdi_prob&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.999&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Wh/km'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Results&lt;/h1&gt;
&lt;p&gt;There is plenty of overlap in these posteriors,
but they do show that e.g., Tesla, Hyundai and Porsche seem to have good base efficiency,
while Jaguar, Audi, and Volvo appear to have poor efficiency.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/ev_range_results.png" /&gt;&lt;/p&gt;
&lt;p&gt;We can also look at the estimated range for each car at 90km/h given dry weather, 18" tires, 25C and a 100kWh battery.
(Caveat: I don't know how to adjust the range for additional battery weight, so there is an unfair advantage for cars with small batteries.)
Still, these results show that once battery density increases a bit, several cars may be able to hit the 400mi/644km range.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/ev_range_results_with_weight.png" /&gt;&lt;/p&gt;
&lt;p&gt;It was also interesting to discover the contributions of other factors,
though the numbers below are just +/-1 standard deviation and should be taken with plenty of salt:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;traveling at 120km/h adds 60–70 Wh/km compared to 90km/h;&lt;/li&gt;
&lt;li&gt;each degree C colder adds 0.5–1.25 Wh/km;&lt;/li&gt;
&lt;li&gt;each ton weight adds 20–40 Wh/km;&lt;/li&gt;
&lt;li&gt;each inch of tire adds 2–6 Wh/km;&lt;/li&gt;
&lt;li&gt;wet weather adds 10–20 Wh/km.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My main takeaways were that speed is extremely important (drag),
tire size was less important than I had guessed based on the Porsche example,
but wet weather was more important than I had guessed (maybe equivalent to carrying an extra ton??)&lt;/p&gt;
&lt;p&gt;As always, there are things I could improve in the model, especially with more data:
better chosen, bounded priors;
more prior and posterior predictive checks (I had some issues here);
checking for interactions (e.g., wet*dgC);
perhaps some multiplicative effects
(e.g., wet weather reduces efficiency by 5% instead of subtracting 10 Wh/km).
I could also maybe predict optimal conditions for maximum range,
though the current model would say on the surface of the sun with 0 inch tires.&lt;/p&gt;
&lt;p&gt;I might come back to it when the database has grown a bit, but I am pretty satisfied with these results for now.&lt;/p&gt;
&lt;h2&gt;data / brms code&lt;/h2&gt;
&lt;p&gt;If anyone wants to rerun/improve upon the above, I put all the data here:
&lt;a href="/static/ev_range/ev_range.tsv"&gt;ev_range.tsv&lt;/a&gt;,
&lt;a href="/static/ev_range/ev_weight.tsv"&gt;ev_weight.tsv&lt;/a&gt;,
&lt;a href="/static/ev_range/df_ev_range.csv"&gt;df_ev_range.csv&lt;/a&gt;,
&lt;a href="/static/ev_range/df_ev_range_clean.csv"&gt;df_ev_range_clean.csv&lt;/a&gt;,
&lt;a href="/static/ev_range/df_ev_range_sim.csv"&gt;df_ev_range_sim.csv&lt;/a&gt;.
This could be a pretty nice dataset for teaching.&lt;/p&gt;
&lt;p&gt;To validate (or at least reproduce) the model above, I ran the following R code.
The results were virtually identical.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nf"&gt;library&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'brms'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df_clean&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;read.csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/tmp/df_ev_range_clean.csv"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;priors&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;c&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;set_prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"student_t(3,100,50)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coef&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;paste&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"car"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_clean&lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="nf"&gt;set_prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"student_t(3,50,20)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coef&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"ton"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="nf"&gt;set_prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"student_t(3,-1,2)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coef&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"dgC"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="nf"&gt;set_prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"student_t(3,10,20)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coef&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"wet"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="nf"&gt;set_prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"student_t(3,2,5)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coef&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"tir"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="nf"&gt;set_prior&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"student_t(3,50,30)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coef&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"spd"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;res_clean&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;brm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;Whk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ton&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dgC&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;tir&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;spd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;wet&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;car&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;df_clean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;chains&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;iter&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;cores&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;prior&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;priors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;control&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;adapt_delta&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;max_treedepth&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="datascience"/><category term="metrology"/><category term="datascience"/></entry><entry><title>Numpyro probabilistic model of blood glucose</title><link href="/numpyro-model-blood-glucose.html" rel="alternate"/><published>2020-08-02T11:00:00-07:00</published><updated>2020-08-02T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2020-08-02:/numpyro-model-blood-glucose.html</id><summary type="html">&lt;p&gt;Numpyro probabilistic model of blood glucose&lt;/p&gt;</summary><content type="html">&lt;div&gt;
&lt;style scoped&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }
    .dataframe tbody tr th {
        vertical-align: top;
    }
    .dataframe thead th {
        text-align: right;
    }

    .dataframe {
        font-size: 11pt;
        font-family: Arial;
        border-collapse: collapse;
        border: 1px solid silver;

    }
    .dataframe td, th {
        padding: 5px;
    }
    .dataframe tr:nth-child(even) {
        background: #E0E0E0;
    }
    .dataframe tr:hover {
        background: silver;
        cursor: pointer;
    }
    .dataframe th {
      background:#d5ddf5;
    }

&lt;/style&gt;
&lt;/div&gt;

&lt;p&gt;This post is a &lt;a href="https://github.com/pyro-ppl/numpyro"&gt;numpyro&lt;/a&gt;-based probabilistic model of my blood glucose data (see my &lt;a href="blog.booleanbiotech.com/blood-glucose-and-food.html"&gt;original blogpost&lt;/a&gt; for necessary background).
The task is, given my blood glucose readings, my heart rate data, and what I ate,
can I figure out the contribution of each food to my blood glucose.&lt;/p&gt;
&lt;p&gt;This is a classic Bayesian problem, where I have some observed data (blood glucose readings),
a model for how food and heart rate influence blood glucose,
and I want to find likely values for my parameters.&lt;/p&gt;
&lt;p&gt;Normally I would use &lt;a href="https://docs.pymc.io"&gt;pymc3&lt;/a&gt; for this kind of thing, but this was a good excuse to try out numpyro, which is built on &lt;a href="https://github.com/google/jax"&gt;JAX&lt;/a&gt;,
the current favorite for automatic differentiation.&lt;/p&gt;
&lt;p&gt;To make the problem a little more concrete,
say your fasting blood glucose is 80, then you eat something and an hour later it goes to 120,
and an hour after that it's back down to 90. How much blood glucose can I attribute to that food?
What if I eat the same food on other day, but this time my blood glucose shoots to 150?
What if I eat something else 30 minutes after eating this food so the data overlap?
In theory, all of these situations can be modeled in a fairly simple probabilistic model.&lt;/p&gt;
&lt;h1&gt;Imports&lt;/h1&gt;
&lt;p&gt;I am using numpyro, and jax numpy instead of regular numpy.
In most cases, jax is a direct replacement for numpy, but sometimes I need original numpy, so I keep that as &lt;code&gt;onp&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!pip install numpyro&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;jax.numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;jax&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;jax.scipy.special&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;logsumexp&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpyro&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpyro.distributions&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;dist&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpyro.diagnostics&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;hpdi&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpyro&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;handlers&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpyro.infer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;MCMC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;NUTS&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;onp&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;glob&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;io&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;tqdm.autonotebook&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;contextlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;redirect_stdout&lt;/span&gt;

&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'retina'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Some simple test data&lt;/h1&gt;
&lt;p&gt;Simple test data is always a good idea for any kind of probabilistic model.
If I can't make the model work with the simplest possible data,
then it's best to figure that out early, before starting to try to use real data.
I believe &lt;a href="https://xcelab.net/rm/statistical-rethinking/"&gt;McElreath&lt;/a&gt; advocates for something similar, though I can't find a citation for this.&lt;/p&gt;
&lt;p&gt;To run inference with my model I need three 1D arrays:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;bg_5min&lt;/code&gt;: blood glucose readings, measured every 5 minutes&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hr_5min&lt;/code&gt;: heart rate, measured every 5 minutes&lt;/li&gt;
&lt;li&gt;&lt;code&gt;fd_5min&lt;/code&gt;: food eaten, measured every 5 minutes&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;str_to_enum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;foods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;foods&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;foods&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;mapk&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;foods&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;mapk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;foods&lt;/span&gt;

&lt;span class="n"&gt;bg_5min_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;91&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;89&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;92&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;93&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                         &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;108&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;114.4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;119.52&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;123.616&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;126.89&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;119.51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;113.61&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;108.88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;105.11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                         &lt;span class="mf"&gt;102.089&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;99.67&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;97.73&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;96.18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;94.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;93.96&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;93.16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;92.53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;92.02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;91.62&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;91.29&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;91.03&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;90.83&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;90.66&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;90.53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                         &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;89&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;89&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;_fd_5min_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'food'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                 &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                 &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                 &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'doof'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                 &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="n"&gt;fd_5min_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_test_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;str_to_enum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_fd_5min_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;hr_5min_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min_test&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;bg_5min_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fd_5min_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd_5min_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;hr_5min_test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr_5min_test&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Example test data (len &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;):"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"bg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bg_5min_test&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"heart rate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min_test&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"food as enum"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_test&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr_5min_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd_5min_test&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;Example&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;test&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;len&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;span class="n"&gt;bg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;91.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;89.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;92.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;90.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;90.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;90.&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;heart&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;enum&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Read in real data as a DataFrame&lt;/h1&gt;
&lt;p&gt;I have already converted all my Apple Health data to csv.
Here I process the data to include naive day and date (local time) — timezones are impossible otherwise.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;df_complete&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"HK*.csv"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;';'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;skiprows&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'startdate'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
                                                      &lt;span class="n"&gt;infer_datetime_format&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
             &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;day&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                     &lt;span class="n"&gt;time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
          &lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'unit'&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'unit'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'type'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;df_complete&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;df_complete&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="s1"&gt;'type'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sourcename'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'unit'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'day'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'time'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;]]])&lt;/span&gt;

&lt;span class="c1"&gt;# clean up the names a bit and sort&lt;/span&gt;
&lt;span class="n"&gt;df_complete&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_complete&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'type'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'TypeIdentifier'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expand&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
                          &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'type'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;
&lt;span class="n"&gt;df_complete&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I can remove a bunch of data from the complete DataFrame.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_complete&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isin&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s2"&gt;"HeadphoneAudioExposure"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"BodyMass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"UVExposure"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"SleepAnalysis"&lt;/span&gt;&lt;span class="p"&gt;})]&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sourcename&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isin&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s2"&gt;"Brian Naughton’s iPhone"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Strava"&lt;/span&gt;&lt;span class="p"&gt;})]&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_complete&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sourcename&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'Connect'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'type'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sourcename'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border="1" class="dataframe"&gt;
  &lt;thead&gt;
    &lt;tr style="text-align: right;"&gt;
      &lt;th&gt;type&lt;/th&gt;
      &lt;th&gt;sourcename&lt;/th&gt;
      &lt;th&gt;unit&lt;/th&gt;
      &lt;th&gt;day&lt;/th&gt;
      &lt;th&gt;time&lt;/th&gt;
      &lt;th&gt;date&lt;/th&gt;
      &lt;th&gt;value&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;ActiveEnergyBurned&lt;/td&gt;
      &lt;td&gt;Connect&lt;/td&gt;
      &lt;td&gt;kcal&lt;/td&gt;
      &lt;td&gt;2018-07-08&lt;/td&gt;
      &lt;td&gt;21:00:00&lt;/td&gt;
      &lt;td&gt;2018-07-08 21:00:00&lt;/td&gt;
      &lt;td&gt;8.00&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;BasalEnergyBurned&lt;/td&gt;
      &lt;td&gt;Connect&lt;/td&gt;
      &lt;td&gt;kcal&lt;/td&gt;
      &lt;td&gt;2018-07-08&lt;/td&gt;
      &lt;td&gt;21:00:00&lt;/td&gt;
      &lt;td&gt;2018-07-08 21:00:00&lt;/td&gt;
      &lt;td&gt;2053.00&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;BloodGlucose&lt;/td&gt;
      &lt;td&gt;Dexcom G6&lt;/td&gt;
      &lt;td&gt;mg/dL&lt;/td&gt;
      &lt;td&gt;2020-02-24&lt;/td&gt;
      &lt;td&gt;22:58:54&lt;/td&gt;
      &lt;td&gt;2020-02-24 22:58:54&lt;/td&gt;
      &lt;td&gt;111.00&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;DistanceWalkingRunning&lt;/td&gt;
      &lt;td&gt;Connect&lt;/td&gt;
      &lt;td&gt;mi&lt;/td&gt;
      &lt;td&gt;2018-07-08&lt;/td&gt;
      &lt;td&gt;21:00:00&lt;/td&gt;
      &lt;td&gt;2018-07-08 21:00:00&lt;/td&gt;
      &lt;td&gt;0.027&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;FlightsClimbed&lt;/td&gt;
      &lt;td&gt;Connect&lt;/td&gt;
      &lt;td&gt;count&lt;/td&gt;
      &lt;td&gt;2018-07-08&lt;/td&gt;
      &lt;td&gt;21:00:00&lt;/td&gt;
      &lt;td&gt;2018-07-08 21:00:00&lt;/td&gt;
      &lt;td&gt;0.00&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;HeartRate&lt;/td&gt;
      &lt;td&gt;Connect&lt;/td&gt;
      &lt;td&gt;count/min&lt;/td&gt;
      &lt;td&gt;2018-07-01&lt;/td&gt;
      &lt;td&gt;18:56:00&lt;/td&gt;
      &lt;td&gt;2018-07-01 18:56:00&lt;/td&gt;
      &lt;td&gt;60.00&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;RestingHeartRate&lt;/td&gt;
      &lt;td&gt;Connect&lt;/td&gt;
      &lt;td&gt;count/min&lt;/td&gt;
      &lt;td&gt;2019-09-07&lt;/td&gt;
      &lt;td&gt;00:00:00&lt;/td&gt;
      &lt;td&gt;2019-09-07 00:00:00&lt;/td&gt;
      &lt;td&gt;45.00&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;StepCount&lt;/td&gt;
      &lt;td&gt;Connect&lt;/td&gt;
      &lt;td&gt;count&lt;/td&gt;
      &lt;td&gt;2018-07-01&lt;/td&gt;
      &lt;td&gt;19:30:00&lt;/td&gt;
      &lt;td&gt;2018-07-01 19:30:00&lt;/td&gt;
      &lt;td&gt;33.00&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;I have to process my food data separately, since it doesn't come from Apple Health.
The information was just in a Google Sheet.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;df_food&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"food_data.csv"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sep&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sc"&gt;'\t'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"date"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="s"&gt;"datetime64[ns]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"food"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;lambda&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"food"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sc"&gt;','&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;expand&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lambda&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isin&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;"chocolate clusters"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"cheese weirds"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"skinny almonds"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"asparagus"&lt;/span&gt;&lt;span class="p"&gt;})]&lt;/span&gt;
&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;            &lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df_food&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style scoped&gt;
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
&lt;/style&gt;
&lt;table border="1" class="dataframe"&gt;
  &lt;thead&gt;
    &lt;tr style="text-align: right;"&gt;
      &lt;th&gt;date&lt;/th&gt;
      &lt;th&gt;food&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;2020-03-03 14:10:00&lt;/td&gt;
      &lt;td&gt;egg spinach on brioche&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2020-03-11 18:52:00&lt;/td&gt;
      &lt;td&gt;lentil soup and bread&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2020-02-27 06:10:00&lt;/td&gt;
      &lt;td&gt;bulletproof coffee&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2020-03-02 06:09:00&lt;/td&gt;
      &lt;td&gt;bulletproof coffee&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;For inference purposes, I am rounding everything to the nearest 5 minutes.
This creates the three arrays the model needs.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;_df_food&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_food&lt;/span&gt;
              &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rounded_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'5min'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
              &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'rounded_date'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;_df_hr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'HeartRate'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rounded_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'5min'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'rounded_date'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;get_food_at_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_df_food&lt;/span&gt;
              &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
              &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'food'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;))[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;get_hr_at_datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;hr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_df_hr&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Timedelta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr&lt;/span&gt;&lt;span class="p"&gt;))[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;


&lt;span class="n"&gt;df_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; \
&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"BloodGlucose"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
   &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2020&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
   &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rounded_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'5min'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
           &lt;span class="n"&gt;day&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'5min'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
           &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'rounded_date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get_food_at_datetime&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
           &lt;span class="n"&gt;hr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'rounded_date'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;get_hr_at_datetime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
          &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;bg_5min_real&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;onp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_5min&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pivot_table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'day'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'time'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'value'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;interpolate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'linear'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;hr_5min_real&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;onp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_5min&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pivot_table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'day'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'time'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'hr'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;interpolate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'linear'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;fd_5min_real&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;onp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_5min&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fillna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pivot_table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'day'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'time'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'food'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;aggfunc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fillna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;bg_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;hr_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;fd_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"array size mismatch"&lt;/span&gt;

&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"Real data (len &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;bg_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;):"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"bg"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bg_5min_real&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hr"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min_real&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"food"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_real&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;Real data (len (30, 288)):
bg [102. 112. 114. 113. 112. 111.]
hr [50.33333333 42.5        42.66666667 43.         42.66666667 42.5       ]
food ['' '' '' '' '' '']
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;numpyro model&lt;/h1&gt;
&lt;p&gt;The model is necessarily pretty simple, given the amount of data I have to work with.
Note that I use "g" as a shorthand for mg/dL, which may be confusing.
The priors are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;baseline_mu&lt;/code&gt;:
  I have a uniform prior on my "baseline" (fasting) mean blood glucose level.
  If I haven't eaten, I expect my blood glucose to be distributed around this value.
  This is a uniform prior from 80–110 mg/dL.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;all_food_g_5min_mu&lt;/code&gt;:
  Each food deposits a certain number of mg/dL of sugar into my blood every 5 minutes.
  This is a uniform prior from 8–16 mg/dL per 5 minutes.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;all_food_duration_mu&lt;/code&gt;:
  Each food only starts depositing glucose after a delay for digestion and absorption.
  This is a uniform prior from 45–100 minutes.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;all_food_g_5min_mu&lt;/code&gt;:
  Food keeps depositing sugar into my blood for some time.
  Different foods may be quick spikes of glucose (sugary) or slow release (fatty).
  This is a uniform prior from 25–50 minutes.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;regression_rate&lt;/code&gt;:
  The body regulates glucose by releasing insulin,
  which pulls blood glucose back to baseline at a certain rate.
  I allow for three different rates, depending on my heart rate zone.
  Using this simple model, the higher the blood glucose, the more it regresses, so it produces a
  somewhat bell-shaped curve.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Using uniform priors is really not best practices, but it makes it easier to keep values in a reasonable range.
I did experiment with other priors, but settled on this after failing to keep my posteriors to reasonable values.
As usual, explaining the priors to the model is like asking for a wish from an obtuse genie.
This is a common problem with probabilistic models, at least for me.&lt;/p&gt;
&lt;p&gt;The observed blood glucose is then a function that uses this approximate logic:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;all_5_minute_increments&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;blood_glucose&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;baseline&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;blood&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;glucose&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;no&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;foods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;time_eaten&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food_delays&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;has&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;started&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;entering&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bloodstream&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time_eaten&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food_delays&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food_duration&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="err"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;then&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;still&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;entering&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;bloodstream&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="n"&gt;blood_glucose&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;food_g_5min&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;blood_glucose&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;blood_glucose&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blood_glucose&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;baseline&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;regression_rate&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;heart_rate_zone_at_time(t)&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This model has some nice properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;every food has only three parameters: the delay, the duration, and the mg/dL per 5 minutes.
The total amount of glucose (loosely defined) can be easily calculate by multiplying &lt;code&gt;food_duration&lt;/code&gt; * &lt;code&gt;food_g_5_min&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;the model only has two other parameters: the baseline glucose, and regression rate
&lt;br/&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;MAX_TIMEPOINTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt; &lt;span class="c1"&gt;# effects are modeled 350 mins into the future only&lt;/span&gt;
&lt;span class="n"&gt;DL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;288&lt;/span&gt; &lt;span class="c1"&gt;# * 5 minutes = 1 day&lt;/span&gt;
&lt;span class="n"&gt;SUB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt; &lt;span class="c1"&gt;# or a number, to subset&lt;/span&gt;
&lt;span class="n"&gt;DAYS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="o"&gt;%%&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;zone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;hr&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;hr&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;140&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"3"&lt;/span&gt;

    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;all_foods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;

    &lt;span class="c1"&gt;# ----------------------------------------------&lt;/span&gt;

    &lt;span class="n"&gt;baseline_mu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'baseline_mu'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="n"&gt;all_food_g_5min_mu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"all_food_g_5min_mu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;food_g_5mins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"food_g_5min_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                          &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_food_g_5min_mu&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;all_food_g_5min_mu&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_foods&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;all_food_duration_mu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"all_food_duration_mu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;food_durations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"food_duration_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                            &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_food_duration_mu&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;all_food_duration_mu&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                      &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_foods&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;regression_rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;zone&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"regression_rate_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;zone&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.96&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                       &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;zone&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;"123"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;all_food_delay_mu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"all_food_delay_mu"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;food_delays&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"food_delay_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;all_food_delay_mu&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;all_food_delay_mu&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                   &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_foods&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;food_g_totals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deterministic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"food_g_total_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;food_durations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;food_g_5mins&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
                     &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_foods&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;result_mu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;

        &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MAX_TIMEPOINTS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
            &lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deterministic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"add_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;regression_rate&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;zone&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="p"&gt;])]&lt;/span&gt;
                 &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;food_delays&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                            &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food_delays&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;food_durations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;_j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;food_g_5mins&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                            &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;


    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
        &lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deterministic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"result_mu_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;baseline_mu&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="c1"&gt;# observations&lt;/span&gt;
    &lt;span class="n"&gt;obs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;numpyro&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'result_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dist&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;obs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
           &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result_mu&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;make_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;functools&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Sample and store results&lt;/h1&gt;
&lt;p&gt;Because the process is slow, I usually only run one day at at time,
and store all the samples in json files.
It would be much better to run inference on all days simultaneously,
especially since I have data for the same food on different days.
Unfortunately, this turned out to take way too long.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ravel&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ravel&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;DAYS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"day &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;bg_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bg_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ravel&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
    &lt;span class="n"&gt;hr_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hr_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ravel&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
    &lt;span class="n"&gt;_fd_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fd_5min_real&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ravel&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DL&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
    &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;str_to_enum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_fd_5min&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;#&lt;/span&gt;
    &lt;span class="c1"&gt;# subset it for testing&lt;/span&gt;
    &lt;span class="c1"&gt;#&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;SUB&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"bg_5min_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
    &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"hr_5min_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
    &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"fd_5min_key_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"fd_5min_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ix&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;

    &lt;span class="n"&gt;rng_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PRNGKey&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rng_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rng_key_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rng_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;num_warmup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_samples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5500&lt;/span&gt;

    &lt;span class="n"&gt;kernel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NUTS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;make_model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;mcmc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MCMC&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kernel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_warmup&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_samples&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;mcmc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rng_key_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;mcmc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print_summary&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;samples_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mcmc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_samples&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples_1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples_1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"total"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples_1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples_1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"delay"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples_1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples_1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"duration"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"samples_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;vs&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;vs&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples_1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()}))&lt;/span&gt;

    &lt;span class="n"&gt;print_io&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;redirect_stdout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;print_io&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;mcmc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print_summary&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"summary_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;print_io&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getvalue&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;day&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;11&lt;/span&gt;


&lt;span class="nl"&gt;sample:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%|&lt;/span&gt;&lt;span class="err"&gt;██████████&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;6000&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mh"&gt;6000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mh"&gt;48&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mh"&gt;58&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mh"&gt;00&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mh"&gt;00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="mf"&gt;2.04&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mh"&gt;1023&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;3.29e-04&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;prob&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.81&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;



&lt;span class="w"&gt;                                             &lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;median&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;5.0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;95.0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;n_eff&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;r_hat&lt;/span&gt;
&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="n"&gt;all_food_delay_mu&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.39&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.29&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.40&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.95&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.86&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.32&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.04&lt;/span&gt;
&lt;span class="w"&gt;                   &lt;/span&gt;&lt;span class="n"&gt;all_food_duration_mu&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.22&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.22&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;8.93&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.51&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.77&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.28&lt;/span&gt;
&lt;span class="w"&gt;                     &lt;/span&gt;&lt;span class="n"&gt;all_food_g_5min_mu&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.81&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.37&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.78&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.16&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.32&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;5.55&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.44&lt;/span&gt;
&lt;span class="w"&gt;                            &lt;/span&gt;&lt;span class="n"&gt;baseline_mu&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;89.49&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.37&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;89.47&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;88.89&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;90.09&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.89&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.00&lt;/span&gt;
&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="n"&gt;food_delay_bulletproof&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coffee&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.59&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.86&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.51&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.37&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;8.98&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;23.44&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.02&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="n"&gt;food_delay_egg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;spinach&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;brioche&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;13.75&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.41&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;13.92&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;13.04&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;14.26&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;4.81&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.08&lt;/span&gt;
&lt;span class="w"&gt;              &lt;/span&gt;&lt;span class="n"&gt;food_delay_milk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;chocolate&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.70&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.21&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.74&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.38&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.00&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;17.39&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.00&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;food_delay_vegetables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;potatoes&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;12.03&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.93&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;12.15&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.52&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;13.44&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;16.36&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.08&lt;/span&gt;
&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="n"&gt;food_duration_bulletproof&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coffee&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.92&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.36&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.72&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;8.27&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;12.09&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.72&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.68&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;food_duration_egg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;spinach&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;brioche&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;11.42&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.34&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;11.42&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.94&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;11.93&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.51&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.59&lt;/span&gt;
&lt;span class="w"&gt;           &lt;/span&gt;&lt;span class="n"&gt;food_duration_milk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;chocolate&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.01&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.22&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.98&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.58&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.34&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;16.01&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.00&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;food_duration_vegetables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;potatoes&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;8.56&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.40&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;8.52&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.55&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.43&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;4.89&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.37&lt;/span&gt;
&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="n"&gt;food_g_5min_bulletproof&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;coffee&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.45&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.38&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.41&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.86&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;3.01&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.07&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.58&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;food_g_5min_egg&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;spinach&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;on&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;brioche&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.38&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.33&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.39&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;6.86&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;7.92&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.65&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.36&lt;/span&gt;
&lt;span class="w"&gt;             &lt;/span&gt;&lt;span class="n"&gt;food_g_5min_milk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;chocolate&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;11.38&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.38&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;11.40&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.70&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;11.94&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;21.69&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.06&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="n"&gt;food_g_5min_vegetables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;potatoes&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;14.46&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;2.99&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;15.55&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;9.90&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;18.17&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;10.31&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.17&lt;/span&gt;
&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="n"&gt;regression_rate_1&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.93&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.00&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.93&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.92&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.93&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="mf"&gt;24.68&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.04&lt;/span&gt;
&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="n"&gt;regression_rate_2&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.74&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.03&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.73&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.71&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.78&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;3.68&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.69&lt;/span&gt;
&lt;span class="w"&gt;                      &lt;/span&gt;&lt;span class="n"&gt;regression_rate_3&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.78&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.03&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.77&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.73&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;0.82&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;4.28&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="mf"&gt;1.60&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Plot results&lt;/h1&gt;
&lt;p&gt;Plotting the data in a sensible way is a little bit tricky.
Hopefully the plot is mostly self-explanatory,
but note that baseline is set to zero, the y-axis is on a log scale,
and the x-axis is midnight to midnight, in 5 minute increments.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;get_plot_sums&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;samples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;onp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
    &lt;span class="n"&gt;bg_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;onp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;hr_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;onp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;means&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;))):&lt;/span&gt;
        &lt;span class="n"&gt;means&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s2"&gt;"baseline"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"baseline_mu"&lt;/span&gt;&lt;span class="p"&gt;])})&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MAX_TIMEPOINTS&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"add_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;means&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"add_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;_j&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

    &lt;span class="n"&gt;plot_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;ordered_foods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'baseline'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;means&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'baseline'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;means&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;tot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([])&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ordered_foods&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tot&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'baseline'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;tot&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ordered_foods"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ordered_foods&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ordered_foods&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;DAYS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"summary_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="n"&gt;samples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"samples_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;bg_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"bg_5min_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;hr_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"hr_5min_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;fd_5min&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"fd_5min_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;fd_5min_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"fd_5min_key_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.json"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fd_5min_key"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;plot_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_plot_sums&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bg_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fd_5min_key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'real'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bg_5min&lt;/span&gt;
    &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'heartrate'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hr&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;hr&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hr_5min&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="n"&gt;baseline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'baseline'&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;
    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;baseline&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;baseline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;baseline&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;log_plot_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'baseline'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;log_plot_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'real'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="n"&gt;plot_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'baseline'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log_plot_data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lineplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;log_plot_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"heartrate"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"hr"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
                                        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'hr'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
                      &lt;span class="n"&gt;dashes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_ylim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"day &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; baseline &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;baseline&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log_plot_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_linestyle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"--"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;savefig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'food_model_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;.png'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;savefig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'food_model_&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="si"&gt;}{&lt;/span&gt;&lt;span class="n"&gt;SUB&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s1"&gt;.svg'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/numpyro_glucose_day_11.png"&gt;&lt;/p&gt;
&lt;h2&gt;Total blood glucose&lt;/h2&gt;
&lt;p&gt;Finally, I can rank each food by its total blood glucose contribution.
Usually, this matches expectations, and occasionally it's way off.
Here it looks pretty reasonable:
the largest meal by far contributed the largest total amount, and the milk chocolate had the shortest delay.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pprint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pprint&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"### total grams of glucose"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;pprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples_1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples_1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"total"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"### food delays"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;pprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples_1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples_1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"delay"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"### food durations"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;pprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;([(&lt;/span&gt;&lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;samples_1&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;samples_1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"duration"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;food_type&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="gu"&gt;##&lt;/span&gt;# total blood glucose contribution
[(123.52, 'food_g_total_vegetables and potatoes'),
 (84.24, 'food_g_total_egg spinach on brioche'),
 (79.69, 'food_g_total_milk chocolate'),
 (23.88, 'food_g_total_bulletproof coffee')]
&lt;span class="gu"&gt;##&lt;/span&gt;# food delays
[(13.75, 'food_delay_egg spinach on brioche'),
 (12.03, 'food_delay_vegetables and potatoes'),
 (10.39, 'all_food_delay_mu'),
 (7.59, 'food_delay_bulletproof coffee'),
 (6.7, 'food_delay_milk chocolate')]
&lt;span class="gu"&gt;##&lt;/span&gt;# food durations
[(11.42, 'food_duration_egg spinach on brioche'),
 (9.92, 'food_duration_bulletproof coffee'),
 (9.22, 'all_food_duration_mu'),
 (8.56, 'food_duration_vegetables and potatoes'),
 (7.01, 'food_duration_milk chocolate')]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h1&gt;Conclusions&lt;/h1&gt;
&lt;p&gt;It sort of works. For example, day 11 looks pretty good!
Unfortunately, when it's wrong, it can be pretty far off,
so I am not sure about the utility without imbuing the model with more robustness.
(For example, note that the &lt;code&gt;r_hat&lt;/code&gt; is often &lt;a href="https://cran.r-project.org/web/packages/bayesplot/vignettes/visual-mcmc-diagnostics.html"&gt;out of range&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;The parameterization of the model is pretty unsatisfying.
To make the model hang together I have to constrain the priors to specific ranges.
I could probably grid-search the whole space pretty quickly to get to a maximum posterior here.&lt;/p&gt;
&lt;p&gt;I think if I had a year of data instead of a month, this could get pretty interesting.
I would also need to figure out how to sample quicker, which should be possible given the simplicity of the model.
With the current implementation I am unable to sample even a month of data at once.&lt;/p&gt;
&lt;p&gt;Finally, here is the complete set of plots I generated, to see the range of results.&lt;/p&gt;
&lt;p&gt;&lt;img alt="png" src="/images/numpyro_glucose_all.png"&gt;&lt;/p&gt;</content><category term="stats"/><category term="cgm"/><category term="quantifiedself"/><category term="pymc3"/><category term="numpyro"/><category term="jax"/></entry><entry><title>Water purity analysis with a GeneQuant</title><link href="/water-purity-genequant.html" rel="alternate"/><published>2020-07-04T11:00:00-07:00</published><updated>2020-07-04T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2020-07-04:/water-purity-genequant.html</id><summary type="html">&lt;p&gt;Using a GeneQuant to measure water purity&lt;/p&gt;</summary><content type="html">&lt;p&gt;In the past, I have had trouble extracting high quality DNA for sequencing,
so I decided I need a spectrophotometer to help figure this out — or at least to stop running poor quality samples.&lt;/p&gt;
&lt;p&gt;In this post I'll report what I learned about spectrophotometers and what happens when I test a few water samples with one.&lt;/p&gt;
&lt;h2&gt;DNA quantitation&lt;/h2&gt;
&lt;p&gt;It seems like the terms spectrophotometer and spectrometer are &lt;a href="https://physics.stackexchange.com/questions/150895/spectrometer-vs-spectrophotometer#:~:text=A%20spectrometer%20measures%20emission%20spectrum,of%20a%20sample%20placed%20inside."&gt;essentially synonymous&lt;/a&gt;.
Spectrophotometers are generally focused on absorption (e.g., DNA absorbing at 260nm)
and spectrometers are focused on emission (e.g., stars emitting light at various wavelengths).&lt;/p&gt;
&lt;p&gt;One of the major uses of spectrophotometers in the lab is DNA quantitation. 
Despite that, most regular spectrophotometers are unsuitable for this purpose.
Typically, you want readings at 230nm (sugars, salts, organic solvents),
260nm (nucleic acid),
280nm (protein),
and 320nm ("turbidity", air bubbles, other stuff).
The most often used metrics for DNA purity are the 260/280 and 260/230 ratios.
Notably, none of these wavelengths are in the visible spectrum.&lt;/p&gt;
&lt;p&gt;There are a few ways you can measure DNA quantity in solution:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;measure absorption at all wavelengths from ~200 to 400nm and plot a curve&lt;/li&gt;
&lt;li&gt;measure absorption at the specific wavelengths listed above&lt;/li&gt;
&lt;li&gt;add a dye that fluoresces upon binding nucleic acid and measure that wavelength&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;DIY Spectrometers&lt;/h2&gt;
&lt;p&gt;The problem doesn't sound too complicated, so you'd think there might be a way to do this cheaply.
Once you can detect the appropriate wavelengths, the rest is simple.&lt;/p&gt;
&lt;p&gt;In fact, there are several DIY spectrometer projects out there,
including a nice &lt;a href="https://publiclab.org/wiki/economist"&gt;Public Lab&lt;/a&gt; one.
(I bought that one a few years ago and it was a fun toy.)
Even though at least one of these projects describes itself as a &lt;a href="https://hackteria.org/wiki/DIY_NanoDrop"&gt;DIY Nanodrop&lt;/a&gt;,
I think this is a misleading name.
The volume required is low,
but like all of these projects, it uses a regular LED and camera,
so it only measures light in the visible spectrum (~400-750nm, plus some IR and a little UV).&lt;/p&gt;
&lt;p&gt;Visual spectrum spectrophotometers are fine for OD readings (which uses 600nm, aka yellow), but that's about it.&lt;/p&gt;
&lt;p&gt;Another DIY option you could imagine is to use a UV lamp and bandpass filters like 
&lt;a href="https://www.edmundoptics.com/f/uv-bandpass-filters/39502/"&gt;these from Edmunds Optical&lt;/a&gt;,
and a simple photosensor.
It's actually not even easy to get a UV lamp that emits at 230nm,
and the optical filters are surprisingly expensive ($300 each),
so sadly this is not an economical option.&lt;/p&gt;
&lt;h2&gt;Nanodrop vs Qubit&lt;/h2&gt;
&lt;p&gt;The most popular lab tools for DNA quantitation are the Nanodrop and the Qubit.
These devices are prohibitively expensive: a Nanodrop is about $7k new and $3k+ second-hand,
and a Qubit is $3k and $1k+, respectively.&lt;/p&gt;
&lt;p&gt;The main difference between the two is that the Qubit is a fluorometer,
and hence requires a nucleic-acid–binding dye.
This makes the Qubit more accurate for quantitation, since other molecules absorb at 260nm,
but also a bit more work.
The Nanodrop has the advantages of using very little material (~1µl),
and the ability to detect contaminants at other wavelengths.
Either may suit, depending on whether quantitation or contamination is more important.
A &lt;a href="https://twitter.com/kurtyaki/status/1278739650786455552"&gt;recent Twitter thread&lt;/a&gt; covered this topic;
apparently every other lab calls a nanodrop a "random number generator".&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/nanodrop_example.jpg" max-width="750px"/&gt;&lt;/p&gt;
&lt;figcaption&gt;*Example nanodrop output with a relatively clean sample*&lt;/figcaption&gt;

&lt;h2&gt;GeneQuant&lt;/h2&gt;
&lt;p&gt;I thought there might be a sweet spot device that measures only at 230/260/280/320nm.
There was even a promising one on alibaba a while ago, that sadly turned out not to be real...
It turned out there was a better option: I learned about the GeneQuant, the device I ended up buying, from this &lt;a href="https://groups.google.com/forum/#!topic/diybio/meUhbg3UZqA"&gt;relevant Google Groups thread&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I bought a second-hand GeneQuant (25 years old!) on ebay for ~$150.
The device I bought came with a nice 500µl cuvette (the sample holder you insert), which is nice,
but an enormous volume for DNA quantitation.
Unfortunately, cuvettes are expensive, I assume due to the high quality quartz required,
and the lower the cuvette volume, the more they cost. I'll probably need a 10µl cuvette at some point.&lt;/p&gt;
&lt;p&gt;Even though this GeneQuant is old, I thought it would probably work fine for my purposes,
because even if it's miscalibrated,
I should still be able to learn what a contaminated sample looks like.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/genequant.jpg" max-width="750px"/&gt;&lt;/p&gt;
&lt;h2&gt;Water Purity&lt;/h2&gt;
&lt;p&gt;At home we use a PUR filter, which is supposedly better than a Brita, at least according to &lt;a href="https://www.nytimes.com/wirecutter/reviews/best-water-filter-pitcher/"&gt;The Wirecutter&lt;/a&gt;.
I have been periodically curious if it is doing much, since our tap water is pretty good — especially towards the end of the filter's life when the filtration slows down.&lt;/p&gt;
&lt;p&gt;This is a useful experiment because it's also a good way to check the precision and reproducibility of readings from the GeneQuant.&lt;/p&gt;
&lt;p&gt;I took samples from the kitchen sink, bathroom sinks, PUR filter, distilled water bought at a grocery store, and nuclease-free lab-grade water.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;io&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StringIO&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"""name,sample,230 nm,260 nm,280 nm,320 nm&lt;/span&gt;
&lt;span class="s2"&gt;kitchen cold,     2020-05-03a, 0.011, 0.048, 0.064, 0.089&lt;/span&gt;
&lt;span class="s2"&gt;lab distilled,    2020-05-03a, 0.003, 0.005, 0.006, 0.007&lt;/span&gt;
&lt;span class="s2"&gt;PUR filtered,     2020-05-03a, 0.021, 0.008, 0.009, 0.011&lt;/span&gt;
&lt;span class="s2"&gt;kitchen cold,     2020-06-03a, 0.051, 0.041, 0.033, 0.031&lt;/span&gt;
&lt;span class="s2"&gt;kitchen cold,     2020-06-03a, 0.051, 0.041, 0.033, 0.031&lt;/span&gt;
&lt;span class="s2"&gt;PUR filtered,     2020-06-03a, 0.027, 0.014, 0.019, 0.023&lt;/span&gt;
&lt;span class="s2"&gt;PUR filtered,     2020-06-03a, 0.033, 0.016, 0.024, 0.023&lt;/span&gt;
&lt;span class="s2"&gt;kitchen hot,      2020-06-03a, 0.056, 0.047, 0.038, 0.037&lt;/span&gt;
&lt;span class="s2"&gt;kitchen hot,      2020-06-03a, 0.060, 0.051, 0.042, 0.041&lt;/span&gt;
&lt;span class="s2"&gt;lab distilled,    2020-06-03a, 0.005, 0.011, 0.014, 0.025&lt;/span&gt;
&lt;span class="s2"&gt;lab distilled,    2020-06-03a,-0.005, 0.001, 0.003, 0.015&lt;/span&gt;
&lt;span class="s2"&gt;grocery distilled,2020-06-03a,-0.016,-0.005, 0.002, 0.015&lt;/span&gt;
&lt;span class="s2"&gt;grocery distilled,2020-06-03a,-0.016,-0.005, 0.003, 0.016&lt;/span&gt;
&lt;span class="s2"&gt;grocery distilled,2020-06-03a,-0.016,-0.005, 0.003, 0.015&lt;/span&gt;
&lt;span class="s2"&gt;bathroom cold,    2020-06-03a, 0.051, 0.035, 0.032, 0.032&lt;/span&gt;
&lt;span class="s2"&gt;bathroom cold,    2020-06-03a, 0.050, 0.034, 0.031, 0.031&lt;/span&gt;
&lt;span class="s2"&gt;garage cold,      2020-06-03a, 0.088, 0.055, 0.046, 0.037&lt;/span&gt;
&lt;span class="s2"&gt;garage cold,      2020-06-03a, 0.087, 0.054, 0.046, 0.037&lt;/span&gt;
&lt;span class="s2"&gt;"""&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;df&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;df_plot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'sample'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;agg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'median'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reset_index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sample'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;melt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id_vars&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"absorbance"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stripplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;df_plot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sort_values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"absorbance"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
              &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"absorbance"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;hue&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"variable"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src="/images/output_11_0.png" max-width="750px" /&gt;&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;I didn't bother to run many replicates, but still,
there are some pretty interesting results here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the precision of the instrument is very high — at least when readings are taken close together — which is encouraging.&lt;/li&gt;
&lt;li&gt;the distilled water from the grocery store is "cleaner" than the lab-grade water.
  There are confounders, like the fact that the lab-grade water is older, but it's still interesting to see the grocery store water coming back so pure.&lt;/li&gt;
&lt;li&gt;The PUR is basically half-way between distilled water and tap water, so it's definitely doing something.
  It's unclear to me if the residual difference is stuff you want (minerals etc. that influence the taste) or just incomplete purification.&lt;/li&gt;
&lt;li&gt;The various faucets in the house produce similar purity water, as does hot and cold water.
  I thought faucets that had not been used in many days, like the garage sink, might have some detectable residue, but if it's there, it's a minor difference at most.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Another interesting thing I recently noticed about tap water vs distilled is that when we ran a humidifier with
tap water, eventually the PM2.5 in the house would climb way beyond 10µg/m&lt;sup&gt;3&lt;/sup&gt; (which is very bad).
I thought this might be just aerosolized water, but it didn't happen with distilled water.
I don't know which impurities were causing this issue, so it could be harmless,
but we completely stopped using tap water in the humidifier after that.&lt;/p&gt;</content><category term="sequencing"/><category term="metrology"/><category term="dnasequencing"/><category term="genetics"/><category term="dna"/><category term="aqi"/></entry><entry><title>A month with a CGM: an analysis of blood glucose responses to food</title><link href="/blood-glucose-and-food.html" rel="alternate"/><published>2020-04-19T11:00:00-07:00</published><updated>2020-04-19T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2020-04-19:/blood-glucose-and-food.html</id><summary type="html">&lt;p&gt;Using a CGM to test the effect of foods on blood glucose.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Blood glucose control,
and specifically how steady your blood glucose levels are after eating,
is an important indicator of health.
According to a &lt;a href="https://www.cell.com/cell/fulltext/S0092-8674(15)01481-6"&gt;paper from the Segal lab&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"Postprandial hyperglycemia is an independent risk factor for the development of TIIDM, cardiovascular disease, and liver cirrhosis and is associated with obesity, and enhanced all-cause mortality in both TIIDM and cancer."&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;In this paper they showed there was individual variation in response to foods,
which they related to the microbiome and other features,
and showed that dietary changes could improve blood glucose control.
This work led to the publication of a fascinating book called &lt;a href="https://www.amazon.com/Personalized-Diet-Pioneering-Program-Prevent/dp/1478918802"&gt;The Personalized Diet&lt;/a&gt;,
whose results can be summarized as "find out which foods spike your blood glucose and don't eat them".&lt;/p&gt;
&lt;p&gt;There isn't that much other data out there on blood glucose control in non-diabetics.
The other relevant paper I know of is a recent &lt;a href="https://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.2005143"&gt;PLoS Biology paper&lt;/a&gt; from the Snyder group at Stanford.&lt;/p&gt;
&lt;!-- (Snyder himself discovered early signs of diabetes in an [older study](https://www.sciencemag.org/news/2012/03/examining-his-own-body-stanford-geneticist-stops-diabetes-its-tracks)). --&gt;
&lt;p&gt;They also showed significant variation in how non-diabetics responsed to the same foods.&lt;/p&gt;
&lt;p&gt;There is also an appealing, intuitive &lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3267662"&gt;connection of blood glucose to cancer progression and prevention&lt;/a&gt;,
which rests on the fact that cancer benefits from readily available energy sources in the blood.&lt;/p&gt;
&lt;p&gt;I thought it was worth knowing my personal food response profile,
so I wore a &lt;a href="https://www.dexcom.com/get-started-cgm/"&gt;Dexcom G6 CGM&lt;/a&gt; for 30 days.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;CGM&lt;/h1&gt;
&lt;p&gt;A Continuous Glucose Monitor (CGM) is a device that samples your blood glucose continuously.
The technology has been around for a few years, but from what I understand,
the latest iteration (Dexcom G6) is a pretty big advance over the G5 — mainly in size and accuracy —
and is arguably more accurate than competitors like the &lt;a href="http://www.freestylelibre.myehcs.com/"&gt;Freestyle Libre&lt;/a&gt;.
Dexcom is not a hugely well known company, but it is large (&lt;a href="https://www.google.com/search?tbm=fin&amp;amp;q=NASDAQ:+DXCM"&gt;market cap of around $25B&lt;/a&gt; at the time of writing.)&lt;/p&gt;
&lt;p&gt;The G6 is available by prescription only
(I have never heard an explanation for why, but this is partially why we don't have useful preventive data for non-diabetics...)
and the cost is approximately $10-20 per day without insurance.
The G6 reads out blood glucose in mg/dL every 5 minutes, and transmits directly to an app on your smartphone.&lt;/p&gt;
&lt;p&gt;I have done &lt;a href="https://www.cvs.com/shop/contour-next-blood-glucose-monitoring-system-prodid-926077"&gt;finger prick tests&lt;/a&gt; intermittently,
and while that's inexpensive and pretty accurate, there are issues:
specifically, it hurts and you can't do it often enough to really see granular responses to foods.&lt;/p&gt;
&lt;h2&gt;Applying the CGM&lt;/h2&gt;
&lt;p&gt;The process of applying the G6 is very simple, and surprisingly almost entirely painless (less painful than a finger prick).
Each "sensor" (the part that samples blood glucose) comes with its own applicator,
which inserts the sensor interstitially, surrounded by a large adhesive bandaid.
The transmitter (the grey lozenge) then snaps into the sensor, and relays data back to your phone via bluetooth.&lt;/p&gt;
&lt;p&gt;The G6 is only approved for use when applied to the abdomen,
though many users apply it to the backs of their arms.
Since I do not depend on the readings for anything critical,
I can be a bit more relaxed about this part, so I stuck it to my arm.
Overall, it's very unobtrusive, and with the exception of worrying about getting it wet in the shower,
I mostly just forgot it was there.&lt;/p&gt;
&lt;p&gt;&lt;img display="inline" width="45%" src="/images/cgm_dexcom_2.png" /&gt;
&lt;img display="inline" width="45%" src="/images/cgm_dexcom_1.jpg"&gt;
&lt;br/&gt;&lt;/p&gt;
&lt;h2&gt;Glucose readings&lt;/h2&gt;
&lt;p&gt;The G6 integrates with Apple Health, which helps a lot with data wrangling.
For some pseudomedical reason the readout is delayed by three hours, but that's not a big deal.
To get all my Apple Health data, I can just click the export data button on the Apple Health app,
then convert from xml to csv using this &lt;a href="https://www.ericwolter.com/projects/apple-health-export/"&gt;handy in-browser converter&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Apple Health also includes data from my &lt;a href="https://buy.garmin.com/en-US/US/p/574602"&gt;Garmin vivosport&lt;/a&gt;.
The main datatypes here are steps, heart rate, and sleep data.&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Get to the graphs&lt;/h1&gt;
&lt;p&gt;My main questions were: how does my blood glucose change with my diet, sleep, and exercise?&lt;/p&gt;
&lt;p&gt;First, what was my average blood glucose over the 30 days?
Surprisingly high.
A fasting blood glucose reading of above 100 indicates &lt;a href="https://www.cdc.gov/diabetes/basics/prediabetes.html"&gt;prediabetes&lt;/a&gt;.
I believe that a really good number would be hovering around 75-85 with food-induced spikes of 100-120.
(Note the graph below includes all readings, fasting and non-fasting so it's not as bad as it may seem.)&lt;/p&gt;
&lt;p&gt;&lt;img width="100%" src="/images/cgm_output_25_0.png" /&gt;&lt;/p&gt;
&lt;h2&gt;over the course of the day&lt;/h2&gt;
&lt;p&gt;Here I show my average blood glucose over the day,
and I have marked my estimated sleep and waking times from my Garmin data with grey lines (it's not terribly accurate).
By 3am I am usually at a good fasting glucose number (~85)
but during the day I have a pretty consistently high number (&amp;gt;100) that depends a lot on the foods I eat,
and this can persist past midnight.&lt;/p&gt;
&lt;p&gt;&lt;img width="100%" src="/images/cgm_output_34_0.png" /&gt;&lt;/p&gt;
&lt;h2&gt;coffee spike&lt;/h2&gt;
&lt;p&gt;There's a clear spike when I wake up.
Is that due to circadian rhythms, or morning coffee?
These two charts show my glucose by time of day, and by time of first coffee (which varied +/- 45m).
The two charts look almost the same,
but time of day is a more consistent pattern than minutes after drinking coffee,
so I don't think this is a coffee- or breakfast-specific effect.&lt;/p&gt;
&lt;p&gt;&lt;img width="100%" src="/images/cgm_output_36_0.png" /&gt;
&lt;img width="100%" src="/images/cgm_output_36_1.png" /&gt;&lt;/p&gt;
&lt;h2&gt;Foods that spike my blood glucose&lt;/h2&gt;
&lt;p&gt;Over the 30 days, I took a photo of everthing I ate using an app (&lt;a href="https://apps.apple.com/us/app/bitesnap-photo-food-journal/id1108291490"&gt;BiteSnap&lt;/a&gt;).
This heatmap that shows when my glucose went high,
and it's annotated with the foods I ate from 30 minutes to three hours before.
The most intense red is due to an impossible burger (mainly the bun...)&lt;/p&gt;
&lt;object width="100%" height="900px" data="/images/heatmap.html"&gt;&lt;/object&gt;

&lt;h2&gt;blood glucose trajectories&lt;/h2&gt;
&lt;p&gt;After eating each food type, what does my blood glucose response look like?
Some foods quickly spike (sugary foods like oatmeal with honey),
some do not spike at all (fatty foods like chocolate mousse),
and others contribute a large amount of blood glucose over time (carby foods like dutch crunch bread).
One caveat here is that foods eaten in the evening (e.g., milk chocolate)
appear to have lower spikes, but partially this is due to starting at a higher value after dinner.
This effect is hard to account for except by manually binning breakfast, lunch, and dinner.
The foods are sorted from highest mean increase over four hours to lowest.&lt;/p&gt;
&lt;div style="max-width:100%;overflow-x:scroll"&gt;
&lt;object width="1100px" height="1000px" data="/images/cgm_food_response.svg"&gt;&lt;/object&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Exercise can help drive blood glucose down&lt;/h1&gt;
&lt;p&gt;There have been a few publications on post-meal exercise and blood glucose.
For example, a &lt;a href="https://pubmed.ncbi.nlm.nih.gov/28974942/?from_single_result=Exercise+after+You+Eat%3A+Hitting+the+Postprandial+Glucose+Target&amp;amp;expanded_search_query=Exercise+after+You+Eat%3A+Hitting+the+Postprandial+Glucose+Target"&gt;2017 study&lt;/a&gt;
found that exercise at 60% of VO&lt;sub&gt;2&lt;/sub&gt; max for 50 minutes was effective at driving down blood glucose.
This squares with my own observations.&lt;/p&gt;
&lt;p&gt;Anecdotally, I observed that being sedentary post-meal (&amp;lt;90bpm) led to a prolonged high-glucose plateau,
zone 2 exercise (approximately 110-140pm) led to rapid post-meal glucose reduction
— down to just below my typical fasting level after 45 to 60 minutes —
and prolonged, higher intensity exercise (&amp;gt;140bpm) led to flat or increased glucose,
I assume due to the physical stresses involved.&lt;/p&gt;
&lt;p&gt;The charts below show my change in blood glucose over 30 minutes, at a given heart rate, starting at &amp;gt;110
(i.e., post-meal).
The second chart shows only the subset of data where my blood glucose is going down;
this is because post-meal you will hit 110 twice, on the way up and on the way down,
and only the latter is really informative here.
Unfortunately, I do not have enough data at higher heart rates to make much of a claim there.&lt;/p&gt;
&lt;p&gt;&lt;img display="block" width="100%" src="/images/cgm_exercise_going_up_or_down.png" /&gt;
&lt;img display="block" width="100%" src="/images/cgm_exercise_going_down.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;Was this experiment worthwhile?&lt;/h1&gt;
&lt;p&gt;I didn't find too many unexpected responses to food (carbs are bad; greens, protein and fat are good),
though the same food could produce quite different results on different days or different times of day.
In a podcast, CGM enthusiast &lt;a href="https://peterattiamd.com/podcast/"&gt;Peter Attia&lt;/a&gt; noted that after
3 years of CGM use he was still learning his patterns, and
I believe he also recommends his patients collect a minimum of 90 days of CGM data.&lt;/p&gt;
&lt;p&gt;Despite all that, this was probably the most useful health intervention I have done.
I learned a bunch of actionable things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;my blood glucose is too high for too much of the day.
At the very least, it would be good to have glucose levels go down to fasting level at bedtime and stay there all night.
Therefore I have tried to stop eating late in the day.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;bread triggered an especially bad response for me.
It was not surprising that bread is bad, but the magnitude of the effect was.
Some bready but fatty foods (butter-heavy deep dish pizza) were tolerated much better, thankfully.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;post-meal, zone 1 or especially zone 2 exercise is a good way to modulate glucose levels.
I now associate that food coma feeling with a spike of glucose that needs to be corrected with exercise.
Even a short, brisk walk seems to help.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;as you might expect, some foods, like bread and oatmeal, dropped way down my food pecking order,
but less obviously I now know that some "treats" like dark chocolate mousse or almond flour cookies are fine to eat.
Finding foods that strike the balance between tasting sweet (unsavory?) without triggering glucose spikes is a fun diversion.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The graphs posted here are the highlights, but I did a bunch of other analyses.
The most interesting is a pymc3/numpyro probabilistic model of glucose response that works reasonably well.
The main purpose of this model is try to explain each reading by a mixture of contributions from time-of-day, food, etc.
I will probably publish this as a separate post.&lt;/p&gt;
&lt;p&gt;I plan to do this exercise again in six months or so, to see if my interventions are generating better numbers.
In general it's pretty simple,
&lt;a href="https://www.webmd.com/food-recipes/news/20090323/7-rules-for-eating"&gt;Michael Pollan&lt;/a&gt;
and the paleo people were right: eat clean unprocessed food, not too much....&lt;/p&gt;
&lt;p&gt;&lt;br/&gt;&lt;/p&gt;
&lt;h1&gt;ADDENDUM: CGM-approved desserts&lt;/h1&gt;
&lt;h2&gt;Almond flour chocolate chip cookies:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;6 Tbs. butter, softened&lt;/li&gt;
&lt;li&gt;2 Tbs. coconut oil&lt;/li&gt;
&lt;li&gt;1/4 cup brown sugar, packed&lt;/li&gt;
&lt;li&gt;1 tsp. vanilla extract&lt;/li&gt;
&lt;li&gt;1 large eggs&lt;/li&gt;
&lt;li&gt;1/4 tsp. baking soda&lt;/li&gt;
&lt;li&gt;1/4 tsp. salt&lt;/li&gt;
&lt;li&gt;1 1/2 cups almond flour&lt;/li&gt;
&lt;li&gt;1 cup dark chocolate chips (we use Pascha 85%)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Preheat oven to 350°F. Line a baking sheet with parchment paper (or use a Silpat).&lt;/p&gt;
&lt;p&gt;In the bowl of a stand mixer, cream together the butter, coconut oil, and brown sugar. Add the vanilla and eggs, mixing until incorporated.&lt;/p&gt;
&lt;p&gt;Mix in the baking soda and salt. Add the almond flour, 1 cup at a time, beating well after each addition. Fold in the chocolate chips and walnuts with a wooden spoon.&lt;/p&gt;
&lt;p&gt;Form the dough into ~2-3 tablespoon rounds and place on the lined baking sheet about 3 inches apart (~24 cookies). Flatten them a bit with the spatula, they do not flatten very much while baking. Bake for 13 minutes, or until golden brown around edges. Cool and enjoy! Cookies will be fragile until completely cooled.&lt;/p&gt;
&lt;p&gt;Adapted from: &lt;a href="https://meaningfuleats.com/almond-flour-chocolate-chip-cookies-grain-free/"&gt;https://meaningfuleats.com/almond-flour-chocolate-chip-cookies-grain-free/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Almond flour brownies:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;100 g 85%+ chocolate bar, broken into squares (we use Lindt 90%)&lt;/li&gt;
&lt;li&gt;8 Tbs. unsalted butter&lt;/li&gt;
&lt;li&gt;1/4 cup granulated sugar&lt;/li&gt;
&lt;li&gt;2 large eggs&lt;/li&gt;
&lt;li&gt;1 teaspoon vanilla extract&lt;/li&gt;
&lt;li&gt;1/2 teaspoon salt&lt;/li&gt;
&lt;li&gt;1 cup almond flour&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Preheat oven to 350°F. Line an 8×8-inch square baking pan with foil to use as a sling for removing the brownies. Butter the foil or spray it with a nonstick cooking spray.&lt;/p&gt;
&lt;p&gt;Melt chocolate and butter together in the microwave in 30-second bursts, stirring between each. When only a couple unmelted bits remain stir to finish melting. Whisk in sugar, then eggs, one at a time, then vanilla and salt. Stir in almond flour with a spoon or flexible spatula. Scrape batter into prepared pan, spread until even. Bake for 25 minutes, or until a toothpick inserted into the center comes out batter-free.&lt;/p&gt;
&lt;p&gt;Let cool 5 min in the pan, then lift out gently using the foil. Brownies will be fragile until completely cooled.&lt;/p&gt;
&lt;p&gt;Adapted from: &lt;a href="https://smittenkitchen.com/2012/08/my-favorite-brownies/"&gt;https://smittenkitchen.com/2012/08/my-favorite-brownies/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Breakfast cookies:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;3 large ripe bananas&lt;/li&gt;
&lt;li&gt;1 tsp. vanilla extract&lt;/li&gt;
&lt;li&gt;1/4 cup coconut oil, melted&lt;/li&gt;
&lt;li&gt;2 cups rolled oats&lt;/li&gt;
&lt;li&gt;2/3 cup almond meal&lt;/li&gt;
&lt;li&gt;2/3 cup coconut (finely shredded &amp;amp; unsweetened)&lt;/li&gt;
&lt;li&gt;1 tsp. cinnamon&lt;/li&gt;
&lt;li&gt;1/2 tsp. kosher salt&lt;/li&gt;
&lt;li&gt;1 tsp. baking powder&lt;/li&gt;
&lt;li&gt;7 ounces very dark chocolate chips, or a chopped very dark chocolate bar&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Preheat oven to 350°F.&lt;/p&gt;
&lt;p&gt;Thoroughly mash the bananas in a large bowl. Add the vanilla extract and coconut oil, and stir to combine. Add the oats, almond meal, and shredded coconut, and mix well to fully moisten the dry ingredients. Add the cinnamon, salt, and baking powder, and mix until well combined. Fold in the chocolate chunks/chips.&lt;/p&gt;
&lt;p&gt;Drop dollops of the dough, each about 2 teaspoons in size, an inch apart, onto a parchment (or Silpat) lined baking sheet. A cookie scoop works very well for this. Bake for about 20 minutes, until lightly browned.&lt;/p&gt;
&lt;p&gt;Adapted from: &lt;a href="https://smittenkitchen.com/2012/08/my-favorite-brownies/"&gt;https://www.101cookbooks.com/healthy-cookie-recipe/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Chocolate Mousse&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://chocolatechocolateandmore.com/easy-whipped-dark-chocolate-mousse/"&gt;https://chocolatechocolateandmore.com/easy-whipped-dark-chocolate-mousse/&lt;/a&gt; but modified with with 1/3rd the sugar and using (Alter Eco) 85% chocolate.&lt;/p&gt;</content><category term="health"/><category term="quantifiedself"/><category term="health"/><category term="cgm"/></entry><entry><title>DNA sequencing at home with the flongle</title><link href="/sequencing-at-home-with-flongle.html" rel="alternate"/><published>2019-07-27T11:00:00-07:00</published><updated>2019-07-27T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2019-07-27:/sequencing-at-home-with-flongle.html</id><summary type="html">&lt;p&gt;DNA sequencing at home using Oxford Nanopore's new flongle sequencer.&lt;/p&gt;</summary><content type="html">&lt;p&gt;It's been a dream of mine for a long time to be able to do sequencing at home —
just take whatever stuff I want: microbiome, viral/bacterial infections, insects, fungi, foods, sourdough, sauerkraut, and sequence it.
Now at last, with the debut of Oxford Nanopore's flongle, it's possible!&lt;/p&gt;
&lt;p&gt;So, a few months back, I bought some flongles (basically on launch day) and set up a home sequencing lab.
In this post I'll describe what's in the lab and my first sequencing experiments.&lt;/p&gt;
&lt;h2&gt;What is a flongle?&lt;/h2&gt;
&lt;p&gt;As a refresher, Oxford Nanopore's MinION sequencer is a hand-held, single molecule nanopore sequencer.
As DNA passes through a pore, the obstruction modulates the current across the pore in a pattern that can be mapped
onto a sequence of nucleotides.&lt;/p&gt;
&lt;p&gt;&lt;img width="100%" src="/images/home_lab_nanopore_video.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;DNA going through a pore, from an &lt;a href="https://vimeo.com/337258910"&gt;ONT video&lt;/a&gt;&lt;/figcaption&gt;

&lt;p&gt;The MinION device itself is a fairly simple container for the nanopore-containing flow-cells.
The standard MinION flow-cell contains 512 channels (each of which has one active pore at a time),
plus the ASIC chip that reads the changes in current.
There's a great &lt;a href="https://nanoporetech.com/how-it-works"&gt;explainer on the Oxford Nanopore website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Oxford Nanopore's newest flow-cell, the flongle ("flow-cell dongle"),
is basically a cheaper, more disposable version of the standard MinION flow-cell.
The flongle snaps into an adapter that includes the ASIC you usually find
in a regular flow-cell.&lt;/p&gt;
&lt;p&gt;&lt;img width="47%" src="/images/home_lab_minion.png" /&gt;
&lt;img width="47%" src="/images/home_lab_flongle.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;(a) MinION sequencer with loaded flow-cell. (b) Flongle and adapter.&lt;/figcaption&gt;

&lt;!--
Instead of the 512 channels the MinION flow-cell has,
a flongle only has 126.
(A channel is a set of pores, only one of which is
active at a time, so it's kind of like 126 pores.)
--&gt;

&lt;p&gt;Whereas a 512 channel flow-cell costs
&lt;a href="https://nanoporetech.com/products/comparison"&gt;$475-900&lt;/a&gt;,
126 channel flongles cost about $90-150 each.
At the time of writing, you have to buy at least &lt;a href="https://store.nanoporetech.com/flongle.html"&gt;a starter pack of 12 for $1860&lt;/a&gt;,
which includes the adapter.&lt;/p&gt;
&lt;p&gt;Each pore can output several megabases of sequence,
so the total amount of sequence can be in the hundreds of
megabases
(the &lt;a href="https://twitter.com/OmicsOmicsBlog/status/1131612735115075584"&gt;biggest flongle run I know of is ~2Gb&lt;/a&gt;, in the hands
of an experienced lab.)&lt;/p&gt;
&lt;p&gt;For now, you have to spend quite a lot to get access to flongles, and supply is &lt;em&gt;severely&lt;/em&gt; limited.
I have received only four so far, out of the 48 I bought! (That was the minimum order size at launch.)
So, there are definitely beta program issues here. Still, $100 NGS runs!&lt;/p&gt;
&lt;h2&gt;Home Lab Equipment&lt;/h2&gt;
&lt;p&gt;Surprisingly, you don't actually need that much expensive equipment to do nanopore sequencing.
For my home lab, I bought the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.the-odin.com/pipette/"&gt;Three calibrated pipettes&lt;/a&gt; for $35 each and &lt;a href="http://www.the-odin.com/pipette-tips-1-200ul-box-of-96/"&gt;boxes of pipette tips&lt;/a&gt; for $5 each from &lt;a href="https://www.the-odin.com"&gt;the-odin.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A &lt;a href="http://www.the-odin.com/mini-4k-centrifuge/"&gt;mini-centrifuge&lt;/a&gt; for $45 from &lt;a href="https://www.the-odin.com"&gt;the-odin.com&lt;/a&gt;. They also sell a nice &lt;a href="http://www.the-odin.com/10k-mini-centrifuge/"&gt;10k rpm version&lt;/a&gt; for $99&lt;/li&gt;
&lt;li&gt;An &lt;a href="https://www.nist.gov/laboratories/tools-instruments/eppendorf-5415c-centrifuge"&gt;Eppendorf 5415C&lt;/a&gt; centrifuge from &lt;a href="https://www.ebay.com/sch/i.html?_nkw=eppendorf+5415C"&gt;ebay&lt;/a&gt; for around $300. For DNA extraction, I needed a centrifuge that can spin at &amp;gt;=12k rpm&lt;/li&gt;
&lt;li&gt;An &lt;a href="https://www.amazon.com/Anova-Culinary-Precision-Bluetooth-Included/dp/B07C7PW3PC"&gt;Anova sous vide&lt;/a&gt; for $70 from amazon, for water baths&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.amazon.com/gp/product/B009EJ2SY4/"&gt;vortex mixer&lt;/a&gt; for ~&amp;dollar;120 from amazon ($191 at time of writing)&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://nanoporetech.com/products/minion"&gt;MinION nanopore sequencer&lt;/a&gt;. You do not get one with a &lt;a href="https://store.nanoporetech.com/flongle.html"&gt;flongle starter pack&lt;/a&gt;. I got a free one at the London Calling conference a few years ago, but it's been lost at a lab I worked at so I've had to borrow one... The only way I know of to get a new one is in a &lt;a href="https://store.nanoporetech.com/configure-minion-basic"&gt;MinION starter pack&lt;/a&gt; for $1000, which includes two MinION flow-cells worth approximately $1000.&lt;/li&gt;
&lt;li&gt;A refrigerator that does not have a defrost cycle.
I bought a &lt;a href="https://www.amazon.com/BLACK-DECKER-BCRK17V-Compact-Refrigerator/dp/B01DZQI732/"&gt;mini-fridge&lt;/a&gt; from amazon for $130 so my lab stuff would not be in the kitchen fridge.&lt;/li&gt;
&lt;li&gt;I already had a freezer that does not have a &lt;a href="https://en.wikipedia.org/wiki/Auto-defrost"&gt;defrost cycle&lt;/a&gt;, specifically a chest freezer&lt;/li&gt;
&lt;li&gt;An &lt;a href="https://www.amazon.com/Digital-Infrared-Thermometer-Temperature-Non-Contact/dp/B07PVZ4WH4/"&gt;infrared thermometer&lt;/a&gt; to check out which parts of the fridge are at the right temperature... These are not necessary, just cheap and handy.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="/images/home_lab_desk.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;The lab during a sequencing run. MinION running and Used flongle on the desk in front&lt;/figcaption&gt;

&lt;p&gt;&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_centrifuge.jpg" /&gt;
&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_sous_vide.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;(a) Eppendorf 5415C centrifuge. (b) Anova sous vide in a Costco coffee can&lt;/figcaption&gt;

&lt;h2&gt;DNA Extraction&lt;/h2&gt;
&lt;p&gt;The first step in sequencing is DNA extraction.
I bought a &lt;a href="https://www.zymoresearch.com/collections/quick-dna-kits/products/quick-dna-microprep-plus-kit"&gt;Zymo Quick-DNA Microprep Plus Kit&lt;/a&gt; for $132 (50 preps, so a little under $3 per prep).&lt;/p&gt;
&lt;p&gt;This kit takes "20 minutes" (it takes me about 40 minutes including setting up).
It can work with "cell culture, solid tissue, saliva, and any biological fluid sample".
This prep is very easy to do, and almost all the reagents are just stored at room temperature.
They claim it can recover &amp;gt;50kb fragments, which is very respectable.
This is far from the megabase-long &lt;a href="https://twitter.com/search?q=whale%20nanopore&amp;amp;src=typed_query"&gt;"whale" reads&lt;/a&gt;
some labs work to achieve, but those preps are much more complex and time-consuming.
Generally speaking, 10kb reads are more than long enough for most use-cases,
and even 100bp-1kbp reads can still be used for species ID.&lt;/p&gt;
&lt;p&gt;I am lucky to have access to a nanodrop spectrophotometer at work, so I can check my DNA quality.
(Nanodrops cost thousands of dollars, even &lt;a href="https://www.ebay.com/sch/i.html?_nkw=nanodrop"&gt;second-hand&lt;/a&gt;.)
I think this wouldn't matter if I was was sequencing saliva repeatedly:
that seems to work the same every time.
However, it matters quite a bit for experimenting with sequencing different sample types.&lt;/p&gt;
&lt;!--
Host depletion:

https://www.zymoresearch.com/collections/zymobiomics-dna-kits/products/zymobiomics-dna-microprep-kit
https://www.zymoresearch.com/blogs/blog/addition-by-subtraction-host-dna-depletion-for-microbiome-analyses
https://www.zymoresearch.com/products/hostzero-sup-trade-sup-microbial-dna-kit-microprep
## Protocol

- DNA extraction ($3)
- Library prep (~$50)
- Sequencing (~$90)
--&gt;

&lt;h2&gt;Library prep&lt;/h2&gt;
&lt;p&gt;Library prep is the process of preparing the DNA for sequencing,
for example by attaching the "motor protein" that ratchets the DNA through the pore one base at a time.
Not being an experimentalist, I like to stick to the simplest possible protocols.
That means rapid DNA extraction
and ONT's rapid library prep (&lt;a href="https://store.nanoporetech.com/sample-prep/rapid-sequencing-kit.html"&gt;RAD-004&lt;/a&gt;),
which costs $600 for 12 preps (&amp;dollar;50 per prep).&lt;/p&gt;
&lt;p&gt;Library prep is a little harder than DNA extraction, but still only takes around 40 minutes.
There are some very low volumes involved (0.5µl, which is as low as my pipettes go!),
and you need two water bath temperatures, but overall it's pretty straightforward.&lt;/p&gt;
&lt;p&gt;The total time from acquiring a sample to beginning sequencing is maybe 1.5 hours.
You definitely pay for this convenience in read length and throughput,
but the tradeoff is not too bad.&lt;/p&gt;
&lt;p&gt;Admittedly, the cost is more like $150 than $100 per run,
but with the &lt;a href="https://community.nanoporetech.com/protocols/nuclease-flush-protocol/v/NFL_9076_v109_revC_08Oct2018"&gt;nuclease wash protocol&lt;/a&gt; now available to rejuvenate flow-cells,
I think it's ok to round down...&lt;/p&gt;
&lt;h2&gt;Experiment one: saliva&lt;/h2&gt;
&lt;p&gt;This is probably the simplest possible experiment:
extract human and bacterial DNA from saliva, and sequence it.
Saliva has lots of human DNA — surprisingly, most of it is from white blood cells —
and plenty of oral microbiome bacteria,
and it's easy to get as much as you want.
However, since bacterial genomes are about 0.001X the size of a human genome,
you'd need 1000 bacterial genomes for every human genome if you want equal coverage of both.&lt;/p&gt;
&lt;p&gt;&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_nanodrop_saliva.jpg" /&gt;
&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_hist1.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Experiment one: (a) DNA quantification from saliva. (b) A decent read length distribution, topping out at 60kb.&lt;/figcaption&gt;

&lt;p&gt;This experiment generated a pretty respectable 100 megabases of sequence in 24 hours,
which is basically what I was hoping for.&lt;/p&gt;
&lt;p&gt;As soon as the DNA is loaded, reads start to get written to disk.
After a minute, you have reads you can feed into &lt;a href="https://blast.ncbi.nlm.nih.gov/Blast.cgi?PAGE_TYPE=BlastSearch"&gt;BLAST&lt;/a&gt;
to see if everything is working as expected.
The instant access to data is a great reward for doing the boring prep work.&lt;/p&gt;
&lt;p&gt;&lt;img min-width="65%" src="/images/home_lab_sequencing.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;First sequencing run at home: pores sequencing, 34 minutes and 10 megabases in!&lt;/figcaption&gt;

&lt;p&gt;There are a few ways to analyze the data.
There are several metagenome analysis tools,
like &lt;a href="https://ccb.jhu.edu/software/centrifuge/"&gt;Centrifuge&lt;/a&gt; and &lt;a href="https://ccb.jhu.edu/software/kraken/"&gt;Kraken&lt;/a&gt;.
I spent a couple of days(!) downloading the Centrifuge databases
— which are massive since they need reference sequence data from bacteria, fungi, viruses etc. —
only to have the build fail right afterward.&lt;/p&gt;
&lt;p&gt;Luckily, Oxford Nanopore has some convenient tools online for analysis.
It turns out that one of these, &lt;a href="https://nanoporetech.com/resource-centre/whats-my-pot-wimp-quantitative-analysis-tool-real-time-species-identification"&gt;What's In My Pot&lt;/a&gt; (WIMP) is based on Centrifuge
so it's convenient to just run that.&lt;/p&gt;
&lt;p&gt;&lt;img width="47%" src="/images/home_lab_wimp_1.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Experiment one: WIMP results for unfiltered saliva&lt;/figcaption&gt;

&lt;p&gt;As we can see, &amp;gt;99% of the reads are human or Escherichia.
Upon closer inspection, the reads labeled "Escherichia coli" and "Escherichia virus Lambda" are all lambda DNA.
As a QC step, I spiked lambda DNA (provided by ONT for QC purposes) into my DNA library at approximately 13% by volume.
About 12% of my reads are lambda,
so I know the molarity of my input sample is not too far off the reference lambda DNA.&lt;/p&gt;
&lt;p&gt;After you get past the human and lambda DNA,
the vast majority of reads map to known oral microbiome bacteria.
Without anything to compare to, I can't point to any specific trends here yet.&lt;/p&gt;
&lt;h3&gt;Human DNA&lt;/h3&gt;
&lt;p&gt;What can you do with 80 megabases of human DNA?
I know from just BLASTing reads that the accuracy is consistently 89-91%.
Since a hundred megabases is only a 0.03X genome, it's not very useful for any human genetics tasks
except maybe ancestry assignment, &lt;a href="https://gencove.com"&gt;Gencove-style&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One thing I can do is intersect these reads with my 23andme data,
and see how often it's concordant
(the 23andme data is diploid and these are single molecule reads so it's not quite simple matching).
Doing this intersection using &lt;a href="https://samtools.github.io/bcftools/bcftools.html"&gt;bcftools&lt;/a&gt;
and including only high quality reads resulted in only a few hundred SNPs.
I did not find any variants that disagreed, which was surprising but nice to see.&lt;/p&gt;
&lt;h2&gt;Experiments two and three: failing to filter saliva&lt;/h2&gt;
&lt;p&gt;Obviously, it's a waste to generate so many human reads.
Since I don't need my genome sequenced again (ok, I only have exome data),
especially 0.03X at a time, I wanted to try to enrich for oral bacteria.
There are &lt;a href="https://www.zymoresearch.com/blogs/blog/addition-by-subtraction-host-dna-depletion-for-microbiome-analyses"&gt;host depletion kits&lt;/a&gt;
that apparently work well,
but that's kind of expensive, so I wanted to see what would happen if I just tried to physically filter saliva.&lt;/p&gt;
&lt;p&gt;We know that human cells are &lt;a href="http://book.bionumbers.org/how-big-is-a-human-cell/"&gt;usually &amp;gt;10µm&lt;/a&gt;
and bacterial cells are &lt;a href="https://education.seattlepi.com/size-comparisons-bacteria-amoeba-animal-plant-cells-4966.html"&gt;usually &amp;lt;10µm&lt;/a&gt;
so that's a pretty simple threshold to filter by.
I bought a &lt;a href="https://smile.amazon.com/Premium-Qualitative-Filter-Medium-micron/dp/B00AZ3ATH6/"&gt;"10µm" paper filter&lt;/a&gt;
on amazon, and just filtered saliva through it.&lt;/p&gt;
&lt;p&gt;Experiments two and three produced almost identical results.
The only differences were that after experiment two failed I tried to eliminate contamination from the paper filter
by pre-washing it, and I quantified the DNA with a nanodrop, a step I skipped in experiment two.
After multiple rounds of filtering–centrifugation–pouring off, I only managed to get 10ng/µl of DNA, which is very low.
However, I knew that my first 32ng/µl run worked fine,
so I convinced myself it must reach the recommended minimum of 5 femtomoles of DNA
(that's only &lt;a href="https://www.wolframalpha.com/input/?i=5+femtomoles+in+molecules"&gt;3 billion molecules!&lt;/a&gt;),
especially since the &lt;a href="https://en.wikipedia.org/wiki/Nucleic_acid_quantitation"&gt;260/280&lt;/a&gt; was not that bad.&lt;/p&gt;
&lt;p&gt;The experiment worked as planned, in the sense that instead of 99+% human DNA, I got 50% human DNA and 50% bacterial.
However, instead of 100 megabases, I only got 2, and most were low quality!&lt;/p&gt;
&lt;p&gt;&lt;img width="50%" src="/images/home_lab_nanodrop_filter.jpg" /&gt;
&lt;img width="40%" src="/images/home_lab_wimp_2.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Experiment three: (a) DNA quantification from filtered saliva. (b) WIMP on filtered saliva&lt;/figcaption&gt;

&lt;p&gt;My best guess here is that somehow the paper contaminated the DNA,
since the pores apparently got clogged after just a couple of hours.
I should at least have made sure I had a lot of DNA,
though I don't have great ideas on how to do that beyond just spitting for an hour...
It's likely I'll just need to use a proper microbiome prep kit next time.&lt;/p&gt;
&lt;h2&gt;Experiment four: wasp sequencing&lt;/h2&gt;
&lt;p&gt;Amazingly, despite having pretty small genomes (100s of megabases), most insects have never been sequenced!
It's not clear to me that you can create a high quality genome assembly from only flongle reads,
but if you can get 100 megabases of DNA,
that's definitely a good start.&lt;/p&gt;
&lt;p&gt;We have a wasp trap in our back yard. It caught a wasp but we were not sure what kind.
It could be the most common type of wasp in the area,
the &lt;a href="https://en.wikipedia.org/wiki/Vespula_pensylvanica"&gt;western yellowjacket&lt;/a&gt;.
It looks exactly like one, which is a bit of a clue.&lt;/p&gt;
&lt;p&gt;&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_western_yellowjacket.jpg" /&gt;
&lt;img width="47%" style="vertical-align:bottom" src="/images/home_lab_common_aerial_yellowjacket.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Distribution of western yellowjacket vs common aerial yellowjacket, according to &lt;a href="https://www.inaturalist.org"&gt;iNaturalist&lt;/a&gt;&lt;/figcaption&gt;

&lt;p&gt;But eyes can deceive.
The &lt;a href="https://www.inaturalist.org"&gt;only real way&lt;/a&gt; to figure out for sure if this is even a wasp is by sequencing its genome,
or at least it would be if there were a reference genome.
Surprisingly there is no genome for the &lt;a href="https://www.ncbi.nlm.nih.gov/nuccore/?term=Vespula%20pensylvanica"&gt;western yellowjacket&lt;/a&gt;
or the other likely species, the &lt;a href="https://www.ncbi.nlm.nih.gov/search/all/?term=Dolichovespula%20arenaria"&gt;common aerial yellowjacket&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img width="47%" style="font-size:80%;vertical-align:bottom" src="/images/home_lab_wasp1.jpg" /&gt;
&lt;img width="47%" style="font-size:80%;vertical-align:bottom" src="/images/home_lab_wasp2.jpg" /&gt;&lt;/p&gt;
&lt;figcaption&gt;(a) Before mushing, with an aphid and other tiny insects in the second tube. (b) After mushing, which was pretty gross.&lt;/figcaption&gt;

&lt;p&gt;I took the wasp, plus an aphid that looked freshly caught in a spiderweb,
and a few other tiny insects scurrying around nearby.
Then I mushed them up and used the Zymo solid tissue protocol to extract DNA.&lt;/p&gt;
&lt;p&gt;&lt;img width="40%" style="vertical-align:bottom" src="/images/home_lab_nanodrop_wasp.jpg" /&gt;
&lt;img width="50%" style="vertical-align:bottom" src="/images/home_lab_hist2.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Experiment four: (a) DNA quantification and (b) read-length distribution&lt;/figcaption&gt;

&lt;p&gt;This time the DNA extraction was great quantity and quality.
The total amount of sequence generated was 100 megabases again.
However, the read length is &lt;em&gt;extremely&lt;/em&gt; short on average.
A general rule for nanopore sequencing is that you get out what you put in.
In retrospect this problem should have been pretty obvious:
although it looked ok, the wasp was not fresh enough so its DNA was very degraded.&lt;/p&gt;
&lt;p&gt;Interestingly, there are quite a few long fragments (&amp;gt;5kb) in here too,
and these map imperfectly to various aphid genomes (indicating that this particular aphid has also not been sequenced)
and bacteria including possible wasp endosymbionts like &lt;em&gt;Pantoea agglomerans&lt;/em&gt;.
This is expected if the aphid and bacteria are fresh.&lt;/p&gt;
&lt;p&gt;&lt;img width="40%" style="vertical-align:bottom" src="/images/home_lab_wimp_wasp.png" /&gt;
&lt;img width="40%" style="vertical-align:bottom" src="/images/home_lab_blast.png" /&gt;&lt;/p&gt;
&lt;figcaption&gt;Experiment four: (a) WIMP of wasp and aphid reads. (b) BLASTing reads produces better results&lt;/figcaption&gt;

&lt;p&gt;I also ran WIMP but it turned out not to be useful, since this is not a "real" metagenomics run
(i.e., it's not mainly a mixture of microbes and viruses).
The closest matches are just misleading.&lt;/p&gt;
&lt;!--
Of course it makes sense that the bacteria colonizing the wasp do not die immediately after the wasp dies.
You could probably measure that rate with sequencing too..
--&gt;

&lt;p&gt;It would have been nice to be the first to assemble the western yellowjacket genome,
or even a commensal bacterial genome, but I would have needed a lot more reads.
Wasp genomes are around 200 megabases, so to get a decent quality genome I'd need at least
10 gigabases of sequence (50X coverage). That means a MinION run (or several), perhaps polished with some illumina data.
The commensal bacteria are probably under 5 megabases,
so it would be easier to create a reference genome, assuming any could be grown outside the wasp...&lt;/p&gt;
&lt;h2&gt;Next steps&lt;/h2&gt;
&lt;p&gt;Four flongles in, I am still pretty amazed that I can generate a hundred megabases of sequence, at home,
for so little money and equipment.&lt;/p&gt;
&lt;p&gt;I can almost run small genome projects at home,
and submit the assembled genomes to &lt;a href="https://ncbi.nlm.nih.gov"&gt;ncbi&lt;/a&gt;.
(I still need more sequencing throughput to do this in earnest.)
Like the western yellowjacket,
there are tons of genomes yet to be sequenced that should be sequenced.
In general, plants and more complex eukaryotes will be too difficult,
but bacteria, fungi, and insects should all be possible at home.&lt;/p&gt;
&lt;p&gt;Preserving the DNA sequences of species could become an extremely important step in conservation and even de-extinction.
The only group I know of doing work in this area is &lt;a href="https://reviverestore.org"&gt;revive &amp;amp; restore&lt;/a&gt;.
One of their projects is to try to &lt;a href="https://reviverestore.org/projects/woolly-mammoth/"&gt;bring back the woolly mammoth&lt;/a&gt;
by bootstrapping from elephant to elephant–mammoth hybrid, and eventually to full mammoth.
Of course this would not be possible without the mammoth genome sequence.
The &lt;a href="https://awionline.org/content/list-endangered-species"&gt;list of endangered species&lt;/a&gt; is very long,
so there's a lot to do.&lt;/p&gt;</content><category term="biotech"/><category term="sequencing"/><category term="flongle"/><category term="nanopore"/><category term="homelab"/><category term="biotech"/></entry><entry><title>Comparing bioinformatics workflow systems: nextflow, snakemake, reflow</title><link href="/nextflow-snakemake-reflow.html" rel="alternate"/><published>2019-06-02T11:00:00-07:00</published><updated>2019-06-02T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2019-06-02:/nextflow-snakemake-reflow.html</id><summary type="html">&lt;p&gt;A brief comparison of three bioinformatics workflow tools: nextflow, snakemake, reflow.&lt;/p&gt;</summary><content type="html">&lt;p&gt;There are a &lt;em&gt;lot&lt;/em&gt; of bioinformatics workflow languages and systems these days.
&lt;a href="https://twitter.com/AlbertVilella"&gt;Albert Vilella&lt;/a&gt; maintains a
&lt;a href="https://docs.google.com/spreadsheets/d/1plkAsT_S3CzSeb7ivxyjRnHyrK3JclUCXeUMf_azraY/edit#gid=0"&gt;comprehensive spreadsheet&lt;/a&gt; and it's massive.
A little confusingly, some of these are actual languages (CWL),
some are engines for running workflows (Cromwell),
and some are self-contained systems (reflow, nextflow, snakemake).&lt;/p&gt;
&lt;p&gt;The point of these tools is to take a multi-part process
— usually a combination of scripts and binaries —
and run it many times,
keeping a log of what succeeded and what failed,
and managing the resources required.&lt;/p&gt;
&lt;p&gt;Among the most popular (or at least ones I've heard of people using)
are &lt;a href="https://snakemake.readthedocs.io/en/stable/"&gt;snakemake&lt;/a&gt;,
&lt;a href="https://toil.readthedocs.io/en/latest/"&gt;toil&lt;/a&gt;,
&lt;a href="https://www.nextflow.io/"&gt;nextflow&lt;/a&gt;,
&lt;a href="https://github.com/spotify/luigi"&gt;luigi&lt;/a&gt;,
&lt;a href="https://github.com/ssadedin/bpipe"&gt;bpipe&lt;/a&gt;,
&lt;a href="https://github.com/scipipe/scipipe"&gt;scipipe&lt;/a&gt;, and
&lt;a href="https://software.broadinstitute.org/wdl/"&gt;Cromwell/WDL&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For a comprehensive review, see &lt;a href="https://academic.oup.com/bib/article/18/3/530/2562749"&gt;this 2017 paper&lt;/a&gt; by &lt;a href="https://twitter.com/jermdemo"&gt;Jeremy Leipzig&lt;/a&gt;.
Here, I'm just going to compare an example script from the nextflow website to the equivalent in snakemake and reflow. These are the three workflow systems I am most familiar with, and I think the differences between them are pretty interesting.&lt;/p&gt;
&lt;h2&gt;Nextflow&lt;/h2&gt;
&lt;p&gt;Nextflow is probably the most popular workflow system right now.
It is powerful, simple to get started with, and very well supported by &lt;a href="https://twitter.com/PaoloDiTommaso"&gt;Paolo Di Tommasso&lt;/a&gt;,
with plenty of &lt;a href="https://github.com/nextflow-io/patterns"&gt;example scripts&lt;/a&gt;.
It supports running pipelines locally, on a local cluster, or on the cloud.
It can use containers (Docker or Singularity) for reproducibility.
Nextflow uses &lt;a href="https://www.nextflow.io/blog/2017/scaling-with-aws-batch.html"&gt;AWS Batch&lt;/a&gt; as its main cloud backend (apparently &lt;a href="http://zachcp.org/blog/2019/aws_hcls_2019/"&gt;everyone is these days&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The basic script below, from the &lt;a href="https://www.nextflow.io/example1.html"&gt;nextflow site&lt;/a&gt;, is pretty self-explanatory.&lt;/p&gt;
&lt;h3&gt;script&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="ch"&gt;#!/usr/bin/env nextflow&lt;/span&gt;

params.in&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$baseDir&lt;/span&gt;&lt;span class="s2"&gt;/data/sample.fa"&lt;/span&gt;
&lt;span class="nv"&gt;sequences&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;file&lt;span class="o"&gt;(&lt;/span&gt;params.in&lt;span class="o"&gt;)&lt;/span&gt;

/*
&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;split&lt;span class="w"&gt; &lt;/span&gt;a&lt;span class="w"&gt; &lt;/span&gt;fasta&lt;span class="w"&gt; &lt;/span&gt;file&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;multiple&lt;span class="w"&gt; &lt;/span&gt;files
&lt;span class="w"&gt; &lt;/span&gt;*/
process&lt;span class="w"&gt; &lt;/span&gt;splitSequences&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;input:
&lt;span class="w"&gt;    &lt;/span&gt;file&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'input.fa'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;sequences

&lt;span class="w"&gt;    &lt;/span&gt;output:
&lt;span class="w"&gt;    &lt;/span&gt;file&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'seq_*'&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;into&lt;span class="w"&gt; &lt;/span&gt;records

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;"""&lt;/span&gt;
&lt;span class="s2"&gt;    awk '/^&amp;gt;/{f="&lt;/span&gt;seq_&lt;span class="s2"&gt;"++d} {print &amp;gt; f}' &amp;lt; input.fa&lt;/span&gt;
&lt;span class="s2"&gt;    """&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

/*
&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;Simple&lt;span class="w"&gt; &lt;/span&gt;reverse&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;sequences
&lt;span class="w"&gt; &lt;/span&gt;*/
process&lt;span class="w"&gt; &lt;/span&gt;reverse&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;input:
&lt;span class="w"&gt;    &lt;/span&gt;file&lt;span class="w"&gt; &lt;/span&gt;x&lt;span class="w"&gt; &lt;/span&gt;from&lt;span class="w"&gt; &lt;/span&gt;records

&lt;span class="w"&gt;    &lt;/span&gt;output:
&lt;span class="w"&gt;    &lt;/span&gt;stdout&lt;span class="w"&gt; &lt;/span&gt;result

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s2"&gt;"""&lt;/span&gt;
&lt;span class="s2"&gt;    cat &lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="s2"&gt; | rev&lt;/span&gt;
&lt;span class="s2"&gt;    """&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

/*
&lt;span class="w"&gt; &lt;/span&gt;*&lt;span class="w"&gt; &lt;/span&gt;print&lt;span class="w"&gt; &lt;/span&gt;the&lt;span class="w"&gt; &lt;/span&gt;channel&lt;span class="w"&gt; &lt;/span&gt;content
&lt;span class="w"&gt; &lt;/span&gt;*/
result.subscribe&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;println&lt;span class="w"&gt; &lt;/span&gt;it&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;output&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;F&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;L&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;O&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;W&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;19.04.1&lt;/span&gt;
&lt;span class="n"&gt;Launching&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;basic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;hungry_celsius&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;revision&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;c3e3b933c7&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;warm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;up&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;executor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;local&lt;/span&gt;
&lt;span class="n"&gt;executor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;local&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ea&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;b4bcb4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;splitSequences&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="mf"&gt;1F&lt;/span&gt;&lt;span class="n"&gt;DSA&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;ACCAAACACAGTA&lt;/span&gt;
&lt;span class="mf"&gt;2F&lt;/span&gt;&lt;span class="n"&gt;DSA&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;ACCAAACACAGTA&lt;/span&gt;
&lt;span class="mf"&gt;3F&lt;/span&gt;&lt;span class="n"&gt;DSA&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="n"&gt;ACCAAACACAGTA&lt;/span&gt;
&lt;span class="n"&gt;executor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;local&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ea&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;b4bcb4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;splitSequences&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;✔&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ef&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mo"&gt;0377&lt;/span&gt;&lt;span class="n"&gt;ba&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;process&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;✔&lt;/span&gt;
&lt;span class="n"&gt;Completed&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;May&lt;/span&gt;&lt;span class="mi"&gt;-2019&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;39&lt;/span&gt;
&lt;span class="nl"&gt;Duration&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;951&lt;/span&gt;&lt;span class="n"&gt;ms&lt;/span&gt;
&lt;span class="n"&gt;CPU&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;few&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nl"&gt;Succeeded&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The output is quite comprehensive and easy to understand.&lt;/p&gt;
&lt;h2&gt;Snakemake&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://snakemake.readthedocs.io/en/stable/"&gt;Snakemake&lt;/a&gt;,
developed by &lt;a href="https://twitter.com/johanneskoester"&gt;Johannes Köster&lt;/a&gt; (also the founder of the bioconda project!)
is the oldest of the three workflow systems here.
As the name implies, it's sort of like make, but in Python.&lt;/p&gt;
&lt;p&gt;Snakemake existed before containers and cloud computing were common.
It is filename-focused, which makes it simple to get started with, and pretty easy to debug.
In contrast, nextflow and reflow try to abstract away the names of files,
sometimes at the cost of simplicity.&lt;/p&gt;
&lt;p&gt;Even though I have used snakemake quite a bit,
I found it pretty difficult to port the nextflow script above,
mainly because it involves splitting one file into multiple.
I think there are at least three ways to handle file splitting in snakemake:
&lt;a href="https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html"&gt;&lt;code&gt;dynamic&lt;/code&gt;&lt;/a&gt; files (soon to be deprecated),
the new &lt;code&gt;checkpoints&lt;/code&gt; (I did not look into this much),
and just using directories.&lt;/p&gt;
&lt;p&gt;The directory option is the simplest to me, but the result is probably far from ideal snakemake.
In previous snakemake pipelines I often relied on something similar:
when one step of the pipeline is done, instead of relying on the appearance of a specific filename,
I would just output a "sentinel" file,
e.g., &lt;code&gt;echo done &amp;gt; {output.sentinel}&lt;/code&gt;,
and use that as the trigger for the next step.&lt;/p&gt;
&lt;p&gt;Since Snakemake is based on Python,
it is easy to extend and integrate with other scripts.
To copy the nextflow script, here I just use the bash though.&lt;/p&gt;
&lt;h3&gt;script&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;rule&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"rev"&lt;/span&gt;

&lt;span class="n"&gt;rule&lt;/span&gt; &lt;span class="n"&gt;split_fasta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"input.fa"&lt;/span&gt;
    &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"split"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"""awk '/^&amp;gt;/{{f="&lt;/span&gt;&lt;span class="si"&gt;{output}&lt;/span&gt;&lt;span class="s2"&gt;/seq_"++d}} {{print &amp;gt; f}}' &amp;lt; &lt;/span&gt;&lt;span class="si"&gt;{input}&lt;/span&gt;&lt;span class="s2"&gt;"""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;rule&lt;/span&gt; &lt;span class="n"&gt;reverse_fasta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"split"&lt;/span&gt;
    &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"rev"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"""for f in &lt;/span&gt;&lt;span class="si"&gt;{input}&lt;/span&gt;&lt;span class="s2"&gt;/*; do cat $f |rev &amp;gt; &lt;/span&gt;&lt;span class="si"&gt;{output}&lt;/span&gt;&lt;span class="s2"&gt;/rev_$(basename $f); done"""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;output&lt;/h3&gt;
&lt;p&gt;Snakemake outputs a directory, &lt;code&gt;rev&lt;/code&gt;,
containing the files &lt;code&gt;rev_seq_1&lt;/code&gt;, &lt;code&gt;rev_seq_2&lt;/code&gt;, &lt;code&gt;rev_seq_3&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Reflow&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://github.com/grailbio/reflow"&gt;Reflow&lt;/a&gt; is a relatively new workflow language developed by at Grail by
&lt;a href="https://twitter.com/marius"&gt;@marius&lt;/a&gt; and colleagues.
I've been using Reflow for a year or so,
and it's the system I am most familiar with.&lt;/p&gt;
&lt;p&gt;One big difference between reflow and the other systems is how constrained it is:
simplifying a bit, every function takes
(a) a docker container,
(b) a file or directory stored in s3, and
(c) some bash;
and outputs another file or directory stored in s3.&lt;/p&gt;
&lt;p&gt;Everything gets run on AWS. You cannot run it on a regular cluster.
You can run a reflow pipeline locally but it's mostly for debugging, and feels more like emulating the real AWS pipeline.&lt;/p&gt;
&lt;h3&gt;script&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"$/files"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;dirs&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"$/dirs"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"s3://booleanbiotech/input.fa"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;func&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;dir&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nx"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"ubuntu"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;
&lt;span class="s"&gt;        echo Split {{input}};&lt;/span&gt;
&lt;span class="s"&gt;        awk '/^&amp;gt;/{f="&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;seq_&lt;/span&gt;&lt;span class="s"&gt;"++d} {print &amp;gt; f}' &amp;lt; {{input}}&lt;/span&gt;
&lt;span class="s"&gt;    "&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;func&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nx"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;image&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"ubuntu"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;out&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;
&lt;span class="s"&gt;        echo Reverse {{input}};&lt;/span&gt;
&lt;span class="s"&gt;        cat {{input}} | rev &amp;gt; {{out}}&lt;/span&gt;
&lt;span class="s"&gt;    "&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;split_dir&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;rev_files&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;f&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;lt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;dirs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Files&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;split_dir&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;

&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Main&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;rev_files&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;output&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;[file(sha256=sha256:15a48aae8b19682a84dcf39f9260901e0b8331e8f9f974efd11a9a15c950320f, size=16),
 file(sha256=sha256:adad5843ce952755cd5b5b71fd92c7a67be3063d047350cf7fffdd6031ee5c2e, size=16),
 file(sha256=sha256:441ff0551203c350251abc5782698371116cca12a735fa2dbed66de4820b9201, size=16)]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There is logging too,
but overall the output of reflow is pretty opaque!&lt;/p&gt;
&lt;p&gt;To see the contents of the generated files, you have to use
&lt;code&gt;reflow cat 15a48aae8b19682a84dcf39f9260901e0b8331e8f9f974efd11a9a15c950320f&lt;/code&gt;.
Generally, the last step in your pipeline should copy the outputs to S3, but debugging this can be tough.&lt;/p&gt;
&lt;h2&gt;Comparing the Three&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Snakemake&lt;/strong&gt; has been great for local pipelines.
Its "reports" — html output from stages of the pipeline — are especially nice.
It also now supports containers (and conda), so it is far from stagnant.
However, I haven't tried to run snakemake pipelines on the cloud,
and I suspect since it is so file-focused it might be less suited to this.&lt;/p&gt;
&lt;p&gt;I only seriously experimented with &lt;strong&gt;nextflow&lt;/strong&gt; before it had AWS Batch support,
which made it unsuitable for my purposes.
At that time running pipelines on the cloud required quite a lot of setup,
but now this issue seems to be solved.
Nextflow development also seems to be the most active of the three.
There are even Nextflow meetings, periodically.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reflow&lt;/strong&gt; is the least popular, least flexible, and least documented of the three.
Nevertheless, as a user who exclusively runs pipelines on the cloud,
I still like the reflow model best.
It gets closest to my ideal for a workflow system,
which is basically just annotating code with the resources required to run it.&lt;/p&gt;
&lt;p&gt;This is because to reflow, everything is a hash:
containers, code, inputs, outputs.
For example, if you have genome A (&lt;code&gt;sha256(genome_sequence_bytes)=&amp;lt;hash1&amp;gt;&lt;/code&gt;),
and you run adapter trimming function B (&lt;code&gt;sha256(script_bytes)=&amp;lt;hash2&amp;gt;&lt;/code&gt;),
using container C (&lt;code&gt;sha256(docker_container_bytes)=&amp;lt;hash3&amp;gt;&lt;/code&gt;),
then you "know" the output is the hash of &lt;code&gt;sha256(&amp;lt;hash1&amp;gt;+&amp;lt;hash2&amp;gt;+&amp;lt;hash3&amp;gt;)=&amp;lt;hash4&amp;gt;&lt;/code&gt;.
If the file &lt;code&gt;s3://my-reflow-cache/&amp;lt;hash4&amp;gt;&lt;/code&gt; exists,
even if it's from an old workflow,
you don't need to recalculate!
(The above is the gist of how it works, anyway. As usual with caches, this system can also result in tricky bugs...)&lt;/p&gt;
&lt;p&gt;For some technical details on differences between nextflow and reflow, this &lt;a href="https://twitter.com/marius/status/1129036323778486278"&gt;Twitter thread&lt;/a&gt; may also be of interest,
since it includes some discussion from the authors of the tools.&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;If I were starting today,
I would probably choose nextflow as the safe option, mainly due to its new AWS Batch support.
Snakemake still works great, though it may be showing its age a bit,
while reflow is excellent if you are AWS-exclusive and can deal with its lack of documentation and support.&lt;/p&gt;
&lt;p&gt;I think my ideal workflow language would have reflow-style decorators on Python functions
(or a subset of python). I'll be interested to see if the reflow model inspires some new workflow systems like this.&lt;/p&gt;</content><category term="datascience"/><category term="datascience"/><category term="cloud"/><category term="gcp"/><category term="aws"/><category term="bioinformatics"/></entry><entry><title>Tools for working on the cloud</title><link href="/tools-for-working-on-the-cloud.html" rel="alternate"/><published>2019-03-23T11:00:00-07:00</published><updated>2019-03-23T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2019-03-23:/tools-for-working-on-the-cloud.html</id><summary type="html">&lt;p&gt;A list of tools for working remotely on a cloud instance.&lt;/p&gt;</summary><content type="html">&lt;p&gt;These days most everything is on the cloud.
However, probably the most common mode of working is to
develop locally on a laptop, then deploy to the cloud when necessary.
Instead, I like to try to run everything remotely on an instance on the cloud.&lt;/p&gt;
&lt;h3&gt;Why?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;All your files are together in one place.&lt;/li&gt;
&lt;li&gt;You can backup your cloud instance very easily (especially on GCP),
  and even spawn clone machines as necessary with more CPU etc.&lt;/li&gt;
&lt;li&gt;You can work with large datasets. Laptops usually max out at 16GB RAM,
  but on a cloud instance you can get 50GB+.
  You can also expand the disk size on your cloud instance as necessary.&lt;/li&gt;
&lt;li&gt;You can do a lot of computational work without making your laptop fans explode.&lt;/li&gt;
&lt;li&gt;Your laptop becomes more like a dumb terminal.
  When your laptop dies, or is being repaired, it's easy to continue work without interruption.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The big caveats here are that this requires having an always-on cloud instance,
which is relatively expensive, and you cannot work without an internet connection.
As someone who spends a lot of time in jupyter notebooks munging large dataframe,
I find the trade-offs are worth it.&lt;/p&gt;
&lt;p&gt;Here are some tools I use that help make working on the cloud easier.&lt;/p&gt;
&lt;h2&gt;Mosh&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://mosh.org/"&gt;Mosh&lt;/a&gt; is the most important tool here for working on the cloud.
Instead of sshing into a machine once or more a day, now my laptop is continuously
connected to a cloud instance, essentially until the instance needs to reboot (yearly?).
Mosh also works better than regular ssh on weak connections, so it's
handy for working on the train, etc.
It makes working on a remote machine feel like working locally.
If you use ssh a lot, try mosh instead.&lt;/p&gt;
&lt;h2&gt;Tmux&lt;/h2&gt;
&lt;p&gt;Since I just have one mosh connection at a time,
I need to have some tabs.
Most people probably already use &lt;a href="https://linux.die.net/man/1/screen"&gt;screen&lt;/a&gt; or &lt;a href="https://github.com/tmux/tmux"&gt;tmux&lt;/a&gt; anyway.
I have a basic tmux setup, with ten or so tabs,
each with a two-letter name just to keep things a bit neater.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/tmux-plugins/tmux-resurrect"&gt;tmux resurrect&lt;/a&gt;
is the only tmux add-on I use.
It works ok: if your server needs to restart,
tmux resurrect will at least rememeber the names of your tabs.&lt;/p&gt;
&lt;h2&gt;Autossh&lt;/h2&gt;
&lt;p&gt;Mosh works amazingly well for a primary ssh connection,
but to run everything on the cloud I also need a few ssh tunnels.
Mosh cannot do this, so instead I need to use &lt;a href="https://www.harding.motd.ca/autossh/"&gt;autossh&lt;/a&gt;.
Like mosh, autossh tries to keep a connection open indefinitely.
It seems to be slightly less reliable and fiddlier to set up than mosh,
but has been working great for me recently.&lt;/p&gt;
&lt;p&gt;Here's the command I use, based on &lt;a href="https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-autossh/"&gt;this article&lt;/a&gt; and others.
It took a while to get working via trial and error, so there may well be better ways.
The ssh part of this autossh command comes from running &lt;code&gt;gcloud compute ssh --dry-run&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;autossh&lt;span class="w"&gt; &lt;/span&gt;-M&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ServerAliveInterval 30"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ServerAliveCountMax 3"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-f&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;-i&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.ssh/google_compute_engine&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;CheckHostIP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;HostKeyAlias&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;compute.1234567890&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;IdentitiesOnly&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;yes&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;StrictHostKeyChecking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;yes&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;UserKnownHostsFile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/Users/briann/.ssh/google_compute_known_hosts&lt;span class="w"&gt; &lt;/span&gt;brian@12.345.67.890&lt;span class="w"&gt; &lt;/span&gt;-N&lt;span class="w"&gt; &lt;/span&gt;-L&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2288&lt;/span&gt;:localhost:8888&lt;span class="w"&gt; &lt;/span&gt;-L&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2280&lt;/span&gt;:localhost:8880&lt;span class="w"&gt; &lt;/span&gt;-L&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;8385&lt;/span&gt;:localhost:8384&lt;span class="w"&gt; &lt;/span&gt;-L&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2222&lt;/span&gt;:localhost:22&lt;span class="w"&gt; &lt;/span&gt;-L&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;8443&lt;/span&gt;:localhost:8443
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The tunnels I set up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;2288-&amp;gt;8888&lt;/code&gt; : to access jupyter running on my cloud instance (I keep &lt;code&gt;8888&lt;/code&gt; for local jupyter)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;2280-&amp;gt;8880&lt;/code&gt; : to access a remote webserver (e.g., if i run &lt;code&gt;python -m http.server&lt;/code&gt; on my cloud instance)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;8385-&amp;gt;8384&lt;/code&gt; : syncthing (see below)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;2222-&amp;gt;22&lt;/code&gt; : sshfs (see below)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;8443-&amp;gt;8443&lt;/code&gt; : coder (see below)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So to access jupyter, I just run &lt;code&gt;jupyter notebook&lt;/code&gt; in a tmux tab on my cloud box,
and go to &lt;code&gt;https://localhost:2288&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To view a file on my cloud box I run &lt;code&gt;python -m http.server&lt;/code&gt; on my cloud box,
and go to &lt;code&gt;https://localhost:2280&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Syncthing&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://syncthing.net/"&gt;Syncthing&lt;/a&gt; is a dropbox-like tool that syncs files across a group of computers.
Unlike dropbox, the connections between machines are direct (i.e., there is no centralized server).
It's pretty simple: you run syncthing on your laptop and on your cloud instance,
they find each other and start syncing.
Since &lt;code&gt;8384&lt;/code&gt; is the default syncthing port, I can see syncthing's local and remote dashboards on
&lt;code&gt;https://localhost:8384&lt;/code&gt; and &lt;code&gt;https://localhost:8385&lt;/code&gt; respectively.
In my experience, syncthing works pretty well, but I recently stopped using it
because I've found it unnecessary to have files synced to my laptop.&lt;/p&gt;
&lt;h2&gt;Sshfs&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://osxfuse.github.io/"&gt;sshfs&lt;/a&gt; is a tool that lets you mount a filesystem over ssh.
Like syncthing, I also don't use sshfs much any more since it's pretty slow and can fail on occasion.
It is handy if you want to browse PDFs or similar files stored on your cloud instance though.&lt;/p&gt;
&lt;h2&gt;Coder&lt;/h2&gt;
&lt;p&gt;I recently started using &lt;a href="https://coder.com/"&gt;Coder&lt;/a&gt;,
which is &lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt; (my preferred editor),
but running in a browser.
Amazingly, it's almost impossible to tell the difference between "native" VS Code (an Electron app)
and the browser version, especially if it's running in full-screen mode.&lt;/p&gt;
&lt;p&gt;It's very fast to get started. You run this on your cloud instance:
&lt;code&gt;docker run -t -p 127.0.0.1:8443:8443 -v "${PWD}:/root/project" codercom/code-server code-server --allow-http --no-auth&lt;/code&gt;
then go to &lt;code&gt;http://localhost:8443&lt;/code&gt; and that's it!&lt;/p&gt;
&lt;p&gt;Coder is new and has had some glitches and limitations for me.
For example, I don't know how you are supposed to install extensions without also
updating the Docker image, which is less than ideal, and the documentation is minimal.
Still, the VS Code team seems to execute very quickly,
so I am sticking with it for now. It think it will improve and stabilize soon.&lt;/p&gt;
&lt;h2&gt;Annoyances&lt;/h2&gt;
&lt;p&gt;One annoyance with having everything on the cloud is viewing files.
X11 is the typical way to solve this problem, but I've never had much success with X11.
Even at its best, it's ugly and slow.
Most of my graphing, etc. happens in jupyter, so this is usually not a big issue.&lt;/p&gt;
&lt;p&gt;However, for infrequent file viewing, this python code has come in handy.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pathlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Path&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;flask&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;send_file&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="vm"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;get_view_func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_filename&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;send_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename_or_fp&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;
    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s1"&gt;'python -m webbrowser -t "http://localhost:2280"'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add_url_rule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rule&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'/'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;view_func&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;get_view_func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;FLASK_PORT_LOCAL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;debug&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div style="height:35px"&gt;&lt;/div&gt;

&lt;h2&gt;Appendix: GCP activation script&lt;/h2&gt;
&lt;p&gt;This is the bash script I use to set up the above tools from my mac for my GCP instance.
People using GCP might find something useful in here.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;_gcp_activate&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# example full command: _gcp_activate myuserid myuserid@mydomain.com my-instance my-gcp-project us-central1-c $HOME/gcp/&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;clear
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n#    [[ gcp_activate script ]]   \n#\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"# mosh: on mac, 'brew install mosh'\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"# autossh: on mac, 'brew install autossh'\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"# sshfs: on mac, download osxfuse and sshfs from https://osxfuse.github.io/\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#     https://www.everythingcli.org/ssh-tunnelling-for-fun-and-profit-autossh/\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#     sshfs may need a new entry in &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/known_hosts if logging in to a new host\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#     The error is \"remote host has disconnected\"\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#     to achieve that, delete the localhost:2222 entry from &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.ssh/known_hosts\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n"&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$#&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-eq&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"No arguments supplied\n"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;account&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$3&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;gcpproject&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$4&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;zone&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$5&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$6&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n# 1. set gcp project, if it's not set \n#\n"&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# automatically set project&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gcloud&lt;span class="w"&gt; &lt;/span&gt;config&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;account&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;account&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gcloud&lt;span class="w"&gt; &lt;/span&gt;config&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;project&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;gcpproject&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# unmount sshfs&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n# 2. unmount sshfs (this command fails if it's already unmounted, which is ok)\n#\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;umount&lt;span class="w"&gt; &lt;/span&gt;-f&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# commands&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;ssh_cmd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;gcloud&lt;span class="w"&gt; &lt;/span&gt;compute&lt;span class="w"&gt; &lt;/span&gt;ssh&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;@&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;instance&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--zone&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;zone&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--dry-run&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;external_ip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ssh_cmd&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;sed&lt;span class="w"&gt; &lt;/span&gt;-E&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'s/.+@([0-9\.]+)/\1/'&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;autossh_cmd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;ssh_cmd&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;sed&lt;span class="w"&gt; &lt;/span&gt;s/&lt;span class="s1"&gt;'\/usr\/bin\/ssh'&lt;/span&gt;/&lt;span class="s1"&gt;'autossh -M 0 -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -f'&lt;/span&gt;/&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;fullssh_cmd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;autossh_cmd&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; -N -L 2288:localhost:8888 -L 2222:localhost:22 -L 2280:localhost:8000 -L 8385:localhost:8384 -L 8443:localhost:8443"&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n# 3. run autossh to set up ssh tunnels for jupyter (2288), web (2280), and sshfs (2222)\n#\n"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;fullssh_cmd&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n# 4. run sshfs to mount to &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;\n#\n"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;sshfs&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;2222&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;reconnect,compression&lt;span class="o"&gt;=&lt;/span&gt;yes,transform_symlinks,defer_permissions,IdentityFile&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.ssh/google_compute_engine,ServerAliveInterval&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;30&lt;/span&gt;,ServerAliveCountMax&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;-f&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;@localhost:.&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;mountpoint&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n# 5. run mosh\n#\n"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;mosh&lt;span class="w"&gt; &lt;/span&gt;-p&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;60000&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--ssh&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;ssh&lt;span class="w"&gt; &lt;/span&gt;-i&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.ssh/google_compute_engine&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;@&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;external_ip&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--&lt;span class="w"&gt; &lt;/span&gt;tmux&lt;span class="w"&gt; &lt;/span&gt;a
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#\n# 6. if mosh fails run this\n#\n"&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;gcloud&lt;span class="w"&gt; &lt;/span&gt;compute&lt;span class="w"&gt; &lt;/span&gt;ssh&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;user&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;@&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;instance&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;--&lt;span class="w"&gt; &lt;/span&gt;killall&lt;span class="w"&gt; &lt;/span&gt;mosh-server
&lt;span class="o"&gt;}&lt;/span&gt;

gcp_activate&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;_gcp_activate&lt;span class="w"&gt; &lt;/span&gt;myuserid&lt;span class="w"&gt; &lt;/span&gt;myuserid@mydomain.com&lt;span class="w"&gt; &lt;/span&gt;my-instance&lt;span class="w"&gt; &lt;/span&gt;my-project&lt;span class="w"&gt; &lt;/span&gt;us-central1-c&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;/gcp/
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content><category term="datascience"/><category term="datascience"/><category term="cloud"/><category term="gcp"/><category term="aws"/></entry><entry><title>Instagram celebrity generation using neural nets: Jake Dangerback</title><link href="/neural-net-celebrity-jake-dangerback.html" rel="alternate"/><published>2019-01-20T11:00:00-08:00</published><updated>2019-01-20T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2019-01-20:/neural-net-celebrity-jake-dangerback.html</id><summary type="html">&lt;p&gt;Using several neural nets to create an instagram celebrity, Jake Dangerback.&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;a href="https://www.instagram.com/jakedangerback/"&gt;Jake Dangerback&lt;/a&gt; is an instagram celebrity and influencer (of sorts).
He's unusual in that he does not exist; he was created using millions of matrix multiplications.
This post is a look at some of the freely available state-of-the-art neural networks I used to create him.&lt;/p&gt;
&lt;h2&gt;Background&lt;/h2&gt;
&lt;p&gt;Neural nets, specifically &lt;a href="https://en.wikipedia.org/wiki/Generative_adversarial_network"&gt;GANs&lt;/a&gt;,
are getting really good at hallucinating realistic faces.
Notably, NVIDIA had a &lt;a href="https://arxiv.org/abs/1812.04948"&gt;paper in December 2018&lt;/a&gt;
that showed some pretty amazing results.&lt;/p&gt;
&lt;div style="width:100%;margin:auto;text-align:center"&gt;
&lt;img src="/images/jdb_gan_tweet.jpg" style="max-width:40%;max-height:400px;display:inline;margin:auto;" alt="GANs"/&gt;
&lt;img src="/images/jdb_gan_tweet2.jpg" style="max-width:40%;max-height:400px;display:inline;margin:auto;" alt="GANs"/&gt;
&lt;/div&gt;

&lt;p&gt;Since these faces do not belong to anyone,
they are perfect for use as celebrities.
They don't need to be paid, never complain,
and can be tailored to appeal to any niche demographic.&lt;/p&gt;
&lt;!--
------------------
------- 1 --------
------------------
--&gt;

&lt;h2&gt;Step One: Making A Face&lt;/h2&gt;
&lt;p&gt;I used this &lt;a href="https://www.kaggle.com/summitkwan/tl-gan-demo"&gt;awesome tool on kaggle&lt;/a&gt; (&lt;a href="https://github.com/SummitKwan/transparent_latent_gan"&gt;github&lt;/a&gt;) to create a face.
I did not know that kaggle supported this &lt;a href="https://colab.research.google.com"&gt;colab&lt;/a&gt;-like interface but it's quite advanced.
The tool has 21 levers to pull so you can create the perfect face for your audience.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/jdb_kaggle.jpg" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb_kaggle"/&gt;&lt;/p&gt;
&lt;p&gt;Using this tool I created country music star Jake Dangerback's face (his fans call him jdb).
He is handsome but rugged and most importantly he has no legal personhood so I can use his likeness to
endorse and sell products of all kinds.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/jdb_jake_dangerback.jpg" style="max-width:90%;max-height:400px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb_jake_dangerback"/&gt;&lt;/p&gt;
&lt;h3&gt;Photoshopping jdb&lt;/h3&gt;
&lt;p&gt;It's fairly easy to create new images using this face.
There are several sources of royalty-free images (e.g., &lt;a href="https://www.pexels.com/royalty-free-images/"&gt;pexels&lt;/a&gt;)
where I can photoshop jdb's face in.
&lt;img src="/images/jdb_cowboy_hat.jpg" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb_cowboy_hat"/&gt;&lt;/p&gt;
&lt;!-- https://github.com/YuvalNirkin/face_swap --&gt;

&lt;p&gt;Photoshopping a face is not that hard — at least at this quality —
but it would be easier if a neural net did the photoshopping for me.
Luckily there are many &lt;a href="https://arxiv.org/abs/1611.09577"&gt;papers&lt;/a&gt;
and &lt;a href="https://github.com/YuvalNirkin/face_swap"&gt;github repos&lt;/a&gt; that do
&lt;a href="https://www.theguardian.com/technology/2016/mar/08/love-faceswapping-apps-memes-trend-kanye"&gt;face swapping&lt;/a&gt;
since it produces funny pictures.
Most face swapping tools are mobile apps, but I did find
&lt;a href="https://reflect.tech/faceswap/hot"&gt;Reflect face swap&lt;/a&gt; online.
It seems to do a good job generally, but the result below looks a bit weird.
It seems to be trying to mix the photos for realism rather than just replace the face.&lt;/p&gt;
&lt;div style="display:block;margin:auto;text-align:center;"&gt;
&lt;img src="/images/jdb_reagan.jpg" style="max-width:40%;max-height:400px;padding:2em 0 2em 0;display:inline;margin:auto;" alt="reagan"/&gt;
&lt;img src="/images/jdb_reagan_faceswap.jpg" style="max-width:40%;max-height:400px;padding:2em 0 2em 0;display:inline;margin:auto;" alt="reagan faceswap"/&gt;
&lt;div&gt;Reagan wearing a cowboy hat; jdb &lt;i&gt;wearing&lt;/i&gt; a cowboy hat&lt;/div&gt;
&lt;/div&gt;

&lt;h3&gt;Optimizing&lt;/h3&gt;
&lt;p&gt;If we had enough photos, we might consider automatically optimizing the image for likes using
some kind of selfie-rating neural net like &lt;a href="http://karpathy.github.io/2015/10/25/selfie/"&gt;@karpathy's&lt;/a&gt;.
I think the photoshopped images would have to be autogenerated to make this worthwhile.&lt;/p&gt;
&lt;p&gt;Image filters, which are popular on instagram, can also use neural nets.
The most famous example is &lt;a href="https://github.com/jcjohnson/neural-style"&gt;neural style&lt;/a&gt;,
which maps the style of one image — usually a painting — onto the content of another.
The website &lt;a href="https://deepart.io"&gt;deepart.io&lt;/a&gt; does this as a service.
These neural style filters are very cool but not that useful for instagram content.&lt;/p&gt;
&lt;div style="text-align:center;margin:auto"&gt;
&lt;img src="/images/jdb_deepart.jpg" style="max-width:40%;max-height:400px;padding:2em 0 2em 0;display:inline;margin:auto;" alt="jdb deepart"/&gt;
&lt;img src="/images/jdb_deepart2.jpg" style="max-width:40%;max-height:400px;padding:2em 0 2em 0;display:inline;margin:auto;" alt="jdb deepart2"/&gt;
&lt;/div&gt;

&lt;h3&gt;What About DeepFake?&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Deepfake"&gt;DeepFake&lt;/a&gt; is a powerful technique for swapping faces in video
that can produce very realistic results.
There's even a tool called &lt;a href="https://www.alanzucconi.com/2018/03/14/how-to-install-fakeapp/"&gt;FakeApp&lt;/a&gt; 
that &lt;a href="https://www.theverge.com/2018/2/11/16992986/fakeapp-deepfakes-ai-face-swapping"&gt;automates some of the steps&lt;/a&gt;.
There's a &lt;a href="https://www.kdnuggets.com/2018/03/exploring-deepfakes.html"&gt;nice blogpost&lt;/a&gt;
showing how to swap Jimmy Fallon's face for John Oliver's. It looks pretty convincing.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/jdb_deepfake2.jpg" style="max-width:90%;max-height:436px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb deepfake"/&gt;&lt;/p&gt;
&lt;p&gt;DeepFake creates video, which I do not really need,
and to train it you need video of the subject, which I do not have.
I suppose theoretically you could create a 3D model and use that to generate the source video...&lt;/p&gt;
&lt;!--
------------------
------- 2 --------
------------------
--&gt;

&lt;h2&gt;Step Two: The Third Dimension&lt;/h2&gt;
&lt;p&gt;It is limiting if every photo has to have jdb's face looking head-on.
Luckily, there is a very cool &lt;a href="http://cvl-demos.cs.nott.ac.uk/vrn/"&gt;3D face reconstruction neural net&lt;/a&gt;
that works based on a single photo.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/jdb_3d.jpg" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb in 3D"/&gt;&lt;/p&gt;
&lt;p&gt;The results are great and it takes less than a minute to work.
You can even load it into Blender.
&lt;img src="/images/jdb_blender.jpg" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb in blender"/&gt;&lt;/p&gt;
&lt;p&gt;Taking it a step further,
the free &lt;a href="http://www.makehumancommunity.org/"&gt;MakeHuman&lt;/a&gt; software
will create a mesh of a body with various parameters.
&lt;img src="/images/jdb_makehuman.jpg" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb in blender"/&gt;&lt;/p&gt;
&lt;p&gt;This could probably be made to work well but it's way beyond my Blender skills.
&lt;img src="/images/jdb_makehuman_blender.jpg" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb in blender"/&gt;&lt;/p&gt;
&lt;p&gt;There's also an interesting iOS app called &lt;a href="https://www.muglife.com/"&gt;mug life&lt;/a&gt; that will
animate photos based on an inferred 3D mesh.
&lt;img src="/images/jdb_muglife.gif" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="jdb muglife"/&gt;
The results are impressive, if creepy. jdb looks so alive! I don't think you can download the mesh though.&lt;/p&gt;
&lt;h3&gt;Enhance!&lt;/h3&gt;
&lt;p&gt;Sometimes the resulting photoshopped image can be pretty blurry,
partially because the 3D model's texture resolution is not that high.
Luckily there is another deep net to help here, called &lt;a href="[https://github.com/alexjc/neural-enhance]"&gt;neural-enhance&lt;/a&gt;.
It really does enhance a photo by doubling the resolution, which is
pretty slick.
The author includes a docker container, which makes running it very simple.&lt;/p&gt;
&lt;p&gt;The results are very impressive in general,
and it only takes a few minutes even on a CPU.
Since it's trained on real photos, I am guessing it might also remove artifacts and rogue pixels due to photoshopping.&lt;/p&gt;
&lt;div style="display:block;margin:auto;text-align:center"&gt;
&lt;img src="/images/jdb_singing.jpg" style="max-width:42%;display:inline;margin:auto;" alt="jdb singing"/&gt;
&lt;img src="/images/jdb_singing_ne2x.jpg" style="max-width:42%;display:inline;margin:auto;" alt="jdb singing enhanced"/&gt;
&lt;div&gt;From blurry (left) to enhanced (right). The shirt buttons are the most obvious improvement.&lt;/div&gt;
&lt;/div&gt;

&lt;!--
------------------
------- 3 --------
------------------
--&gt;
&lt;h2&gt;Step Three: Captioning&lt;/h2&gt;
&lt;p&gt;Instagram posts have captions, which I assume are important for engagement.
There have been many attempts to caption or describe images using neural nets.
The oldest one I remember is an influential &lt;a href="https://cs.stanford.edu/people/karpathy/deepimagesent/"&gt;Stanford paper from 2015&lt;/a&gt;.
There are a few tools online too.
I first tried Microsoft's &lt;a href="https://captionbot.ai"&gt;captionbot.ai&lt;/a&gt;, assuming it used a neural net.
The results were very meh,
and it turns out it's not a neural net and is &lt;a href="https://www.washingtonpost.com/news/the-intersect/wp/2016/04/13/microsofts-caption-bot-is-the-latest-bot-were-mocking-on-the-Internet/?utm_term=.fc42a6d81206"&gt;famously vague/bad&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Google's &lt;a href="https://cloud.google.com/vision/"&gt;Cloud Vision API&lt;/a&gt;
does much better though it's still not super-engaging content.
For now, computers have not solved the instagram captioning problem.&lt;/p&gt;
&lt;div style="display:block;margin:auto;text-align:center"&gt;
&lt;img src="/images/jdb_beach_walk_google.jpg" style="max-width:90%;max-height:300px;padding:2em 0 2em 0;display:inline;margin:auto;" alt="jdb beach walk"/&gt;
&lt;div style="text-align:center;margin:auto;width:75%"&gt;
&lt;div style="text-align:left;"&gt;&lt;b&gt;Captionbot&lt;/b&gt;: I think it's a person standing on a beach and he seems 😐.&lt;/div&gt;
&lt;div style="text-align:left;"&gt;&lt;b&gt;Google Cloud Vision&lt;/b&gt;: couple looking at each other on beach&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;!--
------------------
------- 4 --------
------------------
--&gt;

&lt;h2&gt;Step Four: Songs&lt;/h2&gt;
&lt;p&gt;jdb is a country music celebrity, so he may need some songs.
Thankfully there's a neural net for everything, including &lt;a href="https://www.mattmoocar.me/blog/RNNCountryLyrics/"&gt;country music lyrics&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;Some example lyrics:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;No one with the danger in the world&lt;br&gt;
I love my black fire as I know&lt;br&gt;
But the short knees just around me&lt;br&gt;
Fun the heart couldnes fall to back&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It's not terrible ("couldnes"?), but it's also pretty dark for instagram...
You can also &lt;a href="http://www.hexahedria.com/2015/08/03/composing-music-with-recurrent-neural-networks/"&gt;generate music using RNNs&lt;/a&gt;
but I did not find an easy way to generate country music.&lt;/p&gt;
&lt;h3&gt;Singing&lt;/h3&gt;
&lt;p&gt;Creating a speaking/singing voice from lyrics was not as easy as I thought it would be.
I tried a few iOS apps, including &lt;a href="https://lyrebird.ai"&gt;LyreBird&lt;/a&gt;,
but got &lt;a href="https://soundcloud.com/user-725262533/jdb-lyrebird-1"&gt;strange results&lt;/a&gt;.
Macs also have the say command (just type &lt;code&gt;say hello&lt;/code&gt; into the terminal),
which works ok.&lt;/p&gt;
&lt;p&gt;I ended up using &lt;a href="https://cloud.google.com/text-to-speech/"&gt;Google Cloud text-to-speech&lt;/a&gt;,
which uses &lt;a href="https://deepmind.com/blog/wavenet-generative-model-raw-audio/"&gt;WaveNet&lt;/a&gt;,
to turn lyrics into speech.
It works via a simple json upload.
Sadly, none of the available voices sounded particularly country.&lt;/p&gt;
&lt;p&gt;To produce actual singing, there are several autotune apps,
e.g., &lt;a href="https://itunes.apple.com/us/app/voloco/id1052970183?mt=8"&gt;Voloco&lt;/a&gt;.
However, the ones I tried sounded pretty autotuned, so perhaps more suitable for another genre.&lt;/p&gt;
&lt;p&gt;I replaced the RNN lyrics with wikipedia-derived specs for
a truck (a product jdb could endorse and a scalable lyric-generation system), added some royalty-free music, and the
&lt;a href="https://soundcloud.com/user-725262533/truck-1"&gt;result is really something&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;The Future&lt;/h2&gt;
&lt;p&gt;One of the most difficult aspects here is finding working neural nets and getting them to run.
Even if the code is on github there are often missing files or onerous installation steps.
Things will be easier when more neural nets get converted to &lt;a href="https://js.tensorflow.org/"&gt;javascript/tensorflow.js&lt;/a&gt;
or appear on colab.&lt;/p&gt;
&lt;p&gt;I don't know how many instagram celebrities are computer-generated today,
though computer-generated celebrities are not a new thing,
&lt;a href="https://www.wired.com/story/computer-generated-celebrities/"&gt;especially in Japan&lt;/a&gt;.
&lt;a href="https://www.instagram.com/lilmiquela/?hl=en"&gt;Lil Miquela&lt;/a&gt; has &amp;gt;1M followers on instagram,
though it's clear she is computer-generated.&lt;/p&gt;
&lt;p&gt;It's pretty obvious there will be a lot of this kind of thing in the future.
We can evolve new celebrities as ecological niches emerge, catering to new audiences.
As people lose interest in one celebrity, we can just create others.
They could even &lt;a href="https://en.wikipedia.org/wiki/Tl%C3%B6n,_Uqbar,_Orbis_Tertius"&gt;inhabit the same world&lt;/a&gt;
and date each other.
Eventually they will outnumber us, then maybe skynet us.&lt;/p&gt;
&lt;p&gt;In the meantime, &lt;a href="https://www.instagram.com/jakedangerback/"&gt;jdb&lt;/a&gt; is available to endorse products of all kinds.&lt;/p&gt;</content><category term="deeplearning"/><category term="deeplearning"/><category term="datascience"/><category term="neuralnet"/></entry><entry><title>The Sequencing Gap</title><link href="/sequencing-gap.html" rel="alternate"/><published>2018-11-11T11:00:00-08:00</published><updated>2018-11-11T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2018-11-11:/sequencing-gap.html</id><summary type="html">&lt;p&gt;Sequencing gap&lt;/p&gt;</summary><content type="html">&lt;p&gt;I took a look at the data in &lt;a href="https://twitter.com/AlbertVilella"&gt;Albert Vilella&lt;/a&gt;'s
very useful &lt;a href="https://docs.google.com/spreadsheets/d/1GMMfhyLK0-q8XkIo3YxlWaZA5vVMuhU1kg41g4xLkXc/edit?hl=en_GB&amp;amp;hl=en_GB#gid=1569422585"&gt;NGS specs spreadsheet&lt;/a&gt;
using Google's slick &lt;a href="https://colab.research.google.com"&gt;colab&lt;/a&gt; notebook.
(If you have yet to try colab it's worth a look.)&lt;/p&gt;
&lt;p&gt;Doing this in colab was a bit trickier than normal, so I include the code here for reference.&lt;/p&gt;
&lt;p&gt;First, I need the gspread lib to parse google sheets data, and the id of the sheet itself.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="sx"&gt;!pip install --upgrade -q gspread&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sheet_id = "1GMMfhyLK0-q8XkIo3YxlWaZA5vVMuhU1kg41g4xLkXc"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then I authorize myself with Google (a bit awkward but it works).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;google.colab&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;
&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;authenticate_user&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;gspread&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;oauth2client.client&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;GoogleCredentials&lt;/span&gt;

&lt;span class="n"&gt;gc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gspread&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GoogleCredentials&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_application_default&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I parse the data into a pandas DataFrame.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;sheet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open_by_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sheet_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;
&lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sheet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;worksheet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"T"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_all_values&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;from_records&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I have to clean up the data a bit so that all the sequencing rates are Gb/day numbers.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;re&lt;/span&gt;
&lt;span class="n"&gt;dfr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iloc&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Rate: (Gb/d) "&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Rate: (Gb/d)"&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Platform"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="s2"&gt;"Rate: (Gb/d)"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;dfr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dfr&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;dfr&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"--"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dfr&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"TBC"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dfr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"-"&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;rg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"(\d+).(\d+)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rg&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;dfr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;span class="n"&gt;dfr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dfr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reset_index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I tacked on some data I think is representative of Sanger throughput, 
if not 100% comparable to the NGS data.&lt;/p&gt;
&lt;p&gt;A large &lt;a href="https://www.thermofisher.com/order/catalog/product/3730XL"&gt;ABI 3730XL&lt;/a&gt; can 
apparently output up to 1-2 Mb of data a day in total (across thousands of samples).
A lower-throughput 
&lt;a href="https://www.thermofisher.com/us/en/home/life-science/sequencing/sanger-sequencing/sanger-sequencing-technology-accessories/seqstudio-genetic-analyzer.html"&gt;ABI SeqStudio&lt;/a&gt;
can output 1-100kb (maybe more).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;dfr_x = pd.concat([dfr, 
                   pd.DataFrame.from_records([{"Platform":"ABI 3730xl", "Rate: (Gb/d)":.001}, 
                                              {"Platform": "ABI SeqStudio", "Rate: (Gb/d)":.0001}])])

dfr_x["Rate: (Mb/d)"] = dfr_x["Rate: (Gb/d)"] * 1000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If I plot the data there's a pretty striking, three-orders-of-magnitude gap from 1Mb-1Gb.
Maybe there's not enough demand for this range, 
but I think it's actually just an artifact of how these technologies evolved,
and especially how quickly Illumina's technology scaled up.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;
&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;fax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stripplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dfr_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Platform"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Rate: (Mb/d)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;fax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xscale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"log"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;fax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xlim&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src="/images/ngs_seq_7_0.png" style="max-height:500px;padding:1 0 1em 0;display:block;margin:auto;" alt="sequencing gap plot"/&gt;&lt;/p&gt;
&lt;p&gt;Getting a single 1kb sequencing reaction done by a service in a day for a couple of dollars is easy,
so the very low throughput end is pretty well catered for.&lt;/p&gt;
&lt;p&gt;However, if you are a small lab or biotech doing any of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;microbial genomics: low or high coverage WGS&lt;/li&gt;
&lt;li&gt;synthetic biology: high coverage plasmid sequencing&lt;/li&gt;
&lt;li&gt;disease surveillance: pathogen detection, assembly&lt;/li&gt;
&lt;li&gt;human genetics: HLA sequencing, immune repertoire sequencing, PGx or other panels&lt;/li&gt;
&lt;li&gt;CRISPR edits: validating your edit, checking for large deletions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;you could probably use a few megabases of sequence now and then without having to multiplex 96X.&lt;/p&gt;
&lt;p&gt;If it's cheap enough, I think this is an interesting market that Nanopore's new 
&lt;a href="https://nanoporetech.com/products/flongle"&gt;Flongle&lt;/a&gt;
can take on, and for now there's no competition at all.&lt;/p&gt;</content><category term="sequencing"/><category term="biotech"/><category term="sequencing"/><category term="dna"/></entry><entry><title>The amyloid hypothesis</title><link href="/amyloid-hypothesis.html" rel="alternate"/><published>2018-07-12T11:00:00-07:00</published><updated>2018-07-12T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2018-07-12:/amyloid-hypothesis.html</id><summary type="html">&lt;p&gt;A review of the amyloid hypothesis in Alzheimer's and some recent drug trials.&lt;/p&gt;</summary><content type="html">&lt;p&gt;There have been a lot of results coming out from Alzheimer's trials recently, and a lot of discussion about the "amyloid hypothesis" and &lt;a href="https://www.forbes.com/sites/arleneweintraub/2018/01/24/latest-alzheimers-flop-raises-doubts-about-amyloid-hypothesis/"&gt;its role in the disease&lt;/a&gt;.
In this post I'll review some of the evidence, and see how it relates to data from recent AD trial results from Merck and Biogen/Eisai.
I mainly reference three good reviews that cover most of the basic facts and arguments around the amyloid hypothesis.
Much of my additional data is from &lt;a href="https://www.alzforum.org"&gt;AlzForum&lt;/a&gt;, a fantastic resource for Alzheimer's news.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.nature.com/articles/nrd3505"&gt;The amyloid cascade hypothesis for Alzheimer’s disease: an appraisal for the development of therapeutics&lt;/a&gt; (2011)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4888851/"&gt;The amyloid hypothesis of Alzheimer's disease at 25 years&lt;/a&gt; (2016)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nature.com/articles/nn.4017"&gt;The case for rejecting the amyloid cascade hypothesis&lt;/a&gt; (2015)&lt;/li&gt;
&lt;/ul&gt;
&lt;!--
## at 25 years

&gt;Several similar studies suggest that Aβ—particularly soluble oligomers of Aβ42 (Shankar et al, 2008)—can trigger AD‐type tau alterations, supporting the sequence that human genetics has indicated.

&gt;Pre‐specified, post hoc analyses of the combined mild subjects of the trials showed a statistically significant ~34% slowing of cognitive decline vs. placebo over 18 months [see tables 3 and 4 in Doody et al, 2014].

&gt;These brains were selected to have similar plaque densities, but the oligomer‐specific ELISA revealed that the non‐demented plaque‐rich subjects had much lower oligomer‐to‐plaque ratios than the mildly demented plaque‐rich patients

&gt;There was no relationship between neocortical plaque burden and the density of limbic neurofibrillary tangles: thus, there was no correlation between neurofibrillary tangles and plaque burden

&gt; the deposition of amyloid-β does not correlate with the presence of neurofibrillary tangles, cell loss or dementia

&gt; in our view it is unlikely that brain resilience and age of onset would always be so
perfectly balanced as to produce no net difference in disease duration.

&gt; once amyloid-β deposition has occurred, the amount of deposition — or
its neuroanatomical location — can be correlated with
neuronal loss, paired helical filaments of tau or dementia

Interesting:
&gt;it is not impossible to imagine that a natural process (such as autoimmunity or exaggerated clearance) could  spontaneously occur in the brain of someone with AD and also remove their plaques.

--&gt;

&lt;h2&gt;The basics&lt;/h2&gt;
&lt;p&gt;A simplified model of the amyloid hypothesis is that the cell-surface protein APP (Amyloid Precursor Protein) gets cleaved by BACE1 and γ-secretase and released as a 42 amino acid peptide, Aβ42; Aβ42 forms oligomers, then extracellular plaques in the brain; these oligomers and/or plaques somehow lead to intracellular Tau tangles which cause neuronal death.&lt;/p&gt;
&lt;p&gt;One big question here is whether it's the plaques or oligomers that are the &lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4888851/"&gt;main trigger&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Several similar studies suggest that Aβ — particularly soluble oligomers of Aβ42 (Shankar et al, 2008) — can trigger AD‐type tau alterations&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This model is nicely summarized by a &lt;a href="https://www.nature.com/articles/nrd.2016.281"&gt;diagram from NRD&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/alz_app.jpg" style="max-width:90%;max-height:350px;padding:2em 0 2em 0;display:block;margin:auto;" alt="amyloid primer"/&gt;&lt;/p&gt;
&lt;!--
There are still questions over whether it's the oligomers or the plaques that are damaging,
and how Tau tangles cause neuronal death.
--&gt;

&lt;p&gt;As the diagram shows, the obvious drug targets are γ-secretase and BACE1 (to stop Aβ42 production),
Aβ42 monomers/oligomers/plaques (to reduce plaque formation),
Tau (to prevent Tau tangles).&lt;/p&gt;
&lt;p&gt;There have been drugs targeting all of these processes. None have been successful:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;gamma-secretase&lt;/strong&gt;: semagacestat (Lilly), a gamma-secretase inhibitor, &lt;a href="https://www.alzforum.org/therapeutics/semagacestat"&gt;failed Phase III in 2010&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;BACE1&lt;/strong&gt;: &lt;a href="https://www.alzforum.org/therapeutics/azd3293"&gt;lanabecestat&lt;/a&gt; (Lilly) failed Phase III in 2018; &lt;a href="https://www.nejm.org/doi/10.1056/NEJMoa1706441"&gt;verubecestat&lt;/a&gt; (Merck) failed Phase III in 2017 and 2018&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tau&lt;/strong&gt;: LMTM (TauRX) &lt;a href="https://www.alzforum.org/therapeutics/lmtm"&gt;failed Phase III in 2016&lt;/a&gt;; &lt;a href="https://www.alzforum.org/therapeutics/c2n-8e12"&gt;AbbVie's anti-Tau antibody is still in Phase II&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Aβ42&lt;/strong&gt;: &lt;a href="https://www.alzforum.org/therapeutics/solanezumab"&gt;solanezumab&lt;/a&gt; (Lilly) failed Phase III in 2016 and 2018; &lt;a href="https://www.alzforum.org/therapeutics/bapineuzumab"&gt;bapineuzumab&lt;/a&gt; (Pfizer) failed Phase III in 2012; &lt;a href="https://www.alzforum.org/therapeutics/crenezumab"&gt;crezenumab&lt;/a&gt; (Roche) is still in Phase III; &lt;a href="https://www.alzforum.org/therapeutics/aducanumab"&gt;aducanumab&lt;/a&gt; (Biogen) is still in Phase III.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only approved drugs for Alzheimer's are fairly ineffectual cholinesterase inhibitors (and an accompanying NMDA receptor inhibitor).
These drugs are usually thought of more as symptom relief than treatment.&lt;/p&gt;
&lt;h3&gt;Aβ42 Antibodies&lt;/h3&gt;
&lt;p&gt;Why do drug companies keep making Aβ42 antibodies after so many failures? In fact, there is quite a bit of variability in what these antibodies actually do. Ryan Watts, now CEO of &lt;a href="https://www.denalitherapeutics.com/"&gt;Denali Therapeutics&lt;/a&gt;, gave an interview with &lt;a href="https://www.alzforum.org/news/research-news/qa-ryan-watts-genentech-lead-scientist-api-trial"&gt;AlzForum back in 2012&lt;/a&gt; where he explained the difference between Genentech's crezenumab and other Aβ42 antibodies.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Q: How is crenezumab different from the other Aβ antibodies that are currently in Phase 2 and 3 trials?&lt;/p&gt;
&lt;p&gt;A: We have a manuscript under review that describes its properties. Basically, crenezumab binds to oligomeric and fibrillar forms of Aβ with high affinity, and to monomeric Aβ with lower affinity. By comparison, solanezumab binds monomeric Aβ, and gantenerumab binds aggregated Aβ, as does bapineuzumab. Crenezumab binds all forms of the peptide. Crenezumab is engineered on an IgG4 backbone, which allows it to activate microglia just enough to promote engulfment of Aβ, but not so strongly as to induce inflammatory signaling through the p38 pathway and release of cytokines such as tumor necrosis factor α. Crenezumab is the only IgG4 anti-Aβ antibody in clinical development that I am aware of. We have not seen vasogenic edema in our Phase 1 trials, which was the first main hurdle for us to overcome.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="http://investors.biogen.com/news-releases/news-release-details/biogen-and-neurimmune-announce-option-exercise-alzheimers"&gt;Biogen&lt;/a&gt; describes the MOA of their aducanumab antibody like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Aducanumab is thought to target aggregated forms of beta amyloid including soluble oligomers and insoluble fibrils which can form into amyloid plaque in the brain of Alzheimer’s disease patients.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;Denali Therapeutics&lt;/h4&gt;
&lt;p&gt;As an aside, &lt;a href="https://www.sec.gov/Archives/edgar/data/1714899/000119312517340997/d445892ds1.htm"&gt;Denali&lt;/a&gt; is not working on an Aβ42 inhibitor (perhaps for IP reasons since Ryan Watts was heavily involved in the development of crezenumab). Apart from their novel RIPK1 program, they are still pursuing BACE1 and Tau.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Our lead RIPK1 product candidate, DNL747, is a potent, selective and brain penetrant small molecule inhibitor of RIPK1 for Alzheimer’s disease and ALS. Microglia are the resident immune cells of the brain and play a significant role in neurodegeneration. RIPK1 activation in microglia results in production of a number of pro-inflammatory cytokines that can cause tissue damage.&lt;/p&gt;
&lt;p&gt;Our three antibody programs are against known targets including aSyn, TREM2 and a bi-specific therapeutic agent against both BACE1 and Tau. Our BACE1 and Tau program is an example of combination therapy, which we believe holds significant promise in developing effective therapies in neurodegenerative diseases.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;How does amyloid cause disease?&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://www.nature.com/articles/nrd3505"&gt;By one definition&lt;/a&gt;, the amyloid hypothesis "posits that the deposition of the amyloid-β peptide in the brain is a central event in Alzheimer's disease pathology".
There are several ways that amyloid could cause AD.
This &lt;a href="https://www.nature.com/articles/nrd3505"&gt;diagram from a 2011 NRD review&lt;/a&gt; shows three options:&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/alz1.png" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="amyloid hypothesis"/&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Aβ trigger&lt;/strong&gt;: Aβ triggers the disease once it reaches a threshold, and once it starts, reducing Aβ levels does not help&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Aβ threshold&lt;/strong&gt;: Aβ triggers the disease once it reaches a threshold, but reducing Aβ levels back below the threshold does help&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Aβ driver&lt;/strong&gt;: Aβ causes Alzheimer's, and reducing Aβ levels at any time should ameliorate disease&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Simplifying, if the Aβ trigger model is correct, then we don't expect anti-Aβ42 antibodies to work, except perhaps preventatively.
If the Aβ driver model is correct, then these antibodies should work, at least partially.&lt;/p&gt;
&lt;p&gt;From the same review:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A strong case can be made that the deposition of amyloid-β in the brain parenchyma is crucial for initiating the disease process, but there are no compelling data to support the view that, once initiated, the disease process is continuously driven by or requires amyloid-β deposition.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For this reason, after Aβ42 antibody trials fail, the stock answer from pharma is that they need to begin treatment earlier.
Of course, the earlier you treat, the longer the trial takes,
and the more you need new amyloid detection technologies like Florbetavir/PET to see what's going on.
So it's probably natural that there is a gradual transition to ever earlier interventions and longer trials,
even though this can also seem like excuse-making.&lt;/p&gt;
&lt;!--
Maybe look at this: NPS, Tau
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3575183/
--&gt;

&lt;h2&gt;Evidence for the amyloid hypothesis&lt;/h2&gt;
&lt;p&gt;Despite all the failed drugs and holes in our understanding,
the amyloid hypothesis remains durable due to the &lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4888851/"&gt;weight of evidence&lt;/a&gt; in its corner.&lt;/p&gt;
&lt;h3&gt;APP&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://www.ncbi.nlm.nih.gov/books/NBK1236/"&gt;Mutations in APP&lt;/a&gt; both cause and prevent Alzheimer's.
Half of people with trisomy 21 (or any APP duplication, it seems) develop AD by the time they reach their fifties.&lt;/p&gt;
&lt;p&gt;A &lt;a href="https://www.ncbi.nlm.nih.gov/pubmed/22801501"&gt;protective variant found in APP&lt;/a&gt; also points to a causal relationship, and therapeutic potential (see &lt;a href="https://www.nature.com/articles/nrd4051"&gt;Robert Plenge on allelic series&lt;/a&gt;).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We found a coding mutation (A673T) in the APP gene that protects against Alzheimer's disease and cognitive decline in the elderly without Alzheimer's disease. This substitution is adjacent to the aspartyl protease β-site in APP, and results in an approximately 40% reduction in the formation of amyloidogenic peptides in vitro.
Carriers are about 7.5 times more likely than non-carriers to reach the age of 85 without suffering major cognitive decline&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A &lt;a href="http://science.sciencemag.org/content/358/6359/116/tab-e-letters"&gt;cryoEM structure of Aβ42 fibril from 2017&lt;/a&gt; gives us structural evidence for why APP mutations should be protective or damaging, suggesting that APP's effect on AD is via amyloid/Aβ42.
&lt;img src="/images/alz2.png" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="amyloid"/&gt;&lt;/p&gt;
&lt;!-- cryoEM from https://luysii.wordpress.com/2017/10/26/we-dont-understand-amyloid-very-well/ --&gt;

&lt;h3&gt;APOE&lt;/h3&gt;
&lt;p&gt;The APOE e4 allele strongly predisposes people to Alzheimer's.
It's one of the strongest genetic associations known, besides Mendelian diseases.
In 2018, Yadong Huang's team at the Gladstone Institiute used iPSCs to &lt;a href="https://www.nature.com/articles/s41591-018-0004-z"&gt;investigate the mechanism&lt;/a&gt;.
Confusingly, they found that &lt;a href="https://www.alzforum.org/news/research-news/human-neurons-apoe4-promotes-av-production-and-tau-phosphorylation"&gt;APOE is independently associated with both Aβ42 and Tau&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"ApoE4 in human neurons boosted production of Aβ40 and Aβ42"&lt;/p&gt;
&lt;p&gt;"It does not do that in mouse neurons. Independent of its effect on Aβ, ApoE4 triggered phosphorylation and mislocalization of tau."&lt;/p&gt;
&lt;p&gt;"Based on these data, we should lower ApoE4 to treat AD"&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This research may also help explain why mouse models of Alzheimer's have often been misleading.&lt;/p&gt;
&lt;h3&gt;Other evidence&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Mutations in PSEN1 and PSEN2 (&lt;a href="https://www.alzforum.org/alzpedia/presenilin-1-psen1"&gt;components of gamma-secretase&lt;/a&gt;) cause Alzheimer's.&lt;/li&gt;
&lt;li&gt;Other diseases are caused by mutations in amyloid-forming proteins. For example, there is a mutation that enables &lt;a href="https://luysii.wordpress.com/2018/04/01/a-research-idea-yours-for-the-taking/"&gt;IAPP to form amyloid&lt;/a&gt;, which causes Familial British Dementia.
In ALS, &lt;a href="http://www.pnas.org/content/115/18/4661.long"&gt;the aggregated form of SOD1 may be protective&lt;/a&gt; and the soluble form disease-causing.&lt;blockquote&gt;
&lt;p&gt;The formation of large aggregates is in competition with trimer formation, suggesting that aggregation may be a protective mechanism against formation of toxic oligomeric intermediates.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;!--
SOD1 thing originally from luysii's comment in http://blogs.sciencemag.org/pipeline/archives/2018/05/04/mercks-bace-inhibitor-alzheimers-wipeout
&gt;Have a look at Proc. Natl. Acad. Sci. vol. 115 pp. 4661 – 4665 ’18 for an example of the aggregated form of a protein (SOD1) being protective for a neurologic disease (ALS) and the soluble trimer being the toxic form. Similar considerations may apply to the aBeta42 aggregates of Alzheimer’s disease.
--&gt;

&lt;h2&gt;Criticism of the amyloid hypothesis&lt;/h2&gt;
&lt;p&gt;The main criticism of the antibody hypothesis is that we have been testing anti-amyloid drugs
 — especially antibodies against Aβ42 — for a long time now, and none of them have had any effect on disease progression.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.sciencemag.org/pipeline/archives/2018/06/12/an-alzheimers-statement"&gt;Derek Lowe&lt;/a&gt; (and many of his commenters) has written  especially skeptically on his blog:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Eli Lilly remains committed to plunging through this concrete wall headfirst.
[...]
our gamma-secretase inhibitor completely failed in 2010. Then we took our antibody, solanezumab into Phase III trials that failed in 2012. And found out in 2013 that our beta-secretase inhibitor failed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Morgan Sheng, VP of Neuroscience at Genentech, is much more positive.
In a &lt;a href="https://www.nature.com/articles/nrd.2017.271"&gt;recent interview in NRD&lt;/a&gt; he said:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Let me start by saying that I fully believe in the amyloid hypothesis, and I think it’s going to be vindicated completely within years.
[...]
phase III results from drugs like Eli Lilly’s solanezumab suggest these agents sort of work; they just don’t work very well&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It seems like targeting Tau is an &lt;a href="http://blogs.sciencemag.org/pipeline/archives/2017/05/26/a-movement-towards-tau-in-alzheimers"&gt;acceptable strategy&lt;/a&gt;
to amyloid hypothesis skeptics because it's not targeting Aβ42,
even though it's still part of the standard amyloid hypothesis model.
Drugs that are based on the "amyloid hypothesis" and drugs that work by trying
to reduce amyloid tend to get conflated in a confusing way.&lt;/p&gt;
&lt;h3&gt;Evidence against the amyloid hyothesis&lt;/h3&gt;
&lt;p&gt;Here I am mainly summarizing from a &lt;a href="https://www.nature.com/articles/nn.4017"&gt;2015 review&lt;/a&gt;.
In this review, the author mainly disputes the "linear story" of the amyloid hypothesis
and not the fact that Aβ plays some kind of role in AD.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Many people have plaque but no disease.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The existence of this group of individuals (healthy, but amyloid positive) is a substantial challenge to the amyloid cascade hypothesis. It is clearly possible to have amyloid deposits without dementia; therefore amyloid is not sufficient to cause disease.&lt;/p&gt;
&lt;p&gt;Such individuals are not rare; rather, they account for a quarter to a third of all older individuals with normal or near-normal cognitive function.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Anti-Aβ42 antibodies can reduce plaque without alleviating the disease.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The second test of the amyloid cascade hypothesis has also been done: amyloid has been removed from the brains of individuals with AD and from mice with engineered familial forms of the disease. Here the tests have been less definitive and the evidence is mixed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Other drugs that should work (beta-secretase inhibitors, gamma-secretase inhibitors, BACE1 inhibitors, Tau inhibitors) don't appear to work.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Mutations in the Tau gene can cause dementia without plaques forming, so amyloid is not a necessary step in the process.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We &lt;a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4888851/"&gt;do not understand AD pathology well&lt;/a&gt;. For example, what are the toxic species of Aβ and Tau? What is the connection between Aβ and tangle pathology? Do Tau tangles spread between neurons like prions?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There are other possible causes of AD. For example, certain infections could be causative.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Infection&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://www.alzforum.org/news/research-news/herpes-triggers-amyloid-could-virus-fuel-alzheimers"&gt;Recent work&lt;/a&gt;
showing an association between herpes virus and Alzheimer's could be thought of as supporting or disputing the amyloid hypothesis.
In this model, the virus "seeds" amyloid plaque formation, which then sequesters the virus. The idea that amyloid plaques are &lt;a href="https://www.ncbi.nlm.nih.gov/pubmed/29504537"&gt;protective&lt;/a&gt; is not entirely new, beginning with the &lt;a href="https://www.ncbi.nlm.nih.gov/pubmed/12470802"&gt;"bioflocculant hypothesis"&lt;/a&gt; for Aβ, published in 2002.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;[Robinson and Bishop] posited that Aβ’s aggregative 332 properties could make it ideal for surrounding and sequestering pathogenic agents in the brain&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If herpes causes AD, then we'd expect to see evidence in epidemiological datasets.
Both &lt;a href="https://www.alzforum.org/news/research-news/herpes-triggers-amyloid-could-virus-fuel-alzheimers"&gt;herpes infection&lt;/a&gt; and &lt;a href="https://alzres.biomedcentral.com/articles/10.1186/s13195-017-0282-6"&gt;periodontitis&lt;/a&gt; appear to be associated with AD risk.
Further, &lt;a href="https://content.iospress.com/articles/journal-of-alzheimers-disease/jad180266"&gt;antiherpetic medications&lt;/a&gt; appear to reduce the risk of AD.
A lot more could be done here with a large database of phenotypic information, like UK biobank...&lt;/p&gt;
&lt;p&gt;Relatedly, a Bay Area company, &lt;a href="https://www.cortexyme.com"&gt;Cortexyme&lt;/a&gt;, recently raised $76M to pursue an AD drug against a bacterial protease found in plaques.&lt;/p&gt;
&lt;!--
&lt;img src="/images/alz_cortexyme.png" style="max-width:90%;max-height:400px;padding:2em 0 2em 0;display:block;margin:auto;" alt="Cortexyme"/&gt;
--&gt;

&lt;h2&gt;Recent news&lt;/h2&gt;
&lt;p&gt;So what about the recent trial results?
There were two major trials with new results this year:
Merck's BACE1 inhibitor, verubecestat, and Biogen/Eisai's anti-Aβ42 antibody, BAN2401.
Meanwhile the &lt;a href="https://www.bloomberg.com/news/articles/2018-02-14/biogen-drops-after-alzheimer-s-drug-trial-change-raises-concerns"&gt;trial design for Biogen's aducanumab is being tweaked&lt;/a&gt;
— not a good sign generally — and there should be new data on that later this year.&lt;/p&gt;
&lt;!--
random paper: Amyloid-β in Alzheimer Disease: The Null versus the Alternate Hypotheses
http://jpet.aspetjournals.org/content/321/3/823.full
--&gt;

&lt;h3&gt;Verubecestat&lt;/h3&gt;
&lt;p&gt;After &lt;a href="http://blogs.sciencemag.org/pipeline/archives/2017/02/15/guess-how-this-latest-alzheimers-trial-came-out"&gt;failing a Phase III in 2017&lt;/a&gt;
verubecestart had more bad news &lt;a href="https://www.nejm.org/doi/10.1056/NEJMoa1706441"&gt;last month&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Treatment with verubecestat reduced the concentration of Aβ-40 and Aβ-42 in cerebrospinal fluid by 63 to 81%, which confirms that the drug had the intended action of reducing Aβ production. In the PET amyloid substudy, treatment with verubecestat reduced total brain amyloid load by a modest amount; the mean standardized uptake value ratio was reduced from 0.87 at baseline to 0.83 at week 78 in the 40-mg group. These results suggest that lowering Aβ in the cerebrospinal fluid is associated with some reduction in brain amyloid.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Notably, despite the drug working as intended, the reduction in brain amyloid was minimal.
Hence, some people claim that amyloid &lt;em&gt;removal&lt;/em&gt; has &lt;a href="https://twitter.com/gcbioinv/status/992342505382391808"&gt;not been tested&lt;/a&gt;:
&lt;img src="/images/alz_gc.png" style="max-width:90%;max-height:300px;padding:2em 0 2em 0;display:block;margin:auto;" alt="gc tweet"/&gt;&lt;/p&gt;
&lt;!--
&gt; In the PET amyloid substudy, no change from baseline in the brain amyloid load was observed in the placebo group at week 78; in contrast, both verubecestat groups showed a reduction from baseline (Table 2, and Fig. S5 in the Supplementary Appendix). In the 40-mg group, the mean (±SD) standardized uptake value ratio changed from 0.87±0.11 at baseline to 0.83±0.10 at week 78.
--&gt;

&lt;h3&gt;Merck's Aβ42 antibody, BAN2401&lt;/h3&gt;
&lt;p&gt;New &lt;a href="https://www.eisai.com/news/2018/news201858.html"&gt;Phase II results&lt;/a&gt;
for Merck's soluble protofibril antibody,
&lt;a href="https://www.alzforum.org/therapeutics/ban2401"&gt;BAN2401&lt;/a&gt;, were just released in July 2018.
The results were hotly disputed because while the Bayesian analysis failed to show an effect,
an alternative p-value based analysis (ANCOVA) showed positive results.
I don't know exactly what the differences between the analyses were,
but generally you would hope for agreement between the two,
unless the effect was pretty marginal or just not real.
The data pulled out in the tweet below shows how strange this situation is.
&lt;img src="/images/alz_andy_biotech.png" style="max-width:90%;max-height:500px;padding:2em 0 2em 0;display:block;margin:auto;" alt="Merck tweet"/&gt;&lt;/p&gt;
&lt;p&gt;Given the ambivalent nature of the result,
naturally some saw it as positive news, since there was at least &lt;em&gt;something&lt;/em&gt;,
while skeptics saw the opposite.&lt;/p&gt;
&lt;!--
(http://blogs.sciencemag.org/pipeline/archives/2018/07/06/biogen-and-eisai-tease-an-alzheimers-result).
--&gt;

&lt;h3&gt;Aducanumab&lt;/h3&gt;
&lt;p&gt;Aducanumab often seems like the most promising anti-Aβ antibody,
and maybe the last chance for anti-Aβ antibodies to prove themselves.
Back in 2015, Aducanumab showed some &lt;a href="https://www.nature.com/articles/nrd.2016.281"&gt;promising Phase Ib results&lt;/a&gt;.
(&lt;a href="http://blog.booleanbiotech.com/biib037_analyzing_biogens_alzheimers_drug_data.html"&gt;I even wrote about it&lt;/a&gt;).&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“They’re the most striking data we have seen with anything, period,” says [an AD trialist]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;However, since then the many related trial failures,
plus Biogen changing the trial design due to &lt;a href="https://www.fiercebiotech.com/biotech/biogen-tweaks-alzheimer-s-phase-3-sparking-stock-slide"&gt;"variability"&lt;/a&gt;,
have left many people pessimistic.
Perhaps BAN2401's recent results, however unsatisfying, show that an Aβ inhibitor is not just doomed to show no effect.&lt;/p&gt;
&lt;!--
FIXFIX sola had mild effect too

### BAN2401
- https://www.bioarctic.se/en/alzheimers-disease-2541/
- https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4822297/
&gt;CSF concentration 24 h after a single dose was 0.04 % of its serum concentration and after monthly multiple doses 0.04 - 0.08 %, but was somewhat higher, 0.13 % at 24 h post dose at steady state after biweekly dosing.
--&gt;

&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;There doesn't actually seem to be much controversy about whether amyloid has a role in Alzheimer's;
the genetic evidence is especially hard to dispute.
I think the disagreement is more whether reducing Aβ plaques (or oligomers) can treat or prevent Alzheimer's.
If the plaque is protective, then it's possible that reducing plaque may even worsen the disease.&lt;/p&gt;
&lt;!--
There's also the question of whether Tau tangles can be triggered by other processes besides plaques.
The answer is probably yes, but these cases are not Alzheimer's!
--&gt;

&lt;p&gt;There are also still plenty of unanswered disease mechanism questions,
like whether it's oligomers or plaques that are causative,
how Tau tangles cause neuronal death, and how tangles spread from neuron to neuron.
Also, a &lt;a href="https://www.sciencedaily.com/releases/2018/06/180628120028.htm"&gt;2018 paper&lt;/a&gt; suggests that Tau's function is the opposite of what we thought: instead of stabilizing microtubules, it keeps them dynamic.&lt;/p&gt;
&lt;p&gt;One obvious question is why are there not more Tau-based drugs?
Tau pathology is not a new idea and Tau's causal relationship with dementia is one of the least controversial parts of the AD story.
In fact, there are now at least &lt;a href="https://www.nature.com/articles/nrd.2016.176"&gt;five Phase I trials underway&lt;/a&gt;,
so these drugs might just be lagging behind Aβ42 antibodies by a few years.
Certainly, Tau tangles being intracellular and in the brain makes drug development &lt;a href="(https://www.nature.com/articles/nrd.2016.176)"&gt;more complicated&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;"Anti-tau antibodies don’t enter neurons and they don’t bind intracellular tau. We’ve invested a lot of careful rigorous work to try and understand this and I hope that the field will agree that we can put to rest that question"&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;(Crossing the blood-brain barrier is a problem for almost all AD drugs and especially antibodies — an interesting rule of thumb is that about &lt;a href="https://www.nature.com/articles/nrd.2016.281"&gt;0.1% of antibody gets into the brain&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;Despite all the failures, I think the story is coming together and I'm pretty optimistic.
We haven't actually tried that many ways of attacking the disease.
I think that reducing plaque and/or oligomers very early could still work
— mainly because we have seen the "drug" APP A673T working —
meanwhile, reducing Tau tangles is arguably the most promising avenue of intervention,
and it is yet to be properly tested.&lt;/p&gt;</content><category term="biotech"/><category term="biotech"/><category term="alzheimers"/><category term="antibody"/></entry><entry><title>DNA alignment with Python, Nim and JavaScript</title><link href="/dna-alignment-with-python-nim-and-javascript.html" rel="alternate"/><published>2017-10-17T11:00:00-07:00</published><updated>2017-10-17T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2017-10-17:/dna-alignment-with-python-nim-and-javascript.html</id><summary type="html">&lt;p&gt;Implementing Needleman-Wunsch a few different ways in Python, Nim, and JavaScript.&lt;/p&gt;</summary><content type="html">&lt;p&gt;This small project started when I was looking for an implementation of &lt;a href="https://en.wikipedia.org/wiki/Needleman%E2%80%93Wunsch_algorithm"&gt;Needleman-Wunsch&lt;/a&gt; (pairwise global DNA alignment) in javascript. 
I just wanted to align two sequences on a website and in a google sheet (using &lt;a href="https://developers.google.com/apps-script/"&gt;Google Apps Script&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;I looked around for a simple javascript implementation (preferably one self-contained javascript file) but I was surprised that I couldn't find one. 
Needleman-Wunsch is a pretty simple algorithm so I decided to implement it. 
I did get a little bit side-tracked...&lt;/p&gt;
&lt;p&gt;The first step was to find someone else's implementation to copy, so I started with some &lt;a href="https://bitbucket.org/brentp/biostuff/src/282b504ac9020fe1449e23f800b20b5bd7d12061/nwalign/?at=default"&gt;numpy code&lt;/a&gt; from &lt;a href="https://twitter.com/brent_p"&gt;@brent_p&lt;/a&gt;. Based on his other work, I think it's a safe assumption it's implemented correctly.
(There is also a complete Cython version in this repo, which implements gap_extend and other parameters, and is obviously much faster. I really just need a very basic alignment so the simpler numpy version is fine for me).&lt;/p&gt;
&lt;h3&gt;numpy and friends&lt;/h3&gt;
&lt;p&gt;There are lots of ways to tweak the numpy implementation of Needleman-Wunsch to try to make it faster. 
Here are the things I tried:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;orig&lt;/strong&gt;: the original numpy implementation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;orig3&lt;/strong&gt;: the original numpy implementation run with python 3.&lt;br&gt;
   This is just to test how much faster or slower Python 3.6 is than 2.7.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;numpy&lt;/strong&gt;: my numpy implementation.&lt;br&gt;
   This is like the original numpy code, but modified a bit to make it more like my code.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;numba&lt;/strong&gt;: my numpy implementation, but with numba applied.&lt;br&gt;
&lt;a href="https://numba.pydata.org/"&gt;Numba&lt;/a&gt; is a pretty amazing JIT compiler you can turn on by adding one line of code. 
   It comes with anaconda, and it's always worth trying just in case.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;torch&lt;/strong&gt;: my numpy implementation, but with numpy replaced with PyTorch.&lt;br&gt;
&lt;a href="http://pytorch.org/"&gt;PyTorch&lt;/a&gt; seems like a friendly alternative to TensorFlow, especially with its numpy-like syntax. 
   Without explicitly applying &lt;code&gt;.cuda()&lt;/code&gt; to my arrays it just uses the CPU, so it should not be too different to regular numpy.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;torchcuda&lt;/strong&gt;: my numpy implementation, but with numpy replaced with PyTorch, and &lt;code&gt;.cuda()&lt;/code&gt; applied to each array.&lt;br&gt;
   The same as &lt;strong&gt;torch&lt;/strong&gt; except using the GPU.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;cupy&lt;/strong&gt;: my numpy implementation, but with numpy replaced with CuPy.&lt;br&gt;
&lt;a href="https://github.com/cupy/cupy"&gt;CuPy&lt;/a&gt; is a drop-in replacement for numpy and, like PyTorch, only requires changing a couple of lines.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Nim&lt;/h3&gt;
&lt;p&gt;Nim is an interesting language that can compile to C (&lt;strong&gt;nimc&lt;/strong&gt;) or javascript (&lt;strong&gt;nimjs&lt;/strong&gt;).
I thought this was a pretty good use-case for nim since I need javascript but writing scientific code in javascript is not fun.
I started with a numpy-like library called &lt;a href="https://github.com/mratsim/Arraymancer"&gt;arraymancer&lt;/a&gt;,
which worked well, but since it relies on BLAS it would not compile to javascript (I could have checked that earlier...)
Luckily, changing the code to simple for loops was pretty easy.
Nim's syntax is a lot like Python, with some unnecessary differences like using &lt;code&gt;echo&lt;/code&gt; instead of &lt;code&gt;print&lt;/code&gt;.
As someone used to Python, I didn't find it to be as friendly as I expected.
The dream of Python-with-static-types is still a dream...&lt;/p&gt;
&lt;h3&gt;Javascript&lt;/h3&gt;
&lt;p&gt;Finally, I just programmed the alignment in javascript (&lt;strong&gt;js&lt;/strong&gt;). 
All of the implementations are almost line-for-line identical, so this did not take long.&lt;/p&gt;
&lt;h2&gt;Speed comparison&lt;/h2&gt;
&lt;p&gt;I ran all the above implementations on some random DNA of various lengths and the results are plotted below.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;
&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'orig'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;8.50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;18.96&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;33.45&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;52.70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;76.44&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;209.90&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'orig3'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2.62&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;10.34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;22.68&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;40.22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;62.03&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;90.15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;248.93&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'numpy'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;3.41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;6.27&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;10.60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;16.11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;22.87&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;67.45&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'numba'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;5.54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;7.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;9.28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;13.08&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;17.40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;22.21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;56.69&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'torch'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.67&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;3.92&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;7.61&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;12.86&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;19.55&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;27.48&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;82.90&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'torchcuda'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;8.54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;22.47&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;46.26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;80.12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;119.92&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;169.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;467.04&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'cupy'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;35.71&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;138.86&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;951.97&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1713.57&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;2660.11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;3798.51&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'nimc'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.016&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.041&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.08&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.85&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'nimjs'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.48&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.53&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;4.06&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; 
        &lt;span class="s1"&gt;'js'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.09&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.82&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;1.64&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;vfast_ones&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"nimjs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"nimc"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;fast_ones&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"torch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"numpy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"numba"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;vfast_ones&lt;/span&gt;
&lt;span class="n"&gt;ok_ones&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"torchcuda"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"orig3"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"orig"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;fast_ones&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div&gt;
&lt;style&gt;
    .dataframe thead tr:only-child th {
        text-align: right;
    }

    .dataframe thead th {
        text-align: left;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }
&lt;/style&gt;
&lt;table border="1" class="dataframe"&gt;
  &lt;thead&gt;
    &lt;tr style="text-align: right;"&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;cupy&lt;/th&gt;
      &lt;th&gt;js&lt;/th&gt;
      &lt;th&gt;nimc&lt;/th&gt;
      &lt;th&gt;nimjs&lt;/th&gt;
      &lt;th&gt;numba&lt;/th&gt;
      &lt;th&gt;numpy&lt;/th&gt;
      &lt;th&gt;orig&lt;/th&gt;
      &lt;th&gt;orig3&lt;/th&gt;
      &lt;th&gt;torch&lt;/th&gt;
      &lt;th&gt;torchcuda&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;500&lt;/th&gt;
      &lt;td&gt;35.71&lt;/td&gt;
      &lt;td&gt;0.09&lt;/td&gt;
      &lt;td&gt;0.01&lt;/td&gt;
      &lt;td&gt;0.13&lt;/td&gt;
      &lt;td&gt;5.54&lt;/td&gt;
      &lt;td&gt;1.54&lt;/td&gt;
      &lt;td&gt;2.23&lt;/td&gt;
      &lt;td&gt;2.62&lt;/td&gt;
      &lt;td&gt;1.67&lt;/td&gt;
      &lt;td&gt;8.54&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1000&lt;/th&gt;
      &lt;td&gt;138.86&lt;/td&gt;
      &lt;td&gt;0.13&lt;/td&gt;
      &lt;td&gt;0.04&lt;/td&gt;
      &lt;td&gt;0.28&lt;/td&gt;
      &lt;td&gt;7.05&lt;/td&gt;
      &lt;td&gt;3.41&lt;/td&gt;
      &lt;td&gt;8.50&lt;/td&gt;
      &lt;td&gt;10.34&lt;/td&gt;
      &lt;td&gt;3.92&lt;/td&gt;
      &lt;td&gt;22.47&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1500&lt;/th&gt;
      &lt;td&gt;951.97&lt;/td&gt;
      &lt;td&gt;0.20&lt;/td&gt;
      &lt;td&gt;0.08&lt;/td&gt;
      &lt;td&gt;0.48&lt;/td&gt;
      &lt;td&gt;9.28&lt;/td&gt;
      &lt;td&gt;6.27&lt;/td&gt;
      &lt;td&gt;18.96&lt;/td&gt;
      &lt;td&gt;22.68&lt;/td&gt;
      &lt;td&gt;7.61&lt;/td&gt;
      &lt;td&gt;46.26&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2000&lt;/th&gt;
      &lt;td&gt;1713.57&lt;/td&gt;
      &lt;td&gt;0.34&lt;/td&gt;
      &lt;td&gt;0.13&lt;/td&gt;
      &lt;td&gt;0.75&lt;/td&gt;
      &lt;td&gt;13.08&lt;/td&gt;
      &lt;td&gt;10.60&lt;/td&gt;
      &lt;td&gt;33.45&lt;/td&gt;
      &lt;td&gt;40.22&lt;/td&gt;
      &lt;td&gt;12.86&lt;/td&gt;
      &lt;td&gt;80.12&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2500&lt;/th&gt;
      &lt;td&gt;2660.11&lt;/td&gt;
      &lt;td&gt;0.41&lt;/td&gt;
      &lt;td&gt;0.20&lt;/td&gt;
      &lt;td&gt;1.12&lt;/td&gt;
      &lt;td&gt;17.49&lt;/td&gt;
      &lt;td&gt;16.11&lt;/td&gt;
      &lt;td&gt;52.70&lt;/td&gt;
      &lt;td&gt;62.03&lt;/td&gt;
      &lt;td&gt;19.55&lt;/td&gt;
      &lt;td&gt;119.92&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3000&lt;/th&gt;
      &lt;td&gt;3798.51&lt;/td&gt;
      &lt;td&gt;0.82&lt;/td&gt;
      &lt;td&gt;0.31&lt;/td&gt;
      &lt;td&gt;1.53&lt;/td&gt;
      &lt;td&gt;22.21&lt;/td&gt;
      &lt;td&gt;22.87&lt;/td&gt;
      &lt;td&gt;76.44&lt;/td&gt;
      &lt;td&gt;90.15&lt;/td&gt;
      &lt;td&gt;27.48&lt;/td&gt;
      &lt;td&gt;169.95&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;5000&lt;/th&gt;
      &lt;td&gt;NaN&lt;/td&gt;
      &lt;td&gt;1.64&lt;/td&gt;
      &lt;td&gt;0.85&lt;/td&gt;
      &lt;td&gt;4.06&lt;/td&gt;
      &lt;td&gt;56.69&lt;/td&gt;
      &lt;td&gt;67.45&lt;/td&gt;
      &lt;td&gt;209.90&lt;/td&gt;
      &lt;td&gt;248.93&lt;/td&gt;
      &lt;td&gt;82.90&lt;/td&gt;
      &lt;td&gt;467.04&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;I'll skip &lt;strong&gt;cupy&lt;/strong&gt; since it's much slower than everything else and throws the plots off. 
That doesn't imply anything negative about &lt;strong&gt;cupy&lt;/strong&gt; and I'd use it again. It's extremely easy to replace &lt;strong&gt;numpy&lt;/strong&gt; with &lt;strong&gt;cupy&lt;/strong&gt;, 
and for properly vectorized code I'm sure it's much faster than &lt;strong&gt;numpy&lt;/strong&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fast: everything except cupy"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ok_ones&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="plot_fast" src="/images/alignment_plot_fast.png"&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"faster: numpy vs C vs js"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;fast_ones&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="plot_faster" src="/images/alignment_plot_faster.png"&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"fastest: C vs js"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;vfast_ones&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="plot_fastest" src="/images/alignment_plot_fastest.png"&gt;&lt;/p&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;I learned some interesting things here... &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;numba is good. It didn't speed this code up very much, but it was a bit faster than numpy for large alignments and didn't cost anything. I expected this to be the fastest Python-based code because there are several Python for loops (i.e., unvectorized code), which is where numba can help a lot. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I'm not sure why my numpy is faster than the original numpy since my changes were minimal. 
The original version is not coded for speed anyway.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;GPUs don't help unless your code is written for GPUs. 
That basically means one repetitive task handed off to the GPU along with the data (no back-and-forth). 
There are ways to implement Needleman-Wunsch in a GPU-friendly way, but it complicates the code a lot. 
On the one hand this is a very obvious result to anyone who has used GPUs for computation — 
on the other hand, maybe a really smart compiler could use the CPU where appropriate and GPU where appropriate...&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Nim is a pretty interesting language. 
I have seen it described as either "an easier C" or a "statically typed Python". 
To me it's definitely more like the former. 
It's not all that friendly compared to Python, but I think I'd try it again as a C/Cython replacement. 
Don't forget to compile with &lt;code&gt;-d:release&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Javascript is fast! If nim is not compiled with &lt;code&gt;-d:release&lt;/code&gt; it's even faster than nim's C code.
Sadly, Google Apps Scripts' javascript is &lt;em&gt;extremely&lt;/em&gt; slow for some reason. 
That was an unfortunate surprise, especially since it times out after about five minutes, so long alignments just fail! 
I can't explain why it's so slow...&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Finally, just to note that this implementation is good enough for my purposes, 
but I haven't really spent any time making sure it works in all situations
(apart from affirming that its output is the same as the original numpy code), 
so I wouldn't trust it too much. 
The code is available in this &lt;a href="https://github.com/hgbrian/nw_align"&gt;repo&lt;/a&gt;.&lt;/p&gt;</content><category term="genomics"/><category term="bioinformatics"/><category term="genomics"/><category term="programming"/></entry><entry><title>Normal-looking distributions and maximum entropy</title><link href="/normal-and-maximum-entropy-distributions.html" rel="alternate"/><published>2017-09-22T11:00:00-07:00</published><updated>2017-09-11T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2017-09-22:/normal-and-maximum-entropy-distributions.html</id><summary type="html">&lt;p&gt;Deriving the normal distribution and others using maximum entropy.&lt;/p&gt;</summary><content type="html">&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scipy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rc&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;

&lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'animation'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'html5'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ggplot'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;
&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'retina'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Like many scientists, I've always been confused by and uncomfortable with the menagerie of available statistical tests, 
how they relate, and when to use them ("use a Chi-square test, unless n&amp;lt;5...").
It's hard to recover the logic underlying diagrams like the one below.
Many of these tests rely on the data "being normal", but why? 
And how normal do they have to be?&lt;/p&gt;
&lt;p&gt;&lt;img alt="statistical tests flowchart" src="/images/maxent_statistical_tests.png"&gt;&lt;/p&gt;
&lt;h1&gt;Normal-looking distributions&lt;/h1&gt;
&lt;p&gt;As we learn, the normal — or Gaussian —
results from the &lt;a href="http://mathworld.wolfram.com/CentralLimitTheorem.html"&gt;central limit theorem&lt;/a&gt;, 
when you add together random samples from the same distribution. 
There are some conditions, like the samples must be independent and the distribution must have finite variance. &lt;/p&gt;
&lt;p&gt;If we know the underlying process producing the samples meets these conditions, 
then we can use the normal distribution with confidence. 
We also learn that even if the above conditions are not met, 
it's probably ok to just use the normal anyway 
(e.g., multipying values instead of adding, samples not from the same distribution), 
or we can apply a transformation to make the distribution "look normal". 
Then once we have a normal-looking distribution, we can use a standard $t$-test, etc. 
To many of us, this is not a hugely satisfying way to apply statistics, 
and it definitely does not feel very scientific.&lt;/p&gt;
&lt;p&gt;Additionally, the normal doesn't seem particularly differentiated from other distributions. 
The binomial, Poisson, normal and t-distributions all look very similar... 
In fact, they can look very very similar, as we can see below. 
(Of course, the first three are members of the &lt;a href="https://en.wikipedia.org/wiki/Exponential_family"&gt;exponential family&lt;/a&gt;, 
so they are not unrelated, but I'll leave that aside.)&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"normal"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;'r-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Poisson"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;poisson&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pmf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;'r-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"binomial"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;binom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pmf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;'r-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"t (df=10)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;'r-'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/maxent_four_dists.png"&gt;&lt;/p&gt;
&lt;p&gt;It turns out that these distributions are indeed all closely related, 
and you can derive them and understand how they are related
 using relatively simple (high school-ish level) maths. 
 The trick is that you have to use the principle of "maximum entropy".&lt;/p&gt;
&lt;h2&gt;What is entropy?&lt;/h2&gt;
&lt;p&gt;I won't attempt to define entropy rigorously, 
since I am not a statistician and definitions are fiddly things,
but I think it suffices to think of a maximum entropy distribution as the smoothest, 
most even distribution that still fits with some constraints. 
In other words, the distribution should not prefer any value in particular unless 
forced to do so to meet its constraints.&lt;/p&gt;
&lt;p&gt;In the simplest example, the maximum entropy distribution bounded by two finite values 
is just a flat (uniform) distribution (the "&lt;a href="https://en.wikipedia.org/wiki/Principle_of_indifference"&gt;principle of indifference&lt;/a&gt;").&lt;/p&gt;
&lt;p&gt;You can calculate the entropy of a distribution using 
$H(X) = -\sum_{k\geq1}p_k log(p_k)$; or for continuous distributions: 
$H(X) = -\int_{-\infty}^{\infty}p(x) \log p(x)dx$. 
The concept of entropy is fundamental across several fields including information theory
and statistical mechanics, so these formulas may look familiar.&lt;/p&gt;
&lt;p&gt;Because we can measure the entropy of any distribution, 
we can define some constraints (e.g., a distribution has bounds 0 to 1, the mean is $\mu$, etc), 
and derive the maximum entropy distribution given those constraints, 
using differentiation to find the maximum and Lagrange multipliers to enforce the constraints.&lt;/p&gt;
&lt;p&gt;For a proper description and derivation, see &lt;a href="https://smile.amazon.com/Data-Analysis-Bayesian-Devinderjit-Sivia/dp/0198568320/ref=sr_1_1"&gt;Data Analysis, A Bayesian Tutorial by Sivia &amp;amp; Skilling (Section 5.3)&lt;/a&gt;. That is where I first learned about this, and it is still the best treatment I have seen.
&lt;a href="https://smile.amazon.com/Statistical-Rethinking-Bayesian-Examples-Chapman/dp/1482253445/ref=sr_1_1"&gt;Statistical Rethinking by McElreath (Section 9.1)&lt;/a&gt; also discusses this topic; &lt;a href="http://www.inference.org.uk/itprnn/book.html"&gt;Information Theory by MacKay (Section 22.13)&lt;/a&gt; (a free book) discusses it in passing, and I'm sure a lot of other books do too. &lt;/p&gt;
&lt;p&gt;I will just give the gist, but hopefully it's near enough correct.&lt;/p&gt;
&lt;h2&gt;Deriving the normal distribution&lt;/h2&gt;
&lt;p&gt;To derive the normal distribution, we start with this formula (Sivia &amp;amp; Skilling, Section 5.3.2):&lt;/p&gt;
&lt;p&gt;&lt;img alt="Sivia &amp;amp; Skilling, 5.3.2" src="/images/maxent_normal.png"&gt;&lt;/p&gt;
&lt;p&gt;It looks complicated, but it's really just the entropy formula with two Lagrange multipliers (and three constraints):
the sum of $p$'s is $1$ (because it's a probability distribution), the mean is $\mu$, and the variance is $\sigma^2$.
If we take the derivative to find the maximum entropy — by setting ${\partial}Q/{\partial}p = 0$ — out pops the normal distribution in just a couple of steps (see the book for details!)&lt;/p&gt;
&lt;p&gt;So, the normal distribution is the "fewest-assumptions" distribution there is if you have only a mean and a variance, 
and that is partially why it's so broadly applicable!
That also explains (I think) why it's generally ok to use the normal distribution even when its conditions (i.i.d. samples, finite variance, etc) have not been met.
It's about as general a distribution as you can get.&lt;/p&gt;
&lt;h2&gt;Other distributions&lt;/h2&gt;
&lt;p&gt;Sivia derives a few other fundamental distributions using maximum entropy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Exponential:&lt;/strong&gt; this is derived identically to the normal, but with no variance constraint (just the mean).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Binomial:&lt;/strong&gt; this is derived using similar methods, but starting with the formula for ${n \choose k}$.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Poisson:&lt;/strong&gt; this is derived similarly to the binomial, though it also requires a Taylor expansion.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sivia also draws some interesting connections between the distributions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The binomial can be approximated by the Poisson, for large $N$ and small $p$.&lt;/li&gt;
&lt;li&gt;The Poisson can be approximated by the normal, for large $\mu$, using Stirling's approximation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I think this sums up pretty nicely how these common distributions are related and why they all look so similar.&lt;/p&gt;
&lt;h1&gt;Which distributions correspond to which constraints?&lt;/h1&gt;
&lt;p&gt;There is a nice &lt;a href="https://en.wikipedia.org/wiki/Maximum_entropy_probability_distribution"&gt;wikipedia article on maximum entropy probability distributions&lt;/a&gt;, with a table of twenty or so distributions and the associated constraints (below are just a subset):&lt;/p&gt;
&lt;p&gt;&lt;img alt="maximum entropy distributions" src="/images/maximum_entropy_distributions.png"&gt;&lt;/p&gt;
&lt;p&gt;Interestingly, sometimes apparently simple constraints (e.g., bounds are $a$ to $b$, mean is $\mu$) can produce &lt;a href="https://mathoverflow.net/questions/116667/whats-the-maximum-entropy-probability-distribution-given-bounds-a-b-and-mean"&gt;complicated answers&lt;/a&gt;.&lt;/p&gt;
&lt;h1&gt;The fat-tailed $t$-distribution&lt;/h1&gt;
&lt;p&gt;The $t$-distribution, of $t$-test fame, is not covered in the above section of Sivia &amp;amp; Skilling, though it can be derived using &lt;a href="https://en.wikipedia.org/wiki/Student%27s_t-distribution#As_a_maximum_entropy_distribution"&gt;maximum entropy too&lt;/a&gt;. 
One description of the $t$-distribution that shows its connection to the normal is 
that it represents samples from a normal distribution of uncertain variance 
(hence its common description as "like the normal distribution with fatter tails"). 
As the number of degrees of freedom grows, the $t$-distribution approaches the normal distribution. 
At $\geq10$ degrees of freedom, the $t$ and normal distributions are difficult to distinguish 
(see my plots at the start of this post).&lt;/p&gt;
&lt;p&gt;Another interesting thing about the $t$-distribution versus the normal is that MacKay 
claims that the normal distribution is not really a good "real world" distribution, 
since its tails are too light (Information Theory, Section 23.2).
For example, fatter tails are more forgiving to outliers, and the natural world has a lot of outliers: 
height is almost the canonical example of a normally distributed trait, 
but dwarfism and gigantism produce heights more standard deviations from the mean 
than a normal distribution expects.&lt;/p&gt;
&lt;p&gt;For any natural data, 
it might actually be better overall to use a $t$-distribution or other fatter tailed distribution. 
Of course, that makes it more difficult to solve 
&lt;a href="https://en.wikipedia.org/wiki/Ordinary_least_squares#Simple_regression_model"&gt;Ordinary Least Squares&lt;/a&gt; and so on, 
but we have powerful computers now that can solve these things numerically, so maybe it should not matter?
Similarly, when choosing priors, experts will often 
&lt;a href="https://github.com/stan-dev/stan/wiki/Prior-Choice-Recommendations"&gt;recommend fatter tailed distributions&lt;/a&gt;, 
like the $t$-distribution or the related half-Cauchy over the normal, especially for scale parameters (e.g., standard deviation).&lt;/p&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Many of the common distributions we come across in science can be understood from the 
perspective of deriving the maximum entropy distribution subject to some constraints.
Relatedly, some of the most fundamental distributions can be understood as approximations 
of each other under different conditions.
This perspective on probability distributions was not at all obvious to me for a long time, 
but I wish probability and statistics were taught more in this style instead of the "cookbook" style. &lt;/p&gt;
&lt;p&gt;With the growth in probabilistic programming (Stan, PyMC3, Edward),
sometimes replacing standard statistical tests,
it is becoming more important to think about which distributions really 
represent your data and why. It's not always normal.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/p&gt;
&lt;h1&gt;Appendix&lt;/h1&gt;
&lt;p&gt;It's not so difficult to prove that the maximum entropy distribution is uniform. Nevertheless here's a simulation. 
The highest entropy distribution from this simulation looks uniform, and the lowest entropy distribution looks very skewed.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;min_ent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_ent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;
&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;vals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;randint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;vals&lt;/span&gt; &lt;span class="o"&gt;/=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;ent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ent&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;max_ent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
        &lt;span class="n"&gt;max_vals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;[:]&lt;/span&gt;
        &lt;span class="n"&gt;max_ent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ent&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ent&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;min_ent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; 
        &lt;span class="n"&gt;min_vals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;[:]&lt;/span&gt;
        &lt;span class="n"&gt;min_ent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ent&lt;/span&gt;

&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_ylim&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;.2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_ylim&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;.2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"highest entropy (&lt;/span&gt;&lt;span class="si"&gt;{:.2f}&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_ent&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"lowest entropy (&lt;/span&gt;&lt;span class="si"&gt;{:.2f}&lt;/span&gt;&lt;span class="s2"&gt;)"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min_ent&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_vals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_vals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;img alt="png" src="/images/maxent_simulation.png"&gt;&lt;/p&gt;
&lt;p&gt;The beta distribution is also a &lt;a href="https://en.wikipedia.org/wiki/Maximum_entropy_probability_distribution"&gt;maximum entropy distribution&lt;/a&gt; 
bounded by 0 and 1. 
It also starts to look pretty normal after a few samples.
(Thanks to the &lt;a href="http://louistiao.me/posts/notebooks/save-matplotlib-animations-as-gifs/"&gt;louistao.me blog&lt;/a&gt; for instructions on how to animate it).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;ps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;linspace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;101&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;n_start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k_start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;90&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;        &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;

    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n_start&lt;/span&gt;
    &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;k_start&lt;/span&gt;

    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ps&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;/=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_label&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"heads:&lt;/span&gt;&lt;span class="si"&gt;{:2d}&lt;/span&gt;&lt;span class="s2"&gt; flips:&lt;/span&gt;&lt;span class="si"&gt;{:2d}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;legend&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;legend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prop&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'family'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'monospace'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_data&lt;/span&gt;&lt;span class="p"&gt;([],&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt;

&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_xlim&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_ylim&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.15&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;([],&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="n"&gt;lw&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;anim&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;animation&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FuncAnimation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;init_func&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;init&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;frames&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;interval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;blit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;anim&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;video width="576" height="288" controls autoplay loop&gt;
  &lt;source type="video/mp4" src="data:video/mp4;base64,AAAAHGZ0eXBNNFYgAAACAGlzb21pc28yYXZjMQAAAAhmcmVlAADKf21kYXQAAAKuBgX//6rcRem9
5tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTQ4IHIyNjAxIGEwY2Q3ZDMgLSBILjI2NC9NUEVHLTQg
QVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDE1IC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcv
eDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MSByZWY9MyBkZWJsb2NrPTE6MDowIGFuYWx5c2U9
MHgzOjB4MTEzIG1lPWhleCBzdWJtZT03IHBzeT0xIHBzeV9yZD0xLjAwOjAuMDAgbWl4ZWRfcmVm
PTEgbWVfcmFuZ2U9MTYgY2hyb21hX21lPTEgdHJlbGxpcz0xIDh4OGRjdD0xIGNxbT0wIGRlYWR6
b25lPTIxLDExIGZhc3RfcHNraXA9MSBjaHJvbWFfcXBfb2Zmc2V0PS0yIHRocmVhZHM9OSBsb29r
YWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFj
ZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJh
bWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdl
aWdodHA9MiBrZXlpbnQ9MjUwIGtleWludF9taW49MTAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVz
aD0wIHJjX2xvb2thaGVhZD00MCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIzLjAgcWNvbXA9MC42MCBx
cG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAvJZYiE
ABD//veBvzLLXyK6yXH5530srM885DxyXYmuuNAAAAMAAAMACA6DWJmvNLXEhUAAAQNb/t9Ief8A
naMjpoTSV9wSSUSU8XwXE2+hMBkp7SfiDM/JiRkHqFLjZNll8GGQsHqOnAsl6Aql2T98F/pU+kQL
rBMMCUKiqbFCo1vixsbScLzK6bZqyK/oHKY38yPjcxOZBzr+ob3DZHLEMlIvvOSna94KW68IAPan
HoKt7E6CcWH9sGQvZQ3GJffcfRgr6+ja4N+GSXBaqzoVs37gIVGO5QHHGKGesoKGUT54YjAOZl4Q
D0YQ6LkwtgEo5uPhkuEhkh0puDoYs+QBP2DKqJf0K7EzSmHsc+Pvt+cY5+VLRTM+jUQHXyThvjnd
6Rb3646Lapqehh8FiivjFFlPpTE/2iiP2iwNgFOowGDE7JxJ2CDWeTTRneVJNhvbE8aLM6MZDBQ7
49w/533auVVQJCH2mUiHzZuvqaX7Q7Ls0FA3mGS49NuMRwQ3vg93xKhU0SQMO3w8jeMpoP2/gEOA
bTCVZqUmt+eX8GFyh1QL8MwiuKI9f1UjXKpvXvQC2VDs9kM9UN3huHat4v13ofTpErPEW5OI/Ujt
rChDULNnUgYb+KNFa/b+ymFSpIhVR00pq9TePEHR93v1R5EiqpztM3FTFc1pgea1Ccdc7Fb9B+n6
NBWY3VTy8ZVeepnFW0HIam7eISLsS8x05IdETOCtleEXinPWR4kjVLOMkouodTn3yeqP7+K3mMHY
fZAVlDM3r4WNuZGH7TQP7OBtCGugNA+2IyIkRGwDD0PH1ZQvbmQ0FTVaMTO2mcUuHBmWKwvv3xmB
AikfDK9Xcg9XzovsAjJDtDfWk0ESIG07eKibH2+usUbQr8mA+BdoX2rqFMjAdvAfrv0USGyGkGtc
OYPfoFcoKErMxweIAwpk8keMfWiM5QVeypULy9UBuVT3SE4lYbDzzlFjcZJkJ5HjO/ws0VAZSQQ2
3XehpkLKPFUFfduVQQIBN8p1h3jlCqatt0zMqv0DRdddA/TF4Y6Npb1EmrLcJTdrAE6zBAUJtCze
QEAP38fphX3C7rIjmg+dZfB6ZywkhMpwEvZKAwQO+0BpZqovGc+qVB+KH5X+aPFMp+wXe1PVze9m
0Y7y4X30siCdVV2E8INQcFHQAEetxjK7n8Q5ahGevbnZ2SkUesqyGITFB2GXvR+brZQkM1XZPvGX
rwT96j7+GzlN4CUHPbl83EzZ5vOK84xjq61E4VOlsFAqgAunj7jaRs0l/Gg+wSoezoIXmS5OPkMw
SBFLNzTyknKydnl5BSc3Bg+Ie2nVvjBgTA6+oKXL8gT3cxEZdbH19pfzSnhoDPuAqZCdjCXQAEtY
Y5MOThFzA61l2as/MSx0lYx9Oc5jrH9ycciC4fRUntz5rAqRCNjsFmT7wc4Rog7V3yuOKmb3UV2G
3xtlRV/fCNo/T/BPJn4YJjwhKRbelmNhzTpUL2ipxbgame+ZewS1WufpTnftO8BOeTPbQreZ+F4b
fcbxWDutVQIJB4aZQLJM28i61xvQHfPiW5Lg7Qf5KYatx+SuE7IswVTOBP5CxRkznMvKROfz0Ml9
IfxtLxFS8Hoi9W+WtKNfDSuXX/6uWG/ffWKC2Vvd4J/N2dmM1rYSI+8xdvQuOEmJFAixN3Wko0Sq
w9vaZCEWfEejU5yFQ9naQtCPssTO184RNEiRKDkl96JTFr0km6q+/v21Yin41iXW/BjiTdu4RbHc
9OaXWhs91XuxdrD1EQnB0POYZ4Ybj3QPHjSdvxgIN7Ahh31JqjoseqR2Ik8a0ZukgdvrYwq1xHX8
M3YsFXWW14vDuh92KWgnEEnPhuTH7PUrJip3iqXnKqIG1DFAbqwrGV1ZD968TUvSpk1FR5/F32ml
3XTU2dPCkO0SDU9qnXMttBDxdqSbD/2v/DlPST2Y7m2aZ7TV7h22wwfNTfQLa+4+EQeXV9cmOJ5L
ZsRVK+LU8L1vpo389UTqEn8vyc4OGncAyC/VrJmbXwQs90CXuC7e154L5To/83//N55aPX2P/Rnv
2IFZJ3+eerbRGxgoLfKhApwapCQSeSIJqjVuxOOJxHh+KSNKees/JBb0CLHn0hsNykjXyCDDK8lp
WBqEnZECCRBs9W91pZt7qBG7VmQMwDrgni+2kFF8esuwdPviiKraHzADGKwc3CkvbYT/sRr1SOzk
iFm3LwyQtpaem5t7aeN1lJAShUScfz+DBH9gUUpIFBaqYfmS9Xx3kKCOApSWOMJaN/L1YP+svTqL
Zx1c+YsXVf/njv3JolSab0EhTFkmb13JecSWmPaIgYmVBEA0J7R9BLK39FB5T51AHZQKXhrxKvJF
9wz0L1S/migLzS2yvh3txff/Etobcg++6RoQVXzQ2uv6+UXQH1ca7rz8zhZMYY5RxRJ4bkDFZWV7
19UVbhDrtU+KZlVjqP7AenkfS4zl7YFV5SdHzgfwrFLs6h9fNWXwVOFIp0HzSY7ZcRx0ZSzU1E0E
wrqHh1t66WHDhah6qpJZZSXjHM4D/6XM5RU4nuZyxQvI9FGcw4zx+A6yAbpkRT7olB6n/aA8h4b8
ZcZmmHnnlhlVPyFf8GS+6Hr5a1hJoDm9BALNT870Bo/xmcCyyScAtZnaoGwvJ6cr09UVhufWOZI7
j9nbvkFuwAAiS3W0dLj8uI4zhglrIducan8sCeLl0ZJUc/y9U4WtcVLPz7oNVnmDzU+sOql1rBsz
zxC0rkpvYB5M6NQeEvZDoTF87QsjswR3KDEq/91tqWsSEe8lKW471wbV0sAz9wYUY1CBpXD5ZdiL
qs1OZJ0CjLK72VzgCW1IOlWQOf/Az35Et8pu6FtMmcecTBa89T+vFOEN8rdXRcoxuMhBeCVW1Zes
TobH3c90odE9JQCNz6eVtK3/hBLEPira0qzFbDC0ourbOH5LxloaHvrJ5bsnqCxyDp6fURe3119y
cdcAEFi/jZNp3Wpw2Ja5C2V7FAVn672UNoMSUpl8gBgkXsGqviFLZ/lXwaRneuszy/xLk4E07uPG
aP42EkXFN8Kt2pd3DYGXROizPRIilR2LR2nWzk3trNdOCGRlkLtd5kTeXFSOHANRzhT6Yr7cgivm
duzpA0ul0jNr++yegIrlUSY/INOkwcIhSDG0vhfeg2H7CLmm8U9ZQUAFX2IyfzD/X9iKSjdbzFbQ
m5aReGR5H9i2KNWoutQ2ix6CkPt9/cu2ecRKFuiL4qV7+Xm3zGIPCTXKa5MqNSpGSGIlR2rKUX6J
IDOTgN5n3NJ5RpivK43JCkm+0cRm5oEzxLsAqsIYJOkdc7nbfcrQFOSWMVJDwEpXEtn9WUck/uLj
wuYdlSwbsKNgMQ20+63Dr4JJjXy0E0l8Jkx0SD95bivaNzhjepG89Vk/4JGultKMeY//1v5ouU/o
qA7h+FLp26D23txs+M5wVKEdtae5YI4Av78iEG1IHrOUnOGddqPYBwLVzTJH3NdO5yXpsDlpVc69
xzTtVNw1J5XMV6sU8WD/8Sk9IUhskvgIAYx5wX+6x6s0rwZUAnep9GwlTcqQ+GnecnI5cfvxiogO
pKd5l0eAeOsGpAMvBdn4KnyL4LsX5wdfar35Q7JS5UGItBHG2eCzDrgkrVmjHrRyYrKs768g9AMs
GFQlHog6qDbZe64PqGiovaNFBk2dTLjrqHGpS/1Ir/QFibqkXNuNKXaFusE69CKV6mPPnVpfEqkZ
wCtXmUK0flvqxilTLNLBbYJC2zd2wCQQut/NJ75UmJmUt2IFYIgoJFNUOaT/N9d1kqb8J2dKQhUj
65GgTgAJ74yfl9J63s3URLXFnq24VEaXwvFcinm4jc7++BWZcjuvYAS2S944E/zIUPYp2/aqbAFh
O8CXr9pWe9S9bfv/yjE3Ydl2ajwaNItzr/fyyI8n5dVcpHFC7GhX4CVD5aB1GzpA0ei+E4XklK96
50Y8zuk4fnZ/v59uYrIHBj+KLZbeo/m1Wth+uvVSaqI9fItVgzY0W3IHAAAGwAAApoEAAAp5QZoh
bEEP/qpVABMNhQqAAVq2y/3AgGA4nMijQY2dv580RDIHJvoOILJsuuWHvotvn8F1m2b1NAejiwud
1iFqq6xRHjcksbH39L5LSk8sqh1vZ/Ue+inxNqB5ES4lgue+oX8xzivcPu7XNvlQQnh7sH8nbNTF
DUw30glztYO3UXqvM33Y/ZTjdU6c/pC4Z2BmcC4DEYNBrVlOmT9a3hGJ65l3pyirN7h0lwbeoZWw
hdKSvr68xx7Rb9PNRuxzLKwl7UOLECgpcSDzGKRNRrBD+GyIZ5NvJpht7K/+gSp2TRj+WO9qngse
AT+KSeOywMquYSLr6q3paAlhmjZH0O5INuP+JNBCTzRu+cgxydapa7JiJem6/jy1d3ALMGLzI3mQ
axGiUFnSWIhjAhTQP1cJ9AR1wPBtmlyuYNYAptC4jbeP5EYG2OTDzB3c1xqGbtkaWIn5KthlXKs4
KUufKGuNppgNfNHakvMhqs//arMZD6SSbhdu6V5SNo5Z5kLGiw0k8Vu3UZibfKTri+mZILrbyDfD
cSaaTHHv3jVB5i/2OlqaTmKCW5dWYIOMdNC0KPRk7jURlzkJJk0P53bJA8hpLNq6Gi1RDtvWzr1P
Qsi0wgEo422Ja8Y3Lh2Ru5rY7+9McRhyU7FrnWy+hMU1YoXfeAXdgOGLd6UUNqmcycwju6iIIGVg
3skO8pfvjVqd3QJrw6ZJwjp4ZQHUBW0OYsUCkjxE3v6VI39dX6D8Yd0sG0NMjDVUCAREGNDSp08C
AhQQkhQljfZ4vt3G9kJF21uBRrerGtNJAC0yE8RE02NxomUwNbzEJbYlJyDLfrm1clD6MsJtYYW6
JJAczxtgpTDCjenZLpf8Pn/Qtkc7YBqpP3GY3pmz4DNIvb97QJbQPCr/CWJgPlpLM+Ljkes7n0oz
b0him65q+/lvticSBE7f6JWj4ZaK/uBLgYvCFPSk+geRa0BrB1wOe3JKw73264zAgLhpFXY7T/sh
Jfrs8fGpm2BJZ5xC2wL7eLc7Xpc7Zl8KsT2+BgwzAV67dS7j7uW8ck2Hvp/48hfaTpirhR1/uqis
hV22qMH0DpDaKm03i6Q7umBplflGdglSNFteXpGAth3URS5bs00OCnt/UFBe+fCpoW/xeMDemWPv
PJmvqcU6R0yYz2wOS4Me2eGwS0Ko/KhH15nCZDgzyVKMjapatRK6lofwq9slCy2D4nn1CEdSi5G1
FSKwVPp+I10hlaA1VOgnowz327wTMN1nNhMmViUBlew7xG6P5IEPPTjWkW0j6gKZryx+Q35C6BQR
d8NY7E/HX1W6+tEqxJqP2J+ORTSfbj/2DqVwJjsHmgduRSjZaZcmyGjtb2YxZFPMBXvwxcNm3XMH
gGnyDTmuF+RFT4Lb1kxKwVdTpUHMyYT/TwuZBaMMsYj/CQMWEdRugms/xCvsd/pgacG7fq6HXFhX
hJROCreovwVpSLS3fk24Rcnpa2J1e+maEEoVrQ51yfXH2xymgGFd3qFkwwFT6rrk6VGMv34zrSVa
olqEmQ9bThrD36opb4QCHjrtMW8Zgz3iglk7gkATKIp8UVivJpjYCBZual3Wa9wnFuP/6sY88fV6
5Tq2KFnH7xeQnOt75gvLKki2RKBwOvkJxDNNupN1rlefVr7Vcsh4s4RG6iw295ROfljHFZFWFPy2
2MymbVBLuS++09qgLo+jazhg1HJAI0/+L0rV82Vvy+rhXMYBbQ53m7G9teqNDGNCcj7BNmcivNb4
GEKcvkSbEM9UzqUXkCqpLAA5VuvXM5qqDi+N9eCufET2nhPftDn5TVc3FDFuBW4HuMODukNa8n8U
kIvOyzxJi+XTQrwVIGqKwsWJSMaeHOFCkmAnOpcVq1c/mGrFnXLcKtkFYA775NKCey0KbdxVpyqA
0TFEJ3OHXk5EV4LgnzIslXX5aDNZBIcXh5VbF9+1Jve2A02NCtEzOU3TtuLAGDUslR+208o/wIOf
a9daathw8eO4dSutrh1p95WRHQjamNKbRzPH1eMMnOS9aOfYZM2/Dt4riOybzE0OCPpAXXCQ8+uy
dvBS8nPuxzbjtDXtbX/YlscKqfqBG7fSfxQGKxDaH/kNnC0FVJgp1mPFMdKf/n7hkJRLHbqcB2Fx
87C+eWcUf4xpB4YXqoo1J5b0oduP6IEP1srT57xHv2KxXiNJoY+ENBTCkLWGXCqmQBUz2eCDxTk3
ry4NyAM+4UxAx4DD+4LILuKxev2XFENA2nseqmn5fhwJlTZOXucTNckZxKzaIqAJ9o8BNIhFJcKC
b+8EAtMdgS56WWpBosN3RrHiL6X6PXISeVGWjZZ6qRzNyJzcgmn3OZYzT0lzA/Lb/dlkhE1p75Sa
P03bk2QpmySM4SP73tvnhXsUGkNFb7Kz8RL67y+Jwa7pu/ZT64sA17iXv0aqMF5ZJj8SBUuifcu9
WBIzOUBj4segcOz443LKNLZbD4IU66TGfEpCdm3I2hevdXel7e3AOG3lKFivjc8Bvd/Jgkth8UQz
bZQIWt7yqWw2kCIcPf1piTtsvGFkbBcuUEXrMssT2u6/HoAMr8FY8HmzGZP3S1vA9apMh2P5cWPZ
AWz9w7HZYGYTQ3OvBSnufjB2HIcxDLLdJz/etidkD4Mixi6MvsvNarzBhNtJsuINPL4oaqUVsLzq
GftJ8aOCWwFs+9i07jP2KuNGzdOL5jeiuqECwSmr0LU4egXlZqdIjt9b9uWV8EHnB7i5avlxPX9b
qAfRkLQDnh0i9VPXB8LEi7R0DLwcVz89uDnM1QbTY7X7vqXQmRTF7LjGZLFzDFOBjeMuTxud7Z0l
vcOZ++lWgLW0Ezdo/d82bVl3Kj/8YFHEJwN4ldT+oG4KTpCWRCLziViQ0y003TSeoP4QYzAY1h6D
w2jIMeFvNKnx0ZNGjrAAWQpI9Jc7AJ6r+/N2o+uBv3ckyr16ioPlDykUo2Ol+JZc4/y6Oks5+nVd
iIDKl518UycdwFqhDYxicEvuprHqjlVekVK2dHsDqbor6XiVCBT5e4k3R/s0X33GGeO1c+WDl4Lu
czqRG3szSQ39ui93gK/ZnrW5qfbldp+dO71IFfTuZtwulxlhyfbjY3Fy/IVtVMFwOCaauXop47MU
oiyoyvRPcjj9PKBfBV3Ij2h5l841kaMm3d8zh1aX969uMJd2bKUXUzKykYjSZmRJqvXnIHsb4y6M
7LWJqkIvPNHXt7hlVCN9w99c4YxS4chJNp/207Sm7l/FYgu0B19MGNMcwGo56jlEt3R7KhiyR4Y2
cMYZBzDUo10kwmgkoSvMZU9PKfMhoTQNftfthEQsgioinJvhmSxWyinH+cxyRBmfJ6Vcs68uwLny
eh7bXLotxbsK9xesplUHNZpWA3HRqRixSdA4I5OMhf1yJPFKzqxGFhiavDTpEeTxYJkEWN+M98J2
4mNhzSzNE8QUCYeiHrDD627DJZNqu2pyoLX5saqXeLwc7mpfFnQMbr0KvHbwOqMgNLzX9NQvZLfF
DNKaO3f8Ph6ymjCrvQfRNdEJdEfVxvpLZoEhrObEmpanB3IPRGdf+JEhJyUy3eicM/SEa5+kDEgA
AApeQZpFPCGTKYQQ//6qVQATBauAABGKPl/wn9zQ1HB7++ny/osrSeoi/BGZEruVEtDhcBTpZ0Vh
GV6ftSgIv/ia3bbT6fbP/o9fNzJ4JFxoY65LZhgI2p+HbOahcYe0fey0IaAT9U+p61QFrN7/KFW5
ieUgiLZO+y3JsYTb71O4Jm5j2NEGgiBYHSlzDlE5G8PvWsBBtBhugOAMmpftQUHDH8qO3ose/m1I
X6jT229pq3QvIMUkXlNWWEHOJcQZXR7samfR8L3XrYp1NVzrPKFZGYYHp88fo/nRCd/zh0WRNVIM
ptGc48zoo1drdW8LbfTWN4gUaI9mXLiqKdzep6XrgFb5GYut+te+Tt6VE+tv78lDBJIMEt2TltBB
lvOWTxLn57vyzI/CHqp+b8WEJ2sK660Sd2DLUzjmbbNciSGSkq9r/XIymEvpebmGIEmRyq6tlUF0
D5jEunZXeVpwMGLYXfI5Okw+SHkuQabqFxeqvJGj3aOXkdKlAUjfl/VNi8HdKjS6FEn2EUlmTvqE
zDulsaxiPV44sYtQ7lGb3CdeQos/uJ9jEc2MTbvwpJkG5YVfaYmy5dV5G0dASTQzIoUixMkb4Bbo
tIJKHuFN6aTL4Gr8SOrkjb5oOvKz1ffFMF7W4sCsUG4DzhrUTRsu4lcM8/4K30Xi9Jm0xAFecisi
RO99ZGf5FwJlsE4cEG+StZfm0tgKJqrhtNVVImJMfIqsuspbHZ5NY9hV61sRE+pl2XbbM+EBDyBA
Z7ApkmpoyRpj3AqFFtUAb2g5ggN4wX3mIYbEQoJ0kblrxDbTEapnNujDhO0keb6ywnooGUTxfHhn
tFe7J8+PO4ZKnbX9Lar4WvJGcTnx/N6encNjt47/pJVw6SqUUbMWvkLTCRZKFHnvhsnZ2fEv87UW
P7C6vTgWRIsTTkslfQqfckRTL+2DFlEunY4IDauPjwfGGQhCAhCbmJmgGTLQWrylnr5ILJc2yXTT
vQ09RvrOoqY3HD0kBrN9ZfF6vdY7vDWH+EyljR21sHprojbPE/+UjvCcb2g7+JiLShHJ02hw+WPG
2vZ4wl8WrWf024SgsZxAhItZ96859Tbq7S+MY8Ip4iDTdEnUwP8tvGFWQncT+el+lTcQfEjOuskf
Po5Uo8J/J4lgswa+aX5daq9G5HF59S0fewD7se9r6mV2Rr38w0L+KcIS4ehqVCZhwQVleCGHNG8o
e57UakaDmM2bqynmuUs44gkzblvWR/LV4N/GIacXWItfpJABlwmLGE/jTCvt+rwUi20VAXHu8v/7
WWH1htARiRXWLrjs6t3V8flm8n3jVeUDukZurW7DntwWKcfM0H23RB45r83ITQun0FkmJ2/zrlx5
N6EQwOD4U/WS2sMsCvPBsUo+sNnoDmX8dEWV9X3wtYUj604evrjnm649jDN+lWgjUTuQB0xjZhJP
6aYi7rrJui8s7fBBwn9dVC2uWFuIJtuZlcCokoiaPeVF434D1QMD04Cr+3/N2Uz2/n+2OSMzDGsm
FfkmOFEAPII/ot1QB1piQyFu+C79SZ8w+FMDbGTds8C51aTh2EALxeIIXozgPDnA+B6tXNC4130O
DMSVf40YWBVuSrKSE4Pn1w/QX97WdtYaOxRHiYK697CV4aHg5mg3Hds1GNYq+qASPwqDi3qTPHPC
PqEdnbLdGray+FofHjEIbn6k2MC04zoKPIBCOPEVdJacNs8d/Cho7pXzyLbfH1WoYT52uH9FPCzW
1+BmGuDMlxMt3z7DUxKkSeKiQX+qcq8sJ+tMjC5z+uXDN/XlLQLjXp2rK3hs4nBiYtlvQJAbLeQ7
W7nGslQDB8WwvFsxxsADg6LttlChlVHpXLxOJkfb4UJPD/owsV+flQ7ikK2je4IYx29nZOIgMnwl
1EaQ88gR7hjq/kw4sx40DItmeXhuFk9mGVJFWWJqHCQEp1QwfYBvyTb0Hfjkz3ngljDa7+DhOtRG
tzbAOHn8tKnyvBUFdnXgtJJqvA2/oS4mM9eBB84vfBvu5FXlM4LyIScusO0aJrbrCgEyfRZLs2rd
Juyqu0yYjtOx+bI6CqLz0zscf+38DdSHW6hiiAJGJCRqZav8RhZBza2EdaoXgLCX6Dur1mYY7WO4
aPaCHt8S/b/T+tR10ONWKZk2sQ17EEMN79PdMkeQ20pXDSw2TO/X6BZJzF68JeTlVFdvBYNxf6lm
j/LoE42uBF68zvzCZdglkkY9Dp18BW0znEvR+SxmnACQlsOBap0icarWIAcMBFdhNUUYKJdo2e60
72ooo0d33tt6uEBb/TmC5IKRgdKOjBKg/SzQYbQx1v7EOTmP0Tv2uBAgMTMACnMKu7odCfJWF0is
sRWw1Yfx+fk5npXCzGxwhx5LERvF6HfkStNBQu5NjnzlXglWboeFVrK0XplTw6IY4HsMGv7mgwsZ
sH4c0UqrobXhq+sD1ZYpzp+LrO52r1aviXFSJ0dZxI+P1BF19s5jtdoHgm2+8ETulhiDjR6yhpgZ
L9lPLO7PwBA8i6XhmKtgW5iR5Iyx17w8e7LiBFmPtic0exZBKksVfqurn6b6Kl+7J/VJvp3xMdQ9
OYev7YZzqk+hhzRS6MlCJZA+3WIHaflPRW57084qkUTywvlalJdrDnE2ZxcOrF1CDwbVADiEjj24
+Fbq0wTxs4Cu6JASbKLKmgQ0iRjgZjq5EXKt0PYDco6YdYRvRybgkQCxn87myoRk7/y6Zp4hj/ul
pOhRw2RDQLpxRBoQ+EuRE5BtCE8kAjWLFkw7JIn+H243IfXzXhOZ8HgJ3RtYSCXiseWMogitoRFO
7JdN62550dCdHwapC1Cq5J+L9ZDkfYnlnL/UHtw5SzIf/+RykvrWHp62S4FaW/xInkY6wJNOsu3z
9rcr4makYrqTZgpIgrvFMYlK7WxJdV7XWYqYbCswWyW0gJ7n2eLmwPc1WIJguIm5qG/htWoGio1/
SfRdlCP///+/QYcmT7YnvP9E00DTlURKE2/P6mIS07lHefmDDqKWOMbQuuL19KUqYQTnRL09Pspf
/osaV6ll1rIMtQ4CVZeHcre1NYbWsQuetfwD8PTUnAmqVNvZizzArQLzLYj/b/pvwoBfaXLLGThz
2++aaiV8fQSV/JsuSZhiFEmjDHRKTGWUeZMlsZsG0rkjXT+8GwKG8cSq1G0F5bQ3UsK9yawRXCwv
6pnevZ0EfygLQ8QVEzDy204j4T0hI8KziB3Qx063xzPooC87vzVpvD7/Bh8U57E3EElwHTUcCLYt
lXfpMpJuvI8X34d4j9x76mFgakOV9Yr6ol5cIaenZU/AJhhY4H4mgtMCYY4o+8z+ebC6eIIfcF9s
aZLNqyQPpCpkm73HhtvL7ylL5ymx0mcZctNjETjCZDxXg6wA3sd1pXwMbTG6aFqtFMdyWJGeGytg
JthLuHNosIBINTT0emEKE6lQE4Pyh0vyBFj/9FAhRTVx1O4UGSHoCk0oL0MUmX8LKfQaTi4ajaKX
y1+xmqmsgW64p2hEf82jPqJzfij6xT4fV+6j0VbFsiuwLoEAAAUvQZ5jalPDvwAlEi76AC6T+gbE
C1QtpSur/j/f7WCcQ8VngNSsdL0gXzk+MdhqakiYJ6AeB1wU9KUkrFKBRBH8UDwzA+fBQbGh4wtB
RhCFwK3lf+KTRdYMUBzwtzgdX45xSBpwFG4KYug+fAjv4LqH1h9Pr7nA2hFRayYcEPEHd8hV/4+I
wd6ykqBy7dTbWOxwT3H6dCz8ckXdCA4XRd9o07U4gg+WCA8eDrhlnh5EQVpA6uqgKggP+1O+gET5
ORKU9w93M4osxvfj4ijdYORtwQ5mpb49v/hpaKVeN1T0+1GIGySLtuQGyerAzb3syZ5WmrF6GSrq
yk35qMTScCx1FCpsn7tX/vpYsVbCTKfVjVWYz9uzJElju+pwt8q/R0jZM2d+DJc9pUc6Adj5/SkT
Lg3JzwArsZa1iqWrs+5RFOl+1HPzlAOtPD2tD6ne/LSm21bDPgl5KRR6odTtXWPKjOqXZzI0ZTU1
ijUq6MXTS8z/N+ovmChaAu49HLyvcNZrjwqbj/BlxCwhOdCLhrHLHVrW1CrmokchZQ2VYhRAPRId
uaq/fiuUVM6mpaPSd+FOLnep2zz1yrQUv97vqFidhBENy3fnE1YOTsXRXTADvOotqDP02elNKmDP
0c0GrpP/CaWXmucP9mDxNbaTQ6eljqEF795urmUnis/m+NUJbNyi6LenzvXnikkoQq1x+1jq6dAT
+OZhGQKh5YX4ST44u61xd806bbnqweC9MwUhKX0rePI1z3Ux84/7JM0LM4DlTQFrLsAaNgiv/0jF
xoMWz7WUc5ZrHdR6ybDft0tuyFIDk1w2knSdBfzSxewa3evykhmNeWW0BXAZFDFOc/fltwABII3n
u87PmRw0j3GoXMSCoBoSVtyRND/igF0DTd91HbGDdz9e5TMMDsl7sum8GcBci9PLG00UeXMZEUa+
I5XG2y7OH636qFaKvNOewHEWMRUX7q5HWAms3sekmsVfmDrEPRmOEI0qwOIVmy4aNyNC1VQtOA1Q
Kh2Qdb4KeSXJwA3wAfxJFPy1VUO2hbCR9HxF4VvmwwQNyL+wf8CyS/MV6UmJnveAvQHnQe1xqRdt
juHFwACnPdHe1MRtShUZv41+zA9euDbC6Ujjpkq+LZONWimRq3AvhsFw4TEaoJty9olVs4JxNYpE
5A++43O2qRKPzeWxoCBHgO0BS6JVFbEJk6rC0wKsN0mKVUYpaVnUspj0vmbl43Pk8O6wjepO2JuO
jx3xUzDYCABojaxpfmwAOkhlktuIVxcDbODyeyymK1dGHNfk1w0GchWamZbN03a8ZJtg/Vx5pYHv
+lXwM5IHLhshS6Z4FBn47MbUZsYK3btGck4X6kf/WMbJVY7U+tPCNyklU2c23Lhf8VuA8Avtg+7w
8CHvpGHuA5YIzJReWtwMvIdZ9ODM6BiG0DfyJuw/eLe2htAHhZF4YsHwpn7g0/k6jemtnJ9yH6Aq
mS/AwssRgp5bqX5AiiX7RbwL2Av6k6AKGRDohFgxp4EnbqCgaKdva7NbKQ+GaHZz9vVOvmNplAsm
0v8nt50ZXSgR2yBUzwYPw5tYKEGFC1+Ql6j2DyBaVFFoEImx4iwxZsGiBrPEFWHX7rcEOMz0pMKg
Eu79q+uLRip8LKmtJ1M/ZUJardjytQi8PCV6y/+/88RFaHOF6f4INtYaQ1CpwGVU6kc+NtUrCOaj
8UmuinkZbgV9oLbcCiluk7Kvb/tmoGZQiTSoV1jkg27Eer7srcTgrMZwRmHEupiLK+pk+KAaEAAA
AzsBnoJ0Q38ANHPJJCSAFuWlGM6UtjJAOb1GS93DQBCxtZyWg5LUOZs/LIV3QRtRgMXkri+v+xhJ
jJaN3sc5r0iVunlVAcfZDTy6pvUTHrMi+bh6fD62IjBwD7OFmb/ScNSWYEWgV2XorgXPS/+5BpMQ
sLnFiqbrgo8tW5IaMpPNJyFAhykGdlX3KLBftpRMQoTdl0h526UBY/+K8bqTyRNqt4kxajoa9F6V
qCZ95JWtd3awYQXltXb3zcj5jQQhwbeihPoHMX/PyXC4Ud38wJdgMDF7nn6/fFFkntmVxhgc/HS7
5O2odRtqXkb/w9ZnczbaVWcUIDYzDqbV1nv3cJEi3Lm6//v6yCWGgmMTUqQE7b8G1cRRyT9IJEZi
1jNr/3kllox3cmnoXss7PpnB3c1Izp4gMsJMJB7iveSdQdZbBF8+3Rp6TcFNm0Y7gNek08iWjLkb
+yKqWaLSwkroT79aUfveaKC00EBQQDoCLN7e7pePVQwPDmH31YLt13RLJ3N9awO+Z+PWrXcKiZNK
7unQsUUh19JNCDz33zkq5Qs20wbEOt+KiDKGdvycmyioXktd5mCiyhHbvJmStydIHdOmcz1DPhtb
myKnKd1LeFs4xGmsO8tX4aIKkxdPXJZhiIrDoZFZOSM5OlAbwRnUWnVHsnLXTQguS5CwC0TfkU3f
aId8Y9IfuxVK2MMAMD6Mi+DyMV1m3WlMyTAyH+EIEuoSP2KdS1t0aaRZMQwT2sfKNh2nZgNMvKqo
uBPn1H3cS0ufp/PBRT2Af3dOtKEJTHDwET85wwA2bxkk811/3WtaO478nJyocAfLslY01a0xAHNb
N63S1PcP1J6mtxuF/Gnev6FKG0Hquo91112PGQagBpFlXNYBAU6gns6m0tHPJILYW+P0E9rwAACZ
TRpVZ6U4CGMH1j90kbmdN0QEo6IFUA0+7NCAWAJFb17fTvtpM5W7tzy9Xw0FLQqZTy184UDC7P42
fiRCXwVKG5yZdvqHIb7CQ7ArIssbL2yhEfO+f+fHLLbENJjg+TPQafnQzCdNje+xGSxMWWLp6tXj
50ZCI+Bfstqnr3JabvtGNIcUdonz4vb4W2+ChGGiIwAAAjIBnoRqQ38ANKqW9NIASyepkB6Gz9CT
hgv1dZ6fk8Bp7+0p1YwRNX0GFOXmw0m0cyizBuxNTbmh7Oc3ZDKQ06b8+ycMyyvF9walt9Z/r2ct
/XGNY/j8cOI//c/B4ETSMPAv5GO1b5XlD23TPwalRqTA1Frxfje6DISCk7E8eXUYTqf131pkXLdQ
tepiHmJVjjNwj0LwM6Mm2UthUFnq88C+E9mV+9Rz+83GjE9qi4lshcmnwV1nqV+caQfPyTyf17x3
6Hzhu5AOgKTdWFsC8cpjMC+nxEVLsrDQHtv4w8Z8Vtc03H/P6bT3jQvNelSw0yaIv6RQKkl5pWJV
upruY611EK89NFJ811X8EJv/kEoGa6JInCn7lgQMygbImJtuERggY/efxRyz4gAyEV8f8Lj+VWfw
VvOA8N/u2UR6k7Mq3xAUED+f+mb7PP83Lz0jI85Zwd0F/CvQeR1ewWahZMmANjTgdrBJxP67+1d+
B5tGfLD62EksNypFeqQwjshALqDgomrwpsIacqz3L02JwRFNLuEt9W9YNA6qV55Tz15yRGvgPXxD
X9VXYflIye5yvUVCtyZOqp9KAhGnL+C161dm+QajEA1yx/JyEmR+tcHkwBKY/60J4UDQpPjlFRIC
6xyD8zkXzhHg2JsxDrX0nbJuVfhg//Ei8zW3s9vGmAP3a2DgEBJYiNYf92O60J9s3m+n5o6HGJmj
rkNIaAH2l2Xq1APKX2lhWeGf8460o5hHr19BAAADiEGahkmoQWiZTAgh//6qVQATCJqGYAWC2yVK
u8bg/kvIeDKJO/0ffq3tHppncz7iTuX8Ivlgz9ZhvK6WxYmoIfb1U+Mexh25eH8adVoP9J2etwrG
d6KJ9/MsBEdF4kRsuKUWJNbz0B4fXoAlA+Cdc/URlaqDzKEQ+mS25l4Z5nwcfv0xSnQWUTx0CTC6
DyuuKvD3aeZboRRy2ay8BMSbtBNePae3eMdAdYh+ir9lwCWp+sZDt71Tro/28ADHzWW9ANfEKHRR
0xxsC0z/3RUMMwB06qPsJOywglMX1naroVjoPtS8vGwCIj735qkZ99jkxdlhpztXAp/jeboxbmts
GiECe/xWIY3Kh86u8rUj88Dmt9yoviPxq0Dumjvut6e7Xz2vDUgw3ztNMKe+PeGEyeYVRIXRqEeP
DMx4JwkPVE2qb86/h7qlB2aas0Arvitv6pnPLfLe4ir7pAuxu2ao1ASlwyP135O0WONKUlgc3Aet
6EgmjHU1KAjNtNpBF0hHbau74A3upg8RJncSIMZlF40dcAoRayN3yYrgWQZu4lOFYKdTQJoPUdmi
e8M2AFuZdTvLhNyOpUgGlr9J8GzEtmKOMprkLJxnf/0uDFWMT7vTq330yQoG2Gfd+/3LeT4wMe8b
MPTeyC5Rmt+My6DmACLylWBTp4Oh5aa26iZq+Ai4L/ThN+pet7h/g9SiDFxqBbz/LclObwMK1rVX
pRlDrD9vYYK+h97bnEaIwfL7XYw/T2YK3tOQveq40bHAFc7qjpWNIVNPzCfdnZbeUO/+WoJ0sJZT
8Sx6qubt5c7GSsK+lmHsREn1aJ6rfmZ06FZYmWNgAOeHO8DEgGXU3JVj3/kOgKfi1DZxKSBSfdct
pEphk3SmgJQQmEufMlMFyeS8nqN+gf4C9Nf/XavpVwaVmP+iFrc3puy0hKyetdnWS3FyDBXikYfT
2soo/hMzh+fjcskPrkhZ1OahR+VSPdVXSFgLpUvSQH/VSLvrKDcqX0BW/KjmyjOrDuGrQNgJekEY
wimuhAlqnE4aGh7O0cyu67j1Bi9GeJUoUsm2GQTEdv1Q8OIRFlDpHimadX3Ud6qG3ErncH/W9TnL
H1h5DF3AP7gN5TwC8NE8tvpZIvyRM3Qih1YFvky5IDWPJZfCzb6jRzs6H4AV6CzAUg2AdZQDF5Br
vWOhh/FyZw18tUBYBDSlB1SXXBI+OxMAAAPmQZqoSeEKUmUwURLBD/6qVQATBCQzACwW2Sjk9Wlf
2FzcGCUZzf/3vwezc0OENWWxlioyQGVcOaZwvtbpq1PCt7CiJ8gkKiuK9RH0k0dnTcL+0RdwPkwX
M3S2JsMYttyCda55yaOfMJakd+Fv8fVZ5BGAkWvzPcns2rblIU/R1n3v9L2+1pk3+5dzwH8Gb7hQ
PLoYoXVxXaPeeYkz4YOzbgT+Lg3LiUk7eNtBNmFsV+zSkIog9XJ/ahd9jPfCc6gTnsjXyJSJa/pR
lhcpBAGzD3NY9EpIu5M8cuZU2l7rZXWmwcjNfQLOu9GlFGq1OnBeo/KUytXsw3mjYrpRIBgnlRsc
UVhGI0JUvcAtLc2JnadB3Q/SbGovbZzP0frIiZ8hFajH2qsciL71oHIskOfBiaFovmRBr3GMkcK1
2KUUEo8Y6rYfhoFQmhevQ7z4kPoozGq7zPxJ373f+wDs1frkOBlir9aTnFQiF2wM5zu+dJkX8Kl2
+ZP2dNfE5/8/qcpwFSa6kyMPNLm6aerwOGtCd6lzWwgHr+/epvAgYjoqIvr7xDR6TmCDN9pwcEAS
2z4Frk0TsGgJv9kmVjq643SCcDPZFxldGTJJEEl4quuToPmSboNrzOqb1dSfTJJp9f+hGHd7haF9
/yomwm2mUTQ3jehrQCQziMpsGMcYlZGz2qCA4VrjDGTWqUjfaVwjvGKrh06lEays0HTmf4KXmulU
mnOQ+CJCy+kld4vMEG0iVpmrUvUPnpGoPGiE3hB/sfilp3lCljduRbRl1nuw0tgG+G1Iq2Kfb7vT
qlubzNqnmyTHMxa9/Rn4ODj2A6G0ChYyajj0d/lKVsvjXyOlT81IRJU+0UAzHbpkKWASUw5470YJ
p3/QDTElNBlse26+0centZgmzeeyjpElMauc1YaZioqI9ZGEV81oaiWV0d2HYhb4lkMzpLMZdxyf
vEPLJWvTYp8E2rPb43GUZxASB/vd+SXgrxgZlIMHHqldoAWduEMIHA6DPqRODeKDq4AHuWSXiid+
PLuXvRv9ANMUJzMM1p4J0wTC6YmxvFJS0gwHYadpNYyCtmdiIeqyr2zMT95UR1Xp9nLfhW/ZSeIv
iEEIFQ7jvKT3PWzXKoyxF+bOHsgeRf/m31ySXTk+BWUnsQhFtBlXr8vK2tX1A7aj5vR4Ehgz3KQs
hrMK8N2j6Ag/ZMNePkwUL/siC6Wh+x+ForSoA5XRJeiU5erQW/3ghbndHsvsv7W+ZbXnkIKHcfPD
rmFkntTFoFR3X7u8YdYSn7gw+ApxBcaXwLZn0u5kzcsOSUCENHTDsJ968BGbWp2E52Sn96dW+fsA
AAFpAZ7HakN/ADTAuiQAt1AP6D6++F679NcukYsgCNgEvCg/1G5qae1r9kv06BYaiNqrGW8YPk4x
6qWBZWjjp5cqshJsdeyNxkWDaLCQcSoycIRzYt7nIfWdZWbvy1GmPmVWNVNkus14pqr/HBZqKmOv
yYFhaD3IXG/4C8rPvur8uu0YlUV1OIANvJyaI6Je520VH/qLNJ17P+5CIRN3zD3ZbJ9Pxhp45Zul
P9ASe0R1wONp+ttfrHGDI6zKNL74lv28AjsZHdKMu5boSLYnI+Q2hWew0M0Dk9Z+SH+V1bBnTCz2
W4QpHAVBf1N0bLZCGHFMy0vz3vXIpeF2BkYCeoKVUIN3tdL4ZS84Hp3KCXNJNSGGj+7x5V00gqf0
OY1FO2r6Z20eBbBmfhaaca6dST/XMDojQbZZkVFZbR6LTDxIhd6OtalPbJOJ2G1n7qSGvxUq4Z9P
WgyRcEzlWzDQC3cqxGdizFnzFJc0fAAAAtRBmslJ4Q6JlMCCH/6qVQATBCQzADoo+ECv8XubbXdT
PBribUoRCuo7Gv9lZSbon4cpcs36FMN0Uetr3+B/YsMT/jdU2D15jR+cj+5d5kFAMTqaKSEY8GkC
XS0gE46XQ7P/At5npk0gP6FkFXodEyWX6T9R05FNcAZJ8jjt7kke36KhDpYZYqnIpABG3ydYwq6i
eiGYJNBU26E75cheVoo/yj8WM51uc6YK3Woa6pM/liNGilJX5eScM8ZGwW1lrTxlvoD+ar8zOWXw
6KlTVSiXtb9RJyueilt8g75z5Tzm1mr3f1d2r8S3N3XqtCmjgejdsuPGME/qlazihdPzt/1vxO1a
SGNOI20alq/2+deB9X+8pQvRoN0oPfiAD5MpnpfocQz5LBL/MZ9eHG76Udic+RvcHWYMsgiJwCtG
KLC++h2q/UqRHWxcFC6Bz9oWYkqfg9yz2iQsUP3S7C0uDkjper6bwxzrAWQha9HyUyiSFpiMHs5c
gYKH+Djzbhrk5cZ+29b562b1mnWPquyTZjoo4HSOKbNNaXNvxHMlQJMkVBs6as4jgBK92lyy0OCb
6pcXQ2QuaxOiZM1PqWXIHYZtR6sLZSQgDo3RfRyFhPX0se66d559rbJ1hkBuoMsERb2a/Cg4AN2e
FqX1XK0tMc3FcRG9P+b59XMe0ITl9YaxGCoPC0tYtj3r6nHQ6jhLnVkvEtpag//QxHnlY5fBluul
BoUSIwglg+KIka0wlN2g8IGdlvOlQ3UF01NF8ehtwGYyqz1A9DILcP1X8trFgXWkpAN9QJLX1IPV
ukk+lrTWhp1QqXqmsw0AhTiwt75gQeeBeoI1CQR6eBIh/7TYzZVug75sTR4iXCmQW4T7c9DkVvFc
Mi5O4oo48igxVTzHGf5prXU5lHm39l/4+/jUEd/XTUPoo5AaqdPXIs66V+AceNtOmF/MiCvNAEmX
C/tyxVCE7uvTAAADCUGa6knhDyZTAgj//rUqgAnDeDcA3CNYuLlAuAJC/nu4dsr7oYdFKNnoeUT1
5r2vEQkxJu/zREgK8a4YwAPi8bdRwzznIw9l2d5YvZdrlpySXE22nmeNzhUOwiDhr/6z092EnUZ8
ffsR/RchoQeuJSt6wt31QHYnqyA/dnOhVv9GV40ccr8dkWkmyMA3SyORcC7mVk+VsUABqrY9Nza7
02rIEkhReE/eyDc2JlYhHfCw20OgYvxBG7F4nOUJcoXce5TKuWcrPOchDHWz4rpkWxEFDLOdo9Kp
v4AEcKjK0AgESromFeslOHDm7Ogw/Ii5W/4rd7jI8B0SwrI4LfILhAN3h1mG0SYr4hcmGs4jAxeH
xLqi+6PGLcWINWrC7w7xXyH+BnVxrEpynO+W6DSfAmyWy/bcpXQp3kogq5NEbyUGbtfXlwF13PoL
qZ+He88wqKvG2jVq4rKSa1LG7gLFFjbS53uWuvaKiu+4e/VIk1LIsx1L93FxqFfIVkjuk8gjk/bP
yqzaxIWezrIQQKUS1YWfCCafieha6CNzC9IRyu7HDgv622Prk2Q3+AhiVd4MfiQ9dNbNXzgEiesy
DOv43Ca9WfFbdAn5IVTNvUzyR9mFmQVj4TnmVNhz2iX29EP24hqE3JVqGwZKD9iSRvfxy5/Teuwm
GqKV5xV+1atmETiL+tL+FIrQiAUfH0uvBrA/KL1G/hC1hpUiRpBKc5lz6n/EJ2KmQaAN/R0r2n/1
Wd6j8xS9CUuVJwUECMFEd7gTCzUpVUEnbiW6HToZN/qWAax2biCZC1OfOqYaY0UBEGLFXYBxDITM
GjmFAZUDqd8/ix3691C2S5wu3BMeIGL0PYkAD16/XqbBl0ebt50dNHdYHkw+8c2DFapt//X2yUi6
uuED4cisqtRnl689N6QvKf13uMEaaDZ84n6z222HstEm/ECOS1i/XCP1Dn7xQj8L9ogJ7+uZo3JD
mNg1Pxw6Z5N2kH1O5VYXwG/Y9HTYxCzLEVXEHuGl5xwcI35EW3U+Oz1s/o9NKpmTwQAABThBmw5J
4Q8mUwII//61KoAJg4LlwBGKSvhVXgHCrxCzZ2Sonb+oofmOXI8QKDomusv+hX7vrqiGb/0PAzra
V85UfycPQpO+tkJ+lGgENJl+ypyk71654BxFYgYpHHXkaamYVHQuUDHhu1khtaxUk2RHm2mzCMhG
28vUAcPMD2onaRrAsN8qglMLVIyh5wiscLKr+ISC0T9sX9aQRv1YW5TMBA/SXe4Qh3QaC0j52SdV
IMFPZcP6Aa+nHPVXMxpK2Ob7LyDy7eEDhbEUkLPdA3DJ4t5fyLQ2CvVGULdywj8jw5W+jzIEdp6t
I/ED5minazpVXCR7Bym+oSii+ZbgaGMEfvc/1pxr9yCcsVDW5lCZP7E3v8dSpQHxde4496uDre0R
ZruzEVABaL8IHWeHmmIjbdoJe9dEfbHc3nuyL3uA2TcYo+6Cm5y29n47CBR1cVXfR3aYuBuNgOQh
Yx94ATMdOJLYfNpfp2AqRq4h7kV7LT4e0gYG4Ca79xE5TnzS6ZLIzM2Cv8jMg55GwnlpCHpCNDd3
A8UPuAfpUFJRIv6JU2xB0fQ2D4GpWAhcpSRQmhTen8IpsV4WgHa+NiY5+P+BPDC4ooccbqd8Jq1i
NEzNFDu184KQQjK/FoCO7ysy7FTLEGlALG6z2Nu4Sr/evJu6JWQtYIixbtnmLLS2Aw8HUJYt/LPZ
zvJHGnquuPjY4K239vj063KSM2v58hKX8OuEsJ2h3R1ze+Byj10zlCW9FdWU4jxrYwEQYtbuqGKQ
zSyhAo7UcfWQ1I10nFdILOVD36kxkb9I0twYMl6eat0esm60qc8bYWvXcBQBJpvIfKKfFO9MsOBd
y36woDuoj9J/5PwDYpqCZ6wdVmgzvLLHtmRzyhoIX5wsBE1WvFIMxzS75HfYgK3cRiDi0UisT1E8
soqA41/Gm+KhU0KsfxDb5dzJveOG9i4XakZcoSdwFoLB5AYk0ueURkYZhRILCUXT7TVsNrp6ctnr
4PT5SrNzrylwvWB8HYzfPhOnRatwhfCBn3XgNSBHgtHq2/G6A5LprREq8NtHfHQFmV+BYyV00JUq
KOSv0/QoqH+6v4PWn0JUSHJdc8L2DjEMo0U11ssHHA7HMwPKWEsJW+/htKfwQINHE4bJyjZzasdA
R/gB8CRzfIvIU/pvS+Ft96wcDN1oEB88pXpSfvIEPP8dIrSlpBsCfoY2ezfLroaDAFIsbQHuMMBb
CZoiZ5rbJlzmpMVr0QRUL2ABRsk7YeHcOQlytcskHuuX4s8CrpafwwKabvdSfvyc3pqtw0vNpgQU
9VaJaSg2ZpgnAM9MAwUEb24zUcsjQdJRoRkRZzIKDenmxojNKw3f7Yl70s+hCtkcz9O/UDi45pB/
idD2N3QI7TGa+MmmTQgpWIdkI5q/DCd9xZgUfzHS5N8wBh+tF+FJPR9P/6xGos/6IFtb20fZIB+A
v10g8KH+kR+e1z+40czx+hBguqdwSQwyFiDZI+50vpvHlfPtyZ1YJw33/7tvB4KY8xC6gG/TC40i
K6SBEnYSUhbc0V7ODItqOoq7Kl6zhQcCx+1UDDOYuSlpJmnDeIe98GI+nNN4WzK89gDXS1JjCgOs
nbHGRjpLlAfjvudwv+GyXksIBzDskwWFm0a2hhyJPznUNj86vieGZX69VbF8elReZDtMpKOq9Ge7
G+akRLrnmjzSWrhx3iwTqJ53s+roTtPwquSEtWC1o6tLCz71mCq/Ua4FE6HUNmlSNUu58mm1p+7i
5VTXHCCcJ7MZJGKfSIp1J40Zz6zMAAAB90GfLEURPDv/ACUSLvoAOLXeqcQZv2Q7YpFITAGlo3jl
A3nwYoRF+4rO6YKsTO7OZRlwSKnDKMAf4ISluO88TCRNX9XKfpkhJ4eUkCHm6vbUzYnKuJrHOBSQ
gbaS31ykWyCqKcYemcol929oUW2XfRjPkOhg6a4XCnKOgfM78SKMdblgs4TH5UESe+2ay0MnlKXn
9qeKKFquoJLjgIoFZBT+5hfZFuto6yqZnnDmvKsZHGHSfnN2mc6NbzyPo4TzReNZBxLUuwBAaOrq
lGvqe+fECCcn6HfAvfTWVolMupTxMhO5O/v6XaK3DI8u3yl7A49ZmpmwG3jqRfk9atbrEag8iso8
5EO4iSc+5I5JcCupg3PDl8v6v/th9akCYgYDPv1sJmQfLGm9zoDK8FlcT3PViiKlt15MO9ziVUfm
3Ywamldi4ABMFjIqzwTrAUf+CKFAGxHdEI3zBVK3lj/EpfN7kkLJBZ1RZWhAwDO+sjxwW+cn70tx
1fHbhCmnGzftEHKIMBGAOTCA5vBXP5AtAzKx8ZIgVI3nTx7tWXrbbifNSIvCa3MKpvdxc5kgxPWR
dY1ha4p7Kb8FHFcR6lgAGbznovCsgeBlBpvCtC5urd+ChzfTu23vHB9hS/vuLWqtwiz/nkCDLz7+
kka9eyKc0/y5o0JIGHlAAAABPgGfS3RDfwA0KF2ISAFuoDUSHdzEU12sl4PUJTJdx9t5y1TP/nn6
wBQiNxHSl2YbIUFqwscTZYIX/Zq1cSvTbr580Ng+t223WWRyJ0K/r+4AKs2i1dsHLoFTpIfeRRUQ
LZs8uYJ0o4uZkMXy6z66uIXuo527tMAbfoTqifOQzjUdTJR3w9iBOmV/CB850i8iA/avPpnVyS7L
Exoj+V1Ha1krXEPFI+jws5qNpv0qB+UOM8ONtOKxGqyr6bNCouEtMoNFX69LeDFIs9GDm/i++8RB
eHXj0vXdfUD9AZKH+Er4c5//XPehQ2MmbMwqMXj4r0+VC83fTC5vmp8uAMcckzJyO2lIRHwLPR8i
OQ2m2xKhJ/VcUZANJBecoNcCZFwZc8xFwPis0bjju4B6MMFOo8tzMYz1HqImRs0jTXqSsQAAARUB
n01qQ38ANLM3lEgBbqAzkAUCHB1h2BpnWoqBlpxPo/KnO5vpBobBtbTRJkvy5quoJ4KxtIjwQTG7
S//E2sjS0x/+HPoQfaQN4jRcyh4RQzrnK+RFpnkv67n2AMF6SfnYir3p5l2VX5g3p1+OfJy8RMkB
QVf+z5zA86jCbkewV7Gujt539Ur1696ml/XZZxTq9oRMORh74iHUeIBnSwVZPrsUUzVQXkgRdn5e
5FZLQqUm+r/YMkrBIajfvhDdEtBQLV7EnQZ6pjTw+FusVhYOFC7lHJ0vLk+lltgJ6995w29dfjKP
RBvxz5WFNrtv1mrcgE5xjYVKAiKNo/zXnl+pak1jyFENRBvg1DBdyzbWP+gLTHuDAAAE3kGbUkmo
QWiZTAgj//61KoAJgjBcuALBDvzt/WQ+JWwNw/Fcy52zrKcMJlYfcvRUR8znWKYgCyD+PUNsqWaW
CApzYJCCrIQGdxBEpqoSwQCMcEacuDL+jIS9ETiqKwOB0hvxuKt6/+huee40fdMnDfAErQ2aaHe7
495F+XRqhAEY4Vl3rP98fYECAEro2MPMzksO0zFJtPT+/l2K+MsClrUjr2Un8aOD6w3xR72GxMrf
XtwVD3d6TJVbvjld8nGpFdtNH1lp6x1bdDy3qghYTTe0fnv8DcC1pHiT/ox8XHv4Z6wAO3Jn/1cg
9TsUtjNRPz1fkOF06aOpzNwjQDcchlInluSoGHRSQS/IBvTbkgUulTYdSzh28gzj0Fv6HIHnZx1C
bPTG+ur+XNO3GCKkJpMYgf63hD+CGjONgvLCNKLWgaUvD5opsyQegt03+gR9tuDRaSJff0vuerkw
0tDOPXJkhymCrX7kqQk+1WVkU7bv5uG/VEwmenztgNhyF4dAtalwBySOmZLnwMNQkpOCSIXBxidj
9ttIHEz4XzzvzqNCOd7rlRF700uUEfrLNC9sVEUByNcEe01JtNagYqMuejdfYwPggbAy5LwSkDvq
lWTQgNGT38u4ZNnRJ9avWuQoYtLiZ8yXXUm6Tq90sC/dEy7Yq0Fh+bW1C5gmqHt2N4weqtHdDetP
+3au0M9NCtDa9WEt9CvoBmf7AUF7VEk3udSCwle8vjPvJf24zEKlSYTkRLkk5FLF02ytgUZhzJJH
XW3fxM2FNGHz3B24ttHA1mqJZ69IYadaw5u85Hs4kuZBKfHKRtALUfu1DabomZp2QdfWSh4VBxL9
aB1UtfhhUApWoOVKftUUlYE2JqGzqwteX68ouOQaw1z+v9yA0Lj4oENe0scxdtJzXyWm45bTkPha
h06bjiuZURxyjW1cTywCW9qQq7tVNkpXuudp5kmT3p2eQm6sXWAvVGefpt0G8WoiTWRpKC9DC678
uDKx2I7owoL98ekS6KmtrXSwz+EuM+EMg+Gomu0BMmtAK1KcKKkay2NKEuR1ygP+GsCT91iqkZN+
vd3w4mX9UegIqyXkK2sMDgKs+QXOlGbL1Rn5UyN30GCtKmohwlSH3g69P4DEzULAZU15z7Uq7sqy
V56KZcrj8UWbkXS2IjgH0RC5Pop/RAhofk1oAM0pRmcn8+zXz5jxLdPL5tv6dyRfJeENTHEZ1iP0
YP9gM6OiN9zvC5Wva6QBXJacHIBGZ/MUq1B850ptMYPe5h4AmqcOnvxgn1lzy6hsrfIApltvSqWq
W2+ETRdymwXP6JL0uNjYwKrsAV9Rl9JZGfkpvKJr+Bgm5Mx9N9UujxNcqo+m7kk4pbZMfZmnlFYV
b1ezNc1Tb6LLqwyeHOPfw23FjTRWiUAazoWDRrKna78rOJggKpsYcW9PHdtvkjmNQfpHEs6Sj/Q5
AGfk8ecNfsm1jU97f2VcSPLmeuYLMCjGLTEi6JMrJPrvtdAYDpxLoyziNawRwKpk1TEZ4HEgw32v
gkxXaCSTbd4AsRddeRXSonCrjVtsrt3pe5LKQ2YQdoiWBaaniOkcuL3J0rYMliK8d8SSshozYubE
qSUGciwgISRjxjy29LImQCYKa0c1/+LkzNGFr5fVgDJPsN0uIohxaE7ez8EAAAFEQZ9wRREsO/8A
JRN0voARiZ75+MaAnBr6AXJC8PZR3Le1xhTpdDzuNvnuXGRC5L176wCPI3rg2e2WQQ4dZ8c2xqpP
sMEjsfNotx8ZqVu5lg8GJB+LcHr8bcjfKuzsQL92G31LcR06h7VBoR81ljZsdHk9iTvvp781ZgxB
iBs6RFXdACrME28iq1EedTdONFeY+jpmkXdUXxeAR+ZXN5h1ci2D0m3UQUNDs5dfFxw3dQIY12Pv
Spq0bT1r7iIb0eBOXFrJ54nuzn0Pfr/UP+8n4yc3mNFrJJnV78s2hVFSRjbLH0Gbo/dBMuLxoHyG
pj9P/nRGwrunUxF6im63b7CqGV+UUndCNi/NLClntBGHEyEN/MXUULxqsYLFCioPm1Nik5p5aLAV
ZAs2d68m2NzAkH154BrOENdpywV1Eovb4R7aZORsAAAA+AGfj3RDfwA0J18rgBND5mVjte0NXPtQ
pSnu9B7LAxpdlWJbLDr72o2bePBfiApQ7HcykpFAXmMeAQI6LaHZhIq1SCRkF48Lm+EBcQ7AEd+2
2q5yjSuRZOHk8uDc1WIKBRFuTyZaDr7XHixFGV8afMZRNh1Nu+FVJxwl1+X8gl5sUCaRB4Z1C74S
/Xqcukh5g+iARgt5pIDk/n+H9QzzwQY7FWXIgH3XzbdwDbPRBtyLOW9/icnQqQ6fqPZDhGnI8fBl
fd1Fb6GgZTAuUrGdD7V6u/5iqQyQScQjKAT7w2TkI8U44ByEPbftU2GvL5X/XXKVuiZN1/5eAAAB
CwGfkWpDfwA055SAEsoCvcN0asjQhJdOfDqiQJ7ACLHpadTnlTsBNpakN4w1lu+lWSfyPWdGiBp5
3OEV6d9siQI6qn7OojX1FzEnSD1gzgi2FMzHe6AGzixqF6Qww/Qsxl0jKb1fz2JDHHf0cOuaXqof
e7FbmZaiKx6ksSbomS6czAFctlT7B5YTF7qAuHePMbl/Is/fEWakeI6SEP61EN5RtvwQzWTMr8B1
lvnwgAShMDYxIzezZOAe6C8xMuY+gFvRLDRyb/5lVvKSIEsQH487FB5Kppr+snHu23bpVhnOJfV8
tAUPfVgw34Yfwz87q/XBC3dmuHU2flDr+i9O9wsmHOJTvBCaEU7OgQAABMlBm5ZJqEFsmUwII//+
tSqACcN4NwCgH1Ni2dIR772m6Qlhoy4q6/Wtek1I7ts3M3axEIi+jlEasWkH3kTBVBzA6M6Ft39J
ZSO4ifpyMJV4VQeFGbECOG1Q0uqVJ2uBgboAJdxzx3xMre/PwQgjzvNjQLFMZ9N6uad9GrGQcadF
Qem/oVO0A6x0BfCbgp4v1oN6Rf1DQbG08tvjMdAK/rfpkSGJl5GcfqRYCL2WqrTrbReT7HdJdpB6
P9vpqS8JhaJlC6lerA7vzN7fOWRGykjV2G3AvKATAg/w7UKM3BI84RJRaF9IANV6XJO0K77RFrMq
dCphMXNQVPjYZ6RbpOK3BeoTeL3IL4iMH/SUu0LzoBy3OH63B/1j5VB0B+FoXmF2D1xSHmbVe+Ky
lqZcLtScRR5LrsjcL+hWlgW9OgzVd2NY7rpehffoC6A9nx9fxCTFNGwVd7/pci3AQiiZuWu/WshD
3XTKICso2j7+3f32WN7O6RofNUZqroLif8AWP9qrtWnAzysYnfmrRUxj+VUrI8x3Y94lI2ge6Vvt
2XmCIu7qyP+qq9fobwjn7eSjVBTMsbvb6+5LR2UaCdghB1oepP6clcdLHI2sY3u1SL7OI9emFtqc
f2Scnc37CIj+NkFYX+WebZ7WHT7DeOddQxvRBgtaswuHNm4gP9rUwnHWfanE3wrbQvXHGMvu3pCx
LiQ/Mljpyl5cnFLlkc0Hpqtpf+bXQpqvVh18YD2cPHGsqpxRJaOPlv5FfexM6Q9BL7tM82IZp15N
xwboX4r12sN/uOneeRsSaC53ZZj94ro7S3AMQVjq9oXLpbXFLWED4Gf/pJ5rddDfi8T215Y5tqku
D4R8UiUAU63+cAXrip3vMHbjENWSbt0tIHt2WiESnp9WM0eOuPjB2MSrWKIO6O/sfT85BBqoeHso
QNVaJLrX26FaAY+qZDfFd/+78ZTsggDLSE40fz0FzEoIxYn062poStldasD03Mv0CXSM3kD+MTU1
bTote+r8bvmnzGpbgk0FlRWAq3dQAJOBc4gC0+P6+PiMhQUIHEB6MO7Lt0hKB7tTWeWcE406Rh4Y
VVavuokE7tx9ijAmoWbMbEAImay2rffCEG9ZVWNY9YBNgoZuRmz+nmKyHrY1WGcjNglEZ0cnkhAn
ke7LGiepc69yftoDFxnuCZl6NabhhkYqJ6JF4mBIUPRGDkfNMPu4K2+G7c7nAwwbwsKWev7J1mjQ
f84p2PPkjZ/k5y+ub8pkjNnR4AIQ27JfsTcGd7QeUnUifTB/oKwyOMrCc3p7CAUp3eCE3f8mIbwz
PdNfLpabesxeBXml06b7gsslUMwXaxP4TX3kj32dsaV+Vq7vjGxNHlTcPoYj60fhcbVRwZR6Nd/Y
E3LuBB5xlj8m2FN7Sy/i6j6wVBc1Q3rF3wvE72gnQyYlS0SxYMoCkhVRfXxSqSc2E14LNEuhIItp
rJwdSQr7fWFqNG/02okjMoLOz1ESCumXChMsMw5WBIVoUW0PD92uzkEBNDDAcJZXFbRVZcI3lbm4
V6CMqOgzisaJBIvvDkilFcihnm3zWOuxk3qXxWsnzxcnmjBa9HN2fk9HF/2frQnSPrBziPYwgH0y
fLA3P541lIndi6nC9FQMAAABNEGftEUVLDv/ACYOTXg4ANzs9fcklp2orwAlvgr7GYOTlXS83w2N
wCmn4Q7xtVOn33gSRk9og7pBez2PbqxZ/VM87jgdQmCibFimXsAjkCgZDy6Q2CK3mduVztIPnkbB
D5MzhdhpWCUHC+fml/rALCTvB/IPYwWXNANR9sh+gG9EpumljEBy1vIzlTCn/yzN2zVBcKBaRwvn
7U2l6x/64mC64Z6JwXM3GdwPD3CtJe49erMOukuuIOvOT/sBmlUHFJ3HrLvB9+ezgCun+AXeYK7C
WK/rs6c3LIiVU9koyoKy3rs60nZVrGZXeM8N/5oQgzrz5LYPwDcjBIDLliShY6TjZ+lVSJKkja0R
CIo/J0Zet73LezTnPTA6H0vqsiPJA8fEHRnhxYTUJsbfOIz+pfXPl1RAAAABDgGf03RDfwA2CElN
2gAXPvWZtoSIcxGCemaI/y5OFi+1uCHEiiIp+A2BODSHZQa9USGAeJP5m4Z1umoOVZD/7wQ4fdn2
NCcm2RNeNUD6YiVc6C6UGeZ5gXhR9blHszTU7QqtsB675ot4pzHNod2TbSWoSlz5RYNQvHB+jnJi
wbMXElCahs3qUuyVY+cwjDnwWBFiebTSyu7HWA80mopqTF58AIJZMVT7o6URgEQSSAyTuDRfUJ6q
aCZL1Id0kbX69UhOByhwbQABE2+xhr7PlEixGI8VDA/KKecBImmgT/HVyyJebYULyr2LdfN1VaRT
6YZUPzd+p5sndb5EslVDA/3ADQPzppJy2P4SzXNLLwAAAP4Bn9VqQ38ANOeUgBLFq5gk/tNE6Phr
UBxHdUQ4G/fR+Gkc9DNp82CIUZ1J4yZuj4gP+rCB1JGYW7H4xmlPY8cxkeTLAOSoRBfpvo/zjiZ0
Hy3geCLD4oUG7p5ej1cCRjgsxRml4efMzzwji8jHHQKO85Jy3k8pd3UVbGyBNiiG2hR8sHzVLz+f
13loSrNXZJ0m++WI1xKBT9ipHoDAfnrJUkX5u4knaiRps8N6NVIShAbAPZP0UW+2wHBb/vkh3Dkp
DOxGBqbMHhee7we86J+88g/YKLsF+R/w3G2QQSAOguiNZ0hCndam4vR0Vo6KHAKM9/Vn5fJZjuPy
yOesgAAAA41Bm9pJqEFsmUwII//+tSqACYVj3ZcAdFJYuLdvMOQ7t6HRhbgQP377v/EcbO7+LH+e
9x/gwZP3unM9i2ewlFDraD1aFaYhOH+wHx3ysPE0m/LRJuPhFI9Ure0IWWt42+vEgrN6eiP6xE9a
r2fdpRzAKDTY/iLeBww91WjKjG1tQfo45AU53nShQUWuwTekIl0uVNP0ZRpxDcR+zWLVO8fIdzWL
1ogrLuAH9sbb9W1Vwf3nrZjs30H1/rEq0jnSIzpVdlkEZNvwXcqFJWLURkpPmDt76BxbZ2n92154
ezgsyO5XGMuyTHxtc35bWAgDsqSx7tuf6Zs3VFJ0FsBMh88p6xzOONSgwQFgDkOxkLaOuYvKXazc
fZIjHuZ7ACQJMCdkPweliUFpeZ37OscKZ/ePFMODdKjd4TaIttNeX4v3Lv51L57/kKlNHZx5pvyv
5KBei74AUDd/hD1BipxiEmQqhXTWpysiPh0oqWVyCSQs85IG+i9SVjSr9/kAKorSKolbFvBk9ouC
ekUb16fmD1vpqU3M6WjjsGEASHzzPqOU+SimL5tchp9JwSNqupZGSBAP4Z7GltEYzDI374WBAK5C
4PWbPM8jJxBoaF/sSv3yeUHOxd5alrTGqdo+aduwASVrRnfkAm4lzL+XJAvey+60VHAxrOlY/yzX
CAAcH+yH0sflH0EOcpzk3WDhrlM8iCS9M6daM8QzLkIIhtXGkU2nVid8Gd5PrD+G7p62DMcDi+jK
yDYGsGyptkUz+befdYqUeAV2upf125xi7JVt67i7sC1dPMcImPqIiHJcMnlMgWGnmcfMIly0kzxx
W8zFXzQOpOtbA66vAda3aMsMYIKVVHivwbGAHd9J5o2+splENKZWF1GgjJ1OvsmkooGxL5tdQ/pA
7kvVhIfthr2Ni2II2xmz6wGnCHZgm7rNppYsq5sKV98h7sqLfiHQSbjUzqxb/Z+pb3IJhhYgWjxu
8/wTegs6StyX5KzrXRLDyASowCSIGshvD1szHE5JgzwOF9Vb7iMFetv1cXx+ZPMN5ulgDlLVCqbG
c2pulB5PfUBWlda3256IUpoLiuOgbhRkiBv9jlzwH3M2VnqdghySx6b85OVe0YyDxHEB+OfzYxf6
7IUCrtYZC3hz01KfBOeJVj7Y+AMG0dibFxHEIDaHcl24AEeEK4KVBCkR+qo9N3B6rscECkaY0QWh
E7E0YDEAAAEqQZ/4RRUsO/8AJSk+gAulCIwQ/p9bcNWedQGjqkkEeEQLI2caPMrfYFyqWWJdeIfK
gxGKKoZ18sxTfTwnOiR3nHDNj1b9MXV1bOYicl7CAOWnzpJZwHuDztNl7ZVcX0r8jyGEVi1/pADw
sMq9fD0tmG2ijHlsCVOBWECvUpBifApaAPBy3ZyBRrjlBBL7RHxkabsCF/NsyWytUlZ3yytUK0za
9Vz0Z34q+Q46gKA0H1zWfq5Zncqe3GGtF9k9gpt/K5flty2VwWyP3cnb9bna0sD5ASL9QhEQQwhH
gh2KwRNzj/sjNuf70OVZR8GwD0fYvkvqMmwx0ROAf9UZSmy15x4aa3wUpq3VP7OMi8Ba9/SBv1Nl
ar4pg3gM2oizGVjEpSmVI7ZD5b0/wQAAAQoBnhd0Q38ANLNZ+uAFun/obPQAVCp0O9cNCkmp2UXm
KTNg7sZjBv/eIXlcIHK9wntPkOgGrkQDrWB/UAbzbFtYl6hEqnSJmsa08nz1/Kb4Zr6YcbZgyn5t
dlaJ74VK0NwhYTB/5Y8n3PzlumQnaAq9KGU5vwX5syoCchrb+kggiZd2A5EmV9fY5PjZ+4xJLVYb
748FfeKtG8/Cib/4QC7pLdcHpsVtIxPvThWYhB5ZoVOJWeaqWqOfp1V1ZLQc5scDd0LrCRtL97kE
kyBW4ai4yUcvYrOW052nl6aE98s8qK43VoMw1S0Vl53LfaxlJEBJjkH4bnN6MdwB0XhQK6ybEeYl
ZL1rCf0DwAAAAQgBnhlqQ38ANMC6JACaa1ml8o0ZRJfFvfcpHC0a7F3KBvwhpHK3DznlHrKPyAYz
7/C7muyWAnpqnRrp9wEvPIMISDjDcD7VxhH9z/WiLiLekCztx//Bef1YijDfmdASZudN3gjdW89A
o29dxRJvQJx8n7fCw2uK+cd7vk2kO0zfwNVkcXwxd1BROV3toSomrS/klPaKbj+YqEZm/kxVtel8
89If+fJVcT3SRwtd88wBxRDoi4ckA5Vvf39T2M34AwPMFAdOR2QvtL5nYUlT2dn85AiH5mPj2MlP
nFaiLBNCOfuj0RlFb1NFyG/opuai9pQJwSdfAHHrhedzqeBEbEdHzl8ELLY514EAAAPzQZoeSahB
bJlMCCP//rUqgAnDeDcAn0Yso+Z9xRwXuViGfiNrNrHSZn/L/mKBl5RuOe8H5jQ1JQww/XTMZ02R
Ac4RSV4W+IwuZ4K0uJi2m5fxond7hmtBc9JLL+8yuuypb/DA9VgaMb3zZ1yr0rqsKBnjnrA7f09C
1WlT9rnMzWVugh7KOJlY10zCoaTQ65OBfuicR9IV/nMcxWvuO509pWNM0J2dNJONkq5+iM8BjaZZ
ZxIrB88LuF3d5YuWzVAT5KWiZJ7Tpj7IPp6XXUWyGSlpgH/h7peFPG1aplKD2Q12OnH/FEjRG6tu
5vXc+Kdr2RBCuhdiaRoeCsClWq6CxA9QjUToeS1FrgD+YjjfeIUbWp7bJPPso3pDFgSffLH55WU1
nICMrCbt1ao+D6EtthfQTZjSMHJVFC8r+zetNoRotm7AStO/xYKYzEtIDo1Wd5/ba0aIPIBGvpvo
cixPkiXB8FB0SLnqUvRDmDiHB5OmIlT8+n+Hj/uzV//0s5bMv4zDhjNORjK59uw9jpthO5in2EbE
97gcs6oagkv4eVazkK8F9Qi5pcrRn8oOzi3b+rjeXqG4/6xiyaneYJ1o4I3fAwBlTp0ZBx0EW/2u
Gs5wpSmytXrZRz7pf5d9DXsOi0iF17B3tOMA7mLF0yIkayYe9PvkSU9e0JTlEXcwyUirQXTL5OOb
YrWg0kN3HUOck8RaWkjjICzIAz2fEYc3ICu4iMXUG5Oekqjrn+5d1oqolwPnwJSLS7TmQA3Fp6gs
AIacoFDq0ihkmhdBjYTwno+CSVTk6aY0mcWcilGZqEEsLY6E+xkpdEgsfi6l22977XNFwbLmsZE+
GKwat6bbTU3JjrD9/FegYwDFCjW3dsF8RiWDEuXHTDPMlhjxMUM+b7LfhqZfNY5Vv2eG8WJf2uqV
Mc5F7dkE7b4glYujTLljrmpPoX4WlBKB1bnZ4C8TCH+XN1JfUIY+0OYlPzlGPjvRRkk5GuzJf5ot
iH4PdIkQ3oyC34XyMk5z5CyvefhlkfyxpTzkfiI+cdD+4QPEX2SepFcBxadRacyJ3jNxIaBbWh5k
zgqz1XJOlwc1n/W3imK0UrwfnoEQFX9yH+3fPXAiMfN9o58xwx1gnuErbkRvUkZwaXra7Ws6wFZw
gXNIOASg9N4AUuhI8p1eAD3gKgKJJL9NdVJ+bt4urO/sc8BZLk/S8NnNwdBqZN8/FQsms8sEZmq8
ZoIxhQGWNmsqv8O7PsF5xWKq6zTde0wsXGMGA0Pj+CmiqoKAtewSI36o3eQI7PcGhj7+JVuXt4Ch
e6QlqEqpD7mrCTTvXV7eFdJlBHp1Tk8unHP6NUyCwfwuVNuAAAABIUGePEUVLDv/ACYR/rwcAEJN
MVHyfMF79bgI2Nl5Tg23NWvmetRIrozpcSeuQmV2dBMZ0Yy+HZIVNC1+0r9Pct6LD4opIyfqhD4a
iUWZ8rHX48kZ2oCU4MGyv1Rst/4IEaeSzTF9BXOSrh4MC3U0CETqHdbs9S0W0bVHJ5/Wmym5yvcw
GsftLZU5mGoC0e4mGbOhpMRTnS/vI+y54OLespOLQINDJ+IcmgGT2/iWXBbJzVfAHFd8OKz0ZSkH
4Gq7w3vqLl5Rrl+2jTyPwTb9H0QJ1pkchxQiUPPHMYE7eRINRYSf5zZ0wuYjDgC380hu1LKRF4Ff
P6VxNz2k/cqUTecCOe7zHGcJ1k1g5VmOwAcd8jh/kyM1/joMivYxh5Sl1lcAAAD1AZ5bdEN/ADS9
wOgAXSgEK47h6t1ldgGBClXiUyjg9t8D5jc5KzOjgVNqwNiim1Vigj2/ZCcJbQ3Cn9NEdr93ubin
U7SoaytzAHDkB3tYyaOMzq8tGiY802uslzlXQFv/b9ecedS0jc7x6uG9oUmOKe+P8LhFFCVcveSd
paF1FZmVCEEUKWgnn8+aMdVSX97AUUnPc/W+2lxVFMNDgvRd3BwHoPd6FBDDYNfvhRHQR4EdFCH1
3lntOnDp9COLD0i1jQvMrgJIzbH1d0+nDtalBe0EeHqH0TTDaxDyVTQUpp5LrLzEs8Ea32WF/aBv
yBjAIj2rQ8EAAADeAZ5dakN/ADYKaLHtAAufeXe2hIjdSNP91JrH8jaqFbXNl/gc/CNQaJg0efRv
+kpx3R7orygF5jVEckx01uLXI//3ZutoY0x3DueTcQ4Lf9zFTr4aI8Anam4E1eyRg1Rm9yWNJ7E1
wZXSsA4KctuHDqRk9B0XC+hdOM13mmHPsJKk5c548A5aXAxCe7j3lpWogy+32Gzp/v81WgaldKKZ
FpVZ8BGvqMoEaJuNN1aqdm7VIBT9+9VZ5Nxanc93uR/BD/I9Aj6nn8IRL52dEuOxGLDHB/Av3GHQ
mFGqoX1gAAADMkGaQkmoQWyZTAgj//61KoAJgXeSnwWQwA1I21lu8er97Ow3Pr4Uqu9gKROPEjgQ
syAu7sF4+qUWBqySQgU1d2fSnc8b+vDr3y+ldeaQH+x2o/3mr+OzBmd5bYHS8WTgM0XVZvm0TxBS
eNjv78eEvZepPfO239KJH2itmkrM1xl4xdhH0wF+YepVQLKFnNbACcuaV+YjCmHuCzva/UTwCkUc
KFSV7qIhfWvR8c6nwmin2pMvF+ODtTr2wRw4y2WXBClElk/4sdRxQvWZNFXGpGp2e1U4WUU6DOjx
ntiyS9+5rd3Al6vmA36vxH9Nkm7aCRdkde7+HGI3qFQuu4j/6cREeSuEm0hcpm/LBqA2xGj3/O/Y
pp/CRrvptTfvuIVnWBA8ZSrDg6CBiWIbHgsdG3JJDVfluRBYhubeLBPN0DQz9/y5SUXm9C5mqgG1
BC3I/eo88YfUXN/XTLiW9F3oxJBul0rcaYafqq+P8UIZZTJ4hqNlINURTVwFhzULIHZPrsCYXD0J
7+KbItKYhiz2/XKQA6Jvb1S2FDPw65NGyVXGyBVosuCQmd/H5QrcRJaSeVh+sH8Gv9eMJrULw/q7
GctJ29Bil2BBtayUo/dFzCJXddLwR2aErIYbfpFz0WOsrOmhphneE+e0Z8rysqhppxtf9IoBp/Lv
M79pOAHSbtaqofcplp/CfQmWmnV9e+Ld7tgo2mOzxAtD3mWQoIH1FcelmwYSmlE4sFacY7LqbR28
Nvhw9h3eXuCUTflGpSNNI3+Bpmx57W1yUrZ3ypJcEJJbu5J44V6FRBRbIy+vh3FsY4d1ABJn3M48
ryPlbaTfUNnu6RpC9RZTiI6rM6sdg6B2cqUkxnYDqKLjM9ZoOVyBHxd373/oXVBgTLXVTUlLLorW
mwa9yWR4x0W6f45u1WREvvrpeCeWTLqqgcLeXi9MMYXC/5Z49MpZZ9FI36I5csR6e4dic4LsVd7F
lz+jGDk23/xw4kFA1EkXCk+PIou8aGshhNlfdUp7p4kcB5nbqVFMJPFAkdmVg1Lo9qGdWReZ7NDw
1oiYWxFNkswXwRQdlrsaPZtSrT9NWrxBBVnzqb7AAAABIkGeYEUVLDv/ACTG7e7YAbog0lg53RJy
AI9OanY3B1PS6svzsWH/PkwjMq3m2oX/t/+omNHabB+glC0uWYOHl69DEqtHMUMW1cLQPxj7Zcwe
jrZsJfD+uFWDtGc29+W+bwJq4msOogMqRrOimgFwyRo89olgYIY9KVgHJLXTqDQMxVV1ysqTL1E/
ziMQWl2tR9Z/1KOJKEDI3J+clKJ6ZJSlmXcR99egMMuF/Q/E/n/E0XrcAKoxCoCilsX9nRrSz9xU
Z50+3oDZihQd1m2phEnk2/z0BMlHqTzj38sppA1Fxw/Kk0nV+HYfiL8XoG9DH8DX2oI586FvpFoe
vfACJjNc2OOEQVdHwP//shzBbGDTCqBdVjwbTgmXrbVpYlcmlPpBAAAAzAGen3RDfwA0KF2ISAFu
oC22nfh6WHL1TEe8/cTyWNvOPs0r8/YmRL/5KU0Ntz2PXrQmmLrPNJ1rcgtm63uVdn+picVYNbZ1
GhAO6nbNLDLQnwZyw3s/Rqpe2Vfwye6AOUeffNHoEvqrEB6oAiR6jn9/vfSUTKFbFVo1PXrYRe2a
xfckllAmPX4ppFqTwvlST7ox/4EMOB+zD8h2/r/ydUWj6Xly4b7qRaxy19xiciVt1ih2TADglPB2
Nm0z0LniSpxRWBjhUCHqSX3ioAAAALIBnoFqQ38ANKhw3XAC3T/0NnyY8aV4ivXDrQN83Gf0vyFo
1g2R+Df55GYrHAcXtT7N5PJ7MU6vTp0kewrTrE1CL78OhdQOZHA7cbOrv6ERZMDNREwhnq69/2hF
SZgMf0v/kEv2mC3PO33Ss/v4LenIh7VKpy18RmRE2zPdMxYE649mzB2RhI5ayN15yFqSBvXPWm0D
pP+vw6S06+hL3uz/KqUPEG89YII6orVPp2pcFp9ZAAADTEGahkmoQWyZTAgj//61KoAJgjBcuAOi
fTe+/F6vpsflUxXkfTobZ2DWbbVRLCbPVeT7pqu1hfFLHfU/E1fuzf2nfehO8zzG0AEigdjzQkTG
D8F9luEGUYOXBpuiizRKNVQwJ97U5SnQAp5m3m9BaNVBJObu4URTq4VkGDJEuP8IYsgS32oAuRB+
NvP3AHTE3To/VnIkwLUGn5RcEo87SD4P+3bjglXKnTzS9KIVVsJ084VRN80S97ZkzHbMb19PI6Kv
PPrPf60fZxXmBPt+V2lRv1u7g08JfW4fz2uVYGASi2dJLVTjgDetBTCNW5IVxahWI4xHmXJD+o4U
Elyp0orgU38Uz4K63qp1eyCCJKPoQTBODfkisliCXlkkw+nWooOe8sMVSAD4hz7RPyMbzg8pxxiF
4CLWf/iOtCzEwxk4CX8hIiTBEMXZNusDDIbPxEIwUslTaNb//P7TPq0BsPT/Pke70vvO8s2JAMy0
lvN0F5CJVoetg2W9NjDvc4+EjvZbjO+Hyl2jdNIjNbbws5820suwM6J0ohBeAYgfsFeFZJ7zoPX5
3S3nP3rlNL0p5q1hvYakDoM0YOwYMGIG6tQUxhzuFENTxnPHmPXJ7hwS3ccyppYA8RTQVgXZdX+f
tbUIki8tD+UmO0z0wNojoF01UyabYyTc+jcSXekPIRglvXhddX2w01erEWzevv6D10rmGLGnX/nB
/P1clvefRTs6r3I2w5CcgiXV4CUlFkuehDfMPJ5cR0rxYLBTTPuNt8qdtgtBSIK72TJtFJmThZ0u
raKPUu7uNkItvBnHJ7DzlZdvSIDL3du0qY0600OdGiA/uvZIsshG5i1RoD05jMOuXnaqGyJVt6hQ
L0birH9fabTdF7A9jtAqzLNQCoMMTtf+lc4aWGgGG8HqCvN7hMv3Ze6ATf5+yO5HTipdjD/h2Lib
zzXcA7M4RMlOE3ztCIE2jsHOp3m7C0ImIDfVxIUP/jJTqM1PXrQuHMzWBzN10WTmfvAyWOk5fAkv
JsqwpzYLyf6/KLwYxYFUU5erCfc76C9GLLebxtqMMoUrA1P8pYFs1cjiI4n+c58/CEF1NKUEO0mt
RDr/GP7FqsSbw714srwHPrHmaz0tT3AAAAEeQZ6kRRUsO/8AJRN0voARiZaAgjGzh+7dzCiGvTXt
SqsjmdLoedxq3VTztKv3T9fm5xRrV2lzkDnzYndRbj5Vd9v108rwFNBX2+se2Xn9KbX8fvJAnXZn
wIiq9dwKfFrB8WoLhMh+lKF+ra4nJB3esP290DHxDr4Ds0yI5Sm0mRqkzM+lgmp1dKztU/Y6AfZY
W9cBFSzcE/MfXSZkj38z/zTWjVdh/YcoCwxseNAIKtXbe6e1rVPVBExUDrACISrqxbnaXaE9n8uG
Zg3ob9snUQNezvnI2DUAxuf0S+aHNnHA/f5xpqRu330mTD/xetCGiXayZ519yWU/jbulUl5UWLQe
H4Ev0qlxdhGwDk5GVR0r9eZPOl7U3lemgjfiCQAAALYBnsN0Q38ANL3A6ABOtay4KdjIMl12t0MO
HH85y6SiqpuOEoUz8yNw903iH4DgI9A0wipNbpsJoKUM4r/SN0MtgAfk8fvBulY4BqADZoCIEMlx
0KdIymB49rtza6q8ggXflBdQE2AdZLOfKRF+xfiWeojXuBSUhGhOECtyTdIcTbWElayKnrfMQHaj
xtQPFYi+VGWetJ2tgsyGEeQmzAT2pChm2OowG1khHzYz+ltT+mnSd0w94QAAAL8BnsVqQ38ANLkl
CUgBLJ9f51+bcngXmWZOc/z51mg8Vj0T5TBM/EQ984hjYBn61l7tiwfhAr4zyJogqCTzGxZvgVWm
RzH9t/rDTBhKElxl/RhCpH5fogHGDB4/kNRyJTjAvTZ08h2hIM1Y5BVhEz+k64vhLh/yD8kLWmMW
h8G+0SCPQR5Bo69A3YkkD2rayd4eFTY+SUowb35peGGBOgencEi5Lkzrv4iQYXvf77YO3VHIVYnu
U7ONo0/lm/DdEQAAAuRBmspJqEFsmUwII//+tSqACcgOJQAmlVTHrYP30IW1RGoSFsHpAm9iCOZT
W/m4uxDxMzEo7edVI5PGVqf8yaYdB2hiNbRL/5dowugwq8T9PQGMFl01Amof5By9JtLPk7ug4qYK
sEzNujvwrH9bpZ9gtRkrC0PABKDV4JwfJIm1opPNHFd4XL5yk2xXLaYrsrxHCxjiZvtlGcOz5ite
FXcVk4CbnJN+CDX6HH2u3KOJQ03lm4tYpaxNIf+uhC/TkA6r1TXyxf/GDol2/ji/KjBVFHBPJAC7
moJBUYQgR01p6e05NYSETs/QpXUGLtoDNkZn7wekLzfU5aCFjqD/Rc8wRZrLreg7QMYH77bQq7mg
hOeEDuy9AoXA49YO9CDSlZDdgqjp8nOoFw/5RLG1AO2ufvvEONWbOZ0xv6hjuSVj3a1YNJvoScZc
VNQT39HFyPwCxdxWceAiCZ7OdmACSUkHK34oOHeMqCG+6bJAJxmkV55SDEItTm58G29JDiS14MP+
Ud/AdPv4VEEf82MCHLVKarOQZgio/zUK/EDjMhVR3tiVwUoSnbP3XKOF6L2PJLz0k8ggVzNCiEPu
F/k9nhr1fuzPsULfVaxea+WSjqLgFvHn5jjU+CuLwQm/+IwZqNf9GZ6n3Vqpm2h5BJRUHm0i4eyw
Wl8g3zT7lHt3wkHcbJ8bScpwtspAiNq6tPEEIFfZCs8EJZMj65VIrCYnkaXIB6tP2bk0jtMnGIBa
UIHqk5Y9SSnCegnxv/8CVTGouf7STVoS+Hco8NLwlYA50IPwO3MT6Iwo91d1VpkvtQv5Ca+zZ1bM
f2mN+ENaC37pP20Dr9tKxQ2JhqH33m3E0j+j5+bQFkoDjMSdZOM3LaySoJG0gkjdZQGt2JtqcvKp
8A4Nn26yEvnHsaebxdGFxHJTsOd1Gz1EZ7LPiqqBF5tGThu0iEkVRzoFvQYg+4xQVmvYfKURwZD6
jqjGW8Xue8AVZ17J4wAAAEVBnuhFFSw7/wAmDkm7Vw91iLIE2i30Pg4ronrr9IHCfOHC4zlhuD5S
LZrUT11sxuaOs5JdUv/AduGIUcIsPnRckVgYp0AAAACYAZ8HdEN/ADYISU3aABc+88G+HGYZpejf
P7kdEbVZBSS7qwL5O5FlbgBANaLzdVMHh7dtMlRB7b1dPZ0rBriWP8RsOCFvte7VvKA4IQjCmFMb
aqdNnCqlHvyRTKqyag0Io8Az5l2EyXuvxDnQc+qNHyGK8b7eWC9gzPLdZOFoonNEJP3XXn/m8WhB
5InksDYYxXjwyG24cbAAAAAcAZ8JakN/AAtb0Hkdz+BwGfCCbZ2QQBjAel4Z4QAAADVBmw5JqEFs
mUwII//+tSqAA6T2soBXnwBsyTGJi1Qi36M5lpl6c/rudP5TF337Ks7sOu4UwAAAAClBnyxFFSw7
/wAH0Iz0acD/j1r4zcXI4VHCl3xKPLblwvzyTvajj00HxAAAABwBn0t0Q38AC1ne7LObVK6swgm4
dfGOyz3qCQ15AAAAHAGfTWpDfwALW9B5Hc/gcBnwgm2dkEAYwHpeGeEAAAAwQZtSSahBbJlMCCP/
/rUqgAOk9rKAVs8vMzSeY0SB3ujDTVijR760dDAx2yQQwCrpAAAAKEGfcEUVLDv/AAfQjTbiOfns
uvh73hn+vHuWuWuUVgqlBcgjMiJGDxgAAAAeAZ+PdEN/AAtZ3uyzm1SurMIJuHXyGy5RhvIleMiA
AAAAHAGfkWpDfwALW9B5Hc/gcBnwgm2dkEAYwHpeGeEAAALQQZuWSahBbJlMCCP//rUqgAnDeDcA
n3J88ELMlPcum/HZE2Y0kBBIq1gcir0F0jJFQLFfoxyH5EqxfieNj9mfQo2DPotPUb25Ie3RmTsq
MwxHMxS2c7qTsNhdSPMMPAhMDObONfDxX9LT1lXCFcTacUxLUdnZygzH9K06Fehuga7fVPNU6qNz
1FDlYFQXg7a1G5Ty8McHfBQln3FRgO/I+v5ZAF2xyIERR/9retvFXut1orJZzUzA/YK8PQ8oL6aQ
/0m7z4J5nrSL9ilnhu0WKn1WDOzItalIq1Jod8CjtZR2pS1PQxdbP14tnUyUSzCXKOmDVzeui8ok
PUqi0eCQVLLwoPyLCgskuTDwumKvxgNTNDlnrb3nf6YrY86oz6HWEJUsgY+TiPK/kmuhfFrgKM/3
sTIMgkdVZW2/9MKchIXHPJkRVlGgRUacui26lOmooDth2zubV4o1FNkETMSyjnnI9fqeQnVCDlI/
KZqHHBzcWQETC80aFBEqIOvGCNvJ2D48GYrqnG39rW170UnM6F4UnW5jS6tQV2kLWU/F8NYFwOns
zr8FTXdQuAVItUluWYTdzz1AN232umLmo3/rpp2QxNAapkg4I6Gs/n+eXAaJvRfYDUp+9lzquMJs
Y8+SJHoiTlECFS6od8cS7AE0d2cQFb1Ep2hNMuL6Z54Tl41wlWigxsx6gBVUq7KJkXuAI2WyJE3d
rjT7/eeMFTHb7tF0TCN9fQrccwSvtBkBkScISC5ZVejYxIWAXFL/0zeikizexmGEo/l2UD9/d9gP
2UaH+0xJeeG/Y63YlwrrbD1WqEEyCDn3GUYWA3LyUpwKEGRGQdoXMdE9v1FPnjWCWRhESXbc7ylP
PKjLIhpGuYe+2U9AGy+r4nAJwd5HH7elRx9YuNpRn0+jTeMp6VXl49ETG3iTJBUlZKDtC5FDGKjt
Uif5pFbWfnqL+3U8B8NcAAAA8UGftEUVLDv/ACYOSw/egAh4Vw+SU02jkGwRmNFKjwS7X0akA8Ve
wL8jwro+oxop1dTfb4gpFNnFeBNJNyakeq8elsUbpGxvwQ5hslLvSRCe4iBUUQJJDWZQxPdQ14v2
jDZumTNVPMukEJNJzdazE3VpseeRoBR2bgIWyHWCGLBGMYb5qsrsq8ET0K26MAUEhkmAOCQxdFmY
M1k5p7uZDJeByG0DBbYAIP5cuW8Hr9CTndWZADUuuUusoiDTzLXtJT21lS4TbYdVKHavkbS//GxH
e0CCjigHDG3hdjBTDtvEPtW0fejVZhRhAu1pp2RBoIAAAAChAZ/TdEN/ADYCo0aCQAlfeeDfDjMM
0vRvn9yJh8V9TZiXyWRWTDuCjtKEo/OvAsI9Eta72qw2CoqaG5tZssMu1//sJ3BkSJkQshyUXcYh
QRok8RX8CBmmEp37OWpnrz8IBPrSJ7/bxn+BknZ3Rng1JbMCUBk3lUDlXS8Um9ZDGCm9v3UdxOJK
07e+kY9Cee7gVvyoJw5vcZzU975fBYs/YVMAAAC1AZ/VakN/ADTGKRIAW6gH8QOjLaZis6vh2iWe
e+rcfiePmNzU/LWJzaWUn9A62XngB/v2QoaSdKhy+EWDCpc/hrNCJXm5+dh14ftEW5irVIFsIrPQ
iWpBCUzHLGk3dkOE4umq/iumONiBpJJrMv7RxjKYep4BYPgO9QRGPxRQ149UBEAPINTSxNSUX6pl
7rWbBBNqVwLJo8s0bix2KG0AtlbMuO1vV9QeJup1QLRnCvmlOuw9QAAAArpBm9pJqEFsmUwII//+
tSqACYIwXLgBxbhi5yfT9AQS32zyEZpbr6kQ+T7czR8vquQ3jdGNin+tV+rVovinRLA/qKu50RgB
u8d1fp7ShLM+C4YJ707Oae/ECOAPEXdWlqHnnqAH7Utqo6hpZ6Dd+ihm3TVshS0RPkeO2x54e/jx
+TZ8sEcdRehi3jDMK6kHMoFwMAOwbVnHp1Ed89M/J/WlLc2JdL8k7qkoV6yNW/n50cigNv/ixcNV
PU/rWcaE5ecOvS8K71Bfqx6+yIVllyitEWtBzgX1ibJq4BHhrABCyCW8eZ2JFBWrxJVH3EENuPsV
FC32C/oYx9tPLsdUU28c8PjHWWdoE+Hj956dufX8YAxraijE8CFLl1ZeVsLuU6Rn58xNk9ypVvgF
X7xf8/OgoKCl9/HyODEGPX67q9oXgftMkJake284TkbA8n2XEgm37B2Wikx+UjlinpxaUkmYqu3l
7biig0LEN3crnWsOQBIGrPVmng17f4WrTUWOTDyrBD4eCgfbDoumFQTQdM1pB+Nqg2c25uaAl5Bh
9wqL8CXLzdtZHbRLe59+JulNDV7YW/ifTZgoB5xpPBdD6D0zK37O4DbhZLuHel9LahUg9AFi32pb
xk/Qc26cxF7jBOSVIXIids1rCcnRz74A3/H9zn9U7ACgj0Qaw/ojslhRHIz5xxOqEBKq/IZQf/mg
HZmUDFF9049VFTfuXJ/qHMuzS46jKbOTs0hyjrq68FX4ytRE4Iwj2tUklc/s8IU+MfVVEE5hgEMf
UxtLECrHkWiGzsLm59bGoq68JvqyBjlJm3e39qq1rxNqKF4k4mUbDGRDlHWUvZtpP/Bxlfg2c+Hs
ekvDM1TggOzl+tnOzEP9bleEAvb4RY8n9y5wdaPgOLaXsHNhNQnumPnbLT76jlUcs35uO/jYyDS6
QQAAATdBn/hFFSw7/wAlKT6AC6UH3SH9PrboMAKZTh5mHGsHlJMraQ4nxrPdDsfV60rVuHNgnoLD
M9EOnJJ0kuCyTmBWNET6G2+enVHTouK4elCAbI8uDGwdEdRXBQmKydkZbjxnJExiNu3WAj1tXMHS
0tPIM32/rwve/qZpoN/zgyuZpTcOmBikBxwcQLZ4c9rfl8MycRaC4peMsVSfSK74w4yuFR+MCk6r
sYcPSoUY6al/wiuwMErEgG/fy4DrqJHz5CNqmRUIuAQ89FQP0N+HL14oNb3xHMARHYgWYPkEu6z7
vMif1n4bNZMFgVbgSlIXKa49RwZKd+rRqfiUgzTSpTyHJbt+QkJogPaQKKizdNQ8CEFgeemTHfLS
CwjtsAhODn8Rfsqz80CI4EHiIw+zWG/l5+nDrFv5UQAAALYBnhd0Q38ANLNZ+uAE01hBYqvNnki9
NjrQeKiGUZ/1SXuCxSJUqlcMUHs9D1PgxHIS9U1dyrBHHo+DZ8MZrExEsVx7LjnoEkcWJiwhAbKy
XpimuwCbVXIzwLD5iOEQ916xbWipmUMpjwX0Wq+sp2Gj/nsKO9nVnntv27WcnFYS9JCYSnSweDJj
CTplIaXohwbMuA6S7jKJMX0jBNDbTirL4EfUsCCb34yydQXUMtlZws3ZVi7c0AAAAMMBnhlqQ38A
NK3XOuAFun/ocWIH0XHDp9cDqseY6e/3isu4HOyKK474xnQUzIwNWrnwG5U0TWAiUnF45/pHFJHu
86ECsYECuBA1v7I1e62N5rolUdNuLHx13YqtY2/+8CZWcDqTlFGs+w7AiVzwKN2tKs1lHC5QKeDS
UPUxcqy81uWgaLRyE12YKQpOyXDyGdgMVdoAuDXZ98OrFuCV85bLuzNlTaggLDF5uZSLe7Uv77g8
w9HuZFahS1FEer/KWH+PvYEAAAMPQZoeSahBbJlMCCP//rUqgAnDeDcAdE5Hm7mG4yXqIcC9mBuH
FK7j1E0yb0KRLnGU3tbuYgSg0Nn5yWZ5T17hZDzetW3zFPxNQD2ZS7y9hXafL8f8g8kiRvGtUVTZ
6SO6LqsGwjpEUMFCYmUUHt5YsDfnWNLAy8WtWh26XSnqsP2/i4dsce6SgC/0/DfyauxtXsH5v6Fj
RWfecJGSEOMiRNwUOOHYCXzgT7H97izzK8JU/1+CD2O20S+4z2xRPYL5/LbTjZ0tZE/xsE0mVqZB
o0weX2b/lgbMiWvHiX/qDzHgpyjNif+E972P+WH43qQh5vFxkJvrMU62WiPEdT0zcKY9l38KzxUN
Lt1hMs6YFi9CtuI3I7D+0o6Fm7PDl+u3E+OiKOTdmZIgycSZ/zA9QVxPSncj0do6Gln0iVy0J+PW
wrWlgpOnxk2V8QqSmnwXLRDIkYWhFrvQxlw5VKAl6WmFinmqUuyDxxODWKO/uO/t/mDJh3LOQ5WN
kOaMHULnLL0xltLvvtOUsJWk0woQwftou/LAatWMj2XqTfjnJXSnBjrliada+aqAEl2rUd56z5SU
dU/IhYGGJaLa2TxGkGLB1fI9dfKmqgB+kqYtQ9bhbm89bmC8V58GagvPpXlczxho4M5qDJy4/t1z
UrmJpGeSZPgLy5rMGHWwmWI1Rt79LzDLwuI5UoXS0+ya/NCDevV3K19l24HamXhDXVfJv+Px9wxd
N6uF1xlAm/b+BlGf0iFVngtFLifb+YoZKMPk/zG9SW6pLJNp//9c4ItQOHLgBaqZ59mabXJoUULl
gGWO2iF4y6mwvCXiYNzYmYZNabDQC5UvBCVDuvf5kkcDmK6hBp+ZgT+dshIzLUFhU2Xmo23TDASD
G9otXHMC6pWAM+jJM+G9Gw8GcsIEJUpuudhN04jHcuXkAhWN5LZJMgCR2QmOnUoBYmSqV4F0cTeq
pIbPml34PGLhR1QuihPEr2FLUdc6SBvK6vQYcYFex6RsiUMmlPLPPj6vpidaM0oronry+OstFFY+
DmJva6dIAAABF0GePEUVLDv/ACYR/rwcAG52evuSS07Mw/MorBSKYI5MqdvN8QhVHbbiQKaJi1Yd
sypoZgVLW90DaX8c/ZJQQD3d7SSMQXN75URCOpXp8hAqexZsMWt6Gmzz6rKNhOXOlm0s3ZzlULx7
h1ZoFJoWeKJhsTf194y1Ua8kY2d20XVN+8LvbpSh6Lq8PJ2uVeM4ws1yW9Qx+1TkSmWVotxwhPDj
hvPVHVb509ocvKy9kbqkhyU0jGGD+ZqOyUc0TrvW2Y9NLZ3Q0lYIf6sG4qZWVdbbu2+q5ODeVBe7
GUvpO7O0ARKIOQsHRFgdHYZdW5MuSjAGp4LfPbIexceEplpZntEjjHcCN3v8g5AIqqjp/7aQex/a
dd87SQAAANMBnlt0Q38ANOeUgBLFq5gk/tNFNaw1qA4juqIg9BbHzuBFomO8fKY8kP8eNInX3EY8
ankiyFYaw3S1JgkFws3eY3/B60C6bDvdbiMB2bivqJDo+XAf6wCuZT0DBLWV8C2bIi/ycGihkbWm
q6qU3LzgUghvEFlZ33xKbCMvC04eeAIshV3Fzm1YA11p6G376YVZ3zf9+hjRYICwrm5YQ0SXrcWu
blF5B31UZqC4mcTQbhRQo4q/Fe3VD/jJ8ZYdA8O7b91an7O4N6RF4HkWv+Hk7+5PAAAA2wGeXWpD
fwA2AA0F2gAXPvSz9Ik62swxK6nVchSj1i+iqfQf0Nv/Frf1GSsayI46sOyyjEB33J9c51n9haJV
3fsebJzp8plhEw2iLioP/6QLOIovh2lQht5Ci3Jy//nnb45zkbuDowGpT9RrmMTPefMuQc2PAp/d
jB1S6mtdaxTyTjIwZw5i7MlOPdhx5QK/l9uyMAPvluLXtTjLbATgfr1e/3pZhT0juebrgRvXM3Gu
c8BtckYBxx9lmCbyNiMei2foJj/qULXrKdKOPqgCZ4ubeSlki99TEMGTgAAAAtxBmkJJqEFsmUwI
If/+qlUAEwWrgAAWC2wgS8fgu0jDSZUmhHqhqNF/ZbMj6qn0xD6vl893XwtkuCjjRfia3tmsDe5t
ta82VcKY4z2c5cLml3ojrQi7Xz4LrKJtYy+uNJthMGTyBiB8uWLMGQ747nEK+UwNRoJ8T+/BhYRJ
mZsUYcVSZq4OK3Torn6uEtAFY7ACRBfWGJRiUydy65utFR3BCtCCzO/0nViBEK21nH71Xh/9xRqC
75wsWO/xCfmkfNFyeq2Ro0BwxPzNdJBmbxO1iLAZc9RIqKO3VPfW1Dp3Z82L/Yh0Y8RDh5xYnrno
Iearql3R3GlrXV0ftHqulWhzAYycMCb6UQv0Ko04V7UiNZTfJ+WV7+SXxUe0kwCzg7Bk3966vbhq
mUtBLeBLeCvSClqE+xA8jDkfX9b2Wm/yDTU5sghBzCcrujp/m1vRvTnxscDX8MJvLq80PeIIQWzW
WVC3zkNtDAoQwQvoF2A8r+osC/eHy0NMiA8N8SmzfqhpfzsgxwwO2EwPdXmEDZFMSgHL+qQ3Ynm/
Gh5zcsL1V19AaFg54oF9L4vdoOUb8bzXA6CYibg/zaO3Cl/na8Im3aXfNLR9XPV0l/XrKMKdi5/T
a6nnLLykB14Rt/VzliZ3Cz10/VatlBGh4Jo+JoqFTUX7F97hyd/hg3QnrKab2PYWJXFkLIu6Z2dq
bnrupBtT7kaJrLkUQiqXrwMqFCjb1gZIIZzvZ77NK79KPs29DpqtVVKCot2KTGjb1VegY3/DOeRv
wG3q1iFJZTl+q3bxYHIeOgqBK2RTV3TYOl5qeLNgqqrNaB2fUw12jLCwM9tfXGtkRNW1/l8DGjVS
sA7ZBmfq63gSjTl/e+DN0dLvn8yOLW38RwiQ8s9OtF6/a5WMxjPATW9D2vmLd4rM6wQH7jlkXKHJ
sgZvFOsSF9yOpclOwePaDE8ntKBbCEt6hZgtkKWq4YTMZ4Vye+AAAAEtQZ5gRRUsO/8AJRIu+gBF
+XF7dzVS4ehJAJYj/cOZNgGo2peE2vdnckPe6xZ5CDRyO27AfLpZvpkuofmE1LrA1jf/j3E4l69i
eVzulG2EqUih//Kv+I2/r4ENreu2sXifqTYw21YeFMdFf5ESvq8m3oqvi6nPeFA8MWB/1TUdbZJf
6T4ELCi4WXJcVEQRRkgCfvAyIoO/GRIctm4cgrm+9zNnMHHVtIUb6xYxJSNZ2pyxdCipr1DWhRqn
vdIdMR5HJh0ZSzRSW4xjG1b1aQTeEeziSblcMls3+eIkOaap4VO1VbZkTsHgkfZ2VwcAWGyqRPH2
hLKZNw1nGJPHpC87vvkZMIkkhhCnRkk1EuYiMXxKm+E+DrVpS8p5yHygmjbu5sVc+CK2x5cpyWrb
sQAAAPYBnp90Q38ANLlUCUgBLJ8pTr8265WsW6HhxtDxPMPvFZbW90eWbPxFBkIQMaVxAVTpw7Yr
+6HvNBtplJCyVkzL2z/BlDMzI/Or3mqxTTJJMrZ+ev2WknFvbvLxcinQfjunl9NB1FihOx8xX82e
W7qcNmlFC93ccBSo2Q5cEk5oBYIlxUU+oatolBSVqDAkf97lKpYTKupZFOWdIAFh0BvlHL0cyn8+
VrBtAdivjD48owPZm6+8fcgodRfihtR6VoqK4XYONAKQJ7r9jtX4zEMgS4mD8Bj7WY5ndt+ZA4jB
J79FjTmpNIUcR333Rc0+wQALuuTeeHAAAAD0AZ6BakN/ADSocN1wAmmsILFV5s8kXpsOENIRVoys
KIZH4CIOR/M4zWZGV4MLDl9RWn/X0D/9a2PEdyEKRTe04X8I2UZf3lSf5G+yh8EyGCZF136cnZDK
y/xnDDSUHDaAF/wyPDoW4uW2ewIQpLEkxL+ZoqNBDCIMFSjUfEgvZidWi7tmfV5tGCZxJn8lFa/q
vRFTVlIGGdI9lo/7IREVq6GPTv7tGWsHsnGOGtBjhF1o4TOHTjS5xn58FLItJxpImNGuVJCI+Ssh
q+sP2DI4JwPKSvgTvHdjXCe+PruooqY0T5Btin82QxPpV6vCvrNjL7igoQAAAjJBmoNJqEFsmUwI
I//+tSqACYIwXLgCMUli4tbuAdZtG2uLfvFuGJcrDvFGMnL3V450skBdaW9Sok0W/z5CDNod41Sl
caNDNTkiQpfFmjObnRRg0F3wOt5kJ6OuClVNjlP5j4GjHo0BWGa4s+j6cNfghpoQ/Te1qYo7Ahkh
T/7XX+iDj2GhBDNx0tGjeJixXOqH8xLo7wU78QjMRAr3SArIk5R53udwNDj7pcdRQhWL2SeX+Z/p
VNg/4RbqA0eciNywppsZhQ80AXxmZNFvCMdNSUK/D2S1Ibn6AKJygHFfM9GyobSCRziW9r2Ytft8
4C93qIHOjmu7sxJGoryzgGNyycq4lqhCpkbeZZauM4M6FzBrVViu+j5rlD78Ca+rznJFRhA4MV63
jLjwbcTh7IAd4Ch0sI+hnoTgJedeBUtgCEzFbATSJtobdsuzoQxYaQlVhD8bEPO3SrmL/7hpilKK
cuF/WuS6l32VGof2WRuyDH1OJ0aZYK5uC78qKX7xDMQeE32yrr9sQ7dgznp5Wb66BfrXeUHkZFdJ
UTt1BXBZgl16QlUfoTWxzHUwndXT/OiQLhvS6wNv7tTsrvGrU7GAeeUC0vK7XZ88PlUNjtE33FuD
hoBFIHUSCtVMCWqZYaMi6aTGomWtUT7HJYyKGV2uaoorYGRZGc28mvdujui1XCOTYF3acPWRzYPh
VZTVUad5nghE7p0lFVDblYFqyhYl27OKWIRZKOMxj2ES7px++JvIAAADSUGap0nhClJlMCCH//6q
VQAThAfAAX48/N5LdZlh8gVVJ5vyMlwc2MreJtoG/6VocG01WgywRLgo0R9f8+O8BHddHA0aD8eW
ZR4mW3awLBLLG/ORZF/eEAsE6zQw3YFGVY8FwITwPGIrAFOuUa+0RsO9oAwwCxNzJ9/v88Su9/3v
70XY9M5B1s5SvgIFMa2onsB9gApZzz5hFxJLtvjORskTPDD8qkJRnfMy6v2aNEk57VRtqcSYqECB
Nkc+Q1pkGeK1X/ydhnv8kVsi5dm6Z99EMBODC7m1iz6EM6mE6uKQ3zR2tWucaU7QX8OcNnsncSMG
8X8tIHM+5lPoE2TcRlqhnKzajeaR2iYWUekHVMcL/ALVem8QLlMY8g6VYw8naeqpm7+1XTemi641
kXDxvyzDts7MPZCKQCqWAsyZUl69cAP/4/34EcGnEQk+bvGBERPDNi2MhI4RnBvSX87bK0FPv9hV
3TuNa35MthxNzOkdQD3wZscUP7ZNa+4dzREVO5kcUHEN2kH82EooSe1zwA+sVebBlQzmWM9XWwGB
/rZO1NHPncESM8IELOdeeZ1WoSoZ2e+J1+80WmXkkT45Ug97U6t89A+3xllNKVkicuJyDQpbgoMH
u+sd1xwaVF51r+F9BrYYwPBnIajD/4pQRpVNFbl2N0ja8PE3Q3mqpm96Yb/1VBK93b6NDalyoLXc
+OV/mesjZz/NsMnENpjiWz28+fnlUrMzy/9Y/7GTfMvSD28URAx/VA4zNxRPzmDdKyTqPgb606a0
aa1biyZ25ppLvK5OFjGAVJNTneQRmDWnqijFLjmhCcaNzpIlfC8ufx+lxXMDv1828D843ecto3QC
+jJOG9sHEXsHZikZ0lJkfqJtCs9XCeCgUVOzZ6J0M4eVpx5e+oVPCsjkv5Ld6w+WKdTejCXeVhA1
R28oCFlFMzLyycnkcobxvsBtU+jlvuVz7gRGic6+UE9MN77VNdIC91Yd2h8p00cUDPzgWi2zaPC9
vcB0q1rfv2kpxW96DWPm9Gp5IvbHBoZdmQsGrUNUt4TYGV5bQcVT3/bwWK1hvnKI10U6YHtbXOCh
tzxnxAzUQ8FhPPeSdNsxOmLZp2DbiZsYszqZuaEAAAFVQZ7FRTRMO/8AJhH9+/egA4eFTnpOYYxU
GEahRcfeh5IUNb9+AJU6vB+dlz0rtcbYGjJ5lpFjjv/HkTGADp8rjHRWFH6gStF/n2rq6kEOYUCm
299MGE6u0ujx+k1G5+4JCDkv/NSc5px5tYC3V2Sw5/WG0G1snvKaJpoIBoHY3LgrTgl9k4iBEmJ6
FDf+741g9MJ+5hUDUr1Y7+T+c0ppyP6GJnBGfcSIpZIL0dx2+4IqTOHOqVUDgwxl3pItCIoj6lsV
Z9bb412G0X/aZn6gxhyKta1a8XAjfGES+s1ivshG0ocTRYwvs92ABSFHsPvyP+xTprNmlyZdwhKo
lsHthGGTi8FYEa1iIslvKafYH4K/IN1F5ujmPWLEO1F0kgFRn/FcNjw/8rJ5WHPkfocCEXKdl6ej
lnuDqaqUgHmk9Of02BkmYxCWhFt3WPO15KRpEnXr0DEAAAD5AZ7kdEN/ADTnlIASygH7JlojcwHy
n8GPCPm7762lFYXPlfr6Cjm44IwC8IhMBxeS6FfEONm+D6byFlcr24vd/jEtW8z0CSEQRtnbBgHA
mHziFZdJa/JFcGARfmLDVpPsjKgR5JY9FifYIGyRO83Vb+H6qZT186saCD8IIyuupQDzLZ0mwoAy
JQJgAscW9MYMpxC2T1ZcpbekZb6746CE2utGulGKRQDnlzEj1RszEHkgpcHMJf9wRfAG9/YOYpDV
APoZX1/U/GDFx4E4ZLgv5g2QbLZ82EkBeKkL6l+NLuLFMNF9ltwACwr8lvYheA/YB4QnraSo9rKn
AAAA/AGe5mpDfwA2Bc+cXVIAW6baBu9EiLwvXIv2Z7kObPtPSZGjAntVyWtWfJPmXm0suJqdxXlO
fTbeDAZI1HHSSsp4t3WUv9LvJa668sBrJoppivZ7mGXnwLH+mJOx1n/Acs9uofigl+eDRM9RMxE7
4plARU4Wjz/6a3dYmulmTGqqU1GK2D+5X22OCvBmlOX/nEcuHRIF1hGFYJzHf2M5/MAW5oLM+v8u
yfNAu+jpgP/LtAHfPhI7YMyhO37rJ/J+VxV68B13EJ1MVmkIrsEFcB+MqisIHcJUntgLGYVqNYop
cvhemk1bsEHTNRkl99YiTMY8jkhqORklK615wQAAAzhBmutJqEFomUwIf//+qZYASiJZj4AcYij7
KFOcuwaZL9YyG2xDTa1RL5HvaqA4v7EunjbYwb3gVfaCMipmsdnJh6WVXB4B8ySuZk3KQVxvTG+y
yb8WVUQf/DSuqt9ETg7KwCsJqvrcYlX2KHKzHe7TVoeW0oAwpKJqPVnHRBN3XmpvoHJcbRrcO0Fk
oy9co5+NgbbjZTNEAV3byrEV3HgwWkeJaQ1ixqN9xa8mUMMVbOY8kB25wjpK7yy8MsSm1vIyTXPL
n5ZJV9AH3smqoTUAs0wiq70tah0Fm/rhosqm4EPBAvDqv1XqXC88EW79HMdW9XpNMLYSHHwNPey6
P4O+xiWawTyftOg0cF7bhEvmPUURKG7XlhjfdLOwOB5kLteKyBDXokmnEXmEvEbEEp18Enrx0/S7
X1YsBTa5cL8USmFIc028xgz2JFn2WKZvXGg2JbcRZKPJlrKbjOo8JkUnV5KUfq6IzCqJEKU0Nx/z
zqLHJoJ1C2Xh3sxqUWaC7VquLWYDlEh4zsOj4mrOFe5OGHSehdryoyhfbRryu8dW9WQ70BBBzUys
tFFNlGREenQP5/vYmuRJTIMltUCgm4PckD5kZ5Tpdp+StmIQwm50T/LD32BjYSlTvZho7tS2ejlA
fPui6jCMUD8WIvCfCFAKel6NxGYQbAV3nqHiVY7xDU81uBfAjMp3rnKQ7tS5jrzcMUQBynXZIuua
ZRRYdS6ESHF0fRTb/bh7zHVg+9SXPQMWt748f0cwjjqliZXNv/a9y8Gkj+ZsUsHSY0Zh/MmiyqGJ
1hyC879OL5Rx+WvaA1gWmuGirbhH09ha/LNgt+hDvjx59H7IPvh5XQX9pUEU4rPyQp+JeIe3ljBt
ufbcqt6Ds0HopoiBaqrK/CVZ0CH6HmnJWW9DIlYUCzpqZJylSBbShAhqdHK41VIwbm8K5ga1x9Fb
L2+NcSYQeCMOgxV1pVA4TAAPidq7wtBtTkdJ1H/QVTCRuVwtM/b4xnI00tiO3qI7ZaOvdGdKLL15
FX/s8c/h3qMZTcf5nK1Xn26AhcbePOY3bsqEEKsCVMdwCe8u/Zcj290D8bsO60N6IhsEvuxTKDwN
QAAAAXxBnwlFESw7/wAk/kXJbACaTiL+64d1bWy8IfO1vOwpjdCw2Nmmqd3rYsb5M9HhZa1Lsfpt
nOkmb5DAzgi7OXD1oFzAJb3Ejg7Fe12Le/k962szBfOtUJ3+KRXLEsGOMBKIrZkU8w3845UfNDaH
ltTTb+aU3pw5RVk+z+7ckyoWmJ3yl8tOXjil8XgrnyfQq12viYhPsEJo3aW9kZteMWfQk5tLgCEh
5G3YzQATmUd2EDeuY29/NzgRrQYSrwxUChEslHWVRpFIiVp+Y0/u6GfuzkyAlRTkVw2cC0ingt9y
0PMLsD+3YAxkbvTTODpS41Sbzow3OsoldCCg526+AF3q89qnNamD/pie1sf/lV3Qh9jj6+cplzT+
GHRoUqAW4nzR/3s2pd1BrdQ9XYkgqGkjPYAVRjSh8qe/i7t7/e4UGTMgV9bR5qvkA0cZU+yFodId
egEmrRe4Skh42PKDWwaWz+GcGr5ehDYYPHyxPNQ/BbCZR44CtIOn1TStbAAAAQABnyh0Q38ANOeU
gA/g+ZvsrGaNZ2fNsxIYnxOti5FCqVEmhIZH3k1Cw3iBefi6Q5ftwe61dbXFyV0h0TgKIfw47BmP
aGXd/NWSgGfeJOtcDnxR0O8U5Sq8ntTj4a641GhypQUj/Lpt5J5EPfuYA1g6nbWaZQIVWxhxJZ1z
Yo2ZYLDPoS5cQiHSTDfp37ozPOdYRj5ZBw3taK1jLczXpAIOZNCgEt0eP3t8wmmNqZWPgZuzkadV
/yIjSuLIXnLscIxdqat2Us+B+65htqw/b9EjTQss+zKc5gwH/kSSgySCjD78nky5OBt+EdG8EUpJ
EKL0ABU/LRi4CNj2t4jpMiNPAAABFAGfKmpDfwA0uQgyQAFz6RQBQoM5RA3xryXLR5diQ9nBibiX
x3pfg/ES9hswLwPzXD4jsWm+x+A3E+DEYLJVLUmycniZbu7sTODLVMTBCs+oIpRtnksXdDqS9glt
mcwGFTuUWrfPNsKB5FBkWuRfP+jQ/9Kdwa98wnEiUTg7T9TzRCJ4nc2B2sZgn4pNDjFcgSAoWXJM
Jy+5hXPgKhqz3jBtZAGOFSr9WWarzQ4n8zcb+aISN4JvnuZhe9VyelFqWOflQVR+yEZ2hs8C+JA3
2IwjN9cpe5bDfrP0Kej+RUhbpv/Kkd62aPEh6GYkQGB2+2xvSc57zYR/t+Xf0TBFHr0yxG8oDyvw
wn4sWEDBi+NdgOT6gAAAAmhBmyxJqEFsmUwIIf/+qlUAEwF77RkIAAGobcthZl2hTZDuZ0nA9Z3N
8eDZ7ss41hD01elbzzLf3RyuON6Y1SgafK7NN8adhDrdOHPdeGaq5QGSTchHNRO0dM0Q3rFXYPTk
5G0VBPlZmsi0E3VPIT//4EJ44v6Xxf4uQ2mCKGLWXqBsigPjJshVzXvNR2DPqNZqJryiKa851zmX
MPhTD6RboxK3SRemXQir3amlWb6Rpd+K1gb2OCiheIXt4MfB0mY8otItvhq6YcMSH5hTHptmaJBk
svcDARgOfrjIuhGMNFvme3dvhc9vZ3iyB993DiP+yHxxOzzHAXFv4GX6Un0J4+azhubL7vj/J56I
dvGa0qNeEdtfg2bhJoozqKipY1yZPV2DHZdqkYW8Z1jirbFHZ8mC0+Bv+K9f22fuMhRCTAGntUiY
gLa16zP0Mq+lkCc/Co0hYBkSMS8z05IgRln+f6YmiSkbOwVMA4wPx4P68wKudlAPlbSzmRqiQ2AZ
D6bZCiaBra79DXi+jJlT6pmhb1EDaPIR+mzrY/+zphMxmFvqX2BHqbHbYZRsBRdNXdMiGXv+UqIM
/hhmZBoPkX6V/a1DlFiBqHGfZ6Re9mcnhk2EJhuUrR9RERGZdu+6wAmRry6wlVBufFIICck2x0Wd
IVPhWnykAfUB+mcMy8oVwhodhfbbVB/Dt5rMx6+ZErRen2x5lRYkpd1VTv5VtgjnYWj0jJF90cCL
EqFrhuUfyezk1d0ZsGk42eE+cszCDEjorW44muRGe/+hgnYeX+9avMgIqNnj1O3gR6OHNUg6mONU
EDiaClKAAAACU0GbTUnhClJlMCCH//6qVQATEKFdAABxbaiEAghCrT+uhXqBzFvRhrmVyRuvOiRn
jusWk7To2dnYIJ2uKQEY37TGDxoDV2oOEtGJfyHoR+sa1vGqHf5sQ95Np1vjwhOxeOMCO4X9M2bA
lE0+yoAL+Rssup6NJOHzcMKmTysPqT0hLz0qqIBcR507arOhyIVYdcKMJd9MtM25JbqFxgH3qzp8
KjrIbWjoUj8U3Wy7u4/J+pMDJBIqVZkJJauqo0n+AGiHpDBdboHxGO2vQMAFZv8/co9JcyqRuIFC
vA9cHR8FUCwAD0CViKGBQfMujiUUWikLg9tucXSnWjeAOUDvX+TOqkWb8e26yKvTntBAnwarljRT
2/TMSmEGzdJx4a9R2L9omhg/YPW/v24QrJMbbOIC5QzqI9SUAgqvNdnLb/okdwt0n/60Ud16UgLZ
y0LseQ7CpJnreK5PagKtbqJwL+8ZCurE7s3sGOcvC3Pd2rnL6QuOCjSHh/FwIgeUJuAFOBI4OG3F
U1qMEVzgJ2/d6NR60Urh8pV6tgNqrxmJfu8XoLhFqZQZsH6yFp4jpEmJ7U3sOYjU3gZjlUVCm1KE
NdMUrav5LMDwB3x3Rk92kcBfbqJSOIWEkgVm1gc6Bet4Jj6E1OK7gJSlugvWOA5gEA6LIpJzYGw2
KHJACd6ZdxhG5G09BEYDc5ma/l3hTjMBDUhvuwoGFxvvk8+3CiUKTfi2qXJaelk8wGC6PM5mVdfN
BmYbIEjOh9wKzwMse8qQkDGUiKwDMC7zrF5//F/I6NJdOP8AAAJ9QZtuSeEOiZTAgh/+qlUAEwQk
MwAcW2yVKxUEyp5c9pGBym4Ue8Is2lS8WaPIq6Oa4Z3ryvwzei7MMMtmX8HDfYgqF75DACJ6wZXJ
RPlMQCVEBu0y3QWfZGu8csRE9I7hGG84TzrQFxpazelTv9oR5PPJtbhmay8BleahnxzGWTpvBL0D
SfsbDYQZPfoCOyW7KEJFU+LBN+ULHaJCwNIPp/30qV31ven9wN9oO2IIWEHtuTSSML6srrUef7rw
6oIPywsXo2u/84rlCuY9SIeX2KHOIUyE1VXSE3mfKMjiTpXpb0PHakAKNOUN/IQL6hJ3/V8seYu3
MXsbeozWV2JUHqrqag1x8kBb+I1+ORb3hfwOeKaBcxGhhECmxAxVgAcUgWWPOIwoSDMpXDsY82YS
bEuhRIAFeJ6x5Gc+3NTJiq77Kjc5avI2PEePIjdUEgJ4kVw15XJRHcvne9quF9PV9+9bqp2hB/7R
ZtU/snZ5ZZDz81dyKFLd/jZRtnz5aD6n4ojTPd+WvSdaAHOy6pHouk6Frt+lDfvS3VHk5ATJ2aha
CKmGfflg0deYhKeJ201kFKtknNUCWJkMtKRFMrIQsemKrxfO5TYyVwOWULr9E4JP0ecQVFhPcHvB
6JwmwI40fmMetOJmzgnfYbF4K5+KMIPw6xP5ll8pMLAOSYxMVkHXzgMXQIYz41xUYydYHfljlZ/3
rrBzZ6zlD6Wa5BCVhUJtjLGTdGCmHC7GO/E8NLQ56P3ngdNXS30oZVe0If+jaFu9iTKoBsikoVmD
d/fau1shdpUfa3Ehy7DW3XNBlrt4CIX/B0NtAZ26mDcB0Lc618kebyb9tagnd+6GqwAABFJBm5JJ
4Q8mUwIIf/6qVQAThAfAAtd5yVK9jTi8RajUAgdHLVsx8w9D5oX+u3Pvj9GYuMJtOVesheCf6Kgz
s8raWizuqkXkyPGd33kWUXR2LwGUkn7+w4pGtD6eQD+eOi/sEQwuHDwAJzavjw3OVzk4HBJ5jwLe
L03uReVIU1Ag75mRQbrcHmNmWpM0H6sswqL1LHxuV2AR1WjwOGpFSSWAUw8r04vTYKtmDqrI0YKP
113Zyh8mrNoire/+YRg0LW3AkXrL+gfYCadpDMd8ocy809rrBbDPOQa6IlQUbQyzkkTJ1tnYIqg6
DSx1lsDeeyJtvx26yUOPCwVJXSXshMO/+AWcr1x+HVJCjPlvgB6Flo0WC8cBDRD9Okyeu3VkfWoM
hO05VG5uKMYkjO9OawkniuwxSWLj+BHW+NQAmq7O2Nncr66i1yfdz8tUUfLFYHuDomHeuDxMq1KA
xVMuLKkhn/gDkmgXFReb00LD46a9B5V8/JOM0HVtcOY+hSEAZtYLjHjgN/SbWY9Exh/i66F1kgDQ
/+o7IvsuygFoWMIaQBA3fFJ5FVVw6z5/ksgkH0DcVE8u8dzby2t5sFxYOE0WgYflWDrIt6pB28fi
Ca1GuH0QkPSIJTAHSnF71/YkfqaVtpDbi6xWKWcByv/oEeHfBqGB1hBV450R9RwxFRkuI6iKy5CO
8I8iEWM++3agXAkeVKSDOk88V3aulSsY/2fuoc/kDhbTC7DPQujiXTBrliPhar5hPsEkFAdNpsQV
90crI5p8523DuTOmGHgCh4hOle+k2bJgSjSd7un0dMXkeiFJy6Lf1uBVk/J7A3bTwh59aVmVNT+6
393Z96bSLqKDck/7BKUXlrA2u/nowXdUyXb+MHSJKyMie2BO3aEKP/e4BaPrXPEmcIel3FNrtrAt
JlziGiwFupOP6627XIkE04CqKcKZjHiQBF6B2NYkbGv/TGoEj9W1ozm0iFBLGM+aMuOGFjm5f5zi
baI3QvGceoxlNL4QCUblqDfMyHAQDDrvKdAgQjCNvghzR1TTq2yj7n7xYACU1bbnWMexmOwyTbrA
BEWM7Nfn+n0QD2OMQfnsF5G61WlzaZOaq9KQn8nzmJlS5PB7GJlr6muXGGQWYbignmABeQVmgSt5
hEj+jC1j7Vb44E9uISz+GBkpzVGd9EAIMR54+QjvZbjGLGhohMSnMTH0h6hYfnD5iSZ+8KJ4KmV/
M3cEhSqNtPK39AigZZKT9nzsFQp0Qeyiil0TRZumeG06bxpym8WbR8O8BJMjuGiHKTbwcIrKyiZI
1TNc58VQRE48ny65e/sMv5Mi0uCjql8o2XMpJLjGfrYcOjSSzZsmxeJatcThUB5vXuh/yvLChDx0
OfgU8TuesrSiJ5ydpREGWuu3qRgGWpwWbvX0znteQ0UgDyYMhL7EPL2N/9Dt0fjz5jmFfrGwbx+1
vCbcKAyDLgUb8eW+88Xp8xUQgQAAAcVBn7BFETw7/wAmEfXjc0OADc52JxHkISLARNkQR8cNSyxd
kDa0j6oaz6dbqqQyr0rzEVVWw1jlOVHm2KEMiZYdHQhDRaTe1HLqOEpzPpMoTg1tfuth8mMLaoDR
PN515osn6epm44TlV++sVjpb2IH89ZRVKldPMFpwxWxzy4AqgF1yztPrAeJMDpV5QjGsjIJ8dOtZ
mLSua9ef5mH/S+DzeBinD9bggUKLNe+p55H5Dmgp5QKlfSUXzjRTAxm4hU44OecpWwE12nDmknmL
wUSJz4oFZ1Zir32SrPgWDd7XbIsNIJkJmtZiBCozM9JMMGf0qpsmHWvcXMVFDAwiFDz7tda97nDH
c/PC5AK8jgus53bZUqH1ApFqp7+iLKhWRe0sXf/jnbhgJu8GxndxtGAc48/XLi+pGgs5b3pMe1dV
oHerKs7iiaW4WRfm6xYUzATPhovuVxZtrkJEs82+M+4H1p0R3gQntMl28OWvAE3q21+7lJjL2CT7
OWUnrwj5CiypYGjigF8gjAVP7kurcPTK1Uj2ACss7XwW7U9dJqdEiYLvoVW6a/kHeszz44edDdOJ
rCQTZeAwnGz7/aFaesrVQ0Ew6cUAAAE1AZ/PdEN/ADTnlIASxauYJP2y8zretAbG8IPyHA376PxF
mxPlSxRK5IRX9DGuP74oDiiHEyhlE2dKqjpYiIq26SsiicDgyM39szO6OB9DZkUBuR1fy8X+4vlm
dN6p1t/P3nvUnwAAAwEYNogwDlSZw+C9LyZBGUiujGJ0LmiTb3IHNnhKF2L3J5qH3+q6E3axUo/1
YGGFKaBZ719zKyotj/skx8i65au97tObsxDUUSs21Nb91Ylx0idqqxNlaQiakM2NSQSJ7Lfanjyu
WavMq8bqcRQIIzNk7tf+oSyR/UM1ke5eC/lhIPoWBGnI2F4zg5yVxZOW0zwzIk/vrvjZJGM7HKlf
rXVhAYZgYaBiQl5TVtU432AZh9n0WDiqIHLxYOppOBkaXhtGd7sWVp8JBIdn8fRQAAABSwGf0WpD
fwA2AA0F2gAXPcuTpGw/3Ja1dSVvXU6z6s0pKRjpargYmpIfOh1hVTJkYMWbGCpCSQ4+3ZYRScl8
PY8zBGKUU0wcmrg50HY4t/OYO87TcsUcfTSn9mbLX4G2DmD1+u8gszmFj6NojImNM5mDQ92sTnCX
/B8qEDOrjlg3bfJ6We9930jZOk5zpsvaej9LUmGoROshfuMnUmErqB3XHkFxNPrSTqcbwiPQAgka
DRc7crisO2sHHRgE+c1lWLomNIuPstSCWyAzlkrVQ90i7WDuKPpQVSe71OiwsO4P56F9Tf8VyoH2
75sWaW7Ws9p1HZlV5UMrsu4LdX8pLlsViG2f50LywWP7qcHzK2IXLhM/V8vyllQ9YY5vwfdCI7Gy
8kuwDMjiUQ1Iu5Z2u2dFpW8Pr1orYa+fAQXxuMFRi7L1DD7W1ztC9MUAAALpQZvTSahBaJlMCCH/
/qpVABMQoV0AAHFDx9akIKHLJ//d+REITl+jWlCWV0vK67TuF2yEcYa6MVTi+Hz/N2qXALut6ixw
8NyhPEquEVtNnH4DQarPsIJpjeUMf0EG5AUdMozHEJ62/dtAOsTwKXfgs4BRP8Xne+VmEnEYU/AA
ydDOZ83AQIkb/oHMmsIlRbWBvBJnJwGI2vFQC48Kis6hD07Nvl2zYk4Nf5rbFF9/IfDIoIeD/b1V
9gHQ3Ax3ST1/O86MDMNRJZ3dmGDuZsDHMBu6gRtpjgjjBaiLdh0PhmHV3+9LBVjYnkV3GYIwndzu
tMJMAhOO+UTNOrJ51MvCpRpy2IBbNFc6GKYzvRitjLqL8HBUZKV/3qneHbKtzq/uzmdZhfLJ0d8h
fG55hsjAnQjpqwSKv4a6mmDh0Vv+BVtdvBZDQj2eXNOPLwVbpY/oi/PCf/dI4vAMy8FQPcLoxUtp
6W48fgIEHtFMfeFLdVNVwUNZth4XzsHEVTbCFdkquw70cWmcXpsVdrDLQXZ4g4EhGJwXy8W0cbFi
F6VWpPMtdq1LYbm/6trkO9LuvRHahKd55R/lpfR0zaDOJCI7Eh2CzzdIzIzmgzjvqkHKdbYjJq30
fIvjArdsmOeUVZTGtgASIkfxYrZZm3iBewdaWYt9rXgxBMl4LRPtrurN6POdalRKBBzHxwPOl+zr
4QXLKmCRd+8vilCp0tcmSxlvKrHemonn7G1EUCpTxOIPmPBnWwN8ddM1FAKW4u1olhnTQgW/JjUv
YCQQu7arg8EHgtUnuY54QxzK2xyH97yliswwEbK1LFOUgWm2lqYgL5cJiQW5412wi7/qE/EywSkd
jZPa4mhxIm4lueWLIQpNvpV9Cky0okBAJ8pSyXYJWNElFGqomEmOhad10830rt9cQ0zP6RQw6Iui
AG73RS+UlSeTw4QiTVYrZwqn219qdOztjKla4D1A8dHaeMvrOFXi7uUGMxLUb1I5lgAAA4BBm/VJ
4QpSZTBREsEP/qpVABMPUjIAARijzw/1kikcfekQzGyUxiLbhLAi2sc6zPU/AiugtdpryF/QuX5g
+FMWwSZqvywA+NhZJ2ArWB/2RWIjMSUurPh9+22u2oEy9rLRf8y1jY03AugLqoaU5y2yfJsMZPYB
oV2i/P184mAp1qutqbp4DRsdTNl5sLu8JxIAZmyIC93cWF/w8sBHE7fm8jB4eg1W04Pi5T9WTUCS
riAHmp1jkB3T5H/ZP+lbL0lNnpcG1GF24yHETWw1N1O+RPHzGVze+E12nl+nNBgsUyc99x8BpyUi
goZP+yMGZEzeeh2iyI+h5InyCNNlLoijUGLzOH3KCBwdb2O2Jw3uGTVzRLaCmDEF2IHt7FDxMInW
AEbPlmbfTVtQ2LC2Ht56kfo5NYsqhbeN2vJNkonsqBBFhW5t2YYB4lVAZxQmajt5HMmkiy7JZ0ej
CETKWxpQaf61SGeLp1y4ETU7IWJI9Vq2j7I7Uw5a7A8UbQyPW3GHTd6DoTQ0GuEtN51hVQ3PfZ0I
gCyRSDGH8SyyXr0/8OMm92GShAIJjD/9BGoxTBXpl6vnt21Hm2Migtq4AfOij6fLWlYlOv9q9CDE
ZjgT0/98wJJXZqnIYXUN8EVeUZvcZpgKlJA99LtN7W1cte/wAZAbteef9yTz8ZTEcLQVLYqIMa3P
z6QaCrDnoTwDBEWCVzdXjZhuEPE4L1DRPykm2h6+nXBzX9//mnyzW0Qe20G9P0SJCikA1FohF+Nc
tjBrn2dSvQnYufBnB3uTQj33+PEfjROsaNikpB2zrrCEsJ0kJPihWP0pe2kL1CeFS2qi+AQhEsOZ
haVGRfn+gRMyEwDG1XnCk4N9WW1/KiqT3hRh6yotR2JEyQipJimEPBOr6MZ1W5NDsha5i2LTiadn
gcPpheuYSYA7JHCORTwKkrA5m8qxpPK0dtcMPJDyEH7BLsfBA2TfAeZL4uaFTjiPyzQIFAKcqkv2
tM8GgSfBQU1kKU1kXwB6LcoWZbJFhA+h7I2mge/pjOb7qf0GRK5cCUndMGKE8/xEV0UHerlYwDqo
annzxVhhDk7KWUkWY+nQQdbHJwri57Nw0ivMiPdpmnWxKDeuYHmXw0aga7SNfW0Au5ZJm6DZaSNG
VqCrPdviLBgSOV6T6gNQzFIzY5mJEep4yrFSqMKnFQDoOkh5QAAAAY8BnhRqQ38ANGSlaEgBbp9u
b6e1LKBGkZU/35jbOV9BOIWGfna44f1YeIU4DvHlr7Z2f+9B6sxBHKsapGY4aASbg+Crb1fZoMVG
kCqRUybPc9scbizUb4TjPRpbpfa1ZoENmmD/4+ScLzK9fO8PxNArG90W1LVSJnHg8cfboPAPaE+B
JLE1phxBUHv6nPOsBhpNYxnOhp7Kpw5VlV04stbZh4wHq0sh0fBEVLAPDoiMxJw4Sy/BI7bD6Oa4
fKvbb42rBrAKNvvjzQJHC4n97UV80NUGQkncsXhsyuv+G4GB4waTQR7InIYq/8ZUeQQA/frcE84H
+keHwj+hDOvD8ufmKsSQPZzTe71rW8vMtzkL1K6LImzMBlVBIEUMCAyUE7wxfaB2tfTMoiH7gIq3
vPARf1Sy35968YZ11CuOqdxnllCWzDlsUXgKqd3yWbl3jjCZShUqFv7YlEoAIVeT9mj+2Em61dFx
hBq63mebt1jwNBjHaMvhXNKx6J0BGNcCmbu6Kx3L5lptyJWi58NEIW8AAANcQZoWSeEOiZTAgh/+
qlUAEwk0SBmAFgtslSrv8l/C02lp4bMYVMq+IpBXB9JFeAno6rZ8OepNhgSJhOrrf8FaUPtIk+/M
pB5/df7Sg+pSlkivpTgQbpQkczlh4Epp7CH7MtqfggUnvCE5qCtZtWG5LzQ2x/z82R0h4/pg1nWg
FetAxEfQswXw5fwsHNRJbchB0XBgtma7EhHtkzzFk/HbolXUJr+9tfuOg9Z0UiY6GISTcoCbeIvX
LOvP3XsLg/rnaL8DSVX7kfG/WnxMTEezi0CrXaiTta3CQ3Kyp5W5AWD8qqEL42dZZyVxwjbnag0o
LcR0jNqI4F1bJS/0T1hPdxhDrnVIwU450KG0JaXMUQUaw61TyE72pU9vBF9O3xVjsJpHfIOF1eGf
IvFlySDEeypJkt7n/8ySlRHqmVjA12d9wlyj6dvpztH393efF425qveVUPWFFzDav5Q2yst731CT
J5fcfDA6lXvBCiXZ5LXcQDMED19KOlpGilxNsxHuW6KnP+DWtdSBIf6Edq7CjPPkcHrQ3njh3RNs
VUbxGqDygr/H3EcMo8fZ08WBHKMx34uyil1DP3TIkTVY3kJfPQ447WETeTIVWyIGXADauyoxGt0z
3wOi4f5B8NT6QzDRCLa2+ZiysRISpH4Gkm3jJHhEgPC8QiG2rFykdkmtDIE7UaAUMiQrzpBEqHcF
pGXwNPVFI798djdV0rU51i75wGv1J0n38awmhaZQ2gysfhbj9A3R9TKXr/k2Am6Y9wOl4K9rkqBW
Gm+k1x9S7IvwPLmj+tTDuluYpPoosGckZS5wdUtc1OnSfgGvqTVovSk93hf4udwNw+Xb0OsWThRp
PcSHmU+ZlBnFMRaa0v9ARtwiv7JxWfWP/aXrPhOrvdZGEIQkBZan/ezqE0OuNjSOqbA67qglf+Ud
YAvP71JxAjEIEA0g65hwDOFI7kpztHGUj4IqauOVbIaAmv9s+ziTg/8+/NyYrIAGggUjhSzRFMHh
PdByWSF1fWmqqqbLzmeYh7CghD9f37QvIHi+PKzKmwDs4Bb6hWoGLoi4mPIEXeHDp74AkXHxsbrT
3jtvVFOmGIDEVBrIc/PD824Gb73aRi4iQNN5WEVHrt0ISvUhN//u8Yn17R6IJEuuZqAAAAQDQZo3
SeEPJlMCCP/+tSqACYVcjZcARiklYHgzLlBpfq1M64NuL69p25Y8oslniS9pBDAsXGoNhWJs8ddB
Dja6pRJg7lPBnLsG0hcCc+v39Xxb3aCi01leoBnkVHB/etQ7/KqrnshkuW/KDDRoxxqRQovA6gua
xRSbPHcCQck9uQrwGoqWYfffKr5eJ+ojBf17tqvsycMg2ZPttlG34jmjlD0Ul9pbzHGwfWaGDsKO
JyImT6KzxUEgO8yuNhJfnXyneU+FzI7aLnqp96Q2egbsLXDCx6xuzyQhcF8kvBTcy43Vfufrmn5V
bSNJbLVy5JOvMdFzw7kldMoKSUGdFlWJFfz7ICpcIJzFkXWXDYJaXv/CJ/O2qwOyVrJaMKWAI3Di
yL+XEwi/+6e9KPwZwLd0uPqPTrp1usD94HFiNVGO1TtWV968eFB1UfXGflsljKmP0Z14HuXJvaYo
IGJ3swq+NpjNgePxERJ/6cESolKKr8eOqXq2T3mTIqjaEn/ZDDQcLZQi2lvTsvuQzJHtHQ3KrpNE
QyUZQ8MwpK4pC4zYJh+jmg7nSLe8VCPRXxnd7wxULRLxK6TDuly8xAY+FinJVoViYxQ9QRLw6bRw
+Y5ewwulDvKmiT1AbRABABKJPcGOIPvb7lLu3yRhQtcvq7DjUu5hDidgRoxvnV264Jbq4o0sqDa4
MdqZ2PxvheOyXNTGaZvMUtx5eux8mvljDVwF1sICjR5Y2T8c2QAycsnWRxy+1/kX7mQ4JZ0JNJxY
Rwlf6alvh7+3jZyIlALHiQ3wbKCYR2aMadHzZOCrQzANXcpBsW1Ir9cPvtIKDFy62McfCIUj782E
KxdQaKz8WR8agk2efosIZVfP+33YHNli9wMOsnQAEkUCaGj3mxTiR7xBeQQf0emcnbECJ0p1M19v
Nhzb64i3M1Oh2mnLCA8MPxvfJbvvr4E4yjOjDUzfnBVD5+6YnzjZ/FTmm65hQ4W07UzhNXwVLOf/
UTuFeSb931Yir4C1Rx0ZgrW08LlrJJs992K7UymdY6Yu14XGYGjpYHREngsWp+p+9tXtv3hNPiYP
3lIknUdKaAaVUPXxs3Szc+JM0n2/CHlPPWwpqmD8lNYhpxzJvnXJkRXHhMISxfLyGbCl5oEI16DB
jsbSGm+55j8hG1Ayg33B4RlWjaZbrno9S5unQjh6mytJXtYDlQavzuvZANwBh/wAAAMBJVMmoo4D
jjUKHliaIzOeEnBjfqsoPIAoflU42Zsk9QV30DksBk4UJvUUAAADAzTggjNyl26ahSASEQk+V1uT
81mL77XJgLH6fU3bPMERTkKPw8zRPvsb2GaxMFF2GyDlJasGfOdH6y7SyM9CXlqLRouHU3bugQAA
An5BmltJ4Q8mUwIIf/6qVQATBCQzACwW2SpX+L3YnPR1J+NIu9tQHxoJXBLxFW0lvGo3519LXTpM
t4RuL99cvzfs14iYFOmJ0IcEfThNcXanOh7NRVRNkjocHtHluDpdUDEpuJg1QzCRHd7b0C/4FeW0
PGAE97enfFkbaxDr2e2HGIycgLX3OEWcTxGV0utwogbfGOvDvPK6v0p3OdaIjVQKoCws1XZl58WE
pie57tM1ReX/+7XpzmxwOjH0w6/RmuOKUp9Gm+ZGlz/zqrh8CHijU7J5xwNgW+G2cj9sHMVUQgUB
Y1m4BiIlTmAZyZmIOU1qVUb0G0oos0VsRoOHzl/wBX/g4kCoLHVRZuE/ksqdNbPFUzvDsQQfBVhC
wKKDJf5e/iIJI1Qb2JdJdrtoslhq+odf36fA24+1dLXPwtUGkVYhzqWU8qpLyLBh+4ie1hUXlXrj
nVCaXhoHnfTDGJCyHq+mH9DEANqs9sF8Kz32U0qiTmu1yOOF8SDHXDMu8oEPmSdp4SeQF6l1+CAJ
hRAAhpzvCn8+zlr2kLCHbavgLh5YhtD1HgfQGJPh8uj2EEl15YKNNSfsqa6JtGA2V80ZjfSV2AWj
p+qP5SuZRNDCFhRmCpekKb9sNCNDhfIf+HAyzQjASUUK0TlWOfKyVpr4LrNj/4vNviHT+O97A6kK
L3u7ydoiRUQwxEuEmKdBPA1QqrZnrkisfGxkQN4kHjA6X2GrsnDCHiP7A+ENcEO0jtJc0fjTF4nQ
t5osQMpwCf9YXHgUQA1+3/3Zj/uG7niAgB3K4ZQW1yjtits9UpXsZdZwbn5UY7Nqo+9FEc0aWgxi
0cAaOU74Qw9GOVjhgQAACHxBnnlFETw7/wAlFLgdABatlZ3kDRvCgwjUKLj70PMqH/D4x8XsLoyR
z6+rRHAp2sa38FYOQj4PLaKZNlicS4m8HCpi6bTzbkV35lwrLJsWVS26AADuQN2vBu/1mtYnA6w4
EKrYJNibW1n5O/sZZg/AaSX3DyjAeTpMA8NqxDKtsUR0X5GLoPTZ2Y4ttSmiexQ58hI3NP0woy+w
b/lWvb2RUn/xsMnNE+jcbYX3KZRP1JBhCqX5Jo5n//sDwjOEDK5DJyaLlzkGERU0Tk97bIKA6YRf
LgwriE1+DPbJ1Z2ZH9cu+co4hj31f7sVVGsIoyWGqX30UBKS/OUsHyqP/veWTeErx9/ZyM957p6K
DefvQ5pw59Usk0CHtyx4dLd9PX5wog+O4fHqDRDzm6t3VkIR+QC2PVPRXgL5g5vxk6bnBBQmxJMF
EU2AwspZvtnEPk3AB9qOrnTvPSJP2WH28H53YAvsKelplNUlGhq1+mfMVDlo3iEvnc/Xv0JLNXRw
XNBzF9c1LWjHjV2ftYXvNQF4HUOlQnftA6JXsNk/lhbKqGNrjBv/VC3Qis6xqPz7539PL3+RBV65
6a3thCpH+cr5BujdzGf1lFV2qBywCybyli3ybGtob+M/b1UgjrBR4be3lVoz7uOZjtmAVMTCb0yP
Q3SCIDRJMmk/CXB/+Qs4OUumQD4xyUvxx1mntSgSAntK2mYigpTVnJik0GNL1XSiAlWo3IJZTsVI
1FX1KQ0donojVEQ8FpgORkjx4BZ44JKhl2CBpE8+iw1KpEtuU68SZlNH6asaFf+x97P7u+GBCIWF
+iK9y8zh1N6Y+e0Z7/5Kw0iB2/1RoTvP2wHqlkMymPmaqQJu02o6h+F5VFZNQFTrbU0d9+8bQojc
WLUQ25fwU72FHiO5ZDLrCDOBsYHGTEZCswavIDiZbJzNN1DMpfytdXq3syNoDIGG1LJXTrV6eqm0
d/TVWDh8wI8emaD0AJJ1BYkz9xKUytn0tw4/08BgbxaDTAiivataqft/6VodhEUCVjAeGzq7gO1a
QdE6FTGNjt8cuExhRmmXDfMO0K6GftlOrHIGkoiN/VvfJxo01bBFd0NIxjaSHKnP8Am1ZqvVGqxD
wH542/shTPPt+7LTUjHWUhb4fbv2Ip75BAdimO9PHvWTdMnQqm6BE9L3ypp438nh/XUSz020IdeD
HIX63ghqM8YeqTEG+K4j4y1whWQTXgPktRd2RRU+C000lp0o/+3vk7xg4D09+cym/XdS/eGl1u95
ZkXbTSI13N85tWRXRLNJusEKdY0xA+BxuYC3YhXgDrCTWXXycOq5R9SUigO6GZFsML2AwyRjZ4KQ
bHdDBsT0XTEjA1+oixUpPmWTqJ3EEUEB9/QfZgsvZ9aoyQJUg2yIpk6sF7/BwVPI7oMnWdP5LUTJ
pd/I7Uhd2N19x1d2y4a44+qYgOhl9bhNxVlyHC2CBnhAzPZvZTkeugsI8vvZDksgWCvwX2vttK/p
TdRHKqi0rPu7rTMP3mfozcaCBMlfjOHPWSaz2YFawHalZi1M6XeFk05TpaTNE+bqs/2f274nozgN
LFa94704+zqUf+8vYSNnxKSXnhzkaI31kbBAzJ9qxAypU7UmQ9q8vcE9r7X/njgFbDk/O04IVd7v
NyillHtt/DEZP0/7IWJJtsDZJDm2vjKLUVeKVUhmLXcxdrtfuzibp1Quoty9ZKlbth5E8CFDjMbG
NJ7BvBxabTsaNZ9bR9ESyNEAyVuLlleJqyD2vxAwASHmAmuUi+Y9SoyEkp72+MbuTdsx61mwwwX3
46ig5Nb1ekSwnyN5laEJY/kxvEOn/BawysQeSu5ZR5xWe2brwwbSWWx/heF8qXugxqVLfEKPqXal
avv1r4rE98t7NxzF8K/Oon0KxpQiAIEMI97uM23nfXUMF7l5Y7c8WYcaCTQxlc60tWDU2raoK/5V
hjan6OjAqDkfRuuKrhF67I83LYjRHrpQM4fNaeRb8R8ezTgeb85QUE3I1LYYEFkZgQMP78Hq18o2
2uL+G/6/472j1mSZrFCPguijgfpIDhjb+jxOvF4yKXMRD23Zg19W7xjJxT/SA13J2JuXqihUe6jJ
rlXut1dB1P/OWsp4R9/efhcp3S/m5s/rQC3fVx0motkRZcGY+LbM4pjmikaqmQjtPaF7xt8rgxcs
p1Sis2PDy1cHWkrEy5ina1etfvbINYSsGCne2hggpIj/6qVHD1tGSd3F3kiT5nuYqqrl3Yj4zcxR
kSDgwqL8avNF6l6NqsGXX7evI3uV43pYssPiVAEz31wdpfNf5r1KjJmgyHAmoSAfZfWs2YiUT0r6
CbdqaGzbecx/Z62f6CJRuSqMGY9mcsPpxoGRQElOT2TL3qCMB771aLfaCySaDRZ/equudCsM6LiW
8u4KHiHShg9h5K1wiOsldHB8QOYDQ5xGvuUxfHSqst+D84GMpRnXDCKLyRVDnqAQr6xFgvYRvIPk
XKAtoUX3P5N3B5JV9pmOW/LZ1N0DJ42F3exiM1btT8pTUgnlW6OH7N0uMsNLAIojyDBY85XA0RbU
ABijRwDnDNriFiMGyS6yHZBE02FYEbP6Tv3iUaPeWzxlvaggpBYi2r/Jp6vRg2DbIJa1KMHxOIuc
mHmbomJezJ48Fj+JWb5vmcBmU2bcixjKR0WHofe3S7ue9w5CSc0+jL6Kbf46dtqffMr1MHtnq1Aj
5OzATTNiu/mOQlz2XVajqq+NM9b2OhX+JFs14QDMYAnVh9oJoD8mA0DUO17vFdk1IDnB5roJb7G+
rYIL+KT+fJ9ShzzqdBMFEX9gN+2x7FdfpFTTfQgxtlV0k0OCEOunUZalnm76y7+iPq6qtEFA46JF
6UMQUxCbVIU8W0UG/RuIoScoI8V2QdEAAAMHAZ6YdEN/ADTnlIASygH16cli5s/s6nmDeD+7xfw1
Lcg/7OyIjM0bhEK/dBDXJX7f4G5qg4wc0LbWJv5db88l2FRyl5DLXRFVd/uTWLpN3R8oE0z38d6W
IVdYJ4OIr19ip1r9/LoLiwFN0V55pHKxdasGXtGyqK5In9ONKQdOIzRp/T6VH8uhaYcgmbp+inDd
dpZyeyTAN9RHPPfmMTMScEVoeZgPaujhayAWPOH+EavlE/jFJcD2Vl/sMXAMfEkN+1luTRtCLkxX
GUAF6v3v7iNNWJYG9hKIQOp8s33hBkb2UpO9xc2QtqDOYV6C8pjj1JjuenByqfrZ7Qk5H6ug7OAV
5+pnwJL61YEUqpjhgoaM6EAQJ52RhfeBFbcINYPnRRgPrOM1oB/tG6MMAug/fgiHhE7SIIqzohqM
yT07EeQzi/y0C4g+SuDGRUh9m7g9AZExo0Gtu5M0Znp7rCSyJCudSMKknmxjLTxHwgDumRSzAwbg
1v0Q+NLHGWfvqSFRBqriM42U+XkUhP7eVbSxxXxsuXFvAjLI3jI/XS3GfnvP0sQUwxTsIhKgnSrF
f+cA4Li3pbEWk6vbrjE1ejtGqnJ8FHZERM6ws7yIs9OitjRB+IEmpUutFrD62UH04Cursn2cwbtG
8cwhPwI9VC1N2m+k17PgxmOoZcqJ0RSsJHEzaIwIqcHbvK6N5MdIzvQAj4Sq+CWvt8fI7n1jGxjq
j0RjPMYldMpZP5H71mnAT3GkFQCg6OBhjPamNSKVOqUxZ905y00oiAdydfvYHNm+hZgSriXWaoIt
Co1nzaq47mZ2LR+QBIvqzBPGhJxxWNVZuLs4SwOrYRMBw+r+uw+PJVYVVQeAHituGxCcrVhZb3S8
lcd7WzGhNgAHtgrPOvdXrnbe9VpJ/I1StCXwEYK5CAFNtOh3FjwBun6Eh1zA9YLCXG0g7slzqAjB
WaHIpnx/N9foviFXSMwA84/he4AGTvSw/K6JsJbBsGkC3jgyqEfoIvpYSDwC9YCPQVGYASFqxIjp
iBWrmQAAAE0BnppqQ38ANMAmuZxrDL7hzoZJoAAAAwAn0Kz5r0HV+t4kxzspILoWnAgC40dRPiXl
bGw4qYgiyYW2B9Z1Wd9J9HfrcKRj9+E/R0hJlQAAAB1Bmp9JqEFomUwIIf/+qlUAAAMB6DBldikT
X5+1hwAAACVBnr1FESw7/wAABsyP2ltPw2NVJeRJrO2VW2qwydcrA9s/s2V1AAAAHAGe3HRDfwAA
CavrNgUCf2jsaxtfiSbuwQb6LmAAAAAbAZ7eakN/AAAJrXoCJn1ftICYd6/DktpWTEb0AAAAFUGa
w0moQWyZTAhv//6nhAAAAwAHdQAAACJBnuFFFSw7/wAABsyP2ltQMAD67q6mQRO+kz1y8NWDrCKg
AAAAGwGfAHRDfwAACavrNgUCf2jsaxtfiSbuv/wR8QAAABsBnwJqQ38AAAmtegImfV+0gJh3r8OS
2lZMRvQAAAe2bW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAD6AAAJxAAAQAAAQAAAAAAAAAAAAAA
AAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAgAABuB0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAAAAAAAAJxAAAAAAAAAAAAAA
AAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAkAAAAEgAAAAAAAkZWR0
cwAAABxlbHN0AAAAAAAAAAEAACcQAAAIAAABAAAAAAZYbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAA
AAAoAAABkABVxAAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIA
AAAGA21pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1
cmwgAAAAAQAABcNzdGJsAAAAs3N0c2QAAAAAAAAAAQAAAKNhdmMxAAAAAAAAAAEAAAAAAAAAAAAA
AAAAAAAAAkABIABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
GP//AAAAMWF2Y0MBZAAV/+EAGGdkABWs2UCQJaEAAAMAAQAAAwAUDxYtlgEABmjr48siwAAAABx1
dWlka2hA8l8kT8W6OaUbzwMj8wAAAAAAAAAYc3R0cwAAAAAAAAABAAAAZAAABAAAAAAUc3RzcwAA
AAAAAAABAAAAAQAAAwhjdHRzAAAAAAAAAF8AAAACAAAIAAAAAAEAABQAAAAAAQAACAAAAAABAAAA
AAAAAAEAAAQAAAAAAQAACAAAAAABAAAMAAAAAAEAAAQAAAAAAgAACAAAAAABAAAUAAAAAAEAAAgA
AAAAAQAAAAAAAAABAAAEAAAAAAEAABQAAAAAAQAACAAAAAABAAAAAAAAAAEAAAQAAAAAAQAAFAAA
AAABAAAIAAAAAAEAAAAAAAAAAQAABAAAAAABAAAUAAAAAAEAAAgAAAAAAQAAAAAAAAABAAAEAAAA
AAEAABQAAAAAAQAACAAAAAABAAAAAAAAAAEAAAQAAAAAAQAAFAAAAAABAAAIAAAAAAEAAAAAAAAA
AQAABAAAAAABAAAUAAAAAAEAAAgAAAAAAQAAAAAAAAABAAAEAAAAAAEAABQAAAAAAQAACAAAAAAB
AAAAAAAAAAEAAAQAAAAAAQAAFAAAAAABAAAIAAAAAAEAAAAAAAAAAQAABAAAAAABAAAUAAAAAAEA
AAgAAAAAAQAAAAAAAAABAAAEAAAAAAEAABQAAAAAAQAACAAAAAABAAAAAAAAAAEAAAQAAAAAAQAA
FAAAAAABAAAIAAAAAAEAAAAAAAAAAQAABAAAAAABAAAUAAAAAAEAAAgAAAAAAQAAAAAAAAABAAAE
AAAAAAEAABQAAAAAAQAACAAAAAABAAAAAAAAAAEAAAQAAAAAAQAACAAAAAABAAAUAAAAAAEAAAgA
AAAAAQAAAAAAAAABAAAEAAAAAAEAABQAAAAAAQAACAAAAAABAAAAAAAAAAEAAAQAAAAAAwAACAAA
AAABAAAUAAAAAAEAAAgAAAAAAQAAAAAAAAABAAAEAAAAAAEAAAgAAAAAAQAADAAAAAABAAAEAAAA
AAIAAAgAAAAAAQAAFAAAAAABAAAIAAAAAAEAAAAAAAAAAQAABAAAAAABAAAUAAAAAAEAAAgAAAAA
AQAAAAAAAAABAAAEAAAAAAEAABQAAAAAAQAACAAAAAABAAAAAAAAAAEAAAQAAAAAHHN0c2MAAAAA
AAAAAQAAAAEAAABkAAAAAQAAAaRzdHN6AAAAAAAAAAAAAABkAAAOfwAACn0AAApiAAAFMwAAAz8A
AAI2AAADjAAAA+oAAAFtAAAC2AAAAw0AAAU8AAAB+wAAAUIAAAEZAAAE4gAAAUgAAAD8AAABDwAA
BM0AAAE4AAABEgAAAQIAAAORAAABLgAAAQ4AAAEMAAAD9wAAASUAAAD5AAAA4gAAAzYAAAEmAAAA
0AAAALYAAANQAAABIgAAALoAAADDAAAC6AAAAEkAAACcAAAAIAAAADkAAAAtAAAAIAAAACAAAAA0
AAAALAAAACIAAAAgAAAC1AAAAPUAAAClAAAAuQAAAr4AAAE7AAAAugAAAMcAAAMTAAABGwAAANcA
AADfAAAC4AAAATEAAAD6AAAA+AAAAjYAAANNAAABWQAAAP0AAAEAAAADPAAAAYAAAAEEAAABGAAA
AmwAAAJXAAACgQAABFYAAAHJAAABOQAAAU8AAALtAAADhAAAAZMAAANgAAAEBwAAAoIAAAiAAAAD
CwAAAFEAAAAhAAAAKQAAACAAAAAfAAAAGQAAACYAAAAfAAAAHwAAABRzdGNvAAAAAAAAAAEAAAAs
AAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAt
aWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1Ni40MC4xMDE=
"&gt;
  Your browser does not support the video tag.
&lt;/video&gt;</content><category term="stats"/><category term="stats"/><category term="probability"/><category term="bayesianism"/><category term="maxent"/></entry><entry><title>Y Combinator and Biotech, 2017</title><link href="/y-combinator-and-biotech-2017.html" rel="alternate"/><published>2017-09-11T11:00:00-07:00</published><updated>2017-09-11T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2017-09-11:/y-combinator-and-biotech-2017.html</id><summary type="html">&lt;p&gt;A brief look at Y Combinator's biotech investments in 2017.&lt;/p&gt;</summary><content type="html">&lt;p&gt;Y Combinator &lt;a href="https://www.cnbc.com/2017/06/30/yccombinator-biotech-partner-added.html"&gt;recently announced&lt;/a&gt; 
that they want to do more biotech,
specifically "health and synthetic biologies".
This seems like a good thing in general, since there aren't too many incubators for biotech out there.
&lt;a href="http://indiebio.co"&gt;IndieBio&lt;/a&gt; is the biggest, but they are completely focused on biotech, even providing lab space. &lt;/p&gt;
&lt;p&gt;So what are YC actually investing in?
Here are the biotech companies from the 2017 Winter and Summer batches
(data from techcrunch:
&lt;a href="https://techcrunch.com/2017/08/21/y-combinator-summer-2017/"&gt;1&lt;/a&gt;
&lt;a href="https://techcrunch.com/2017/08/22/yc-demo-day-s17-day-2/"&gt;2&lt;/a&gt;
&lt;a href="https://techcrunch.com/2017/03/20/yc-demo-day-winter-2017/"&gt;3&lt;/a&gt;
&lt;a href="https://techcrunch.com/2017/03/21/demo-day-y-combinator/"&gt;4&lt;/a&gt;):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://www.darmiyan.com/"&gt;Darmiyan&lt;/a&gt;&lt;/strong&gt;: Alzheimer's diagnostic&lt;br&gt;
  We definitely need better Alzheimer's diagnostics, so this seems like a great thing.
  Usually these diagnostics are designed to help enroll prodromal patients in clinical trials
  (e.g., &lt;a href="https://en.wikipedia.org/wiki/Avid_Radiopharmaceuticals"&gt;Avid&lt;/a&gt;),
  but this one seems to be for screening too, at least according to techcrunch. 
  It's unclear to me what their technology is, though it appears to be MRI-based.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.helpwear.ca/"&gt;HelpWear&lt;/a&gt;&lt;/strong&gt;: heart attack-detecting wearable&lt;br&gt;
  This watch monitors heart palpitations, arrhythmias and heart attacks. I'd buy one if I were at risk...
  It will enter clinical trials in the "near future."&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="http://oncobox.com/"&gt;Oncobox&lt;/a&gt;&lt;/strong&gt;: cancer genetic test&lt;br&gt;
  This test appears to match cancer drugs to patients, so I guess it's similar to 
  Foundation Medicine, though with "full DNA and RNA profiles".
  Usually, it's pretty expensive to do anything novel like this, since you have to 
  convince doctors that it makes sense. So you need to fund a trial, or &lt;a href="https://en.wikipedia.org/wiki/Oncotype_DX"&gt;ten&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://foreverlabs.com/"&gt;Forever Labs&lt;/a&gt;&lt;/strong&gt;: autologous stem cells&lt;br&gt;
  Pretty cool, but reminiscent of the whole cord blood thing.
  It also reminds me of the companies you can send your surplus teeth to 
  (there are &lt;a href="https://www.stemsave.com/stemcellteeth.aspx"&gt;seve&lt;/a&gt;&lt;a href="http://www.toothbank.com/"&gt;ral&lt;/a&gt;!),
  which is an odd, but noninvasive, way to get stem cells from kids. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.cancergenomics.co.uk/"&gt;Cambridge Cancer Genomics&lt;/a&gt;&lt;/strong&gt;: "next gen liquid biopsy, AI, smart genomics"&lt;br&gt;
  This is quite a few buzzwords, especially for a British company. 
  They say they are "applying our proprietary analysis to a tumour's genomic features",
  to help guide treatment. 
  The team certainly looks solid, but similarly to Oncobox, they will likely need a 
  bunch of money to prove this works.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://modernfertility.com/"&gt;Modern fertility&lt;/a&gt;&lt;/strong&gt;: at-home fertility test&lt;br&gt;
  These guys appear to be packaging a panel of useful fertility tests for home use. 
  I don't think they have to invent anything new here, which is probably a good thing.
  It's "physician-ordered", which avoids FDA involvement (and is also a good phrase to 
  search for in "DTC" genetic tests...)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://www.billiontoone.com/"&gt;BillionToOne&lt;/a&gt;&lt;/strong&gt;: NIPT for developing countries&lt;br&gt;
  (Disclaimer: I know these guys). This one makes sense to me. 
  NIPT is a great technology that should be brought to every country.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="http://predxionbio.com/"&gt;PreDxion&lt;/a&gt;&lt;/strong&gt;: blood test for the ER&lt;br&gt;
  This appears to be a POC blood test. 
  I don't doubt the need for new tests like this, but they'll need to go through FDA, which is a long road. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="http://cleargenetics.com/"&gt;Clear Genetics&lt;/a&gt;&lt;/strong&gt;: automated genetic counseling&lt;br&gt;
  Automating genetic counseling is necessary because there are only a couple of thousand
  genetic counselors in the US and the tests are getting more common and more complex. 
  It's a bit hard to believe genetic counseling is a $5B market in the US though,
  since that implies $2M+ revenue per genetic counselor.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://www.delee.live/"&gt;Delee&lt;/a&gt;&lt;/strong&gt;: a circulating tumor cell diagnostic&lt;br&gt;
  I thought CTCs were done after &lt;a href="http://www.fiercebiotech.com/medical-devices/dx-startup-q-ity-shuts-down"&gt;On-Q-Ity&lt;/a&gt;
  but it's been a while and there's probably something new and interesting to do here.
  They've completed a small trial already, which is great.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://www.alemhealth.com/"&gt;AlemHealth&lt;/a&gt;&lt;/strong&gt;: radiology imaging diagnostic&lt;br&gt;
  Like BillionToOne, AlemHealth is bringing a known-useful technology to emerging markets.
  Perhaps surprisingly, I believe this kind of global radiology outsourcing 
  is already common in the US (one large healthcare system sends images to Brazil and India, apparently).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="http://indeelabs.com/"&gt;Indee&lt;/a&gt;&lt;/strong&gt;: CRISPR research tool&lt;br&gt;
  This is apparently for "developing and manufacturing" cell therapies by gene editing. 
  It sounds novel, cell therapies are here for the long-term,
  and there are dozens of CAR-T companies around to pay for it, 
  so it could be cool.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://www.innamed.com/"&gt;InnaMed&lt;/a&gt;&lt;/strong&gt;: home blood-testing device&lt;br&gt;
  This seems to be a cartridge-based blood diagnostic, kind of like Cepheid, except for home use.
  I don't know if doctors like to bill for these visits or not, which can kill adoption, 
  but if InnaMed can pull it off it seems like a great thing... 
  Like PreDxion, they'll need FDA clearance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="https://www.volthealth.com/"&gt;Volt Health&lt;/a&gt;&lt;/strong&gt;: electrical stimulation medical device&lt;br&gt;
  This seems to be a topical neurostimulation device to treat incontinence.
  It looks like one of those &lt;a href="https://smile.amazon.com/SHENGMI-Abdominal-Trimmer-Trainer-Training/dp/B072267F8M/"&gt;electrical muscle stimulation belts for your abs&lt;/a&gt;.
  I instinctively like this because incontinence is one of those massive problems nobody wants to work on.
  Maybe the trial will be inexpensive too, since the risks seem low.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My sole criterion for a company to make the list 
was that it may involve FDA, CLIA/CAP, or similar.
There may be omissions! — I just skimmed through the techcrunch articles.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.techiatric.com/latest/2015/3/22/ycombinator-ups-the-ante-with-bumper-biotech-batch"&gt;In 2015&lt;/a&gt;, 
18 out of 108 YC companies were labeled "biomedical". 
My criteria are stricter, and I count 14 out of 210 companies from 2017 as "biotech". 
This appears to be lower than — or at least not significantly higher than — 
the number in 2015, somewhat contradicting the YC quote.&lt;/p&gt;
&lt;p&gt;Interestingly, the 2015 batch were also much more computation- and therapeutics-focused,
including &lt;a href="http://20n.com/"&gt;20n&lt;/a&gt;, &lt;a href="http://www.atomwise.com/"&gt;atomwise&lt;/a&gt;, 
&lt;a href="https://www.transcriptic.com/"&gt;Transcriptic&lt;/a&gt; and &lt;a href="https://www.notablelabs.com/"&gt;Notable Labs&lt;/a&gt;.
Synbio leader &lt;a href="http://www.ginkgobioworks.com/"&gt;Ginkgo&lt;/a&gt; was funded in 2014.
11 of the 14 biotechs from 2017 are diagnostics (including Clear Genetics), 
one is a therapy / medical device (Volt),
one a research tool (Indee), 
and one a service I can't classify (Forever Labs).&lt;/p&gt;
&lt;p&gt;It's a curious set of companies, surprisingly light on computation- or data-driven companies, 
which you'd think would be YC's strength.
Also notably, I don't see any synthetic biology companies (arguably Indee?) 
and only Volt Health is therapeutic.
By contrast, IndieBio has many (at least half?) synthetic biology companies, 
and several therapeutics.&lt;/p&gt;
&lt;p&gt;Because the list is so diagnostics-focused, many of the companies on this list 
will need expensive trials to properly enter their markets. 
Perhaps the YC program is setting them up for a raise from traditional biotech VCs? 
I don't yet see what YC wants to do in biotech, 
but their statement about doing more is only a few months old, 
so it will be interesting to see what happens in 2018.&lt;/p&gt;</content><category term="biotech"/><category term="biotech"/><category term="vc"/></entry><entry><title>Drug Targets and Therapies</title><link href="/drug-targets-and-therapies.html" rel="alternate"/><published>2017-06-27T11:00:00-07:00</published><updated>2017-06-27T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2017-06-27:/drug-targets-and-therapies.html</id><summary type="html">&lt;p&gt;Some notes on drug development: classes of drug targets and therapies.&lt;/p&gt;</summary><content type="html">&lt;p&gt;I looked around for a broad review of this area, 
discussing classes of drug targets and therapies,
but didn't really find anything. 
These are some notes I made in an effort to help understand the landscape. &lt;/p&gt;
&lt;h1&gt;Drug target types&lt;/h1&gt;
&lt;p&gt;Every drug has a "target", a biomolecule that the drug affects in humans.
There are only a few options for targets.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Underexpressed protein&lt;/strong&gt;&lt;br&gt;
  Sometimes, a protein is lacking and needs to be upregulated or replaced.
  The solution, for extracellular proteins, can be as simple as injecting the missing protein.
  This may sound like it's an obscure element of drug development, 
  but it's basically the foundation of biotech.
  Genzyme started out replacing the missing enzymes in Gaucher and Fabry disease;
  Genentech got their start with recombinant insulin, an underexpressed peptide;
  Amgen's first big drug was recombinant G-CSF (neupogen).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Overexpressed protein&lt;/strong&gt;&lt;br&gt;
  Sometimes, you are making too much protein and you need to dial it down.
  Many cancer targets are like this (e.g., HER2 amplification), though some are 
  mutated too.
  This is one of the easiest scenarios for drug development, 
  because all you have to do is knock the protein down with high specificity. 
  It's much easier to break something than fix it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Malfunctioning protein&lt;/strong&gt;&lt;br&gt;
  If you have a genetic disease, there's a good chance it's due to an absent or 
  malfunctioning protein. 
  Cystic fibrosis has over a thousand known causative mutations and most of these mutations cause misfolding.
  How do you fix a misfolded protein? It's always difficult and sometimes impossible.
  Vertex's CF drugs represent one unusual success story. 
  Their latest drug, Orkambi, is actually two drugs in one: 
  one that increases CFTR's activity (Kalydeco, a drug originally for the G551D mutation only), 
  and the other helps the mutated CFTR fold properly.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Non-proteins&lt;/strong&gt;&lt;br&gt;
  There are things in the body besides proteins, for example, hormones, lipids, DNA.
  These are much less common targets for therapies, though amazingly gene therapy is starting to become feasible.
  (There are now two human gene therapies approved in Europe, and several veterinary gene therapies).
  According to a &lt;a href="http://www.nature.com/nrd/journal/v16/n1/full/nrd.2016.230.html"&gt;2016 review in NRDD&lt;/a&gt;, 
  FDA-approved drugs targeted non-proteins in only 28/695 cases.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Choice of Therapy&lt;/h1&gt;
&lt;p&gt;There are a plethora of options these days. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Small molecules&lt;/strong&gt;  &lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Chemical&lt;/strong&gt;&lt;br&gt;
  This is what most people mean by a drug. 
  You use chemistry to make them:
  perhaps you have a large library of randomly generated chemicals that you screen against a target,
  or perhaps you design your drug and simulate target binding computationally.
  Computer-aided drug design (CADD) works sometimes and is improving quickly, partially
  thanks to &lt;a href="http://deepchem.io"&gt;deep learning&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Biological&lt;/strong&gt;&lt;br&gt;
  Unlike chemically-derived small molecules, you don't create these, you find them in organisms in the soil, the ocean, etc.
  These molecules are generally more complex structurally than regular small molecules, 
  since they've had millions of years to evolve that complexity.
  &lt;a href="http://pubs.acs.org/doi/abs/10.1021/acs.jnatprod.5b01055"&gt;Many drugs&lt;/a&gt; come from natural sources, 
  especially antibiotics; the main issue is how to find them. 
  We have already found much of the low-hanging fruit, like penicillin, many times over.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DNA-encoded&lt;/strong&gt;&lt;br&gt;
  It's obvious that you can use DNA to encode and evolve proteins. 
  Less obviously, you can encode small molecules too, by chemically fusing DNA barcodes to your chemicals.
  These libraries are interesting because just like proteins, you can evolve them, 
  but you retain the flexible chemistry of small molecules. 
  &lt;a href="http://www.dicemolecules.com/"&gt;DiCE Molecules&lt;/a&gt;, which launched last year, is doing this.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Proteins&lt;/strong&gt;  &lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Recombinant&lt;/strong&gt;&lt;br&gt;
  You can make almost any protein recombinantly in a microbe, then use that to replace a missing (extracellular) enzyme.
  Proteins are big, and get degraded quickly in the gut by proteases, 
  so you usually have to inject them.
  (If ingesting proteins had drug-like effects, then eating would be more hazardous!)
  They are also usually too large to enter cells efficiently, further limiting their use as drugs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Antibodies&lt;/strong&gt;&lt;br&gt;
  Antibodies are proteins, but with a specific template for interfacing with the immune system.
  They are very large and cannot enter cells, so they only target cell-surface or extracellular targets.
  That works extremely well for the 10-20% of proteins that are accessible that way.
  Antibodies are our closest thing to a &lt;a href="https://www.nature.com/nrc/journal/v8/n6/full/nrc2394.html"&gt;magic bullet&lt;/a&gt;, 
  and are among the &lt;a href="https://lifescivc.com/2017/05/human-antibody-discovery-mice-phage/"&gt;most successful drugs&lt;/a&gt; 
  of all time.
  You can evolve antibodies in mice, use phage display, or identify them in humans.
  There are several varieties: &lt;a href="https://en.wikipedia.org/wiki/Single-chain_variable_fragment"&gt;antibody fragments&lt;/a&gt;, 
  &lt;a href="https://en.wikipedia.org/wiki/Single-domain_antibody"&gt;nanobodies&lt;/a&gt;, 
  &lt;a href="https://en.wikipedia.org/wiki/Bi-specific_T-cell_engager"&gt;BiTEs&lt;/a&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Peptides&lt;/strong&gt;&lt;br&gt;
  Peptides are basically just short proteins.
  They are interesting &lt;a href="http://www.sciencedirect.com/science/article/pii/S1359644614003997"&gt;potential drugs&lt;/a&gt; 
  because they exhibit some of the properties of small molecules 
  (small size, sometimes able to enter cells)
  and some of the properties of proteins (safe, easy to synthesize).
  Peptides are still rapidly degraded in the gut, so most are injected. 
  Some of the limitations of peptides being proteins can be overcome by using &lt;a href="https://en.wikipedia.org/wiki/Peptidomimetic"&gt;peptidomimetics&lt;/a&gt;
  like D-peptides.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Peptides (DNA-encoded)&lt;/strong&gt;&lt;br&gt;
  Peptides are generally encoded by DNA anyway, 
  but there is a nice way to evolve a library of peptides, analogous to DNA-encoded small molecules: 
  the decades-old-but-still-futuristic &lt;a href="https://en.wikipedia.org/wiki/Phage_display"&gt;phage display&lt;/a&gt;. 
  You can use phage display to select for antibody fragment binding too. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Protein + nucleotide&lt;/strong&gt;&lt;br&gt;
  CRISPR/Cas9 is a gene editing technology combining an enzyme that cuts DNA (Cas9) 
  and an guide RNA that defines the target.
  Cas9 is a sophisticated enzyme, so it is quite large and cannot enter cells unaided. 
  That means to make Cas9 into a real therapy you need a way to deliver it.
  Older gene editing technologies like TALENs and Zinc Fingers also work well
  if they can be delivered, though they are much harder to program than Cas9.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Protein + small molecule&lt;/strong&gt;&lt;br&gt;
  Antibody-drug conjugates promise to combine the advantages of 
  antibodies (targeting cells with high specificity) with small molecules (ability to enter cells).
  The canonical example is an antibody designed to find a cancer cell, 
  then deliver an attached "warhead" small molecule to kill it. 
  &lt;a href="http://www.stemcentrx.com/clinical-trials.html"&gt;Stemcentrx&lt;/a&gt; is one of many companies working on ADCs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nucleotides&lt;/strong&gt;  &lt;ul&gt;
&lt;li&gt;&lt;strong&gt;mRNA&lt;/strong&gt;&lt;br&gt;
  Instead of delivering proteins to cells, why not just deliver the instructions to make the protein?
  Unfortunately, just like proteins get degraded by proteases, RNA gets degraded by nucleases, 
  so again it comes down to delivery.
  Like proteins, the body tolerates nucleotides very well.
  &lt;a href="https://www.modernatx.com/pipeline"&gt;Moderna&lt;/a&gt; is developing several mRNA-based therapies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Antisense RNA&lt;/strong&gt;&lt;br&gt;
  Antisense RNA binds to mRNA and interferes with translation.
  There have been two successful antisense RNA therapies recently: 
  one for Crohn's (mongersen, which can be orally administered, since Crohn's is a disease of the gut),
  and one for SMA (nusinersen, which is injected into the CSF).
  Despite not being the coolest technology around, antisense RNA has had some amazing successes.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Aptamers&lt;/strong&gt;&lt;br&gt;
  Like antibodies, aptamers are evolved to bind their targets with high specificity,
  but instead of amino acids, they are made from DNA or RNA.
  Aptamers can be evolved using a simple process called
  &lt;a href="https://en.wikipedia.org/wiki/Systematic_evolution_of_ligands_by_exponential_enrichment"&gt;SELEX&lt;/a&gt;
  (unfortunately &lt;a href="(https://www.nature.com/nrd/journal/v9/n7/box/nrd3141_BX1.html)"&gt;IP-encumbered&lt;/a&gt;).
  As nucleotides, aptamers are degraded quickly and require special delivery mechanisms.
  The only approved aptamer therapy, Macugen, is for AMD and it's injected 
  &lt;a href="https://en.wikipedia.org/wiki/Pegaptanib"&gt;directly into the eye&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;RNAi&lt;/strong&gt;&lt;br&gt;
  RNAi encompasses a few related systems that are difficult for me to differentiate: siRNA, shRNA, miRNA, piRNA.
  RNA interference is an extremely effective tool for modifying cell lines, 
  but so far has been less effective as a therapy.
  &lt;a href="http://www.alnylam.com/our-pipeline/"&gt;Alnylam&lt;/a&gt; has several RNAi therapies in development.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Raw DNA/RNA&lt;/strong&gt;&lt;br&gt;
  Raw DNA or RNA with the right sequence will do &lt;a href="https://www.ncbi.nlm.nih.gov/pubmed/11841612"&gt;gene editing at low frequency&lt;/a&gt;,
  even without a proper vector.
  You can also inject complete plasmids that get transcribed and translated
  (assuming some accompanying stress like electroporation). 
  This is called a DNA vaccine, which is conceptually quite similar to an mRNA, except 
  that DNA vaccines are injected with an adjuvant like &lt;a href="https://en.wikipedia.org/wiki/Freund%27s_adjuvant"&gt;Freund's adjuvant&lt;/a&gt;,
  to elicit an immune response to the resultant protein.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cells&lt;/strong&gt;&lt;br&gt;
  Cell-based therapies are becoming increasingly important, especially for cancer treatment.
  In cancer, the idea is to train the immune system (usually T-cells) 
  to attack cancer cells more efficiently. 
  Since the vast majority of cancers are quashed by the immune system anyway, this makes a lot of sense.
  CAR-Ts — perhaps the best-known cell therapy for cancer —
  are T-cells that have been extracted and forced to express a cell-surface antibody fragment
  with specificity for a cancer,
  which forces the T-cell to engage the cancer.
  There's a lot more going on in cell-based therapy, 
  like &lt;a href="http://www.nature.com/news/behind-the-scenes-of-the-world-s-first-commercial-stem-cell-therapy-1.17022"&gt;stem cell therapies&lt;/a&gt;, 
  but I don't know too much about this.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="/images/drug_targets_venn.svg" style="min-width:60%;max-width:80%;padding:3em;display:block;margin:auto;" /&gt;&lt;/p&gt;
&lt;h1&gt;Delivery&lt;/h1&gt;
&lt;p&gt;The big advantage of small molecules over proteins and nucleotides
— and a watchword for most of the novel therapies above — is delivery: 
small molecules can get across the gut 
and penetrate the cell membrane to bind with targets inside the cell.
Proteins and nucleotides are degraded quickly, especially in the gut,
and proteins are usually way too large to enter cells anyway.&lt;/p&gt;
&lt;p&gt;There are exceptions to this rule,  cases when cells are more accessible:
for example, the eye is easier to access than most organs (e.g., the aptamer therapy, Macugen);
if your target is in the gut then you may be able to deliver it orally (e.g., the antisense RNA therapy, mongersen);
if you can apply your therapy ex vivo (especially retransplantable tissue like liver or bone marrow) 
then you no longer need a delivery vector (e.g., &lt;a href="https://en.wikipedia.org/wiki/Sipuleucel-T"&gt;Provenge&lt;/a&gt; 
and other adoptive cell transfers, gene editing in embryos).
Examining the pipelines of the new batch of gene editing and RNA therapy biotechs,
we see that the diseases they tackle are very often in the bone marrow, liver or eye.&lt;/p&gt;
&lt;p&gt;If your target is inside a cell, 
the cell cannot be extracted for treatment ex vivo, 
and you can't develop a good small molecule, then what can you do?
Many of the modern protein or nucleotide-based therapeutics listed above need some some additional help to
protect them from degradation, localize them to target cells, and penetrate the cell membrane.
It could be argued that delivery technology has lagged behind drug technology generally. 
There are still no great options for delivery.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Viruses&lt;/strong&gt;&lt;br&gt;
  Viruses, especially AAV, are especially useful for nucleotide therapies like gene therapy. 
  This makes sense when you consider that viruses are nanomachines, evolved over billions of years to target cells and inject nucleotides.
  However, since viruses are often immunogenic, there can be side-effects.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nanoparticles / Liposomes&lt;/strong&gt;&lt;br&gt;
  In rare cases, liposomes have been used to deliver drugs, like &lt;a href="https://www.ncbi.nlm.nih.gov/pubmed/20671511"&gt;cisplatin&lt;/a&gt;.
  We were &lt;a href="https://www.forbes.com/sites/nathanvardi/2016/12/14/modernas-mysterious-medicines/#53a05a4a6ef6"&gt;recently surprised to learn&lt;/a&gt;
  that Moderna, the mRNA biotech, is using lipid-nanoparticles to deliver mRNA to cells.
  &lt;a href="http://onlinelibrary.wiley.com/store/10.1002/btm2.10049/asset/btm210049.pdf"&gt;Virus-like particles&lt;/a&gt;
  (essentially noninfectious viruses) may combine the best of both worlds.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For a more detailed discussion on delivery methods, 
there's a good &lt;a href="http://www.nature.com/nrd/journal/v16/n6/full/nrd.2016.280.html"&gt;recent review in NRDD&lt;/a&gt;.&lt;/p&gt;
&lt;!--
END


.. [https://en.wikipedia.org/wiki/Lumacaftor/ivacaftor]
   Ivacaftor increases the activity of the CFTR protein at the surface of epithelial cell,
   while lumacaftor acts as a chaperone during protein folding and increases the number of
   CFTR proteins that are trafficked to the cell surface.



Enzyme replacement
------------------
This one is simple: the patient lacks an enzyme (Gaucher, Fabry), so you supply it 
by injecting it. 
[https://en.wikipedia.org/wiki/Enzyme_replacement_therapy]

.. [https://en.wikipedia.org/wiki/Lenalidomide]
   On a molecular level, lenalidomide has been shown to interact with the ubiquitin E3 
   ligase cereblon[26] and target this enzyme to degrade the Ikaros transcription factors 
   IKZF1 and IKZF3.[27] This mechanism was unexpected as it suggests that the major action 
   of lenalidomide is to re-target the activity of an enzyme rather than block the 
   activity of an enzyme or signaling process, and thereby represents a novel mode of drug
   action. A more specific implication of this mechanism is that the teratogenic and 
   anti-neoplastic properties of lenalidomide, and perhaps other thalidomide derivatives, 
   could be disassociated.

Small molecule recruiting proteins
----------------------------------
The main exmaple here is rapamycin recruiting FKBP
[Warp Drive slides]

Small molecule stabilizing protein folding
------------------------------------------
In rare cases, a causative deleterious mutation may be rescued by helping fold better.
These are 

Antibodies
----------
Antibodies are perhaps our best method of making drugs these days.
Antibodies make great drugs. In fact X of the top ten best-selling drugs are antibodies.
The two catches are that you have to infuse them
 drugs are antibodies. Antibodies are excellent at targeting cell-surface proteins.

Bi-specific antibodies are a new, interesting application. 
The general idea is to use one arm of the antibody to bind a cancer cell-surface marker,
and the other engages a T-cell. 
Colocalizing a T-cell with a cancer cell encourages the T-cell to take action.


Antibody-drug conjugates
------------------------
Antibodies can also be loaded up with a "warhead", a toxic small molecule that 
enables . These toxic warheads are often natural products.

.. [https://en.wikipedia.org/wiki/Pyrrolobenzodiazepine]
   In vitro, pyrrolobenzodiazepines typically demonstrate IC50 values in the low to mid 
   picomolar range in a variety of cell types, and unlike the anti-tubulin agents, they 
   can induce cell death in both dividing and non-dividing cells.

Nucleotides
-----------
RNAi (Alnylam), MicroRNA (Mirna), mRNA (Moderna), CRISPR (CRISPR Therapeutics) are all 
pretty similar.
If you can get your nucleotides into the cell, then you can do a lot.

There have been two recent successes in antisense oligos: mongersen and nusinersen
Mongersen is a treatment for Crohn's, and is delivered by a pH-dependent release capsule, 
nusinersen is a treatment for SMA, and is injected directly into the CSF. 

Delivery is the big challenge here. 
If you look at pipelines, most companies focus on /ex vivo/ applications.


Recent successes include the SMA drug 

.. Ionis nusinersen/Spinraza, injected into CSF. It modifies splicing of SMN2.
.. mongersen (shRNA), antisense oligonucleotide. Targets SMAD7.
   [https://lifescicle.wordpress.com/2015/03/26/mongersen-oral-crohns-panacea-or-celgenes-riskiest-bet-yet/]
   (Mongersen is formulated inside a pH-dependent release capsule, intended to release the shRNA only in the terminal ileum and right colon)

Peptides
--------
Peptides are a very flexible way to attack the problem.
Like antibodies, they are generally better at working at the cell surface. 
Antibodies are ~150kDa, where peptides can be as little as 100's of Daltons, so there 
is more flexibility to cross the cell membrane.

There are a few biotechs working on peptides, including Aileron, Synthex.

Larger pharma companies like Sanofi and Abbott also make peptides, 
but it seems like that's more like mimicking and replacing existing hormones 
than new drug discovery.

.. [http://www.sciencedirect.com/science/article/pii/S1359644614003997]


Vaccines
--------
Vaccines are not the same as drugs, but they are not so different.
Usually, we think of vaccines as being injected well before infection, where they
confer immunity.


Therapeutic Vaccines
~~~~~~~~~~~~~~~~~~~~
Vaccines need not necessarily be preventive. There are also therapeutic vaccines.
There is one therapeutic vaccine on the market, Provenge.
However, the process is more involved than you might hope, with the cancer patient's
white blood cells being removed, trained using the vaccine, then reinjected.
(Interestingly, Provenge was also one of the first extremely expensive cancer treatments
that caused uproar).

There are many efforts underway to develop cancer vaccines. 

DNA Vaccines
~~~~~~~~~~~~
A vaccine also does not necessarily have to be a protein. 
If you inject a plasmid, you can get the host cells to express the protein.


.. [https://www.cancer.gov/about-cancer/causes-prevention/vaccines-fact-sheet]

--&gt;</content><category term="biotech"/><category term="biotech"/><category term="drug development"/></entry><entry><title>An Automated Protein Synthesis Pipeline with Transcriptic and Snakemake</title><link href="/transcriptic_protein_synthesis_pipeline.html" rel="alternate"/><published>2017-02-06T11:00:00-08:00</published><updated>2017-02-06T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2017-02-06:/transcriptic_protein_synthesis_pipeline.html</id><summary type="html">&lt;p class="first last"&gt;How to automate protein synthesis pipeline using transcriptic and snakemake&lt;/p&gt;
</summary><content type="html">&lt;p&gt;In a &lt;a class="reference external" href="http://blog.booleanbiotech.com/genetic_engineering_pipeline_python.html"&gt;previous blogpost&lt;/a&gt;
I described a pipeline for synthesizing arbitrary proteins on the
&lt;a class="reference external" href="https://www.transcriptic.com/how-it-works/"&gt;transcriptic robotic lab platform&lt;/a&gt;
using only Python code.
The ultimate goal of that project was to be able to run a program that takes a protein sequence as input,
and &amp;quot;returns&amp;quot; a tube of bacteria expressing that protein.
Here I'll describe some progress towards that goal.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;object data="/images/clab_pipeline.svg" style="width: 100%;" type="image/svg+xml"&gt;pipeline diagram&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="pipelining"&gt;
&lt;h2&gt;Pipelining&lt;/h2&gt;
&lt;p&gt;The usual way to chain together different programs in bioinformatics is with a
pipeline management system, for example,
&lt;a class="reference external" href="https://bitbucket.org/snakemake/snakemake/wiki/Home"&gt;snakemake&lt;/a&gt;,
&lt;a class="reference external" href="https://www.nextflow.io/"&gt;nextflow&lt;/a&gt;,
&lt;a class="reference external" href="https://github.com/BD2KGenomics/toil"&gt;toil&lt;/a&gt;,
&lt;a class="reference external" href="https://github.com/broadinstitute/wdl"&gt;WDL&lt;/a&gt;, and many many more.
I've recently become a big fan of nextflow for computational pipelines,
but its major advantages
(e.g., &lt;a class="reference external" href="https://www.nextflow.io/blog/2016/more-fun-containers-hpc.html"&gt;containerization&lt;/a&gt;)
don't help much here because so much of the work happens outside of the computer.
For this project I've been using the slightly simpler snakemake,
mainly for tracking which steps have been completed,
and deciding which steps can be run in parallel based on their dependencies.&lt;/p&gt;
&lt;p&gt;Each protocol has four associated steps in the pipeline:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;generate protocol&lt;/strong&gt;: create an autoprotocol file describing the protocol&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;submit protocol&lt;/strong&gt;: submit the autoprotocol file to transcriptic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;get results&lt;/strong&gt;: download images, data, etc. from transcriptic&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;create report&lt;/strong&gt;: create a HTML report from the downloaded data&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="figure"&gt;
&lt;object data="/images/clab_rulegraph.svg" style="width: 65%;" type="image/svg+xml"&gt;snakemake pipeline&lt;/object&gt;
&lt;p class="caption"&gt;&lt;em&gt;snakemake pipeline for protein synthesis&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="metaprotocol"&gt;
&lt;h2&gt;Metaprotocol&lt;/h2&gt;
&lt;p&gt;In my terminology, a &amp;quot;metaprotocol&amp;quot; defines the complete process,
which is turned into a series of protocols.
Ideally, the output of a single protocol will be a decision point:
for example, whether or not a gel image includes the expected bands.&lt;/p&gt;
&lt;p&gt;The metaprotocol is defined in yaml, which has its issues,
but is more readable than json, and well supported.
This code depends heavily on &lt;a class="reference external" href="https://github.com/BjornFJohansson/pydna"&gt;Pydna&lt;/a&gt;,
a Python package for cloning and assembly.
Given an insert and a vector, Pydna will design primers and a PCR program.
The following is my metaprotocol yaml for expressing GFP:&lt;/p&gt;
&lt;pre class="code yaml literal-block"&gt;
&lt;span class="p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;assembly&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p-Indicator"&gt;|-&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Assembly:&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Sequences........................: [2690] [786]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Sequences with shared homologies.: [2690] [786]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Homology limit (bp)..............: 25&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Number of overlaps...............: 2&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Nodes in graph(incl. 5' &amp;amp; 3')....: 4&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Only terminal overlaps...........: No&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Circular products................: [3412]&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Linear products..................: [3446] [3442] [34] [30]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;assembly_figure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p-Indicator"&gt;|2-&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="no"&gt;-|SYNPUC19V|31&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;|            \/&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;|            /\&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;|            31|786bp_PCR_prod|30&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;|                              \/&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;|                              /\&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;|                              30-&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;|                                 |&lt;/span&gt;&lt;span class="w"&gt;
       &lt;/span&gt;&lt;span class="no"&gt;---------------------------------&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;metaprotocol_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;1k9ginus&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;pcr_figure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p-Indicator"&gt;|2-&lt;/span&gt;&lt;span class="w"&gt;
                                    &lt;/span&gt;&lt;span class="no"&gt;5AGGAGGACAGCTATGTCGAAAGGA...CATTACCCATGGAATGGATGAACTGTATAAA3&lt;/span&gt;&lt;span class="w"&gt;
                                                                &lt;/span&gt;&lt;span class="no"&gt;||||||||||||||||||||||||||||||| tm 59.8 (dbd) 70.6&lt;/span&gt;&lt;span class="w"&gt;
                                                               &lt;/span&gt;&lt;span class="no"&gt;3GTAATGGGTACCTTACCTACTTGACATATTTTTAAGTGACCGGCAGCAAAATGTTGCAGCA5&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;5ACTCTAGAGGATCCCCGGGTACCGAGCTCGAGGAGGACAGCTATGTCGAAAGGA3&lt;/span&gt;&lt;span class="w"&gt;
                                     &lt;/span&gt;&lt;span class="no"&gt;|||||||||||||||||||||||| tm 62.1 (dbd) 69.3&lt;/span&gt;&lt;span class="w"&gt;
                                    &lt;/span&gt;&lt;span class="no"&gt;3TCCTCCTGTCGATACAGCTTTCCT...GTAATGGGTACCTTACCTACTTGACATATTT5&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;pcr_program&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p-Indicator"&gt;|2&lt;/span&gt;&lt;span class="w"&gt;

      &lt;/span&gt;&lt;span class="no"&gt;Pfu-Sso7d (rate 15s/kb)&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;Two-step|    30 cycles |      |786bp&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;98.0°C  |98.0C         |      |Tm formula: Pydna tmbresluc&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;_____ __|_____         |      |SaltC 50mM&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="no"&gt;00min30s|10s  \        |      |Primer1C 1.0µM&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="no"&gt;|      \ 72.0°C|72.0°C|Primer2C 1.0µM&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="no"&gt;|       \______|______|GC 49%&lt;/span&gt;&lt;span class="w"&gt;
              &lt;/span&gt;&lt;span class="no"&gt;|       0min11s|10min |4-12°C&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;project_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;pUC19_sfGFP_cloning_v1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;linearize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;restriction_enzyme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;EcoRI&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;pUC19&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;oligosynthesize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;ACTCTAGAGGATCCCCGGGTACCGAGCTCGAGGAGGACAGCTATGTCGAAAGGA&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;ACGACGTTGTAAAACGACGGCCAGTGAATTTTTATACAGTTCATCCATTCCATGGGTAATG&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;AGGAGGACAGCTATGTCGAAAGGAGAAGAACTGTTTACCGGTGTGGTTCCGATTCTGGTAGAACTGGATGGGGACGTGAACGGCCATAAATTTAGCGTCCGTGGTGAGGGTGAAGGGGATGCCACAAATGGCAAACTTACCCTTAAATTCATTTGCACTACCGGCAAGCTGCCGGTCCCTTGGCCGACCTTGGTCACCACACTGACGTACGGGGTTCAGTGTTTTTCGCGTTATCCAGATCACATGAAACGCCATGACTTCTTCAAAAGCGCCATGCCCGAGGGCTATGTGCAGGAACGTACGATTAGCTTTAAAGATGACGGGACCTACAAAACCCGGGCAGAAGTGAAATTCGAGGGTGATACCCTGGTTAATCGCATTGAACTGAAGGGTATTGATTTCAAGGAAGATGGTAACATTCTCGGTCACAAATTAGAATACAACTTTAACAGTCATAACGTTTATATCACCGCCGACAAACAGAAAAACGGTATCAAGGCGAATTTCAAAATCCGGCACAACGTGGAGGACGGGAGTGTACAACTGGCCGACCATTACCAGCAGAACACACCGATCGGCGACGGCCCGGTGCTGCTCCCGGATAATCACTATTTAAGCACCCAGTCAGTGCTGAGCAAAGATCCGAACGAAAAACGTGACCATATGGTGCTGCTGGAGTTCGTGACCGCCGCGGGCATTACCCATGGAATGGATGAACTGTATAAA&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;ACTCTAGAGGATCCCCGGGTACCGAGCTCGAGGAGGACAGCTATGTCGAAAGGA&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;p2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;ACGACGTTGTAAAACGACGGCCAGTGAATTTTTATACAGTTCATCCATTCCATGGGTAATG&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;program&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nt"&gt;extension_time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;11.0&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nt"&gt;forward_primer_concentration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;0.001&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nt"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;15.0&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nt"&gt;reverse_primer_concentration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;0.001&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nt"&gt;saltc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;50.0&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nt"&gt;ta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;72.0&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;assemble&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;sfGFP&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nt"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l-Scalar-Plain"&gt;pUC19&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="dna-synthesis"&gt;
&lt;h2&gt;DNA synthesis&lt;/h2&gt;
&lt;p&gt;Of course, before you can run this pipeline,
you need to have the appropriate insert DNA in your transcriptic inventory.
As far as I know, none of the major synthetic DNA suppliers has an API.
However, you can order DNA from IDT by filling in an &lt;a class="reference external" href="https://www.idtdna.com/pages/home/how-to-order"&gt;excel file&lt;/a&gt;.
I have automated filling in and emailing this file,
so DNA synthesis can be included in the pipeline too!
It should take about a week from ordering for DNA to appear at transcriptic.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="reporting"&gt;
&lt;h2&gt;Reporting&lt;/h2&gt;
&lt;p&gt;After each protocol finishes, a HTML report is generated.
This allows the user to evaluate protocol results manually before initiating the next step.
There are ways to automate this more,
like using automated band mapping of gel images,
but I think that kind of thing will work better once the transcriptic API settles down a bit.
The HTML report also serves as a log of the experiment.&lt;/p&gt;
&lt;embed"&gt;
&lt;!--&lt;html class="x"&gt;--&gt;

&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;!--&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;--&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" /&gt;
&lt;title&gt;cut_plasmid FINISHED&lt;/title&gt;
&lt;style type="text/css"&gt;

/**
Credits for the colors and font selection go to the Twitter Bootstrap framework.
*/


body.x {
    color: rgb(51, 51, 51);
    font-size: 10pt;
    padding-top: 10px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
pre.x {
    background-color:transparent;
}
p.x {
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
h1.x {
    font-size: 150%;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

h.x {
    font-size: 140%;
}

h.x {
    font-size: 130%;
}

h.x {
    font-size: 120%;
}

h.x {
    font-size: 110%;
}

h.x {
    font-size: 100%;
}

div.x#attachments {
    display: inline-block;
    color: gray;
    border-width: 1px;
    border-style: solid;
    border-color: white;
    border-radius: 4px 4px 4px 4px;
    padding: 0px;
}

div.x#attachments dt {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments dd p.x {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments :target dt {
    font-weight: bold;
}

div.x#attachments :target a.x {
    color: rgb(70, 136, 71);
}


h1.title.x {
    color: rgb(50,150,50);
    text-align: center;
    margin-bottom:10px;
}

div.x.document {
    position: relative;
    background: white;
    max-width: 800px;
    margin: auto;
    padding: 20px;
    border: 1px solid rgb(221, 221, 221);
    border-radius: 4px 4px 4px 4px;
}

div.x.document:after {
    content: "snakemake report";
    position: absolute;
    top: -1px;
    right: -1px;
    padding: 3px 7px;
    background-color: #f5f5f5;
    border: 1px solid rgb(221, 221, 221);
    color: #9da0a4;
    font-weight: bold;
    font-size: 12pt;
    border-radius: 0 0 0 4px;
}

div.x.document p.x {
    text-align: justify;
}

div.x#metadata.x {
    text-align: right;
}

table.x.docutils {
    border: none;
    border-collapse: collapse;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    text-align: center;
}

table.x.docutils th {
    border: none;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    padding: 5px;
}

table.x.docutils td {
    border: none;
    padding: 5px;
}

table.x.docutils th:last-child, td:last-child {
    text-align: left;
}

table.x.docutils th:first-child, td:first-child {
    text-align: right;
}

table.x.docutils th:only-child, td:only-child {
    text-align: center;
}

table.x.docutils.footnote {
    border: none;
    text-align: left;
}

a.x {
    color: rgb(0, 136, 204);
    text-decoration: none;
}

a.x:hover {
    color: rgb(0, 85, 128);
    text-decoration: underline;
}


div.x.figure {
    margin-left: 2em;
    margin-right: 2em;
}

img.x {
    max-width: 100%;
}

p.x.caption {
    font-style: italic;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="document x" id="cut-plasmid-succeeded"&gt;
&lt;h1 class="title x"&gt;cut_plasmid &lt;strong&gt;FINISHED&lt;/strong&gt;&lt;/h1&gt;

&lt;pre class="literal-block x"&gt;
 Submitted at UTC 2016-08-20 19:42:48
   Started at UTC 2016-08-20 22:52:06
 Completed at UTC 2016-08-21 01:28:49
Ran report at UTC 2016-10-26 22:15:03
&lt;/pre&gt;
&lt;hr class="docutils x" /&gt;
&lt;p&gt;Expected DNA bands of size: &lt;tt class="docutils literal"&gt;2686bp&lt;/tt&gt;&lt;/p&gt;
&lt;!--&lt;img alt="cut_plasmid_pUC19_EcoRI.gel.jpeg" src="cut_plasmid_pUC19_EcoRI.gel.jpeg" /&gt;--&gt;
&lt;img src="/images/clab_1.jpeg"&gt;

&lt;div class="xcontainer x" id="attachments"&gt;
&lt;div class="xcontainer x" id="jpeg"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;jpeg:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:image/jpeg;charset=utf8;filename=cut_plasmid_pUC19_EcoRI.gel.jpeg;base64,MQ==" download="cut_plasmid_pUC19_EcoRI.gel.jpeg" draggable="true"&gt;cut_plasmid_pUC19_EcoRI.gel.jpeg&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="xcontainer x" id="runstatus"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;runstatus:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:application/json;charset=utf8;filename=cut_plasmid_pUC19_EcoRI.runstatus.json;base64,MQ==" download="cut_plasmid_pUC19_EcoRI.runstatus.json" draggable="true"&gt;cut_plasmid_pUC19_EcoRI.runstatus.json&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="xcontainer x" id="sentinel"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;sentinel:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:text/plain;charset=utf8;filename=cut_plasmid_pUC19_EcoRI.sentinel;base64,MQ==" download="cut_plasmid_pUC19_EcoRI.sentinel" draggable="true"&gt;cut_plasmid_pUC19_EcoRI.sentinel&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!--&lt;div class="xcontainer x" id="metadata"&gt;
2016-10-26&lt;/div&gt;--&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;!--&lt;/html&gt;--&gt;
 &lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;!--&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;--&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" /&gt;
&lt;title&gt;synthesize_primers &lt;strong&gt;FINISHED&lt;/strong&gt;&lt;/title&gt;
&lt;style type="text/css"&gt;

/**
Credits for the colors and font selection go to the Twitter Bootstrap framework.
*/


body.x {
    color: rgb(51, 51, 51);
    font-size: 10pt;
    padding-top: 10px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

h1.x {
    font-size: 150%;
}

h2.x {
    font-size: 140%;
}

h3.x {
    font-size: 130%;
}

h4.x {
    font-size: 120%;
}

h5.x {
    font-size: 110%;
}

h6.x {
    font-size: 100%;
}

div.x#attachments {
    display: inline-block;
    color: gray;
    border-width: 1px;
    border-style: solid;
    border-color: white;
    border-radius: 4px 4px 4px 4px;
    padding: 0px;
}

div.x#attachments dt {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments dd p.x {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments :target dt {
    font-weight: bold;
}

div.x#attachments :target a.x {
    color: rgb(70, 136, 71);
}


h1.title.x {
    color: rgb(50,150,50);
    text-align: center;
    margin-bottom:10px;
}

div.x.document {
    position: relative;
    background: white;
    max-width: 800px;
    margin: auto;
    padding: 20px;
    border: 1px solid rgb(221, 221, 221);
    border-radius: 4px 4px 4px 4px;
}

div.x.document:after {
    content: "snakemake report";
    position: absolute;
    top: -1px;
    right: -1px;
    padding: 3px 7px;
    background-color: #f5f5f5;
    border: 1px solid rgb(221, 221, 221);
    color: #9da0a4;
    font-weight: bold;
    font-size: 12pt;
    border-radius: 0 0 0 4px;
}

div.x.document p.x {
    text-align: justify;
}

div.x#metadata.x {
    text-align: right;
}

table.x.docutils {
    border: none;
    border-collapse: collapse;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    text-align: center;
}

table.x.docutils th {
    border: none;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    padding: 5px;
}

table.x.docutils td {
    border: none;
    padding: 5px;
}

table.x.docutils th:last-child, td:last-child {
    text-align: left;
}

table.x.docutils th:first-child, td:first-child {
    text-align: right;
}

table.x.docutils th:only-child, td:only-child {
    text-align: center;
}

table.x.docutils.footnote {
    border: none;
    text-align: left;
}

a.x {
    color: rgb(0, 136, 204);
    text-decoration: none;
}

a.x:hover {
    color: rgb(0, 85, 128);
    text-decoration: underline;
}


div.x.figure {
    margin-left: 2em;
    margin-right: 2em;
}

img.x {
    max-width: 100%;
}

p.x.caption {
    font-style: italic;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="document x" id="synthesize-primers-succeeded"&gt;
&lt;h1 class="title x"&gt;synthesize_primers &lt;strong&gt;FINISHED&lt;/strong&gt;&lt;/h1&gt;

&lt;pre class="literal-block x"&gt;
 Submitted at UTC 2016-08-23 19:35:37
   Started at UTC 2016-08-23 20:00:11
 Completed at UTC 2016-08-24 20:01:03
Ran report at UTC 2016-10-26 22:15:44
&lt;/pre&gt;
&lt;hr class="docutils x" /&gt;
&lt;p&gt;Synthesized primers:&lt;/p&gt;
&lt;p&gt;&lt;tt class="docutils literal"&gt;ACTCTAGAGGATCCCCGGGTACCGAGCTCGAGGAGGACAGCTATGTCGAAAGGA&lt;/tt&gt;
&lt;tt class="docutils literal"&gt;ACGACGTTGTAAAACGACGGCCAGTGAATTTTTATACAGTTCATCCATTCCATGGGTAATG&lt;/tt&gt;&lt;/p&gt;
&lt;div class="xcontainer x" id="attachments"&gt;
&lt;div class="xcontainer x" id="runstatus"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;runstatus:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:application/json;charset=utf8;filename=synthesize_primers_pUC19_sfGFP.runstatus.json;base64,MQ==" download="synthesize_primers_pUC19_sfGFP.runstatus.json" draggable="true"&gt;synthesize_primers_pUC19_sfGFP.runstatus.json&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="xcontainer x" id="sentinel"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;sentinel:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:text/plain;charset=utf8;filename=synthesize_primers_pUC19_sfGFP.sentinel;base64,MQ==" download="synthesize_primers_pUC19_sfGFP.sentinel" draggable="true"&gt;synthesize_primers_pUC19_sfGFP.sentinel&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!--&lt;div class="xcontainer x" id="metadata"&gt;
2016-10-26&lt;/div&gt;--&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;!--&lt;/html&gt;--&gt;
 &lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;!--&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;--&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" /&gt;
&lt;title&gt;add_flanks FINISHED&lt;/title&gt;
&lt;style type="text/css"&gt;

/**
Credits for the colors and font selection go to the Twitter Bootstrap framework.
*/


body.x {
    color: rgb(51, 51, 51);
    font-size: 10pt;
    padding-top: 10px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

h1.x {
    font-size: 150%;
}

h.x {
    font-size: 140%;
}

h.x {
    font-size: 130%;
}

h.x {
    font-size: 120%;
}

h.x {
    font-size: 110%;
}

h.x {
    font-size: 100%;
}

div.x#attachments {
    display: inline-block;
    color: gray;
    border-width: 1px;
    border-style: solid;
    border-color: white;
    border-radius: 4px 4px 4px 4px;
    padding: 0px;
}

div.x#attachments dt {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments dd p.x {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments :target dt {
    font-weight: bold;
}

div.x#attachments :target a.x {
    color: rgb(70, 136, 71);
}


h1.title.x {
    color: rgb(50,150,50);
    text-align: center;
    margin-bottom:10px;
}

div.x.document {
    position: relative;
    background: white;
    max-width: 800px;
    margin: auto;
    padding: 20px;
    border: 1px solid rgb(221, 221, 221);
    border-radius: 4px 4px 4px 4px;
}

div.x.document:after {
    content: "snakemake report";
    position: absolute;
    top: -1px;
    right: -1px;
    padding: 3px 7px;
    background-color: #f5f5f5;
    border: 1px solid rgb(221, 221, 221);
    color: #9da0a4;
    font-weight: bold;
    font-size: 12pt;
    border-radius: 0 0 0 4px;
}

div.x.document p.x {
    text-align: justify;
}

div.x#metadata.x {
    text-align: right;
}

table.x.docutils {
    border: none;
    border-collapse: collapse;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    text-align: center;
}

table.x.docutils th {
    border: none;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    padding: 5px;
}

table.x.docutils td {
    border: none;
    padding: 5px;
}

table.x.docutils th:last-child, td:last-child {
    text-align: left;
}

table.x.docutils th:first-child, td:first-child {
    text-align: right;
}

table.x.docutils th:only-child, td:only-child {
    text-align: center;
}

table.x.docutils.footnote {
    border: none;
    text-align: left;
}

a.x {
    color: rgb(0, 136, 204);
    text-decoration: none;
}

a.x:hover {
    color: rgb(0, 85, 128);
    text-decoration: underline;
}


div.x.figure {
    margin-left: 2em;
    margin-right: 2em;
}

img.x {
    max-width: 100%;
}

p.x.caption {
    font-style: italic;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="document x" id="add-flanks-finished"&gt;
&lt;h1 class="title x"&gt;add_flanks &lt;strong&gt;FINISHED&lt;/strong&gt;&lt;/h1&gt;

&lt;pre class="literal-block x"&gt;
 Submitted at UTC 2016-10-08 15:12:38
   Started at UTC 2016-10-10 22:22:16
 Completed at UTC 2016-10-11 01:04:12
Ran report at UTC 2016-11-17 15:36:02
&lt;/pre&gt;
&lt;hr class="docutils x" /&gt;
&lt;p&gt;PCR program&lt;/p&gt;
&lt;pre class="literal-block x"&gt;
Pfu-Sso7d (rate 15s/kb)
Two-step|    30 cycles |      |786bp
98.0°C  |98.0C         |      |Tm formula: Pydna tmbresluc
_____ __|_____         |      |SaltC 50mM
00min30s|10s  \        |      |Primer1C 1.0µM
        |      \ 72.0°C|72.0°C|Primer2C 1.0µM
        |       \______|______|GC 49%
        |       0min11s|10min |4-12°C
&lt;/pre&gt;
&lt;!--&lt;img alt="add_flanks_pUC19_sfGFP.gel.jpeg" src="add_flanks_pUC19_sfGFP.gel.jpeg" /&gt;--&gt;
&lt;img src="/images/clab_2.jpeg"&gt;

&lt;div class="xcontainer x" id="attachments"&gt;
&lt;div class="xcontainer x" id="jpeg"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;jpeg:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:image/jpeg;charset=utf8;filename=add_flanks_pUC19_sfGFP.gel.jpeg;base64,MQ==" download="add_flanks_pUC19_sfGFP.gel.jpeg" draggable="true"&gt;add_flanks_pUC19_sfGFP.gel.jpeg&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="xcontainer x" id="runstatus"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;runstatus:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:text/plain;charset=utf8;filename=add_flanks_pUC19_sfGFP.runstatus.yaml;base64,MQ==" download="add_flanks_pUC19_sfGFP.runstatus.yaml" draggable="true"&gt;add_flanks_pUC19_sfGFP.runstatus.yaml&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!--&lt;div class="xcontainer x" id="metadata"&gt;
2016-11-17&lt;/div&gt;--&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;!--&lt;/html&gt;--&gt;
 &lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;!--&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;--&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" /&gt;
&lt;title&gt;run_gibson_and_transform FINISHED&lt;/title&gt;
&lt;style type="text/css"&gt;

/**
Credits for the colors and font selection go to the Twitter Bootstrap framework.
*/


body.x {
    color: rgb(51, 51, 51);
    font-size: 10pt;
    padding-top: 10px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

h1.x {
    font-size: 150%;
}

h.x {
    font-size: 140%;
}

h.x {
    font-size: 130%;
}

h.x {
    font-size: 120%;
}

h.x {
    font-size: 110%;
}

h.x {
    font-size: 100%;
}

div.x#attachments {
    display: inline-block;
    color: gray;
    border-width: 1px;
    border-style: solid;
    border-color: white;
    border-radius: 4px 4px 4px 4px;
    padding: 0px;
}

div.x#attachments dt {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments dd p.x {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments :target dt {
    font-weight: bold;
}

div.x#attachments :target a.x {
    color: rgb(70, 136, 71);
}


h1.title.x {
    color: rgb(50,150,50);
    text-align: center;
    margin-bottom:10px;
}

div.x.document {
    position: relative;
    background: white;
    max-width: 800px;
    margin: auto;
    padding: 20px;
    border: 1px solid rgb(221, 221, 221);
    border-radius: 4px 4px 4px 4px;
}

div.x.document:after {
    content: "snakemake report";
    position: absolute;
    top: -1px;
    right: -1px;
    padding: 3px 7px;
    background-color: #f5f5f5;
    border: 1px solid rgb(221, 221, 221);
    color: #9da0a4;
    font-weight: bold;
    font-size: 12pt;
    border-radius: 0 0 0 4px;
}

div.x.document p.x {
    text-align: justify;
}

div.x#metadata.x {
    text-align: right;
}

table.x.docutils {
    border: none;
    border-collapse: collapse;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    text-align: center;
}

table.x.docutils th {
    border: none;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    padding: 5px;
}

table.x.docutils td {
    border: none;
    padding: 5px;
}

table.x.docutils th:last-child, td:last-child {
    text-align: left;
}

table.x.docutils th:first-child, td:first-child {
    text-align: right;
}

table.x.docutils th:only-child, td:only-child {
    text-align: center;
}

table.x.docutils.footnote {
    border: none;
    text-align: left;
}

a.x {
    color: rgb(0, 136, 204);
    text-decoration: none;
}

a.x:hover {
    color: rgb(0, 85, 128);
    text-decoration: underline;
}


div.x.figure {
    margin-left: 2em;
    margin-right: 2em;
}

img.x {
    max-width: 100%;
}

p.x.caption {
    font-style: italic;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="document x" id="run-gibson-and-transform-finished"&gt;
&lt;h1 class="title x"&gt;run_gibson_and_transform &lt;strong&gt;FINISHED&lt;/strong&gt;&lt;/h1&gt;

&lt;pre class="literal-block x"&gt;
 Submitted at UTC 2016-10-24 23:10:06
   Started at UTC 2016-10-28 17:45:56
 Completed at UTC 2016-10-29 17:01:26
Ran report at UTC 2016-10-30 15:12:18
&lt;/pre&gt;
&lt;hr class="docutils x" /&gt;
&lt;embed&gt;&lt;html&gt;&lt;meta charset="utf-8"&gt;&lt;body&gt;
&lt;div&gt;gibson_and_transform_v1_gibson_and_transform_v1_amp_6_flat_t18.png&lt;/div&gt;

&lt;img width=400 src="/images/clab_3.jpeg"&gt;
&lt;div&gt;gibson_and_transform_v1_gibson_and_transform_v1_amp_6_flat_t9.png&lt;/div&gt;

&lt;img width=400 src="/images/clab_4.jpeg"&gt;
&lt;div&gt;gibson_and_transform_v1_gibson_and_transform_v1_noAB_6_flat_t18.png&lt;/div&gt;

&lt;img width=400 src="/images/clab_5.jpeg"&gt;
&lt;div&gt;gibson_and_transform_v1_gibson_and_transform_v1_noAB_6_flat_t9.png&lt;/div&gt;

&lt;img width=400 src="/images/clab_6.jpeg"&gt;

&lt;div class="xcontainer x" id="attachments"&gt;
&lt;div class="xcontainer x" id="imghtml"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;imghtml:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:text/html;charset=utf8;filename=run_gibson_and_transform_pUC19_sfGFP.plates.html;base64,MQ==" download="run_gibson_and_transform_pUC19_sfGFP.plates.html" draggable="true"&gt;run_gibson_and_transform_pUC19_sfGFP.plates.html&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="xcontainer x" id="runstatus"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;runstatus:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:application/json;charset=utf8;filename=run_gibson_and_transform_pUC19_sfGFP.runstatus.json;base64,MQ==" download="run_gibson_and_transform_pUC19_sfGFP.runstatus.json" draggable="true"&gt;run_gibson_and_transform_pUC19_sfGFP.runstatus.json&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="xcontainer x" id="sentinel"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;sentinel:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:text/plain;charset=utf8;filename=run_gibson_and_transform_pUC19_sfGFP.sentinel;base64,MQ==" download="run_gibson_and_transform_pUC19_sfGFP.sentinel" draggable="true"&gt;run_gibson_and_transform_pUC19_sfGFP.sentinel&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!--&lt;div class="xcontainer x" id="metadata"&gt;
2016-10-30&lt;/div&gt;--&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;!--&lt;/html&gt;--&gt;
 &lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;!--&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;--&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" /&gt;
&lt;title&gt;pick_colonies_and_culture FINISHED&lt;/title&gt;
&lt;style type="text/css"&gt;

/**
Credits for the colors and font selection go to the Twitter Bootstrap framework.
*/


body.x {
    color: rgb(51, 51, 51);
    font-size: 10pt;
    padding-top: 10px;
    font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}

h1.x {
    font-size: 150%;
}

h.x {
    font-size: 140%;
}

h.x {
    font-size: 130%;
}

h.x {
    font-size: 120%;
}

h.x {
    font-size: 110%;
}

h.x {
    font-size: 100%;
}

div.x#attachments {
    display: inline-block;
    color: gray;
    border-width: 1px;
    border-style: solid;
    border-color: white;
    border-radius: 4px 4px 4px 4px;
    padding: 0px;
}

div.x#attachments dt {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments dd p.x {
    margin-top: 2px;
    margin-bottom: 2px;
}

div.x#attachments :target dt {
    font-weight: bold;
}

div.x#attachments :target a.x {
    color: rgb(70, 136, 71);
}


h1.title.x {
    color: rgb(50,150,50);
    text-align: center;
    margin-bottom:10px;
}

div.x.document {
    position: relative;
    background: white;
    max-width: 800px;
    margin: auto;
    padding: 20px;
    border: 1px solid rgb(221, 221, 221);
    border-radius: 4px 4px 4px 4px;
}

div.x.document:after {
    content: "snakemake report";
    position: absolute;
    top: -1px;
    right: -1px;
    padding: 3px 7px;
    background-color: #f5f5f5;
    border: 1px solid rgb(221, 221, 221);
    color: #9da0a4;
    font-weight: bold;
    font-size: 12pt;
    border-radius: 0 0 0 4px;
}

div.x.document p.x {
    text-align: justify;
}

div.x#metadata.x {
    text-align: right;
}

table.x.docutils {
    border: none;
    border-collapse: collapse;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    text-align: center;
}

table.x.docutils th {
    border: none;
    border-top: 2px solid gray;
    border-bottom: 2px solid gray;
    padding: 5px;
}

table.x.docutils td {
    border: none;
    padding: 5px;
}

table.x.docutils th:last-child, td:last-child {
    text-align: left;
}

table.x.docutils th:first-child, td:first-child {
    text-align: right;
}

table.x.docutils th:only-child, td:only-child {
    text-align: center;
}

table.x.docutils.footnote {
    border: none;
    text-align: left;
}

a.x {
    color: rgb(0, 136, 204);
    text-decoration: none;
}

a.x:hover {
    color: rgb(0, 85, 128);
    text-decoration: underline;
}


div.x.figure {
    margin-left: 2em;
    margin-right: 2em;
}

img.x {
    max-width: 100%;
}

p.x.caption {
    font-style: italic;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="document x" id="pick-colonies-and-culture-finished"&gt;
&lt;h1 class="title x"&gt;pick_colonies_and_culture &lt;strong&gt;FINISHED&lt;/strong&gt;&lt;/h1&gt;

&lt;pre class="literal-block x"&gt;
 Submitted at UTC 2016-11-02 19:46:39
   Started at UTC 2016-11-04 00:11:21
 Completed at UTC 2016-11-04 17:54:20
Ran report at UTC 2016-11-11 01:10:22
&lt;/pre&gt;
&lt;hr class="docutils x" /&gt;
&lt;div class="section x" id="absorbance-readings"&gt;
&lt;p&gt;Absorbance readings&lt;/p&gt;
&lt;pre class="literal-block x"&gt;
pick_colonies_and_culture_v1_abs_t16

b1     0.047
a2     0.048
a10    0.050
a7     0.050
a6     0.051
a5     0.051
b6     0.054
b5     0.056
a11    0.058
a3     0.060
b7     0.066
a9     0.071
a1     0.073
b4     0.080
a12    0.080
b10    0.081
a4     0.082
b9     0.083
b2     0.086
b3     0.088
a8     0.090
b11    0.116
b8     0.148
&lt;/pre&gt;
&lt;div class="xcontainer x" id="attachments"&gt;
&lt;div class="xcontainer x" id="abs-data"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;abs_data:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:application/json;charset=utf8;filename=pick_colonies_and_culture.abs_data.json;base64,MQ==" download="pick_colonies_and_culture.abs_data.json" draggable="true"&gt;pick_colonies_and_culture.abs_data.json&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;div class="xcontainer x" id="runstatus"&gt;
&lt;dl class="docutils x"&gt;
&lt;dt&gt;runstatus:&lt;/dt&gt;
&lt;dd&gt;&lt;span class="raw-html x"&gt;&lt;a href="data:text/plain;charset=utf8;filename=pick_colonies_and_culture.runstatus.yaml;base64,MQ==" download="pick_colonies_and_culture.runstatus.yaml" draggable="true"&gt;pick_colonies_and_culture.runstatus.yaml&lt;/a&gt;&lt;/span&gt;&lt;/dd&gt;
&lt;/dl&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!--&lt;div class="xcontainer x" id="metadata"&gt;
2016-11-10&lt;/div&gt;--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;!--&lt;/html&gt;--&gt;

&lt;!--&lt;/html&gt;--&gt;
&lt;/embed&gt;&lt;/div&gt;
&lt;div class="section" id="conclusions"&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;There is still plenty to do before the pipeline is completely automatic.
For example, attentive readers will notice that the HTML report above shows
an unsuccessful transformation, one of many!
The first complete transformation took several months to get right.
The biggest challenge is making the process robust to changes in the protein sequence —
even basic PCR can go wrong in many ways.
Currently, debugging is a major undertaking;
unlike regular programming, iterations are slow and expensive.
However, if the protocols can be made robust enough, which I think they can,
then synthesizing a new protein could become as simple as running BLAST.&lt;/p&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="biotech"/><category term="transcriptic"/><category term="snakemake"/><category term="synthetic biology"/></entry><entry><title>Internet of Lab Things</title><link href="/iolt.html" rel="alternate"/><published>2017-01-26T11:00:00-08:00</published><updated>2017-01-26T11:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2017-01-26:/iolt.html</id><summary type="html">&lt;p class="first last"&gt;An internet-connected lab thermometer&lt;/p&gt;
</summary><content type="html">&lt;p&gt;The &lt;a class="reference external" href="https://en.wikipedia.org/wiki/ESP8266"&gt;ESP8266&lt;/a&gt; board
seems to be the new weapon of choice for IoT applications.
As far as I can tell it is basically like an arduino except it has wifi built in,
and, if you're willing to wait on shipping, you can buy one for under $3 on
&lt;a class="reference external" href="https://www.aliexpress.com/wholesale?catId=0&amp;amp;initiative_id=SB_20170125140650&amp;amp;SearchText=d1+mini"&gt;aliexpress&lt;/a&gt;.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="IOT *The D1 Mini has a processor, wifi chip, micro-USB, and 16 GPIO pins*" src="/images/d1_mini1.jpg" /&gt;
&lt;/div&gt;
&lt;p&gt;There are several ESP8266-compatible boards, and the WeMos D1 Mini seems to be popular.
I bought this $4 &lt;a class="reference external" href="https://www.amazon.com/HiLetgo-NodeMcu-bytes-Development-ESP8266/dp/B01IXBWH9Y"&gt;HiLetGo D1 Mini on amazon&lt;/a&gt;.
It includes conveniences like a micro-USB port, so you can plug it straight into your
computer and get started.&lt;/p&gt;
&lt;p&gt;This board runs &lt;a class="reference external" href="http://www.nodemcu.com/index_en.html"&gt;nodemcu&lt;/a&gt;,
an open-source firmware for ESP8266 that I'd never heard of, based on Lua.
The name comes from its &amp;quot;nodejs-style networking&amp;quot;, so a lot of internet/web libraries are built in.
I'm a fan of Lua, so this was very appealing.
Nodemcu describes itself as a &amp;quot;prototyping&amp;quot; kit,
I think reflecting the fact that using a scripting language on a teeny board like this not ideal.
I don't think this is a big problem, and the very nice example code
on the &lt;a class="reference external" href="http://www.nodemcu.com/index_en.html"&gt;main nodemcu site&lt;/a&gt;
should allay many concerns.&lt;/p&gt;
&lt;div class="section" id="how-is-this-gizmo-different-to-a-raspberry-pi"&gt;
&lt;h2&gt;How is this gizmo different to a raspberry pi?&lt;/h2&gt;
&lt;p&gt;I have a raspberry pi, and the learning curve for the D1 Mini is way higher.
The raspberry pi runs linux, and you can treat it like a regular, but low-powered, computer.
These D1 Minis are much more work:
you have to flash the firmware (using &lt;a class="reference external" href="https://nodemcu-build.com/"&gt;nodemcu-build&lt;/a&gt;),
copy code over from your laptop using a special tool&amp;nbsp;(&lt;a class="reference external" href="https://esp8266.ru/esplorer/"&gt;ESPlorer&lt;/a&gt;),
worry about the voltage of the battery you are using, check the baud rate,
solder things if you want permanent connections, etc...&lt;/p&gt;
&lt;p&gt;If I were doing something where I don't care much about size or power consumption and I could plug
into the wall, I'd just use a raspberry pi (or similar linux-capable board) and
program it in Python.
The one caveat is that connecting sensors to a raspberry pi will be about as
difficult as a D1 Mini.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="internet-of-lab-things-1"&gt;
&lt;h2&gt;Internet of Lab Things&lt;/h2&gt;
&lt;p&gt;I think the main reason you'd want one of these things is to connect a sensor
and report readings.&lt;/p&gt;
&lt;p&gt;I thought it would be fun to have a small sensor that you can place in the lab,
forget about, and collect all the data on a server.
There are a few potentially useful sensors for a lab environment:
detecting light, air particles/pollution, movement (presence of people), and vibration,
but temperature and humidity are probably the main ones.&lt;/p&gt;
&lt;p&gt;The sensor should be (a) battery-powered (b) low power (c) cheap (d) precise (or even better, accurate).
I am using a &lt;a class="reference external" href="https://www.adafruit.com/product/386"&gt;DHT11&lt;/a&gt; temperature and humidity sensor,
which is a cheap, common sensor.
There are &lt;a class="reference external" href="https://www.intorobotics.com/pick-best-temperature-sensor-arduino-project/"&gt;lots of options&lt;/a&gt;
for thermometers, but nodemcu can be compiled with built-in support for DHT-compatible sensors.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="IOT *IoLT prototype: solar battery, D1 Mini, DHT11*" src="/images/nodemcu1.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="powering-the-d1-mini"&gt;
&lt;h2&gt;Powering the D1 Mini&lt;/h2&gt;
&lt;p&gt;When the nodemcu is plugged into your computer, it is powered by USB.
It turns out that powering the D1 Mini (and similar boards)
is pretty complicated, especially if you're not used to thinking about voltages.
There's an &lt;a class="reference external" href="https://www.youtube.com/watch?v=heD1zw3bMhw"&gt;interesting video&lt;/a&gt;
that goes into this issue in depth.
My conclusion after watching this video was that this was something I'd really rather not deal with.
For example, if you attach the wrong kind of battery, you can fry the board,
or you can run out of power with a half-full battery (due to voltage drop over time).&lt;/p&gt;
&lt;p&gt;I decided the easiest way to power the board was with USB.
This is an unusual way to power these boards for some reason,
but it solves many of the more &amp;quot;analog&amp;quot; problems associated with batteries.
Luckily, since most smartphones are powered by USB, there are now tons of options.
In fact, probably the most interesting thing about this project is how the D1 Mini is powered.
On amazon, you can buy a &lt;a class="reference external" href="https://www.amazon.com/gp/product/B00R2Y4I1Y/"&gt;1200mAh solar-powered USB battery for $12!&lt;/a&gt;
That means that it has about half the capacity of a typical smartphone! And it's solar-powered!
And it has an LED flashlight!&lt;/p&gt;
&lt;div class="section" id="perpetual-motion-sensors"&gt;
&lt;h3&gt;Perpetual motion sensors&lt;/h3&gt;
&lt;p&gt;Because it's solar-powered, in theory the battery could recharge faster than the D1 Mini consumes power.
The solar charging works best in direct sunlight, but it can collect power from indoor lighting too.
I'm not sure what it would take for it to collect power faster than the sensor uses it,
especially indoors, but I think it might be possible.
(Importantly, the device can simultaneously charge while powering the D1 Mini.)
Even with no solar charging, this battery should last for months — of course,
that depends on how often you take a reading.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="deep-sleep"&gt;
&lt;h3&gt;Deep sleep&lt;/h3&gt;
&lt;p&gt;The D1 Mini has a special deep sleep mode (engaged by connecting two of the pins)
that allows it to conserve battery between readings, so the draw can go below 0.01 amps.
More specialist equipment and knowledge would be required to really minimize the draw.
For my purposes, this is good enough.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="IOT *D1 Mini power draw during deep sleep*" src="/images/nodemcu2.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="code"&gt;
&lt;h2&gt;Code&lt;/h2&gt;
&lt;p&gt;All the code is in this &lt;a class="reference external" href="https://github.com/hgbrian/iolt"&gt;IoLT github repo&lt;/a&gt;.
The Lua code is a hundred lines or so, and the server code is about 20 lines
(this is why I am such a big fan of AppEngine!)
There are lots of places to improve the code (for example replacing HTTP with MQTT),
but frankly the debug cycle here is a bit of a pain.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I love the idea of a self-contained sensor that continually reports back on its environment.
If it can somehow be perpetually powered by light, then it would be perfect, but a year
or two of power would be good too.
The fact that this whole setup costs less than $20 is amazing to me.
I think there's probably a commercial product in here somewhere.&lt;/p&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="biotech"/><category term="iolt"/><category term="nodemcu"/><category term="arduino"/></entry><entry><title>Oxford Nanopore in 2016</title><link href="/nanopore_2016.html" rel="alternate"/><published>2016-10-10T11:00:00-07:00</published><updated>2016-10-10T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2016-10-10:/nanopore_2016.html</id><summary type="html">&lt;p class="first last"&gt;What's been going on with Oxford Nanopore in 2016&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Many genomics people, especially in the US,
are still unfamiliar with Oxford Nanopore's MinION sequencer.
I was lucky enough to join their early access program last year,
so I've been using it for a while.
In that time I've become more and more excited about its potential.
In fact, I think it's the most exciting thing to happen in genomics in a long time.
I'll try to explain why.&lt;/p&gt;
&lt;div class="section" id="minion-vs-illumina"&gt;
&lt;h2&gt;MinION vs Illumina&lt;/h2&gt;
&lt;p&gt;The MinION is a tiny little sequencer that has some serious advantages over
Illumina sequencers:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;it's very portable (see the photos!) and doesn't require any special equipment to run&lt;/li&gt;
&lt;li&gt;it's simple to run: there's a 10 minute prep with just a couple of pipetting steps&lt;/li&gt;
&lt;li&gt;the sequencer itself is essentially free, with a cost of $500-900 per flow-cell (which can be reused several times).&lt;/li&gt;
&lt;li&gt;the reads are very long, about as long as the input DNA (100kb is not unusual)&lt;/li&gt;
&lt;li&gt;it's a single molecule sequencer, so you can detect per molecule variation,
including base modifications (this is still low accuracy though)&lt;/li&gt;
&lt;li&gt;it can read RNA directly, giving you &lt;a class="reference external" href="https://nanoporetech.com/applications/rna"&gt;full-length transcripts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;the turnaround time is very quick: you can generate tens to hundreds of megabases of data in an afternoon&lt;/li&gt;
&lt;li&gt;data analysis is easier than for short-read sequencers, since alignment and assembly are simpler.
You may not even really need any alignment if you are sequencing a plasmid or insert.&lt;/li&gt;
&lt;li&gt;the data arrives per read instead of per base: so in one hour you can have thousands
of long reads (as opposed to Illumina, where you'd have millions of partial reads, each only a few bases)&lt;/li&gt;
&lt;li&gt;seeing reads appear in real-time is amazing and you can literally pull the USB plug when you have enough data&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/MinION1.jpg" /&gt;
&lt;/div&gt;
&lt;p&gt;There are also two big disadvantages:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;its accuracy is at least an order of magnitude worse than Illumina (~90% vs &amp;gt;99%)&lt;/li&gt;
&lt;li&gt;its per base cost is at least an order of magnitude higher than an Illumina HiSeq ($0.5/Mbase vs &amp;lt;$0.02/Mbase)
and 2–10X more expensive than a &lt;a class="reference external" href="http://www.illumina.com/systems/miseq/performance_specifications.html"&gt;MiSeq&lt;/a&gt;.
Of course, these numbers are rough and in flux.
For example, a HiSeq or MiSeq will require a service contract that could be $20k/yr —
the cost of an Illumina run is highly volume-dependent.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Something that's not often discussed is the error rate of short-read sequencers.
On a per base level they are extremely accurate,
but incorrectly determined structural variants are also errors.
In a human genome a miscalled 3Mb inversion could by itself be considered a 0.1% error rate.
and there are &lt;a class="reference external" href="http://bmcgenomics.biomedcentral.com/articles/10.1186/s12864-015-1479-3"&gt;lots of structural variants in humans&lt;/a&gt;.
Unlike incorrect base-calls, it is often impossible to overcome this issue with greater read-depth.&lt;/p&gt;
&lt;p&gt;Despite these advantages, many scientists remain skeptical of the MinION.
There are probably two things going on here:
(a) Oxford has consistently overpromised since announcing in 2012;
(b) the MinION only started to be really competitive in the past few months, so there is a lag.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="what-changed"&gt;
&lt;h2&gt;What changed?&lt;/h2&gt;
&lt;p&gt;About six months ago, you could expect to get about 500Mb of DNA from a flow-cell,
with each pore reading at 70 bases/second and accuracy of 70-80% (at least in our novice hands).&lt;/p&gt;
&lt;p&gt;Earlier this year, Oxford made two important changes that improved performance:
they updated their pore from an unspecified pore
(&amp;quot;R7&amp;quot;, which was tangled up in a &lt;a class="reference external" href="http://www.sciencemag.org/news/2016/03/amid-patent-lawsuit-genetic-sequencing-upstart-unveils-new-technology"&gt;patent dispute with Illumina&lt;/a&gt;)
to an E. coli pore (&amp;quot;R9&amp;quot;),
which has both better throughput and better accuracy than R7.
At the same time, they updated their base-calling algorithm to a deep learning-based
method, further improving accuracy.&lt;/p&gt;
&lt;p&gt;They are still incrementally improving R9, and are already on version R9.4.
At the time of writing, this version is currently only in the hands of the inner circle of nanoporati,
but luckily they are all on Twitter so we can get a pretty good sense of how well it works.
People are reporting excellent results, with runs of over 5Gb at the new R9 speed of 240 bases/second
(this should be 500 bases/second soon, apparently with no loss in accuracy).
Accuracy is also up, with 1D reads perhaps even edging over 90% in experienced hands.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/nanopore_5G_clive_small.jpg" /&gt;
&lt;/div&gt;
&lt;!-- .. figure:: {static}/images/nanopore_clive_brown_graph_small.jpg
:alt: minion --&gt;
&lt;p&gt;So, compared to six months ago, you are probably getting 5-10 times as much data with
half the error rate.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="ok-what-can-i-do-with-one-of-these-gizmos"&gt;
&lt;h2&gt;OK, what can I do with one of these gizmos?&lt;/h2&gt;
&lt;p&gt;The stats are definitely exciting,
but I don't think they really capture why I think the MinION is so interesting.
The MinION has several key areas where it can do some damage,
and other areas where it opens up new possibilities.&lt;/p&gt;
&lt;div class="section" id="sequencing-microbial-genomes-de-novo"&gt;
&lt;h3&gt;sequencing microbial genomes &lt;em&gt;de novo&lt;/em&gt;&lt;/h3&gt;
&lt;p&gt;This is very doable.
I wouldn't say it's easy yet, but long reads negate a lot of the computational problems
of &lt;em&gt;de novo&lt;/em&gt; assembly: finding overlapping 10,000mers is a very different problem to finding overlapping 100mers.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/nanopore_MRSA_small.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="infectious-agent-detection"&gt;
&lt;h3&gt;infectious agent detection&lt;/h3&gt;
&lt;p&gt;Once you have prepped DNA, which takes from 10 minutes (with the &amp;quot;rapid&amp;quot; kit) to two hours,
the actual process of detecting a pathogen could be under ten minutes.
In practice I don't think anybody is going from blood sample to diagnosis this quickly,
but the potential is there.&lt;/p&gt;
&lt;p&gt;There is even software (&lt;a class="reference external" href="http://www.mykrobe.com/"&gt;Mykrobe&lt;/a&gt;) that
detects drug-resistance genes in bacteria, and recommends appropriate antibiotics.
When this is done cheaply and routinely it should help a lot
with drug resistance and overprescription of antibiotics.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/nanopore_mykrobe.jpg" /&gt;
&lt;/div&gt;
&lt;p&gt;Since the data comes in one read at a time,
as soon as you get one read from the infectious agent you are done.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="direct-rna-sequencing"&gt;
&lt;h3&gt;direct RNA sequencing&lt;/h3&gt;
&lt;p&gt;If you want to read full-length transcripts, and see base modifications too,
then the MinION is the only option that I know of.
This capability is new, and the base modification detection is not accurate, but there's
still plenty of interesting research to do with this.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="barcoding"&gt;
&lt;h3&gt;barcoding&lt;/h3&gt;
&lt;p&gt;Sequencing often requires barcoding, which adds fiddly extra steps before and after sequencing.
But, if your reads are long enough, then you may not need to barcode.
For example, you can sequence 96 plasmids at the same time — simply throw away
any reads that are not the full length of the plasmid.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="other-long-read-problems"&gt;
&lt;h3&gt;other long-read problems&lt;/h3&gt;
&lt;p&gt;There are a few classic long-read problems like HLA sequencing, VDJ sequencing and
structural variant detection (especially for cancer).
These are reasonably good applications for MinION, though
VDJ sequencing probably needs more accuracy,
and structural variant detection might need more throughput.
(&lt;a class="reference external" href="http://www.nature.com/nbt/journal/v34/n3/full/nbt.3432.html"&gt;10X + Illumina&lt;/a&gt; makes the most sense for anything like this)&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="minion-in-the-field"&gt;
&lt;h2&gt;MinION in the Field&lt;/h2&gt;
&lt;p&gt;Oxford is making an effort to eliminate the &amp;quot;cold chain&amp;quot; for the MinION.
The flow-cell itself already seems to keep well at temperatures well above refrigeration,
and they claim they can lyophilize the other reagents.
Even before that happens, with basically just a cooler, a laptop, and a way to extract DNA,
doctors, ecologists, and other scientists can go out into the field and do sequencing anywhere.&lt;/p&gt;
&lt;p&gt;Earlier this year, as part of the &lt;a class="reference external" href="http://www.zibraproject.org/"&gt;Zibra project&lt;/a&gt;,
scientists from the UK and Brazil drove a van through Brazil,
sampling and sequencing Zika virus along the way.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/nanopore_zibra.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="biology-labs-and-biotechs"&gt;
&lt;h2&gt;Biology labs and Biotechs&lt;/h2&gt;
&lt;p&gt;The advantage of MinION for non-genomics–focused biology labs is not really widely discussed,
but I think it's one of the most important.&lt;/p&gt;
&lt;p&gt;Basically, if you want a few megabases sequenced and you have a MinION and a flow-cell,
you can have the data in your hands today.
When you're done you can put the flow-cell away and use it again tomorrow.
Depending on your needs, you might get 4-10 uses out of the flow-cell,
meaning each run costs $150-300 including sample prep.&lt;/p&gt;
&lt;p&gt;In contrast, if you want to get some data from a MiSeq,
you are probably signing up for a gigabase of sequence.
That's overkill for most labs, and it produces many gigabytes of raw data to manage too...
If you want reasonable length reads (2x150bp), then sequencing will take at least 24 hours.
If you are lucky enough to have a core lab at your institute then that helps,
but you may still have to wait your turn.&lt;/p&gt;
&lt;p&gt;If you don't work at a university — perhaps you're at a small biotech —
then the alternative is buying a MiSeq (or MiniSeq) at $50-150k plus service contract,
or sending your samples out to a CRO for sequencing.
A CRO will have a turnaround time of at least a week,
and that's after you've explained to them what you need and agreed on the terms.&lt;/p&gt;
&lt;p&gt;It's hard to imagine a one-off MiSeq run happening in under a week,
so being able to just do it yourself is a huge increase in efficiency.&lt;/p&gt;
&lt;p&gt;If you're sequencing a thousand of anything, then Illumina is much cheaper,
but I wonder how many biology labs need megabase-scale sequencing occasionally,
but don't do it because of the current barriers to entry,
including the computational burden of aligning and assembling short reads.
There are cases where I would not have bothered with the hassle of
getting something sequenced except that we could just do it ourselves with the MinION.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/nanopore_rapid_prep_small.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="genomics-for-everyone"&gt;
&lt;h2&gt;Genomics for Everyone&lt;/h2&gt;
&lt;p&gt;I think the most exciting thing going on here is just taking sequencing and
genomics out of the lab and into the real world.
Admittedly, this does require some improvements and inventions from Oxford,
like easier DNA preparation, so there are caveats here, but nothing too crazy.&lt;/p&gt;
&lt;p&gt;Oxford's &lt;a class="reference external" href="https://metrichor.com/s/"&gt;metrichor site&lt;/a&gt; spells out some of the use-cases too.
I'll just give some scattered examples of things to sequence,
some more realistic than others,
but I think each plausibly represent something new that has real economic value:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;hospital surfaces and employees for MRSA&lt;/li&gt;
&lt;li&gt;food at factories (detecting &lt;em&gt;E. coli&lt;/em&gt; etc)&lt;/li&gt;
&lt;li&gt;the environment at airports, workplaces, etc for flu (flu is expensive!)&lt;/li&gt;
&lt;li&gt;at crime scenes (also a big deal since the current methods of forensic DNA analysis are awful)&lt;/li&gt;
&lt;li&gt;at home, to see if you have a cold or flu, the same cold or a new one, and even figure out where you picked up the virus&lt;/li&gt;
&lt;li&gt;the air to detect mold in buildings&lt;/li&gt;
&lt;li&gt;farm animals' microbiomes to monitor gut health and improve growth&lt;/li&gt;
&lt;li&gt;at methane farms, wine fermenters, beer fermenters, to monitor and manage the process&lt;/li&gt;
&lt;li&gt;various kinds of labs for bacterial contamination&lt;/li&gt;
&lt;li&gt;the sewage system of a city to monitor the city's diet and health&lt;/li&gt;
&lt;li&gt;for educational purposes, and at competitions like iGEM&lt;/li&gt;
&lt;li&gt;fish and other foods to detect mislabeling (a surprisingly big problem)&lt;/li&gt;
&lt;li&gt;animals out in the wild for conservation purposes&lt;/li&gt;
&lt;li&gt;your own microbiome to monitor your gut health&lt;/li&gt;
&lt;li&gt;soil, plants, droppings, insects at farms to monitor pests etc.&lt;/li&gt;
&lt;li&gt;at the dentist's to detect decay-causing bacteria&lt;/li&gt;
&lt;li&gt;at the dermatologist's (cosmetologist?) to detect and treat acne-causing bacteria&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These applications (apps?) can potentially be run by anyone.
Stick some DNA in, wait a bit, processing happens on the cloud and the answer
appears on your phone in a few minutes to a few hours.
You don't need to know anything about genetics or molecular biology,
you'll just see a readout that says &amp;quot;E. coli detected&amp;quot; in food or
&amp;quot;DNA from new rhino detected&amp;quot; in droppings.&lt;/p&gt;
&lt;p&gt;There's already a teaser of this with Oxford's
&lt;a class="reference external" href="https://nanoporetech.com/publications/metrichor-applications-whats-my-pot-wimp"&gt;What's in my Pot app&lt;/a&gt;.
It figures out which microbes are in a sample, and draws a nice cladogram for you.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/nanopore_wimp_small.jpg" /&gt;
&lt;/div&gt;
&lt;!-- (comment) http://www.science-practice.com/assets/york-minion/] --&gt;
&lt;p&gt;To realize this potential, the sequencer still needs to be cheaper,
but the lower bound on that seems good,
since the number of molecules involved is really tiny.
(That's another advantage of single-molecule sequencers.)&lt;/p&gt;
&lt;p&gt;Finally, coming back to present-day reality a little bit,
Oxford will need to execute on their plans to make sequencing easier and cheaper
(reagent lyophilization, Zumbador, SmidgION, Voltrax, FPGAs, etc. —
watch Oxford's &lt;a class="reference external" href="https://nanoporetech.com/events/technical-update-clive-g-brown"&gt;latest tech update&lt;/a&gt; for more on that),
but I think MinION is going to become a very big deal in the next few years.&lt;/p&gt;
&lt;/div&gt;
</content><category term="genomics"/><category term="genomics"/><category term="nanopore"/></entry><entry><title>A Toy Oxford Nanopore Simulator Using A Hierarchical Bayesian Model in PyMC3</title><link href="/toy_nanopore_simulator.html" rel="alternate"/><published>2016-08-14T11:00:00-07:00</published><updated>2016-08-14T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2016-08-14:/toy_nanopore_simulator.html</id><summary type="html">&lt;p class="first last"&gt;Estimating parameters for a toy nanopore simulator using a hierarchical Bayesian model in PyMC3&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Oxford Nanopore (ONT) sells an amazing, inexpensive sequencer called the
&lt;a class="reference external" href="https://www.nanoporetech.com/"&gt;MinION&lt;/a&gt;. It's an unusual device in
that the sequencing &amp;quot;flowcells&amp;quot; use protein pores. Unlike a silicon
chip, the pores are sensitive to their environment (especially heat) and
can get damaged or degraded and stop working.&lt;/p&gt;
&lt;p&gt;When you receive a flowcell from ONT, only a fraction of the possible
2048 pores are active, perhaps 800–1500. Because of how the flowcell
works, you start a run using zero or one pores from each of the 512
&amp;quot;channels&amp;quot; (each of which contains 4 pores).&lt;/p&gt;
&lt;p&gt;As the pores interact with the DNA and other stuff in&amp;nbsp;your solution,
they can get gummed up and stop working. It's not unusual to start a run
with 400 pores and end a few hours later with half that many still
active. It's also not unusual to put a flowcell in the fridge and find
it has 20% fewer pores when you take it out. (Conversely, pores can come
&lt;a class="reference external" href="https://twitter.com/kpaszkiewicz/status/764881528539254784"&gt;back to life&lt;/a&gt; after a bit of a rest.)&lt;/p&gt;
&lt;p&gt;All told, this means it's quite difficult to tell how much sequence you
can expect from a run. If you want to sequence a plasmid at 100X, and
you are starting with 400 pores, will you get enough data in two hours?
That's the kind of question we want an answer to.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pymc3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pm&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scipy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sp&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;theano.tensor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;T&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;mpl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'retina'&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;functools&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;For testing purposes — and because I don't have nearly enough real data
— I will simulate some data.&lt;/p&gt;
&lt;p&gt;In this toy example, DNA of length 1000+/-50 bases is sequenced for
1000, 20000 or 40000 seconds at 250bp/s. After 100 reads, a pore gets
blocked and can no longer sequence. The device I am simulating has only
3 pores (where a real MinION would have 512).&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;datatypes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'total_num_reads'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'total_dna_read'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'num_minutes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;float&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;          &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'num_active_pores_start'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'num_active_pores_end'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mean_input_dna_len_estimate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;MAX_PORES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;AXIS_RUNS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;AXIS_PORES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;  &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mf"&gt;20000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;          &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;20000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;          &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mf"&gt;40000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;          &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;40000.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;          &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mf"&gt;1000.0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;datatypes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;div class="section" id="minion-simulator"&gt;
&lt;h2&gt;MinION Simulator&lt;/h2&gt;
&lt;p&gt;To help figure out how long to leave our sequencer running, I made a
MinION simulator in a jupyter notebook. I then turned the notebook into
an app using &lt;a class="reference external" href="https://www.dappled.io"&gt;dappled.io&lt;/a&gt;, an awesome new
service that can turn jupyter notebooks into apps running on the cloud
(including AWS lambda). Here is the &lt;a class="reference external" href="https://dappled.io/hgbrian/ont-minion-simulator/YZBjlXTY"&gt;dappled nanopore simulator app /
notebook&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The model is simple: a pore reads DNA until it's completely read, then
with low probability it gets blocked and can no longer sequence. I've
been fiddling with the parameters to give a reasonable result for our
runs, but we don't have too much data yet, so it's not terribly
accurate. (The model itself may also be inaccurate, since &lt;em&gt;how&lt;/em&gt; the pore
gets blocked is not really discussed by ONT.)&lt;/p&gt;
&lt;p&gt;Nevertheless, the simulator is a useful tool for ballparking how much
sequence we should expect from a run.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="nanopore simulation" src="/images/nanopore_simulation_parameter_estimation_7_0.png" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="hierarchical-bayesian-model"&gt;
&lt;h2&gt;Hierarchical Bayesian Model&lt;/h2&gt;
&lt;p&gt;Here's where things get more complicated...&lt;/p&gt;
&lt;p&gt;In theory, given some data from real MinION runs, we should be able to
learn the parameters for a model that would enable us to predict how
much data we would get from a new run. Like many problems, this is a
good fit for Bayesian analysis, since we have data and we want to learn
the most appropriate model given the data.&lt;/p&gt;
&lt;p&gt;For each run, I need to know:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;what length DNA I think I started with&lt;/li&gt;
&lt;li&gt;how long the run was in minutes&lt;/li&gt;
&lt;li&gt;how many reads I got&lt;/li&gt;
&lt;li&gt;how much sequence I got&lt;/li&gt;
&lt;li&gt;the number of active pores at the start and at the end of a run&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I'll use &lt;a class="reference external" href="https://github.com/pymc-devs/pymc3"&gt;PyMC3&lt;/a&gt; for this
problem. First, I need to specify the model.&lt;/p&gt;
&lt;div class="section" id="input-dna"&gt;
&lt;h3&gt;Input DNA&lt;/h3&gt;
&lt;p&gt;The input DNA depends a lot on its preparation. I believe the
distribution of input DNA lengths could be:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;exponential if it is genomic DNA breaking randomly&lt;/li&gt;
&lt;li&gt;normal with a small variance if it is from a plasmid&lt;/li&gt;
&lt;li&gt;normal but sharply truncated if it is cut out of a gel&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The length of input DNA is different to the length of reads produced by
the sequencer, which is affected by breakage, capture biases, secondary
structure, etc. The relationship between input DNA length and read
length could be learned. We could get arbitrarily complex here: for
example, given enough data, we could include a mixture model for
different DNA types (genomic vs plasmid).&lt;/p&gt;
&lt;p&gt;A simple distribution with small variance but fat tails seems reasonable
here. I don't have much idea what the standard deviation should be, so
I'll make it a fraction of the mean.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;mean_input_dna_len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StudentT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mean_input_dna_len'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'mean_input_dna_len_estimate'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                     &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'mean_input_dna_len_estimate'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This is the first PyMC3 code, so here are some notes on what's going on:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the context must always specify the pymc3 model&lt;/li&gt;
&lt;li&gt;Absent better ideas, I'll generally be using a T distribution instead of a normal, as &lt;a class="reference external" href="http://www.inference.phy.cam.ac.uk/mackay/itprnn/ps/300.318.pdf"&gt;MacKay recommends&lt;/a&gt;.
This distribution should be truncated at zero, but I can't do this for multidimensional data because of what I think is a bug in pymc3.&lt;/li&gt;
&lt;li&gt;I am &lt;strong&gt;not&lt;/strong&gt; modeling the &lt;tt class="docutils literal"&gt;input_dna_len&lt;/tt&gt; here, just the mean of that
distribution. As I mention above, the distribution of DNA lengths could
be modeled several ways, but I currently only need the mean in my model.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="the-shape-parameter"&gt;
&lt;h4&gt;the shape parameter&lt;/h4&gt;
&lt;p&gt;In this experiment, We will encounter three different kinds of
distribution shape:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;shape=1&lt;/tt&gt;: this is a scalar value. For example,
we might think the speed of the nanopore machine is the same for all runs.&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;shape=data.shape[0]&lt;/tt&gt;: &lt;tt class="docutils literal"&gt;data.shape[0]&lt;/tt&gt; is the number of
runs. For example, the length of DNA in solution varies from run to run.&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;shape=(data.shape[0],MAX_NUM_PORES)&lt;/span&gt;&lt;/tt&gt;: we estimate a value for every
pore in every run. For example, how many reads until a pore gets
blocked? This varies by run, but needs to be modeled per pore too.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="r9-read-speed"&gt;
&lt;h3&gt;R9 Read Speed&lt;/h3&gt;
&lt;p&gt;I know that the R9 pore is supposed to read at 250 bases per second. I
believe the mean could be a little bit more or less than that, and I
believe that all flowcells and devices should be about the same speed,
therefore all runs will sample from the same distribution of
&lt;tt class="docutils literal"&gt;mean_read_speed&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;Because this is a scalar, pymc3 lets me set a lower bound of 0 bases per
second. (Interestingly, unlike DNA length, the speed &lt;em&gt;could&lt;/em&gt; technically
be negative, since the voltage across the pore can be positive or
negative, as exploited by &lt;a class="reference external" href="http://www.nature.com/nmeth/journal/vaop/ncurrent/full/nmeth.3930.html"&gt;Read
Until&lt;/a&gt;...)&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;Truncated0T1D&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Bound&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StudentT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lower&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;mean_read_speed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Truncated0T1D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mean_read_speed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="capturing-dna"&gt;
&lt;h3&gt;Capturing DNA&lt;/h3&gt;
&lt;p&gt;DNA is flopping around in solution, randomly entering pores now and
then. How long will a pore have to wait for DNA? I have a very vague
idea that it should take around a minute but this is basically an
unknown that the sampler should figure out.&lt;/p&gt;
&lt;p&gt;Note again that I am using the mean time&amp;nbsp;only, not the distribution of
times. The actual distribution of times to capture DNA would likely be
distributed by an exponential distribution (&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Exponential_distribution"&gt;waiting time for a Poisson
process&lt;/a&gt;).&lt;/p&gt;
&lt;div class="section" id="hierarchical-model"&gt;
&lt;h4&gt;Hierarchical model&lt;/h4&gt;
&lt;p&gt;This is the first time I am using a hierarchical/multilevel model. For
more on what this means, see &lt;a class="reference external" href="http://twiecki.github.io/blog/2014/03/17/bayesian-glms-3/"&gt;this example from pymc3&lt;/a&gt;
or &lt;a class="reference external" href="https://www.amazon.com/Andrew-Gelman/e/B001IGUSKM/ref=sr_tc_2_0?qid=1471097030&amp;amp;sr=1-2-ent"&gt;Andrew Gelman's books&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are three options for modeling &lt;tt class="docutils literal"&gt;mean_time_to_capture_dna&lt;/tt&gt;: (a)
it's the same for each run (e.g., everybody us using the same recommended DNA concentration)
(b) it's independent for each run
(c) each run has a different mean, but the means are drawn from the same distribution (and
probably should not be too different).&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;hierarchical_pymc3.png&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;div class="figure"&gt;
&lt;img alt="nanopore simulation Diagram taken from PyMC3 dev `twiecki's blog &amp;lt;http://twiecki.github.io/blog/2014/03/17/bayesian-glms-3/&amp;gt;`__" src="/images/nanopore_simulation_parameter_estimation_17_0.png" /&gt;
&lt;/div&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;prior_mean_time_to_capture_dna&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Truncated0T1D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'prior_mean_time_to_capture_dna'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;mean_time_to_capture_dna&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StudentT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mean_time_to_capture_dna'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prior_mean_time_to_capture_dna&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                           &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prior_mean_time_to_capture_dna&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="reading-dna"&gt;
&lt;h3&gt;Reading DNA&lt;/h3&gt;
&lt;p&gt;I can use pymc3's Deterministic type to calculate how long a pore spends
reading a chunk of DNA, on average. That's just a division, but note it
uses theano's &lt;tt class="docutils literal"&gt;true_div&lt;/tt&gt; function instead of a regular division. This
is because neither value is a number; they are random variables. Theano
will calculate this as it's being sampled. (A simple &amp;quot;&lt;tt class="docutils literal"&gt;a/b&lt;/tt&gt;&amp;quot; also
works, but I like to keep in mind what's being done by theano if
possible.)&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;mean_time_to_read_dna&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Deterministic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'mean_time_to_read_dna'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;true_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mean_input_dna_len&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mean_read_speed&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Then each pore can do how many reads in this run? I have to be a bit
careful to specify that I mean the number of reads possible per pore.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;num_reads_possible_in_time_per_pore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Deterministic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'num_reads_possible_in_time_per_pore'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;true_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_seconds_run&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mean_time_to_capture_dna&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mean_time_to_read_dna&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="blocking-pores"&gt;
&lt;h3&gt;Blocking Pores&lt;/h3&gt;
&lt;p&gt;In my model, after each read ends, a pore can get blocked, and once it's
blocked it does not become unblocked. I believe about one in a hundred
times, a pore will be blocked after if finishes sequencing DNA. If it
were more than that, sequencing would be difficult, but it could be much
less.&lt;/p&gt;
&lt;p&gt;We can think of the &lt;a class="reference external" href="http://www.wolframalpha.com/input/?i=beta+distribution+a%3D1+b%3D99"&gt;Beta
distribution&lt;/a&gt;
as modeling coin-flips where the probability of heads (pore getting
blocked) is 1/100.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;prior_p_pore_blocked_a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prior_p_pore_blocked_b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;99&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p_pore_blocked&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Beta&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'p_pore_blocked'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prior_p_pore_blocked_a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prior_p_pore_blocked_b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Then, per pore, the number of reads before blockage is distributed as a
geometric distribution (the distribution of the number of tails you will
flip before you flip a head). I have to approximate this with an
exponential distribution — the continuous version of a geometric —
because ADVI (see below) requires continuous distributions. I don't
think it makes an appreciable difference.&lt;/p&gt;
&lt;p&gt;Here the &lt;tt class="docutils literal"&gt;shape&lt;/tt&gt; parameter is the number of runs x number of pores
since here I need a value for every pore.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;num_reads_before_blockage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Exponential&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'num_reads_before_blockage'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lam&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;p_pore_blocked&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="constraints"&gt;
&lt;h3&gt;Constraints&lt;/h3&gt;
&lt;p&gt;Here things get a little more complicated. It is not possible to have
two random variables x and y, set x + y = data, and sample values of x
and y.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;testdata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;testmodel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;x&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;y&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# This does not work&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#z = pm.Deterministic(x + y, observed=data)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# This does work&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;z&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'x+y'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;testdata&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;trace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Metropolis&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I was surprised by this at first but it makes sense. This process is
more like a regression where you minimize error than a perfectly fixed
constraint. The smaller the standard deviation, the more you penalize
deviations from the constraint. However, you need some slack so that
it's always possible to estimate a &lt;tt class="docutils literal"&gt;logp&lt;/tt&gt; for the data given the
model. If the standard deviation goes too low, you end up with numerical
problems (e.g., &lt;tt class="docutils literal"&gt;nan&lt;/tt&gt;s). Unfortunately, I do not know of a
reasonable way to set this value.&lt;/p&gt;
&lt;p&gt;I encode constraints in my model in a similar way: First I define a
Laplace distribution in theano to act as my likelihood. Why Laplace
instead of Normal? It returned &lt;tt class="docutils literal"&gt;nan&lt;/tt&gt;s less often...&lt;/p&gt;
&lt;p&gt;Using your own DensityDist allows you to use any function as a
likelihood. I use DensityDist just to have more control over the
likelihood, and to differentiate from a true Normal/Laplacian
distribution. This can be finicky, so I've had to spend a bunch of time
tweaking this.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;T_Laplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mul&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;neg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;true_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;abs_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;obs&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)))))&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="constraint-1"&gt;
&lt;h3&gt;Constraint #1&lt;/h3&gt;
&lt;p&gt;The total DNA I have read must be the product of &lt;tt class="docutils literal"&gt;mean_input_dna_len&lt;/tt&gt;
and &lt;tt class="docutils literal"&gt;total_num_reads&lt;/tt&gt;. &lt;tt class="docutils literal"&gt;mean_input_dna_len&lt;/tt&gt; can be different to my
estimate.&lt;/p&gt;
&lt;p&gt;This is a bit redundant since I know &lt;tt class="docutils literal"&gt;total_num_reads&lt;/tt&gt; and
&lt;tt class="docutils literal"&gt;total_dna_read&lt;/tt&gt; exactly. In a slightly more complex model we would
have different &lt;tt class="docutils literal"&gt;mean_read_length&lt;/tt&gt; and &lt;tt class="docutils literal"&gt;mean_input_dna_len&lt;/tt&gt;. Here it
amounts to just calculating &lt;tt class="docutils literal"&gt;mean_input_dna_len&lt;/tt&gt; as
&lt;tt class="docutils literal"&gt;total_dna_read / total_num_reads&lt;/tt&gt;.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;apply_mul_constraint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;# 1 fails with NUTS (logp=-inf), 10/100 fails with NUTS too (not positive definite)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;T_Laplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mul&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;f2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;total_dna_read_constraint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;apply_mul_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mean_input_dna_len&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'total_num_reads'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;constrain_total_dna_read&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DensityDist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'constrain_total_dna_read'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total_dna_read_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'total_dna_read'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="constraint-2"&gt;
&lt;h3&gt;Constraint #2&lt;/h3&gt;
&lt;p&gt;The number of reads per pore is whichever is lower:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the number of reads the pore could manage in the length of the run&lt;/li&gt;
&lt;li&gt;the number of reads it manages before getting blocked&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To calculate this, I compare &lt;tt class="docutils literal"&gt;num_reads_before_blockage&lt;/tt&gt; and
&lt;tt class="docutils literal"&gt;num_reads_possible_in_time_per_pore&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;First, I use &lt;tt class="docutils literal"&gt;T.tile&lt;/tt&gt; to replicate
&lt;tt class="docutils literal"&gt;num_reads_possible_in_time_per_pore&lt;/tt&gt; for all pores. That turns it
from an array of length #runs to a matrix of shape #runs x #pores (this
should use
&lt;a class="reference external" href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html"&gt;broadcasting&lt;/a&gt;
but I wasn't sure it was working properly...)&lt;/p&gt;
&lt;p&gt;Then I take the minimum value of these two arrays (&lt;tt class="docutils literal"&gt;T.lt&lt;/tt&gt;) and if the
minimum value is the number of reads before blockage
(&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;T.switch(T.lt(f1,f2),0,1)&lt;/span&gt;&lt;/tt&gt;) then that pore is blocked, otherwise it
is active. I sum these 0/1s over all pores (&lt;tt class="docutils literal"&gt;axis=AXIS_PORES&lt;/tt&gt;) to get
a count of the number of active pores for each run.&lt;/p&gt;
&lt;p&gt;The value of this count is constrained to be equal to
&lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;data['num_active_pores_end']&lt;/span&gt;&lt;/tt&gt;.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;apply_count_constraint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_reads_before_blockage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_possible_in_time_broadcast&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;num_active_pores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;switch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_reads_before_blockage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_possible_in_time_broadcast&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;AXIS_PORES&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;T_Laplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_active_pores&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;num_reads_possible_in_time_broadcast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_reads_possible_in_time_per_pore&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MAX_PORES&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;num_active_pores_end_constraint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;apply_count_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_before_blockage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_possible_in_time_broadcast&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;constrain_num_active_pores_end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DensityDist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'constrain_num_active_pores_end'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_active_pores_end_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'num_active_pores_end'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="constraint-3"&gt;
&lt;h3&gt;Constraint #3&lt;/h3&gt;
&lt;p&gt;Using the same matrix &lt;tt class="docutils literal"&gt;num_reads_possible_in_time_broadcast&lt;/tt&gt; this time
I sum the total number of reads from each pore in a run. I simply sum
the minimum value from each pore: either the number before blockage
occurs or the total number possible.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;apply_minsum_constraint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_reads_before_blockage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_possible_in_time_broadcast&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;# b=1 fails with ADVI and &amp;gt;100 pores (nan)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;min_reads_per_run&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;minimum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_reads_before_blockage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_possible_in_time_broadcast&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;AXIS_PORES&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;T_Laplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min_reads_per_run&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;total_num_reads_constraint&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;apply_minsum_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_before_blockage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_reads_possible_in_time_broadcast&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;constrain_total_num_reads&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DensityDist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'constrain_total_num_reads'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;total_num_reads_constraint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'total_num_reads'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sampling"&gt;
&lt;h2&gt;Sampling&lt;/h2&gt;
&lt;p&gt;There are three principal ways to sample in PyMC3:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Metropolis-Hastings&lt;/strong&gt;: the simplest sampler, generally works fine on simpler problems&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NUTS&lt;/strong&gt;: more efficient than Metropolis, but I've found it to be slow and tricky to get to work&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ADVI&lt;/strong&gt;: this is &amp;quot;variational inference&amp;quot;, the new, fast way to estimate a posterior.
This seems to work great, though as I mention above, it needs continuous distributions only.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I used ADVI most of the time in this project, since NUTS was too slow
and had more numerical issues than ADVI, and the ADVI results seemed
more sensible than Metropolis.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;v_params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;variational&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;advi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;500000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_seed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;trace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;variational&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample_vp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v_params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;draws&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="results"&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;p&gt;In my toy model: there are 8 runs in total; each device has 3 pores; it
takes about 4 seconds to sequence a DNA molecule (~1000 bases / 250
bases per second) and 96 seconds to capture a DNA molecule (so 100
seconds in total to read one DNA molecule).&lt;/p&gt;
&lt;p&gt;In my 8 runs, I expect that &lt;tt class="docutils literal"&gt;[10, 10, 10, 10, 200, 200, 400, 400]&lt;/tt&gt;
reads are possible. However, I expect that runs 4, 5, 6, 7 will have a
blockage at 100 reads.&lt;/p&gt;
&lt;p&gt;Finally, I expect there to be 3 pores remaining in the first four runs,
and 0 pores remaining in the last four.&lt;/p&gt;
&lt;div class="section" id="advi-results"&gt;
&lt;h3&gt;ADVI Results&lt;/h3&gt;
&lt;pre class="literal-block"&gt;
mean_input_dna_len__0                    950.0 (+/- 0.1) # All the input_dna_lens are ok.
mean_input_dna_len__1                   1050.0 (+/- 0.1) # This is a simple calculation since I know
mean_input_dna_len__2                    950.0 (+/- 0.1) # how many reads there are and how long the reads are
mean_input_dna_len__3                   1050.0 (+/- 0.1)
mean_input_dna_len__4                    950.0 (+/- 0.1)
mean_input_dna_len__5                   1049.9 (+/- 0.1)
mean_input_dna_len__6                    950.0 (+/- 0.1)
mean_input_dna_len__7                   1050.0 (+/- 0.1)
num_reads_possible_in_time_per_pore__0    10.1 (+/- 1) # The number of reads possible is also a simple calculation
num_reads_possible_in_time_per_pore__1    10.3 (+/- 1) # It depends on the speed of the sequencer and the length of DNA
num_reads_possible_in_time_per_pore__2    10.2 (+/- 1)
num_reads_possible_in_time_per_pore__3    10.5 (+/- 1)
num_reads_possible_in_time_per_pore__4   210.9 (+/- 36)
num_reads_possible_in_time_per_pore__5   207.4 (+/- 35)
num_reads_possible_in_time_per_pore__6   419.8 (+/- 67)
num_reads_possible_in_time_per_pore__7   413.2 (+/- 66)
num_reads_before_blockage_per_run__0     501.3 (+/- 557) # The total number of reads before blockage per run
num_reads_before_blockage_per_run__1     509.8 (+/- 543) # is highly variable when there is no blockage (runs 0-3).
num_reads_before_blockage_per_run__2     501.9 (+/- 512)
num_reads_before_blockage_per_run__3     502.4 (+/- 591)
num_reads_before_blockage_per_run__4     297.2 (+/- 39)  # When there is blockage (runs 4-7), then it's much less variable
num_reads_before_blockage_per_run__5     298.7 (+/- 38)
num_reads_before_blockage_per_run__6     299.6 (+/- 38)
num_reads_before_blockage_per_run__7     301.2 (+/- 38)
num_active_pores_per_run__0                2.8 (+/- 0.4) # The number of active pores per run is estimated correctly
num_active_pores_per_run__1                2.8 (+/- 0.4) # as we expect for a value we've inputted
num_active_pores_per_run__2                2.8 (+/- 0.4)
num_active_pores_per_run__3                2.8 (+/- 0.3)
num_active_pores_per_run__4                0.0 (+/- 0.1)
num_active_pores_per_run__5                0.0 (+/- 0.1)
num_active_pores_per_run__6                0.0 (+/- 0.0)
num_active_pores_per_run__7                0.0 (+/- 0.0)
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="advi-plots"&gt;
&lt;h3&gt;ADVI Plots&lt;/h3&gt;
&lt;p&gt;We can plot the values above too. No real surprises here, though
&lt;tt class="docutils literal"&gt;num_active_pores_per_run&lt;/tt&gt; doesn't show the full distribution for some
reason.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;traceplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                 &lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;varnames&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                 &lt;span class="n"&gt;lines&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'mean'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;df_summary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iterrows&lt;/span&gt;&lt;span class="p"&gt;()})&lt;/span&gt;
&lt;/pre&gt;
&lt;div class="figure"&gt;
&lt;img alt="nanopore simulation" src="/images/nanopore_simulation_parameter_estimation_43_0.png" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusions"&gt;
&lt;h2&gt;Conclusions&lt;/h2&gt;
&lt;p&gt;It's a pretty complex model. Is it actually useful? I think it's almost
useful, but in its current form it suffers from a lack of robustness.&lt;/p&gt;
&lt;p&gt;The results I get are sensitive to changes in several independent areas:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the sampler/inference method: for example, Metropolis returns different answers to ADVI&lt;/li&gt;
&lt;li&gt;the constraint parameters: changing the &amp;quot;&lt;tt class="docutils literal"&gt;b&lt;/tt&gt;&amp;quot; parameter can lead to numerical problems&lt;/li&gt;
&lt;li&gt;the priors I selected: changes in my priors that I do not perceive as important can lead to
different results (more data would help here)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A big problem with my current model is that scaling it up to 512 pores
seems to be difficult numerically. Metropolis just fails, I think
because it can't sample efficiently; NUTS fails for reasons I don't
understand (it throws an error about a positive definite matrix); ADVI
works best, but starts to get &lt;tt class="docutils literal"&gt;nan&lt;/tt&gt;s as the number of pores grows,
unless I loosen the constraints. It's possible that I should need to
begin with loose constraints and tighten them over time.&lt;/p&gt;
&lt;p&gt;Finally, the model currently expects the same number of pores to be
available for every run. I haven't addressed that yet, though I think it
should be pretty straightforward. There may be nice theano trick I am
overlooking.&lt;/p&gt;
&lt;div class="section" id="more-conclusions"&gt;
&lt;h3&gt;More Conclusions&lt;/h3&gt;
&lt;p&gt;Without ADVI, I think I would have failed to get an answer here. I'm
pretty ignorant of how it works, but it seems like a significant advance
and I'll definitely use it again. In fact, it would be interesting to
try applying &lt;a class="reference external" href="http://edwardlib.org/"&gt;Edward&lt;/a&gt;, a variational inference
toolkit with PyMC3 support, to this problem (this would mean swapping
theano for tensorflow).&lt;/p&gt;
&lt;p&gt;The process of modeling your data with a PyMC3/Stan/Edward model forces
you to think a lot about what is really going on with your data and
model (and even after spending quite a bit of time on it, my model still
needs quite a bit of work to be more than a toy...) When your model has
computational problems, as I had several times, it often means the model
wasn't described correctly (Gelman's &lt;a class="reference external" href="http://andrewgelman.com/2016/08/11/a-little-story-of-the-folk-theorem-of-statistical-computing/"&gt;folk
theorem&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Although it is still a difficult, technical process, I'm excited about
this method of doing science. It seems like the right way to tackle a
lot of problems. Maybe with advances like ADVI and theano/tensorflow;
groups like the Blei and Gelman labs developing modeling tools like
PyMC3, Stan and Edward; and experts like Kruschke and the Stan team
creating robust models for us to copy, it will become more common.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="data"/><category term="data"/><category term="genomics"/><category term="statistics"/><category term="pymc3"/><category term="nanopore"/></entry><entry><title>Cool Things Review</title><link href="/cool_things_2016.html" rel="alternate"/><published>2016-06-05T11:00:00-07:00</published><updated>2016-06-05T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2016-06-05:/cool_things_2016.html</id><summary type="html">&lt;p class="first last"&gt;A review of interesting things in biotech, genomics, data analysis&lt;/p&gt;
</summary><content type="html">&lt;p&gt;This is a short list of interesting projects, companies and technologies I've been following.&lt;/p&gt;
&lt;div class="section" id="biotech"&gt;
&lt;h2&gt;Biotech&lt;/h2&gt;
&lt;div class="section" id="transcriptic"&gt;
&lt;h3&gt;Transcriptic&lt;/h3&gt;
&lt;p&gt;Transcriptic is still the only programmable cloud lab currently open for business.
My &lt;a class="reference external" href="http://blog.booleanbiotech.com/genetic_engineering_pipeline_python.html"&gt;previous blogpost&lt;/a&gt;
has a lot more on this company.
They're continuing to add capabilities,
including &lt;a class="reference external" href="https://developers.transcriptic.com/docs/magnetic-transfer"&gt;magnetic bead operations&lt;/a&gt;,
which enables a lot of new kinds of experiments.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="vium"&gt;
&lt;h3&gt;Vium&lt;/h3&gt;
&lt;p&gt;After several years in stealth,
&lt;a class="reference external" href="www.vium.com"&gt;Vium&lt;/a&gt; (formerly Mousera) just launched this week.&lt;/p&gt;
&lt;p&gt;Essentially, Vium have &amp;quot;smart home&amp;quot; mouse cages that stream data directly to you.
You can control the mouse's environment remotely and get video, humidity and temperature
readings in real-time.
Perhaps most importantly, you can start to analyze the data almost immediately,
whereas with a regular CRO, you might have to wait months for the trial to finish.
That just speeds everything up.&lt;/p&gt;
&lt;p&gt;The advantages of this model are potentially enormous.
I'm especially excited about the potential for adaptive trials:
imagine administering 10 candidate drugs to 50 mice on day one,
and discontinuing ineffectual drugs when your Bayes Factor drops below some threshold.
The speed and cost advantage could be great.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="indiebio"&gt;
&lt;h3&gt;IndieBio&lt;/h3&gt;
&lt;p&gt;IndieBio is an accelerator/VC fund that funds a lot of different kinds of lean biotech.
A lot of it is hard-to-categorize stuff that neither typical biotech VCs nor tech VCs fund
(probably most have no idea what you are talking about).&lt;/p&gt;
&lt;p&gt;IndieBio especially focuses on sectors like food tech, agriculture and cosmetics,
(or perhaps more broadly, biotech that's not a drug or a diagnostic).
These industries are enormous though, and the opportunities are huge.&lt;/p&gt;
&lt;p&gt;Their demo day videos
(&lt;a class="reference external" href="https://www.youtube.com/watch?v=ZsAtsDvi3HA"&gt;2015&lt;/a&gt;,
&lt;a class="reference external" href="https://www.youtube.com/watch?v=WucEx8J_WM0"&gt;2016&lt;/a&gt;)
have an extremely varied group of pitches,
from 3D printed rhino horns to neuron-based computers,
and are definitely worth checking out.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="oxford-nanopore"&gt;
&lt;h3&gt;Oxford Nanopore&lt;/h3&gt;
&lt;p&gt;There's really too much going on with Oxford Nanopore to effectively summarize here.
I might have to write a whole post or something.&lt;/p&gt;
&lt;p&gt;Oxford's CTO, Clive Brown, gave a
&lt;a class="reference external" href="https://publications.nanoporetech.com/2016/05/31/clive-brown-cto-of-oxford-nanopore-talks-at-the-london-calling-conference/"&gt;talk at London Calling&lt;/a&gt; that
that describes their roadmap, and it includes incredible things like
sequencers that attach to your iPhone, portable all-in-one sample prep, and DNA synthesis.&lt;/p&gt;
&lt;p&gt;The next year or two is going to be very interesting for Oxford.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="MinION *The MinION is very portable*" src="/images/MinION1.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="data-analysis"&gt;
&lt;h2&gt;Data Analysis&lt;/h2&gt;
&lt;div class="section" id="continuum-analytics"&gt;
&lt;h3&gt;Continuum Analytics&lt;/h3&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.continuum.io/"&gt;Continuum Analytics&lt;/a&gt;
is Travis Oliphant's new company (of numpy fame),
and it produces some of the most useful software for scientific Python.&lt;/p&gt;
&lt;p&gt;The products I use actively are:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="https://www.continuum.io/why-anaconda"&gt;anaconda Python distribution&lt;/a&gt;: this saves so many headaches it's unbelievable, and it has MKL support now&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://conda.pydata.org/docs/"&gt;conda&lt;/a&gt;: this has replaced virtualenv for me all the time, and pip most of the time&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://numba.pydata.org/"&gt;numba&lt;/a&gt;: this comes up less but replaces Cython or numpy sometimes, and can even automatically use the GPU for you via CUDA&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Continuum also have plotting libraries (&lt;a class="reference external" href="https://www.continuum.io/bokeh"&gt;bokeh&lt;/a&gt;),
big data libraries (&lt;a class="reference external" href="http://dask.pydata.org/en/latest/"&gt;dask&lt;/a&gt;) and more.
I haven't used these much, but I'd presume they are all high quality.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="tensorflow"&gt;
&lt;h3&gt;Tensorflow&lt;/h3&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.tensorflow.org/"&gt;Tensorflow&lt;/a&gt; is a library that is hard to explain,
but basically takes numerical expressions that you define in Python,
and does matrix math for you, including things like calculating gradients.
Because of its design, it can distribute the work across computers, and across CPUs and GPUs.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://deeplearning.net/software/theano/"&gt;Theano&lt;/a&gt; and Tensorflow are very similar:
you can even use
&lt;a class="reference external" href="https://github.com/dementrock/tensorfuse"&gt;Tensorfuse&lt;/a&gt;
as a common interface to both.
Theano was first, but Tensorflow seems to be winning for the moment.
Tensorflow has some advantages like integration with mobile devices
(I don't think that really exists yet, but it's coming).&lt;/p&gt;
&lt;p&gt;Although Theano and Tensorflow are best known as deep learning libraries, they do a lot more than that.
One nice feature of building on Theano/Tensorflow is that you can write in pure Python,
and let the library figure out the best way to compute everything.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="keras"&gt;
&lt;h3&gt;Keras&lt;/h3&gt;
&lt;p&gt;Deep learning requires a lot of matrix multiplications and gradient calculations.
Hence there are lots of deep learning libraries built on Theano/Tensorflow,
and new ones&amp;nbsp;pop up all the time.
My favorite is &lt;a class="reference external" href="http://keras.io/"&gt;keras&lt;/a&gt;,
because it's in Python, high-level, well documented,
and works with both Theano and Tensorflow.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="pymc3"&gt;
&lt;h3&gt;PyMC3&lt;/h3&gt;
&lt;p&gt;&lt;a class="reference external" href="https://github.com/pymc-devs/pymc3"&gt;PyMC3&lt;/a&gt; is a
&lt;a class="reference external" href="https://www.youtube.com/watch?v=LlzVlqVzeD8"&gt;&amp;quot;probabilistic programming&amp;quot;&lt;/a&gt;
library similar to Stan (an MCMC workhorse from Andrew Gelman's lab), but in Python.
Frankly, it's not nearly as polished or popular as Stan,
but because it's built on Theano and scipy, the code is very short and readable Python,
which is a big plus for me. It's extensible in ways Stan just can't be.&lt;/p&gt;
&lt;p&gt;Like Stan, PyMC3 now supports faster-than-MCMC &lt;a class="reference external" href="http://arxiv.org/abs/1506.03431"&gt;Variational Inference (ADVI)&lt;/a&gt;.
This &lt;a class="reference external" href="http://twiecki.github.io/blog/2016/06/01/bayesian-deep-learning/"&gt;blogpost&lt;/a&gt;, from
&lt;a class="reference external" href="https://twitter.com/twiecki"&gt;&amp;#64;twiecki&lt;/a&gt;, one of the PyMC3's core developers,
shows the power of building on Theano.
In just a few dozen lines of Python, he builds a Bayesian neural net
and solves it with ADVI. It's not super-practical, but a very interesting result.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="advi *ADVI Bayesian neural net*" src="/images/advi_nn.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="edward"&gt;
&lt;h3&gt;Edward&lt;/h3&gt;
&lt;p&gt;&lt;a class="reference external" href="https://github.com/blei-lab/edward"&gt;Edward&lt;/a&gt; is a very interesting project
that I won't claim to fully understand.
It's a probabilistic modeling library built on Tensorflow, that somehow
manages to include the ability to use models defined in PyMC3, Stan, or keras.&lt;/p&gt;
&lt;p&gt;It's a pretty amazing project, and I like their
explanation of &lt;a class="reference external" href="http://edwardlib.org/getting-started/"&gt;Box's loop&lt;/a&gt; (due to Edward Box) of
modeling, reasoning, and criticism.
It's also notable for how it shows the convergence of
multiple related inference tools into simple, high-level code that sits on top of
industrial-strength libraries like Tensorflow.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="data"/><category term="biotech"/><category term="genomics"/><category term="statistics"/></entry><entry><title>Convolutional Neural Net Playing a 3D Game</title><link href="/convolutional_neural_net_3d_game.html" rel="alternate"/><published>2016-04-10T11:00:00-07:00</published><updated>2016-04-10T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2016-04-10:/convolutional_neural_net_3d_game.html</id><summary type="html">&lt;p class="first last"&gt;Convolutional neural net playing a 3D game using convnetjs and three.js&lt;/p&gt;
</summary><content type="html">&lt;p&gt;&lt;a class="reference external" href="http://cs.stanford.edu/people/karpathy/convnetjs/"&gt;Convnetjs&lt;/a&gt; is a lovely
javascript-based neural net / deep learning library from
&lt;a class="reference external" href="https://twitter.com/karpathy"&gt;&amp;#64;karpathy&lt;/a&gt;.
Of course, it's slow since it's javascript and doesn't use the GPU, but the demos are terrific.&lt;/p&gt;
&lt;p&gt;Convnetjs implements deep reinforcement learning,
which has famously been used to
&lt;a class="reference external" href="https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf"&gt;teach computers to play video games&lt;/a&gt;
just from looking at the pixels.
Google's DeepMind, the folks responsible for
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/AlphaGo"&gt;AlphaGo&lt;/a&gt;, did the original work.&lt;/p&gt;
&lt;p&gt;The &lt;a class="reference external" href="https://cs.stanford.edu/people/karpathy/convnetjs/demo/rldemo.html"&gt;deep reinforcement learning demo&lt;/a&gt;
is a simple game where an agent wanders around a room,
trying to pick up red balls and avoid green balls.
The agent has nine antennae that register touches with walls and balls.
The input to the neural net is simply the output of the nine antennae.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="convnet *Convnetjs deep reinforcement demo: the agent's antennae sense two green balls*" src="/images/convnet1s.png" /&gt;
&lt;/div&gt;
&lt;p&gt;I wanted to see what the net would do if given some &amp;quot;raw&amp;quot; pixels instead of
a sanitized input. How magical are deep nets anyway?
I made a &lt;a class="reference external" href="http://threejs.org/"&gt;three.js&lt;/a&gt; canvas
where I render a representation of what the agent is seeing.
Then I pull the pixel color values out of the canvas and pass them into the neural net,
replacing the antennae's sensor values.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="convnet *3D view, as rendered by three.js, and below, the pixel values that get fed into the neural net.*" src="/images/convnet3s.png" /&gt;
&lt;/div&gt;
&lt;div class="figure"&gt;
&lt;img alt="convnet *3D view of the play area, from above (agent at the top right)*" src="/images/convnet5s.png" /&gt;
&lt;/div&gt;
&lt;p&gt;The new pixel-based version works too, but it does take forever to learn anything —
at least compared to the original.
I optimistically expected it to just work without much tweaking.
I probably need to understand the parameters a lot better to make it work better.&lt;/p&gt;
&lt;p&gt;The three.js version of the demo is &lt;a class="reference external" href="https://htmlpreview.github.io/?https://github.com/hgbrian/convnetjs/blob/master/demo/rldemo.html"&gt;here&lt;/a&gt;
(and the &lt;a class="reference external" href="https://github.com/hgbrian/convnetjs"&gt;source here&lt;/a&gt;).&lt;/p&gt;
</content><category term="data"/><category term="data"/><category term="machine learning"/><category term="neural nets"/><category term="deep learning"/><category term="threejs"/><category term="webgl"/></entry><entry><title>Engineering Proteins in the Cloud with Python and Transcriptic, or, How to Make Any Protein You Want for $360</title><link href="/genetic_engineering_pipeline_python.html" rel="alternate"/><published>2016-03-21T11:00:00-07:00</published><updated>2016-03-21T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2016-03-21:/genetic_engineering_pipeline_python.html</id><summary type="html">&lt;p class="first last"&gt;A genetic engineering pipeline entirely in Python&lt;/p&gt;
</summary><content type="html">&lt;p&gt;What if you had an idea for a cool, useful protein, and you wanted to
turn it into a reality? For example, what if you wanted to create a
vaccine against &lt;em&gt;H. pylori&lt;/em&gt; (like the &lt;a class="reference external" href="http://2008.igem.org/Team:Slovenia"&gt;2008 Slovenian iGEM
team&lt;/a&gt;) by creating a hybrid
protein that combines the parts of &lt;em&gt;E. coli&lt;/em&gt; flagellin that stimulate an
immune response with regular &lt;em&gt;H. pylori&lt;/em&gt; flagellin?&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_1_0.png" /&gt;
&lt;p&gt;&lt;em&gt;A design for a hybrid flagellin H. pylori vaccine, from the 2008
Slovenian iGEM team&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Amazingly, we're pretty close to being able to create any protein we
want from the comfort of our jupyter notebooks, thanks to developments
in genomics, synthetic biology, and most recently, cloud labs.&lt;/p&gt;
&lt;p&gt;In this article I'll develop Python code that will take me from an idea
for a protein all the way to expression of the protein in a bacterial
cell, all without touching a pipette or talking to a human. The total
cost will only be a few hundred dollars! Using &lt;a class="reference external" href="http://a16z.com/2015/11/18/bio-fund/"&gt;Vijay Pande from
A16Z&lt;/a&gt;'s terminology, this is
Bio 2.0.&lt;/p&gt;
&lt;p&gt;To make this a bit more concrete, this article describes a cloud lab
protocol in Python to do the following:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Synthesize&lt;/strong&gt; a DNA sequence that encodes any protein I want.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Clone&lt;/strong&gt; that synthetic DNA into a &lt;strong&gt;vector&lt;/strong&gt; that can express it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transform&lt;/strong&gt; bacteria with that &lt;strong&gt;vector&lt;/strong&gt; and confirm that it is
expressed.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="python-setup"&gt;
&lt;h2&gt;Python Setup&lt;/h2&gt;
&lt;p&gt;First, some general Python setup that I need for any jupyter notebook. I
import some useful Python modules and make some utility functions,
mainly for plotting and data presentation.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;re&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;logging&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;requests&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;itertools&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;mpl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;io&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pprint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pprint&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;Bio.Seq&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;Bio.Alphabet&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;generic_dna&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_START&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;svg viewBox=&amp;quot;0 0 &lt;/span&gt;&lt;span class="si"&gt;{w:}&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="si"&gt;{h:}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot; xmlns:xlink= &amp;quot;http://www.w3.org/1999/xlink&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;SVG_START&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;astr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/svg&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;table_print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;table&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html_row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;tr style='font-weight:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;'&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bold'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s1"&gt;'normal'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html_row&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html_row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;tr style='font-family:monospace;'&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{:}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html_row&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;clean_seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dna&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;dna&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;\s&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dna&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ACGTN&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;nt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dna&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dna&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;generic_dna&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;clean_aas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;aas&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;aas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;\s&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;aas&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;aa&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ACDEFGHIKLMNPQRSTVWY*&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;aa&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;aas&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;aas&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;Images&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;100%&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="c1"&gt;# to match Image syntax&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;px&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;table style='width:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;'&amp;gt;&amp;lt;tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/th&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;lt;img src='&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;' /&amp;gt;&amp;lt;/td&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;new_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;#66aa33&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;padding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;120px&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;style&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;text-align:center;background:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;;padding:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; 10px &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; 10px;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;style&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;color:#ffffff;font-size:2.55em;line-height:1.2em;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;div style=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Show or hide text&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;
&amp;lt;style&amp;gt;
    .section { display:flex;align-items:center;justify-content:center;width:100%; height:400px; background:#6a3;color:#eee;font-size:275%; }
    .showhide_label { display:block; cursor:pointer; }
    .showhide { position: absolute; left: -999em; }
    .showhide + div { display: none; }
    .showhide:checked + div { display: block; }
    .shown_or_hidden { font-size:85%; }
&amp;lt;/style&amp;gt;
&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Plotting style&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;axes&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;titlesize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labelsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edgecolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#444444'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;notebook&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font_scale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{})&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'retina'&lt;/span&gt; &lt;span class="c1"&gt;# or 'svg'&lt;/span&gt;
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Cloud Labs&lt;/div&gt;&lt;p&gt;Just like AWS or any compute cloud, a cloud lab owns molecular biology
equipment and robots, and will rent them out to you in small increments.
You can issue instructions to their robots by clicking some buttons on
their front-end, or write code to instruct the robots yourself. It's not
necessarily better to write your own protocols as I'll do here — in
general a &lt;em&gt;lot&lt;/em&gt; of molecular biology is the same few routine tasks, so
you generally want to rely on a robust protocol that someone else has
shown performs well with robots.&lt;/p&gt;
&lt;p&gt;There are a number of nascent cloud lab companies out there:
&lt;a class="reference external" href="https://www.transcriptic.com/"&gt;Transcriptic&lt;/a&gt;, &lt;a class="reference external" href="https://wla.bionano.autodesk.com/#/"&gt;Autodesk Wet Lab
Accelerator&lt;/a&gt; (beta, and built on
top of Transcriptic), &lt;a class="reference external" href="https://www.arcturus.io/"&gt;Arcturus BioCloud&lt;/a&gt;
(beta), &lt;a class="reference external" href="http://emeraldcloudlab.com/"&gt;Emerald Cloud Lab&lt;/a&gt; (beta),
&lt;a class="reference external" href="https://www.synthego.com/"&gt;Synthego&lt;/a&gt; (not yet live). There are even
companies built on top of cloud labs, like &lt;a class="reference external" href="http://desktopgenetics.com"&gt;Desktop
Genetics&lt;/a&gt;, which specializes in CRISPR.
Scientific papers,
like this one from the &lt;a class="reference external" href="http://www.businesswire.com/news/home/20160216005377/en/Study-Shows-Transcriptic%E2%80%99s-Robotic-Cloud-Laboratory-Removes"&gt;Siegel lab&lt;/a&gt;,
are just starting to appear that use cloud labs to do real science.&lt;/p&gt;
&lt;p&gt;At the time of writing, only Transcriptic is available for general use
so that's what I'll be using. As I understand it, most of Transcriptic's
business comes from automating common protocols, and writing your own
protocols in Python (as I'll be doing in this article) is less common.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_8_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;A &amp;quot;work cell&amp;quot; at Transcriptic, with freezers visible at the bottom and
various bits of lab equipment on the bench&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I issue instructions to Transcriptic's robots using
&lt;a class="reference external" href="http://autoprotocol.org"&gt;autoprotocol&lt;/a&gt;. Autoprotocol is a JSON-based
language for writing protocols for lab robots (and humans, sort of).
Autoprotocol is mainly written using this &lt;a class="reference external" href="https://github.com/autoprotocol/autoprotocol-python"&gt;Python
library&lt;/a&gt;. The
language was originally developed by, and is still supported by
Transcriptic, but as I understand it it's completely open. There is some
good and improving
&lt;a class="reference external" href="https://developers.transcriptic.com/docs/how-to-write-a-new-protocol"&gt;documentation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;One fascinating thing to think about here is that you could also
generate an autoprotocol protocol and submit it to a lab staffed by
humans — say in China or India — and potentially get some of the
advantages of using humans (their judgement) and robots (their lack of
judgement). I should also mention
&lt;a class="reference external" href="https://www.protocols.io/"&gt;protocols.io&lt;/a&gt; here, which is also an
effort to standardize protocols for increased reproducibility, but aimed
at humans instead of robots.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
&amp;quot;instructions&amp;quot;: [
    {
      &amp;quot;to&amp;quot;: [
        {
          &amp;quot;well&amp;quot;: &amp;quot;water/0&amp;quot;,
          &amp;quot;volume&amp;quot;: &amp;quot;500.0:microliter&amp;quot;
        }
      ],
      &amp;quot;op&amp;quot;: &amp;quot;provision&amp;quot;,
      &amp;quot;resource_id&amp;quot;: &amp;quot;rs17gmh5wafm5p&amp;quot;
    },
    ...
]
&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Example snippet of autoprotocol&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="molecular-biology-python-setup"&gt;
&lt;h2&gt;Molecular Biology Python Setup&lt;/h2&gt;
&lt;p&gt;As well as standard Python imports, I'll need some
molecular-biology–specific utilities. This code is primarily
autoprotocol- and Transcriptic-centric.&lt;/p&gt;
&lt;p&gt;One thing that comes up a lot in this code is the concept of dead
volume. This means the last bit of liquid that Transcriptic's robots
cannot consistently pipette out of tubes (because they can't see!). I
have to spend quite a bit of time ensuring that there is enough volume
left in my tubes.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;autoprotocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;autoprotocol&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;autoprotocol.container&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;autoprotocol.protocol&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;autoprotocol.protocol&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Ref&lt;/span&gt; &lt;span class="c1"&gt;# &amp;quot;Link a ref name (string) to a Container instance.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;requests&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;logging&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Transcriptic authorization&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;org_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'hgbrian'&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;tsc_headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;auth.json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X_User_Email&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X_User_Token&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Transcriptic-specific dead volumes&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_dead_volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-flat-uv&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-deep&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;384-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;384-flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;384-echo&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-2.0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;dead_volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_dead_volume&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;init_inventory_well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tsc_headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;org_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;org_name&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Initialize well (set volume etc) for Transcriptic&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_container_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;container_id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'https://secure.transcriptic.com/&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;/samples/&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;.json'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;org_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;container_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_container_url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;container&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;well_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'aliquots'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;label&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;well_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;well_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'name'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;container&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;label&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;well_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'properties'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'volume_ul'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s1"&gt;'microliter'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'ERROR'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="ne"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; has ERROR property: &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ERROR&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;logging&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;warn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Low volume for well &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; : &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;touchdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fromC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;durations&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stepsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;meltC&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;98&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extC&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;72&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Touchdown PCR protocol generator&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;stepsize&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;toC&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;fromC&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;td&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dur&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:2g}&lt;/span&gt;&lt;span class="s2"&gt;:celsius&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s2"&gt;:second&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dur&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;meltC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;durations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;durations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;td&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;extC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;durations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])]}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;C&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fromC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toC&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;stepsize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;stepsize&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;convert_ug_to_pmol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ug_dsDNA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_nts&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Convert ug dsDNA to pmol&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ug_dsDNA&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;num_nts&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1e6&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;660.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Generate a unique ID per experiment&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;microliters&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Unicode function name for creating microliter volumes&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Unit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;microliters&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;DNA synthesis &amp; synthetic biology&lt;/div&gt;&lt;p&gt;Despite its connection to modern synthetic biology, DNA synthesis is a
fairly old technology. We've been able to make &amp;quot;oligos&amp;quot; (meaning DNA
sequences of &amp;lt;~200bp) for
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Oligonucleotide_synthesis"&gt;decades&lt;/a&gt;.
It's always been expensive though, and the chemistry has never allowed
for long sequences of DNA. Recently, it's become feasible to synthesize
entire genes (up to thousands of bases) at a reasonable price. This
advance is really what is enabling the era of &amp;quot;synthetic biology&amp;quot;.&lt;/p&gt;
&lt;p&gt;Craig Venter's &lt;a class="reference external" href="http://www.syntheticgenomics.com/"&gt;Synthetic
Genomics&lt;/a&gt; has taken synthetic
biology the furthest by &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Mycoplasma_laboratorium"&gt;synthesizing an entire
organism&lt;/a&gt; —
over a million bases in length. As the length of the DNA grows, the
problem becomes more about assembly (i.e., stitching together
synthesized DNA sequences) rather than synthesis. Each time you assemble
you can double the length of your DNA (or more), so after a dozen or so
iterations you can get &lt;a class="reference external" href="http://www.wolframalpha.com/input/?i=200+*+2%5E12"&gt;pretty
long&lt;/a&gt;! The
distinction between synthesis and assembly should become transparent to
the end-user fairly soon.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="moore-s-lab"&gt;
&lt;h2&gt;Moore's Lab?&lt;/h2&gt;
&lt;p&gt;The price of DNA synthesis has been falling pretty quickly, from over
30c per base a couple of years ago to around 10c per base today, but
it's developing more like batteries than CPUs. In contrast, DNA
sequencing costs have been falling faster than Moore's law. A &lt;a class="reference external" href="https://twitter.com/twistbioscience/status/590886375572037632"&gt;target of
2c/base&lt;/a&gt;
has been mooted as an inflection point where you can replace a lot of
money-saving-but-laborious DNA manipulation with simple synthesis. For
example, at 2c/base you could synthesize an entire 3kb plasmid for
&lt;a class="reference external" href="http://www.wolframalpha.com/input/?i=3000+bases+at+2+cents%2Fbase"&gt;$60&lt;/a&gt;,
and skip over a ton of molecular biology chores. Hopefully that's what
we'll all be doing in a couple of years.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_17_0.png" /&gt;
&lt;p&gt;&lt;em&gt;DNA synthesis vs DNA sequencing costs&lt;/em&gt; (&lt;a class="reference external" href="http://synthesis.cc/"&gt;Carlson,
2014&lt;/a&gt;)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="dna-synthesis-companies"&gt;
&lt;h2&gt;DNA Synthesis Companies&lt;/h2&gt;
&lt;p&gt;There are a few big companies in the DNA synthesis space:
&lt;a class="reference external" href="https://www.idtdna.com"&gt;IDT&lt;/a&gt; is the largest manufacturer of oligos,
and can produce longer (up to 2kb) &amp;quot;gene fragments&amp;quot;
(&lt;a class="reference external" href="https://www.idtdna.com/pages/products/genes/gblocks-gene-fragments"&gt;gBlocks&lt;/a&gt;)
too; &lt;a class="reference external" href="https://www.gen9bio.com/"&gt;Gen9&lt;/a&gt;,
&lt;a class="reference external" href="https://www.twistbioscience.com/"&gt;Twist&lt;/a&gt;, &lt;a class="reference external" href="https://www.dna20.com/"&gt;DNA
2.0&lt;/a&gt; generally focus on longer DNA sequences
— these are the gene synthesis companies. There are also some exciting
new companies like &lt;a class="reference external" href="http://cambriangenomics.com/"&gt;Cambrian Genomics&lt;/a&gt;
and &lt;a class="reference external" href="http://www.genesisdna.com/"&gt;Genesis DNA&lt;/a&gt; that are working on
next-generation synthesis methods.&lt;/p&gt;
&lt;p&gt;Other companies, like &lt;a class="reference external" href="https://amyris.com/"&gt;Amyris&lt;/a&gt;,
&lt;a class="reference external" href="http://www.zymergen.com/"&gt;Zymergen&lt;/a&gt; and &lt;a class="reference external" href="http://ginkgobioworks.com/"&gt;Ginkgo
Bioworks&lt;/a&gt;, use the DNA sythesized by
these companies to do organism-scale work. &lt;a class="reference external" href="http://www.syntheticgenomics.com/"&gt;Synthetic
Genomics&lt;/a&gt; also does that but
synthesizes its own DNA.&lt;/p&gt;
&lt;p&gt;Recently, Ginkgo did a &lt;a class="reference external" href="http://www.fiercebiotechit.com/story/flush-90m-vc-cash-twist-and-ginkgo-strike-massive-synthetic-dna-deal/2015-11-06"&gt;deal with
Twist&lt;/a&gt;
for 100 million bases, a leap over anything public I've seen before. In
a move that proves we're living in the future, Twist has even advertised
a promo code on Twitter for a deal where if you buy 10 million bases of
DNA (almost an entire yeast genome!), you get 10 million bases free.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_20_0.png" /&gt;
&lt;p&gt;&lt;em&gt;A niche&lt;/em&gt; &lt;a class="reference external" href="https://twitter.com/twistbioscience/status/621765539002740737"&gt;Twist deal on
Twitter&lt;/a&gt;&lt;/p&gt;
&lt;div style="text-align:center;background:#dfdf44;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Part One: Designing the Experiment&lt;/div&gt;&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Green Fluorescent Protein&lt;/div&gt;&lt;p&gt;For this experiment I want to synthesize the DNA sequence for a simple
protein, &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Green_fluorescent_protein"&gt;Green Fluorescent
Protein&lt;/a&gt;
(GFP). GFP is a protein, first found in a
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Aequorea_victoria"&gt;jellyfish&lt;/a&gt;, that
fluoresces under UV light. It's an extremely useful protein since it's
easy to tell where it is being expressed simply by measuring
fluorescence. There are variants of GFP that produce yellow, red, orange
and &lt;a class="reference external" href="https://www.dna20.com/products/protein-paintbox"&gt;other colors&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It's interesting to see how various mutations&amp;nbsp;affect the color of the
protein, and potentially an interesting machine learning problem. Not
long ago, this would have been a significant investment of time in the
lab, but now, as I'll show, it is (almost) as simple as editing a text
file!&lt;/p&gt;
&lt;p&gt;Technically, my GFP is a &amp;quot;superfolder&amp;quot; variant
(&lt;a class="reference external" href="http://www.nature.com/nbt/journal/v24/n1/full/nbt1172.html"&gt;sfGFP&lt;/a&gt;),
with some enhancing mutations.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_25_0.jpe" /&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.nature.com/nbt/journal/v24/n1/full/nbt1172.html"&gt;Superfolder
GFP&lt;/a&gt;
&lt;em&gt;(sfGFP) has mutations that give it some useful properties&lt;/em&gt;&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_27_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;The Structure of GFP (visualized with&lt;/em&gt;
&lt;a class="reference external" href="http://dx.doi.org/10.5281/zenodo.20980"&gt;PV&lt;/a&gt;&lt;em&gt;)&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="synthesizing-gfp-with-twist"&gt;
&lt;h2&gt;Synthesizing GFP with Twist&lt;/h2&gt;
&lt;p&gt;I was fortunate to be included in Twist's alpha program so I used them
to synthesize my DNA (they graciously accommodated my tiny order —
thanks Twist!) Twist is a new company in the space, with a novel
miniaturized process for synthesis. Although Twist's pricing is probably
the best around at &lt;a class="reference external" href="https://groups.google.com/forum/?fromgroups#!topic/diybio/O1Tn1O-l-mQ"&gt;10c a base or
lower&lt;/a&gt;,
they are &lt;a class="reference external" href="https://www.twistbioscience.com/"&gt;still in beta only&lt;/a&gt;, and
the alpha program I took part in has closed. Twist has &lt;a class="reference external" href="http://www.xconomy.com/san-francisco/2016/01/19/same-twist-new-funding-gene-synthesizer-raises-61m-series-d/"&gt;raised about
$150M&lt;/a&gt;
so there is a lot of enthusiasm for their technology.&lt;/p&gt;
&lt;p&gt;I sent my DNA sequence to Twist as an Excel spreadsheet (there is no API
yet but I assume it'll come soon), and they sent the synthesized DNA
directly to my inventory in Transcriptic's labs. (I also used IDT for
synthesis, but since they did not ship the DNA straight to Transcriptic,
it kind of ruins the fun.)&lt;/p&gt;
&lt;p&gt;This process is clearly not a common use-case yet and required some
hand-holding, but it worked, and it keeps the entire pipeline virtual.
Without this, I would have likely needed access to a laboratory — many
companies will not ship DNA or reagents to a home address.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_30_0.jpe" /&gt;
&lt;p&gt;&lt;a class="reference external" href="http://news.nationalgeographic.com/news/2009/05/photogalleries/glowing-animal-pictures/"&gt;GFP&lt;/a&gt;
&lt;em&gt;is harmless, and can make any species glow&lt;/em&gt;&lt;/p&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;The Plasmid Vector&lt;/div&gt;&lt;p&gt;To express my protein in bacteria, I need somewhere for the gene to
live, otherwise the synthetic DNA encoding the gene will just be
instantly degraded. Generally, in molecular biology we use a plasmid, a
bit of circular DNA that lives outside the bacterial genome and
expresses proteins. Plasmids are a convenient way for bacteria to share
useful self-contained functional modules like antibiotic resistance.
There can be hundreds of plasmids per cell.&lt;/p&gt;
&lt;p&gt;The commonly used terminology is that the plasmid is the &lt;strong&gt;vector&lt;/strong&gt; and
the synthetic DNA is the &lt;strong&gt;insert&lt;/strong&gt;. So here I'm trying to &lt;strong&gt;clone&lt;/strong&gt; the
&lt;strong&gt;insert&lt;/strong&gt; into the &lt;strong&gt;vector&lt;/strong&gt;, then &lt;strong&gt;transform&lt;/strong&gt; bacteria with the
vector.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_34_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;A bacterial genome and plasmid (not to scale!)&lt;/em&gt;
(&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Plasmid"&gt;Wikipedia&lt;/a&gt;)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="puc19"&gt;
&lt;h2&gt;pUC19&lt;/h2&gt;
&lt;p&gt;I chose a fairly standard plasmid in
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/PUC19"&gt;pUC19&lt;/a&gt;. This plasmid is very
commonly used and since it's available as part of the standard
Transcriptic inventory, I do not need to ship anything to Transcriptic.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_37_0.png" /&gt;
&lt;p&gt;&lt;em&gt;The structure of pUC19: the major components are an ampicillin
resistance gene, lacZα, an MCS/polylinker, and an origin of replication&lt;/em&gt;
(&lt;a class="reference external" href="https://en.wikipedia.org/wiki/PUC19"&gt;Wikipedia&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;pUC19 has a nice feature where because it contains a lacZα gene, you can
use it in a &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Blue_white_screen"&gt;blue–white
screen&lt;/a&gt; and see
which colonies have had successful insertion events. You need two
chemicals,
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Isopropyl_%CE%B2-D-1-thiogalactopyranoside"&gt;IPTG&lt;/a&gt;
and &lt;a class="reference external" href="https://en.wikipedia.org/wiki/X-gal"&gt;X-gal&lt;/a&gt;, and it works as
follows:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;lacZα expression is induced by IPTG&lt;/li&gt;
&lt;li&gt;If lacZα is inactivated — by DNA inserted at the multiple cloning
site
(&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Multiple_cloning_site"&gt;MCS/polylinker&lt;/a&gt;)
within lacZα — then the plasmid cannot hydrolyze X-gal, and these
colonies will be white instead of blue&lt;/li&gt;
&lt;li&gt;Therefore a successful insertion produces white colonies and an
unsuccessful insertion produces blue colonies&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_40_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;A blue–white screen shows where lacZα expression has been inactivated&lt;/em&gt;
(&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Blue_white_screen"&gt;Wikipedia&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;A &lt;a class="reference external" href="http://openwetware.org/images/f/f1/Dh5a_sub.pdf"&gt;document on
openwetware&lt;/a&gt; states:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
DH5α E. coli does not require IPTG to induce expression from the lac promoter even though the strain expresses the Lac repressor. The copy number of most plasmids exceeds the repressor number in the cells. If you are concerned about obtaining maximal levels of expression, add IPTG to a final concentration of 1 mM.
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Synthetic DNA Sequences&lt;/div&gt;&lt;/div&gt;
&lt;div class="section" id="sfgfp-dna-sequence"&gt;
&lt;h2&gt;sfGFP DNA Sequence&lt;/h2&gt;
&lt;p&gt;It's straightforward to get a DNA sequence for sfGFP by taking the
&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/protein/532528641"&gt;protein sequence&lt;/a&gt; and
&lt;a class="reference external" href="https://www.idtdna.com/CodonOpt"&gt;encoding it with codons&lt;/a&gt; suitable
for the host organism (here, &lt;em&gt;E. coli&lt;/em&gt;). It's a medium-sized protein at
236 amino acids, which means at 10c/base it costs me about
&lt;a class="reference external" href="http://www.wolframalpha.com/input/?i=236+amino+acids+*+3+base+pairs+per+amino+acid+*+10+cents+per+base"&gt;$70&lt;/a&gt;
to synthesize the DNA.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_45_0.png" /&gt;
&lt;p&gt;&lt;em&gt;Wolfram Alpha, calculating the cost of synthesis&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The first 12 bases of my sfGFP are a &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Shine-Dalgarno_sequence"&gt;Shine-Dalgarno
sequence&lt;/a&gt; that
I added myself, which should in theory increase expression
(AGGAGGACAGCT, then an ATG (&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Start_codon"&gt;start
codon&lt;/a&gt;) starts the
protein). According to a computational tool developed by the &lt;a class="reference external" href="https://salislab.net/software/Results"&gt;Salis
Lab&lt;/a&gt; (&lt;a class="reference external" href="http://www.genscript.com/gsfiles/techfiles/Salis_Genscript.pdf"&gt;lecture
slides&lt;/a&gt;),
I should expect medium to high expression of my protein (a Translation
Initiation Rate of 10,000 &amp;quot;arbitrary units&amp;quot;).&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;sfGFP_plus_SD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;clean_seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;
AGGAGGACAGCTATGTCGAAAGGAGAAGAACTGTTTACCGGTGTGGTTCCGATTCTGGTAGAACTGGA
TGGGGACGTGAACGGCCATAAATTTAGCGTCCGTGGTGAGGGTGAAGGGGATGCCACAAATGGCAAAC
TTACCCTTAAATTCATTTGCACTACCGGCAAGCTGCCGGTCCCTTGGCCGACCTTGGTCACCACACTG
ACGTACGGGGTTCAGTGTTTTTCGCGTTATCCAGATCACATGAAACGCCATGACTTCTTCAAAAGCGC
CATGCCCGAGGGCTATGTGCAGGAACGTACGATTAGCTTTAAAGATGACGGGACCTACAAAACCCGGG
CAGAAGTGAAATTCGAGGGTGATACCCTGGTTAATCGCATTGAACTGAAGGGTATTGATTTCAAGGAA
GATGGTAACATTCTCGGTCACAAATTAGAATACAACTTTAACAGTCATAACGTTTATATCACCGCCGA
CAAACAGAAAAACGGTATCAAGGCGAATTTCAAAATCCGGCACAACGTGGAGGACGGGAGTGTACAAC
TGGCCGACCATTACCAGCAGAACACACCGATCGGCGACGGCCCGGTGCTGCTCCCGGATAATCACTAT
TTAAGCACCCAGTCAGTGCTGAGCAAAGATCCGAACGAAAAACGTGACCATATGGTGCTGCTGGAGTT
CGTGACCGCCGCGGGCATTACCCATGGAATGGATGAACTGTATAAA&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Read in sfGFP plus Shine-Dalgarno: &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; bases long&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sfGFP_plus_SD&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;sfGFP_aas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;clean_aas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;MSKGEELFTGVVPILVELDGDVNGHKFSVRGEGEGDATNGKLTLKFICTTGKLPVPWPTLVTTLTYG
VQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGTYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNFNSHNVYITADKQKN
GIKANFKIRHNVEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSVLSKDPNEKRDHMVLLEFVTAAGITHGMDELYK&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;sfGFP_plus_SD&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;sfGFP_aas&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Translation&amp;nbsp;matches protein with accession 532528641&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Read in sfGFP plus Shine-Dalgarno: 726 bases long
Translation&amp;nbsp;matches protein with accession 532528641
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="puc19-dna-sequence"&gt;
&lt;h2&gt;pUC19 DNA Sequence&lt;/h2&gt;
&lt;p&gt;I first check that the &lt;a class="reference external" href="https://www.neb.com/~/media/NebUs/Page%20Images/Tools%20and%20Resources/Interactive%20Tools/DNA%20Sequences%20and%20Maps/Text%20Documents/puc19fsa.txt"&gt;pUC19 sequence I downloaded from
NEB&lt;/a&gt;
and is the right length, and that it includes the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Multiple_cloning_site"&gt;multiple cloning
site&lt;/a&gt; I expect.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;pUC19_fasta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;cat&lt;/span&gt; &lt;span class="n"&gt;puc19fsa&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pUC19_fwd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;clean_seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pUC19_fasta&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pUC19_rev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse_complement&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ACGT&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;nt&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;2686&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;pUC19_MCS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;clean_seq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GAATTCGAGCTCGGTACCCGGGGATCCTCTAGAGTCGACCTGCAGGCATGCAAGCTT&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Read in pUC19: &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; bases long&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;pUC19_MCS&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Found MCS/polylinker&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Read in pUC19: 2686 bases long
Found MCS/polylinker
&lt;/pre&gt;
&lt;p&gt;I do some basic QC is to make sure that EcoRI and BamHI are only present
in pUC19 once. (The following restriction enzymes are available in
Transcriptic's default inventory: &lt;em&gt;PstI, PvuII, EcoRI, BamHI, BbsI,
BsmBI&lt;/em&gt;.)&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;REs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;EcoRI&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GAATTC&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;BamHI&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GGATTC&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;REs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rfind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;pUC19_rev&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;pUC19_rev&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rfind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;pUC19_rev&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pUC19_fwd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;pUC19_rev&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Asserted restriction enzyme sites present only once: &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;REs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Now I look at the lacZα sequence and make sure there is nothing
unexpected. For example, it should start with a Met and end with a stop
codon. It's also easy to confirm that this is the full 324bp lacZα ORF
by loading the pUC19 sequece into the free &lt;a class="reference external" href="http://www.snapgene.com/products/snapgene_viewer/"&gt;snapgene
viewer&lt;/a&gt; tool.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;lacZ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pUC19_rev&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2217&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2541&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;lacZα sequence:&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lacZ&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;r_MCS sequence:&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pUC19_MCS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse_complement&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;lacZ_p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;lacZ&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;translate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;lacZ_p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;M&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;*&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lacZ_p&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;lacZ_p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;*&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;pUC19_MCS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse_complement&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lacZ&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;pUC19_MCS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse_complement&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;pUC19_rev&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2234&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2291&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Found MCS once in lacZ sequence&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
lacZ sequence:      ATGACCATGATTACGCCAAGCTTGCATGCCTGCAGGTCGACTCTAGAGGATCCCCGGGTACCGAGCTCGAATTCACTGGCCGTCGTTTTACAACGTCGTGACTGGGAAAACCCTGGCGTTACCCAACTTAATCGCCTTGCAGCACATCCCCCTTTCGCCAGCTGGCGTAATAGCGAAGAGGCCCGCACCGATCGCCCTTCCCAACAGTTGCGCAGCCTGAATGGCGAATGGCGCCTGATGCGGTATTTTCTCCTTACGCATCTGTGCGGTATTTCACACCGCATATGGTGCACTCTCAGTACAATCTGCTCTGATGCCGCATAG
r_MCS sequence:     AAGCTTGCATGCCTGCAGGTCGACTCTAGAGGATCCCCGGGTACCGAGCTCGAATTC
Found MCS once in lacZ sequence
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Gibson Assembly&lt;/div&gt;&lt;p&gt;DNA assembly simply means stitching DNA together. Usually, you
&lt;strong&gt;assemble&lt;/strong&gt; several pieces of DNA into a longer segment, and then
&lt;strong&gt;clone&lt;/strong&gt; that into a plasmid or genome. In this experiment I just want
to clone one DNA segment into the pUC19 plasmid downstream of the lac
promoter, so that it will be expressed in &lt;em&gt;E. coli&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;There are many different ways to do cloning (e.g., see
&lt;a class="reference external" href="https://www.neb.com/applications/cloning-and-synthetic-biology"&gt;NEB&lt;/a&gt;,
&lt;a class="reference external" href="http://openwetware.org/wiki/Janet_B._Matsen:Guide_to_Gibson_Assembly"&gt;openwetware&lt;/a&gt;,
&lt;a class="reference external" href="https://www.addgene.org/plasmid-protocols/PCR-cloning/"&gt;addgene&lt;/a&gt;).
Here I will use Gibson assembly (&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Gibson_assembly"&gt;developed by Daniel
Gibson&lt;/a&gt; at Synthetic
Genomics in 2009), which is not necessarily the cheapest method, but is
straightforward and flexible. All you have to do is put all the DNA you
want to assemble (with the appropriate overlaps) in a tube with the
Gibson Assembly Master Mix, and it assembles itself!&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_57_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Gibson assembly overview&lt;/em&gt;
(&lt;a class="reference external" href="https://www.neb.com/products/e2611-gibson-assembly-master-mix"&gt;NEB&lt;/a&gt;)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="starting-material"&gt;
&lt;h2&gt;Starting material&lt;/h2&gt;
&lt;p&gt;I am starting with 100ng of synthetic DNA in 10µl of liquid. That
equates to 0.21 picomoles of DNA or a concentration of 10ng/µl.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;pmol_sfgfp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;convert_ug_to_pmol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sfGFP_plus_SD&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Insert: 100ng of DNA of length &lt;/span&gt;&lt;span class="si"&gt;{:4d}&lt;/span&gt;&lt;span class="s2"&gt; equals &lt;/span&gt;&lt;span class="si"&gt;{:.2f}&lt;/span&gt;&lt;span class="s2"&gt; pmol&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sfGFP_plus_SD&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;pmol_sfgfp&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Insert: 100ng of DNA of length  726 equals 0.21 pmol
&lt;/pre&gt;
&lt;p&gt;According to &lt;a class="reference external" href="https://www.neb.com/protocols/2012/12/11/gibson-assembly-protocol-e5510"&gt;NEB's Gibson assembly
protocol&lt;/a&gt;,
this is sufficient starting material for the protocol:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
NEB recommends a total of 0.02–0.5 pmols of DNA fragments when 1 or 2 fragments are being assembled into a vector and 0.2–1.0 pmoles of DNA fragments when 4–6 fragments are being assembled

0.02–0.5 pmols* X µl
* Optimized cloning efficiency is 50–100 ng of vectors with 2–3 fold of excess inserts. Use 5 times more of inserts if size is less than 200 bps. Total volume of unpurified PCR fragments in Gibson Assembly reaction should not exceed 20%.
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="nebuilder-for-gibson-assembly"&gt;
&lt;h2&gt;NEBuilder for Gibson Assembly&lt;/h2&gt;
&lt;p&gt;New England Biolab's &lt;a class="reference external" href="http://nebuilder.neb.com/"&gt;NEBuilder&lt;/a&gt; is a
really excellent tool to help you design your Gibson assembly protocol.
It even generates a comprehensive four-page PDF protocol for you. Using
this tool, I design a protocol to cut pUC19 with EcoRI and then use PCR
to add appropriately sized flanks to the insert.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_63_0.png" /&gt;
&lt;div style="text-align:center;background:#dddd44;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Part Two: Running The Experiment&lt;/div&gt;&lt;p&gt;There are four steps in the experiment:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;PCR of the insert to add complementary flanks;&lt;/li&gt;
&lt;li&gt;Cutting the plasmid to accommodate the insert;&lt;/li&gt;
&lt;li&gt;Gibson assembly of insert and plasmid;&lt;/li&gt;
&lt;li&gt;Transforming the bacteria with the assembled plasmid.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Step 1. PCR of the Insert&lt;/div&gt;&lt;p&gt;Gibson assembly relies on the DNA sequences you are assembling having
some overlapping sequence (see the NEB protocol above for detailed
instructions). As well as simple amplification, PCR also enables you to
add flanking DNA to a sequence by simply including the additional
sequence in the primers. (You can also &lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3121328/"&gt;clone using only
OE-PCR&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;I synthesize primers according to the NEB protocol above. I used a
&lt;a class="reference external" href="https://developers.transcriptic.com/docs/oligosynthesis-1"&gt;Quickstart
protocol&lt;/a&gt;
on the Transcriptic website to try it out, but there's also an
&lt;a class="reference external" href="http://autoprotocol-python.readthedocs.org/en/latest/autoprotocol.html#protocol-oligosynthesize"&gt;autoprotocol
command&lt;/a&gt;.
Transcriptic does not do oligo synthesis in-house, so after a day or two
of waiting, these primers magically appear in my inventory. (Note, the
gene-specific part of the primers below is upper-case but it's just
cosmetic.)&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;insert_primers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;aaacgacggccagtgTTTATACAGTTCATCCATTCCATG&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;cgggtaccgagctcgAGGAGGACAGCTATGTCG&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="primer-analysis"&gt;
&lt;h2&gt;Primer analysis&lt;/h2&gt;
&lt;p&gt;I can analyze the properties of these primers using &lt;a class="reference external" href="https://www.idtdna.com/calc/analyzer"&gt;IDT
OligoAnalyzer&lt;/a&gt;. It is useful to
know the melting temperatures and propensity for
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Primer_dimer"&gt;dimer-forming&lt;/a&gt; when
debugging a PCR experiment, though the NEB protocol almost certainly
chooses primers with good properties.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
Gene-specific portion of flank (uppercase)
  Melt temperature: 51C, 53.5C
Full sequence
  Melt temperature: 64.5C, 68.5C
  Hairpin: -.4dG, -5dG
  Self-dimer: -9dG, -16dG
  Heterodimer: -6dG
&lt;/pre&gt;
&lt;p&gt;I went through many iterations of this PCR protocol before getting
results I was satisfied with, including experimenting with several
different brands of PCR mixes. Since each of these iterations can take
several days, (depending on the length of the queue at the lab) it is
worth spending time debugging upfront, since it saves&amp;nbsp;a lot of time in
the long run. As cloud lab capacity increases this issue should
diminish. Still, I would not assume that your first protocol will
succeed — there are many variables at work here.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot; PCR overlap extension of sfGFP according to NEB protocol.
v5: Use 3/10ths as much primer as the v4 protocol.
v6: more complex touchdown pcr procedure. The Q5 temperature was probably too hot
v7: more time at low temperature to allow gene-specific part to anneal
v8: correct dNTP concentration, real touchdown
&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Set up experiment&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;sfgfp_pcroe_v8&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;template_length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;740&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;_options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'dilute_primers'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# if working stock has not been made&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s1"&gt;'dilute_template'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# if working stock has not been made&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s1"&gt;'dilute_dNTP'&lt;/span&gt;    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# if working stock has not been made&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s1"&gt;'run_gel'&lt;/span&gt;        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;# run a gel to see the plasmid size&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s1"&gt;'run_absorbance'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# check absorbance at 260/280/320&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s1"&gt;'run_sanger'&lt;/span&gt;     &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;# sanger sequence the new sequence&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Inventory and provisioning&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# https://developers.transcriptic.com/v1.0/docs/containers&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 'sfgfp2':              'ct17yx8h77tkme', # inventory; sfGFP tube #2, micro-1.5, cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 'sfgfp_puc19_primer1': 'ct17z9542mrcfv', # inventory; micro-2.0, cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 'sfgfp_puc19_primer2': 'ct17z9542m5ntb', # inventory; micro-2.0, cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 'sfgfp_idt_1ngul':     'ct184nnd3rbxfr', # inventory; micro-1.5, cold_4, (ERROR: no template)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'Q5 Polymerase'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                     &lt;span class="s1"&gt;'rs16pcce8rdytv'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Q5 High-Fidelity DNA Polymerase&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'Q5 Buffer'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                         &lt;span class="s1"&gt;'rs16pcce8rmke3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Q5 Reaction Buffer&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'dNTP Mixture'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                      &lt;span class="s1"&gt;'rs16pcb542c5rd'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; dNTP Mixture (25mM?)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'water'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                             &lt;span class="s1"&gt;'rs17gmh5wafm5p'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Autoclaved MilliQ H2O&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'sfgfp_pcroe_v5_puc19_primer1_10uM'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ct186cj5cqzjmr'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; micro-1.5, cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'sfgfp_pcroe_v5_puc19_primer2_10uM'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ct186cj5cq536x'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; micro-1.5, cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'sfgfp1'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                            &lt;span class="s1"&gt;'ct17yx8h759dk4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; sfGFP tube #1, micro-1.5, cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# Existing inventory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;template_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sfgfp1'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sfgfp_pcroe_v5_puc19_primer1_10uM'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sfgfp_pcroe_v5_puc19_primer1_10uM'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                       &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sfgfp_pcroe_v5_puc19_primer2_10uM'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'sfgfp_pcroe_v5_puc19_primer2_10uM'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# New inventory resulting from this experiment&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;dilute_template_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp1_0.25ngul&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;dNTP_10uM_tube&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;dNTP_10uM&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;sfgfp_pcroe_out_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amplified&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Temporary tubes for use, then discarded&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;mastermix_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;mastermix&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;     &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;      &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;pcr_plate&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'run_absorbance'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;abs_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;abs_plate&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Initialize all existing inventory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;all_inventory_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;template_tube&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_inventory_wells&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;init_inventory_well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Provision water once, for general use&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Dilute primers 1/10 (100uM-&amp;gt;10uM) and keep at 4C&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'dilute_primers'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;primer_num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;primer_tubes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_before&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Dilute template 1/10 (10ng/ul-&amp;gt;1ng/ul) and keep at 4C&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# OR&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Dilute template 1/40 (10ng/ul-&amp;gt;0.25ng/ul) and keep at 4C&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'dilute_template'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dilute_template_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;195&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dilute_template_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Dilute dNTP to exactly 10uM&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'dilute_DNTP'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="n"&gt;dNTP_10uM_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;dNTP Mixture&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;dNTP_10uM_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Q5 PCR protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# www.neb.com/protocols/2013/12/13/pcr-using-q5-high-fidelity-dna-polymerase-m0491&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 25ul reaction&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# -------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Q5 reaction buffer      5    µl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Q5 polymerase           0.25 µl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 10mM dNTP               0.5  µl -- 1µl = 4x12.5mM&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 10uM primer 1           1.25 µl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 10uM primer 2           1.25 µl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 1pg-1ng Template        1    µl -- 0.5 or 1ng/ul concentration&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# -------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Sum                     9.25 µl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Mastermix tube will have 96ul of stuff, leaving space for 4x1ul aliquots of template&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;             &lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;64&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Q5 Buffer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;      &lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'Q5 Polymerase'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;  &lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dNTP_10uM_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_before&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_before&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_before&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;48:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Transfer mastermix to pcr_plate without template&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mastermix_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;           &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# acknowledged dead volume problems&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Finally add template&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;12.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Thermocycle with Q5 and hot start&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 61.1 annealing temperature is recommended by NEB protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# p.seal is enforced by transcriptic&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;extension_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template_length&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;11.0&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;))))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;extension_time&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;extension time should be reasonable for PCR&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;cycles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;98:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;30:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]}]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; \
         &lt;span class="n"&gt;touchdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;61&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extension_time&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;stepsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; \
         &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;98:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;8:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;61.1:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;25:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;72:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s2"&gt;:second&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;extension_time&lt;/span&gt;&lt;span class="p"&gt;)}]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;72:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;2:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cycles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# --------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Run a gel to hopefully see a 740bp fragment&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'run_gel'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;12.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;F1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;F1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt; &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gel_separate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;F1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                   &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;agarose(10,2%)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ladder1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;10:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gel&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#---------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Absorbance dilution series. Take 1ul out of the 25ul pcr plate wells&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'run_absorbance'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;abs_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;wavelength&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;260&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;280&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;320&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;absorbance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;abs_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                     &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;:nanometer&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wavelength&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;exp_id&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;abs_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wavelength&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;flashes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Sanger sequencing: https://developers.transcriptic.com/docs/sanger-sequencing&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;Each reaction should have a total volume of 15 µl and we recommend the following composition of DNA and primer:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#  PCR product (40 ng), primer (1 µl of a 10 µM stock)&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#  By comparing to the gel ladder concentration (175ng/lane), it looks like 5ul of PCR product has approximately 30ng of DNA&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'run_sanger'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;seq_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;G1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;G2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq_well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]),(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dilute_primer_tubes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;seq_well&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                   &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_before&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;seq_well&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                   &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_before&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;seq_well&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;7.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sangerseq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;seq1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sangerseq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;seq2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -------------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Then consolidate to one tube. Leave at least 3ul dead volume in each tube&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;remaining_volumes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'96-pcr'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Consolidated volume&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;remaining_volumes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;consolidate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;sfgfp_pcroe_out_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remaining_volumes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;allow_carryover&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Protocol 1. Amplify the insert (oligos previously synthesized)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_dict&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{jprotocol}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;transcriptic&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;protocol_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.json&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
WARNING:root:Low volume for well sfGFP 1 /sfGFP 1  : 2.0:microliter
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
sfGFP 1 /sfGFP 1  2.0:microliter {'dilution': '0.25ng/ul'}
sfgfp_pcroe_v5_puc19_primer1_10uM 75.0:microliter {}
sfgfp_pcroe_v5_puc19_primer2_10uM 75.0:microliter {}
Consolidated volume 52.0:microliter

Protocol 1. Amplify the insert (oligos previously synthesized)
---------------------------------------------------------------

  warnings.warn(self.msg_depr % (key, alt_key))
✓ Protocol analyzed
  11 instructions
  8 containers
  Total Cost: $32.18
  Workcell Time: $4.32
  Reagents &amp;amp; Consumables: $27.86
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
19968
&lt;/pre&gt;
&lt;div style="text-align:center;background:#d050a0;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Results: PCR of the insert&lt;/div&gt;&lt;/div&gt;
&lt;div class="section" id="analysis-of-gel-results"&gt;
&lt;h2&gt;Analysis of gel results&lt;/h2&gt;
&lt;p&gt;By running a gel I can see if the amplified product is the right
&lt;strong&gt;size&lt;/strong&gt; (position of the band in the gel), and the right &lt;strong&gt;quantity&lt;/strong&gt;
(darkness of the band). The gel has a ladder corresponding to different
lengths and quantities of DNA that can be used for comparison.&lt;/p&gt;
&lt;p&gt;In the gel photograph below, lanes D1, E1, F1 contain 2µl, 4µl, and 8µl
of amplified product, respectively. I can estimate the amount of DNA in
each lane by comparison to the DNA in the ladder (50ng of DNA per band
in the ladder). I think the results look very clean.&lt;/p&gt;
&lt;p&gt;I tried using
&lt;a class="reference external" href="http://www.frogdance.dundee.ac.uk/FrogDance_Software.html"&gt;GelEval&lt;/a&gt;
to analyze the image and estimate concentrations, and it worked pretty
well, though I'm not sure it would be much more accurate than a more
naive method. However, small changes to the location and size of the
bands led to large changes in the estimate of the amount of DNA. My best
estimate for the amount of DNA in my amplified product using GelEval is
&lt;strong&gt;40ng/µl&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If I assume that I am &lt;a class="reference external" href="http://forums.biotechniques.com/viewtopic.php?f=2&amp;amp;t=9105"&gt;limited by the amount of primer in the
mixture&lt;/a&gt;,
as opposed to the amount of dNTP or enzyme, then since I have 12.5pmol
of each primer, that implies a theoretical maximum of 6µg of 740bp DNA
in 25µl. Since my estimate for the total amount of DNA using GelEval is
40ng x 25µl (1µg or 2pmol), these results are very reasonable and close
to what I should expect under ideal conditions.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_74_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Gel electrophoresis of an EcoRI-cut pUC19, various concentrations (D1,
E1, F1), plus a control (D2)&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="pcr-results-diagnostics"&gt;
&lt;h2&gt;PCR results diagnostics&lt;/h2&gt;
&lt;p&gt;Recently, Transcriptic has started providing some interesting and useful
diagnostic data, outputted by its robots. At the time of writing, the
data were not available for download, so for now I just have an image of
temperatures during thermocycling.&lt;/p&gt;
&lt;p&gt;The data looks good, with no unexpected peaks or troughs. The PCR cycles
35 times in total, but some of these cycles are spent at very high
temperature as part of the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Touchdown_polymerase_chain_reaction"&gt;touchdown
PCR&lt;/a&gt;
process. In my previous attempts to amplify this segment — of which
there were a few! — I had issues with self–primer hybridization so here
I made the PCR spends quite a bit of time at high temperatures, which
should increase the fidelity.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_77_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Thermocycling diagnostics for a touchdown PCR: temperatures of block,
sample and lid over 35 cycles and 42 minutes&lt;/em&gt;&lt;/p&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Step 2. Cutting the Plasmid&lt;/div&gt;&lt;p&gt;To insert my sfGFP DNA into pUC19, I first need to cut the plasmid open.
Following the NEB protocol, I do this with the restriction enzyme
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/EcoRI"&gt;EcoRI&lt;/a&gt;. Transcriptic has the
reagents I need in its standard inventory: this &lt;a class="reference external" href="https://www.neb.com/products/r3101-ecori-hf"&gt;NEB EcoRI and 10x
CutSmart buffer&lt;/a&gt; and
this &lt;a class="reference external" href="https://www.neb.com/products/n3041-puc19-vector"&gt;NEB pUC19&lt;/a&gt;
plasmid.&lt;/p&gt;
&lt;p&gt;Here are the prices from their inventory for reference. I only actually
pay a fraction of the price below since Transcriptic sells by the
aliquot:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
   Item         ID       Amount      Concentration    Price
------------  ------ ------------- -----------------  ------
CutSmart 10x  B7204S       5 ml         10 X          $19.00
EcoRI         R3101L  50,000 units  20,000 units/ml  $225.00
pUC19         N3041L     250 µg      1,000 µg/ml     $268.00
&lt;/pre&gt;
&lt;p&gt;I follow the &lt;a class="reference external" href="https://www.neb.com/protocols/2012/12/07/optimizing-restriction-endonuclease-reactions"&gt;NEB
Protocol&lt;/a&gt;
as closely as possible:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
The buffer must be completely thawed before use. Dilute the 10X stock with dH2O to a final concentration of 1X. Add the water first, buffer next, the DNA solution and finally the enzyme. A typical 50 µl reaction should contain 5 µl of 10X NEBuffer with the rest of the volume coming from the DNA solution, enzyme and dH2O.

One unit is defined as the amount of enzyme required to digest 1 µg of λ DNA in 1 hour at 37°C in a total reaction volume of 50 µl.  In general, we recommend 5–10 units of enzyme per µg DNA, and 10–20 units for genomic DNA in a 1 hour digest.

A 50 µl reaction volume is recommended for digestion of 1 µg of substrate
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Protocol for cutting pUC19 with EcoRI.&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;puc19_ecori_v3&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s1"&gt;'water'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;rs17gmh5wafm5p&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# catalog; Autoclaved MilliQ H2O; ambient&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;pUC19&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;rs17tcqmncjfsh&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# catalog; pUC19; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;EcoRI&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;rs17ta8xftpdk6&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# catalog; EcoRI-HF; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;CutSmart&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17ta93g3y85t&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# catalog; CutSmart Buffer 10x; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;ecori_p10x&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct187v4ea85k2h&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; EcoRI diluted 10x&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Tubes and plates I use then discard&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;re_tube&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;re_tube&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water_tube&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;pcr_plate&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# The result of the experiment, a pUC19 cut by EcoRI, goes in this tube for storage&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;puc19_cut&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Provisioning and diluting.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Diluted EcoRI can be used more than once&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'dilute_ecori'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ecori_p10x&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;EcoRI&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# All &amp;quot;inventory&amp;quot; (stuff I own at transcriptic) must be initialized&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ecori_p10x&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ecori_p10x&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;init_inventory_well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Restriction enzyme cutting pUC19&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 50ul total reaction volume for cutting 1ug of DNA:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 5ul CutSmart 10x&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 1ul pUC19 (1ug of DNA)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 1ul EcoRI (or 10ul diluted EcoRI, 20 units, &amp;gt;10 units per ug DNA)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;       &lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;117&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;CutSmart&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;pUC19&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;    &lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Volumes: re_tube:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; water_tube:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; EcoRI:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;           &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;      &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Incubation to induce cut, then heat inactivation of EcoRI&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;incubate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;warm_37&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;60:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shaking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;65:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;21:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]}],&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# --------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Gel electrophoresis, to ensure the cutting worked&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gel_separate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;agarose(10,2%)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ladder2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;15:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gel&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# ----------------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Then consolidate all cut plasmid to one tube (puc19_cut_tube).&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;remaining_volumes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'96-pcr'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Consolidated volume: &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;remaining_volumes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;))))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;consolidate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remaining_volumes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;allow_carryover&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'micro-1.5'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tube&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ecori_p10x_tube&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Test protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_dict&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{jprotocol}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;transcriptic&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#print(&amp;quot;Protocol {}\n\n{}&amp;quot;.format(experiment_name, jprotocol))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;protocol_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.json&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Volumes: re_tube:135.0:microliter water_tube:383.0:microliter EcoRI:30.0:microliter
Consolidated volume: 78.0:microliter

  warnings.warn(self.msg_depr % (key, alt_key))
✓ Protocol analyzed
  12 instructions
  5 containers
  Total Cost: $30.72
  Workcell Time: $3.38
  Reagents &amp;amp; Consumables: $27.34
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
7764
&lt;/pre&gt;
&lt;div style="text-align:center;background:#d050a0;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Results: Cutting the plasmid&lt;/div&gt;&lt;p&gt;I ended up doing this experiment twice under slightly different
conditions and with different-sized gels, but the results are almost
identical. Both gels look good to me.&lt;/p&gt;
&lt;p&gt;Originally, I did not allocate enough space for &lt;a class="reference external" href="https://developers.transcriptic.com/docs/containers"&gt;dead
volume&lt;/a&gt; (1.5ml
tubes have 15µl of dead volume!), which I believe explains the
difference between &lt;strong&gt;D1&lt;/strong&gt; and &lt;strong&gt;E1&lt;/strong&gt; (these two lanes should be
identical). This dead volume problem&amp;nbsp;would be easily solved by making a
proper working stock of diluted EcoRI at the start of the protocol.&lt;/p&gt;
&lt;p&gt;Despite that error, in both gels, lanes &lt;strong&gt;D1&lt;/strong&gt; and &lt;strong&gt;E1&lt;/strong&gt; contain strong
bands at the correct position of 2.6kb. Lane &lt;strong&gt;D2&lt;/strong&gt; contains uncut
plasmid, so as expected, it is not visible in one gel and barely visible
as a smear in the other.&lt;/p&gt;
&lt;p&gt;The two gel photographs look pretty different, partially just because
this is a step that Transcriptic has yet to automate.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_84_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Two gels showing a cut pUC19 (2.6kb) in lanes D1 and E1, and uncut
pUC19 in D2&lt;/em&gt;&lt;/p&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Step 3. Gibson Assembly&lt;/div&gt;&lt;p&gt;The simplest way to check if my Gibson assembly works is to assemble the
insert and plasmid, then use standard &lt;a class="reference external" href="https://www.neb.com/faqs/2011/08/16/what-primers-should-i-use-to-sequence-an-insert-puc19-pneb193-litmus"&gt;M13
primers&lt;/a&gt;
(which flank the insert) to amplify part of the plasmid and the inserted
DNA, and run
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Real-time_polymerase_chain_reaction"&gt;qPCR&lt;/a&gt;
and a &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Gel_electrophoresis"&gt;gel&lt;/a&gt; to see
that the amplification worked. You could also run a sequencing reaction
to confirm that everything inserted as expected, but I decided to leave
this for later.&lt;/p&gt;
&lt;p&gt;If the Gibson assembly fails, then the M13 amplification will fail,
because the plasmid has been cut between the two M13 sequences.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Debugging transformation protocol: Gibson assembly followed by qPCR and a gel
v2: include v3 Gibson assembly&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;debug_sfgfp_puc19_gibson_seq_v2&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;                       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17gmh5wafm5p&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Autoclaved MilliQ H2O; ambient&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;M13_F&amp;quot;&lt;/span&gt;                       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17tcpqwqcaxe&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; M13 Forward (-41); cold_20 (1ul = 100pmol)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;M13_R&amp;quot;&lt;/span&gt;                       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17tcph6e2qzh&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; M13 Reverse (-48); cold_20 (1ul = 100pmol)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;SensiFAST_SYBR_No-ROX&amp;quot;&lt;/span&gt;       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17knkh7526ha&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; SensiFAST SYBR for qPCR&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v1_clone&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct187rzdq9kd7q&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; assembled sfGFP; cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v3_clone&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct188ejywa8jcv&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; assembled sfGFP; cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# First get my sfGFP pUC19 clones, assembled with Gibson assembly&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;clone_plate1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v1_clone&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v1_clone&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                     &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;clone_plate2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v3_clone&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v3_clone&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                     &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;master_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;master&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;primer_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;primer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;pcr_plate&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;init_inventory_well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;init_inventory_well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B6&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# clone_plate1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;             &lt;span class="s2"&gt;&amp;quot;D2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D6&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# clone_plate2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;             &lt;span class="s2"&gt;&amp;quot;F2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;F4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# control&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# clone_plate2 was diluted 4X (20ul-&amp;gt;80ul), according to NEB instructions&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;clone_plate1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;clone_plate1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;clone_plate2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;78&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;clone_plate2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# --------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Provisioning&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# primers, diluted 2X, discarded at the end&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;M13_F&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;M13_R&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# PCR Master mix -- 10ul SYBR mix, plus 1ul each undiluted primer DNA (100pmol)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Also add 15ul of dead volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'SensiFAST_SYBR_No-ROX'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;master_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;master_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;master_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;63&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;master_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# 15ul dead volume&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;master_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;allow_carryover&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;             &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ul&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;             &lt;span class="n"&gt;allow_carryover&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Template -- starting with some small, unknown amount of DNA produced by Gibson&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt; &lt;span class="n"&gt;one_tip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt; &lt;span class="n"&gt;one_tip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;clone_plate1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;clone_plate2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;66&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# --------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# qPCR&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# standard melting curve parameters&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;95:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;2:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;95:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;5:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                                   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;60:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;20:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                                   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;72:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;15:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;read&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}]}],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="c1"&gt;# volume is optional&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;qpcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;dyes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;SYBR&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="c1"&gt;# dye must be specified (tells transcriptic what aborbance to use?)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;melting_start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;65:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;melting_end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;95:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;melting_increment&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;0.5:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;melting_rate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;5:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# --------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Gel -- 20ul required&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Dilute such that I have 11ul for sequencing&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gel_separate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;agarose(8,0.8%)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ladder1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;10:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gel&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# This appears to be a bug in Transcriptic. The actual volume should be 11ul&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# but it is not updating after running a gel with 20ul.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Primer tube should be equal to dead volume, or it's a waste&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'micro-1.5'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Test and run protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_dict&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{jprotocol}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;transcriptic&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;protocol_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.json&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
WARNING:root:Low volume for well sfgfp_puc19_gibson_v1_clone/sfgfp_puc19_gibson_v1_clone : 11.0:microliter
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
  warnings.warn(self.msg_depr % (key, alt_key))
✓ Protocol analyzed
  11 instructions
  6 containers
  Total Cost: $32.09
  Workcell Time: $6.98
  Reagents &amp;amp; Consumables: $25.11
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
10396
&lt;/pre&gt;
&lt;div style="text-align:center;background:#d050a0;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Results: Gibson assembly qPCR&lt;/div&gt;&lt;p&gt;I can use Transcriptic's data API to access the raw qPCR data as json.
This feature is not very well
&lt;a class="reference external" href="https://developers.transcriptic.com/docs/get-specific-data"&gt;documented&lt;/a&gt;,
but it can be extremely useful. It even gives you access to some
diagnostic data from the robots, which could help with debugging.&lt;/p&gt;
&lt;p&gt;First, I request data on the run:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;project_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;run_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;p16x6gna8f5e9&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;r18mj3cz3fku7&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;api_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;https://secure.transcriptic.com/hgbrian/&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;/runs/&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;/data.json&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;project_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;run_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;data_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tsc_headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data_response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Then I use that id to get &amp;quot;postprocessed&amp;quot; data from the qPCR:&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;qpcr_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'debug_sfgfp_puc19_gibson_seq_v1_qpcr'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pp_api_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;https://secure.transcriptic.com/data/&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.json?key=postprocessed_data&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qpcr_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;data_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pp_api_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tsc_headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pp_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data_response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Here are the &lt;strong&gt;Ct&lt;/strong&gt; (cycle threshold) values for each well. The Ct is
simply the point at which the fluorescence exceeds a certain value. It
tells us approximately how much DNA is currently present (and hence
approximately how much we started with).&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;# Simple util to convert wellnum to wellname&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;n_w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wellnum&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="s1"&gt;'ABCDEFGH'&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;wellnum&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;wellnum&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;wellnum&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;96&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;w_n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;n_w&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;ct_vals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n_w&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pp_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;SYBR&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cts&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;ct_df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ct_vals&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Ct&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;ct_df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ct_df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;barplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Ct&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ct_df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_96_0.png" /&gt;
&lt;p&gt;We can see that amplification happens earliest in wells D2/4/6 (which
uses DNA from my &amp;quot;v3&amp;quot; Gibson assembly), then B2/4/6 (my &amp;quot;v1&amp;quot; Gibson
assembly). The differences between v1 and v3 are mainly that the v3 DNA
was diluted 4X according to the NEB protocol, but both should work.
There is some amplification after cycle 30 in the control wells (F2, F4)
despate having no template DNA, but that's not unusual since they
include lots of primer DNA.&lt;/p&gt;
&lt;p&gt;I can also plot the qPCR amplification curve to see the dynamics of the
amplification.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_color_cycle&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'#fb6a4a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#de2d26'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#a50f15'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#74c476'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#31a354'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#006d2c'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#08519c'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'#6baed6'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;amp0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pp_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'amp0'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'SYBR'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'baseline_subtracted'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amp0&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;w_n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'B2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B6'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'D2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'D4'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'D6'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'F2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'F4'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_ylim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;qPCR (reds=Gibson v1, greens=Gibson v3, blues=control)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;legend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bbox_to_anchor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;.75&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;bbox_transform&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gcf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transFigure&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_99_0.png" /&gt;
&lt;p&gt;Overall, the qPCR results looks great, with good amplification for both
versions of my Gibson assembly, and no real amplification in the
control. Since the v3 assembly worked a bit better than v1 I will use
that from here on.&lt;/p&gt;
&lt;div style="text-align:center;background:#d050a0;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Results: Gibson assembly gel&lt;/div&gt;&lt;p&gt;The gel is also very clean, showing strong bands at just below 1kb in
lanes B2, B4, B6, D2, D4, D6, which is the size I expect (the insert is
about 740bp, and the M13 primers are about 40bp upstream and
downstream). The second band corresponds to primers. We can be pretty
sure of this since lanes F2 and F4 have only primer DNA and no template
DNA.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_103_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Gel electrophoresis: the &amp;quot;v3&amp;quot; Gibson assembly has stronger bands (D2,
D4, D6), in line with the qPCR data above.&lt;/em&gt;&lt;/p&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Step 4. Transformation&lt;/div&gt;&lt;p&gt;&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Transformation_(genetics_)"&gt;Transformation&lt;/a&gt;
is the process of altering an organism by adding DNA. So in this
experiment I am &lt;strong&gt;transforming&lt;/strong&gt; &lt;em&gt;E. coli&lt;/em&gt; with the sfGFP-expressing
plasmid pUC19.&lt;/p&gt;
&lt;p&gt;I am using an easy-to-work-with &lt;a class="reference external" href="http://www.zymoresearch.com/e-coli/chemically-competent-cells/strain-zymo5alpha"&gt;Zymo DH5α
Mix&amp;amp;Go&lt;/a&gt;
strain and the recommended &lt;a class="reference external" href="http://www.zymoresearch.com/downloads/dl/file/id/173/t3015i.pdf"&gt;Zymo
protocol&lt;/a&gt;.
This strain is part of the standard Transcriptic inventory. In general,
transformations can be tricky since competent cells are quite fragile,
so the simpler and more robust the protocol the better. In regular
molecular biology labs, these competent cells would likely be too
expensive for general use.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_107_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Zymo Mix &amp;amp; Go cells have a simple protocol&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="the-trouble-with-robots"&gt;
&lt;h2&gt;The trouble with robots&lt;/h2&gt;
&lt;p&gt;This protocol is a good example of how adapting human protocols for use
with robots can be difficult, and can fail unexpectedly. Protocols can
be surprisingly vague (&amp;quot;shake the tube from side to side&amp;quot;), relying on
the shared context of molecular biologists, or they may ask for advanced
image processing (&amp;quot;check that the pellet was resuspended&amp;quot;). Humans don't
mind these tasks, but robots need more explicit instructions.&lt;/p&gt;
&lt;p&gt;There are some interesting timing issues with this transformation. The
transformation protocol advises that the cells not stay at room
temperature for more than a few seconds, and that the plate should be
pre-warmed to 37C. In theory, you would want to start the pre-warming so
it ends at the same time as the transformation, but it's not clear how
the Transcriptic robots would handle this situation — to my knowledge,
there is no way to sync up the steps of the protocol exactly. A lack of
fine control over timing seems like it will be a common issue with
robotic protocols, due to the comparative inflexibility of the robotic
arm, scheduling conflicts, etc. We will have to adjust our protocols
accordingly.&lt;/p&gt;
&lt;p&gt;There are usually reasonable solutions: sometimes you just have to use
different reagents (e.g., hardier cells, like the Mix&amp;amp;Go cells above);
sometimes you just try overkill (e.g., shake the thing ten times instead
of three); sometimes you have to come up with tricks to make the process
work better with robots (e.g., use a PCR machine for heat-shocking).&lt;/p&gt;
&lt;p&gt;Of course, the big advantage is that once the protocol works once, you
can mostly rely on it to work again and again. You may even be able to
quantify how robust the protocol is, and improve it over time!&lt;/p&gt;
&lt;div style="text-align:center;background:#66aa33;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Test Transformation&lt;/div&gt;&lt;p&gt;Before I start transforming with my fully assembled plasmid, I run a
simple experiment to make sure that a transformation using regular pUC19
(i.e., no Gibson assembly, and no sfGFP insert DNA) works. pUC19
contains an ampicillin-resistance gene, so a successful transformation
should allow the bacteria to grow on plates that contain this
antibiotic.&lt;/p&gt;
&lt;p&gt;I transfer the bacteria straight onto plates (&amp;quot;6-flat&amp;quot; in Transcriptic's
terminology) that either have ampicillin or no ampicillin. I expect that
transformed bacteria contain an ampicillin-resistance gene, and hence
will grow. Untransformed bacteria should not grow.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Simple transformation protocol: transformation with unaltered pUC19&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;debug_sfgfp_puc19_gibson_v1&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17gmh5wafm5p&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Autoclaved MilliQ H2O; ambient&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;DH5a&amp;quot;&lt;/span&gt;        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs16pbj944fnny&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Zymo DH5α; cold_80&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17bafcbmyrmh&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; LB Broth Miller; cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;Amp 100mgml&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17msfk8ujkca&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Ampicillin 100mg/ml; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;pUC19&amp;quot;&lt;/span&gt;       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17tcqmncjfsh&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; pUC19; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Catalog&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;transform_plate&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;transform_tube&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# ------------------------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Plating transformed bacteria according to Tali's protocol (requires different code!)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# http://learn.transcriptic.com/blog/2015/9/9/provisioning-commercial-reagents&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Add 1-5ul plasmid and pre-warm culture plates to 37C before starting.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Extra inventory for plating&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;lb-broth-100ug-ml-amp_6-flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ki17sbb845ssx9&amp;quot;&lt;/span&gt; &lt;span class="c1"&gt;# (kit, not normal ref) from blogpost&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;noAB-amp_6-flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ki17reefwqq3sq&amp;quot;&lt;/span&gt; &lt;span class="c1"&gt;# kit id&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17bafcbmyrmh&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Ampicillin and no ampicillin plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;amp_6_flat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;container_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'6-flat'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'amp_6_flat'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                           &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;reserve&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'lb-broth-100ug-ml-amp_6-flat'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;store&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;where&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cold_4'&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;noAB_6_flat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;container_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'6-flat'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;noAB_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'noAB_6_flat'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                            &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;reserve&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'noAB-amp_6-flat'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;store&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;where&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cold_4'&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt; &lt;span class="n"&gt;noAB_6_flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Provision competent bacteria&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;DH5a&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;pUC19&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Heatshock the bacteria to transform using a PCR machine&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="s2"&gt;&amp;quot;4:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="s2"&gt;&amp;quot;5:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;     &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;37:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;30:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]}],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Then dilute bacteria and spread onto 6-flat plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Put more on ampicillin plates for more opportunities to get a colony&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;355&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;noAB_6_flat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Incubate and image 6-flat plates over 18 hours&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;flat_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flat&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;noAB_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;noAB_6_flat&lt;/span&gt;&lt;span class="p"&gt;)]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;timepoint&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;incubate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;warm_37&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;6:hour&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uncover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image_plate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;top&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;_t&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timepoint&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Analyze protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_dict&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{jprotocol}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;transcriptic&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#print(&amp;quot;Protocol {}\n\n{}&amp;quot;.format(experiment_name, protocol))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;protocol_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.json&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
✓ Protocol analyzed
  43 instructions
  3 containers
  $45.43
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
6582
&lt;/pre&gt;
&lt;div style="text-align:center;background:#d050a0;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Results: Test transformation&lt;/div&gt;&lt;p&gt;In the following plate photographs, we can see that with no antibiotic
(left-hand side plates), there is growth on all six plates, though the
amount of growth is quite variable, which is worrying. Transcriptic's
robots do not seem to do a great job with spreading, a task that does
require some dexterity.&lt;/p&gt;
&lt;p&gt;In the presence of antibiotic (right-hand side&amp;nbsp;plates), I also see
growth, though again it's inconsistent. The first two antibiotic plates
look odd, with lots of growth, which is likely the result of adding 55µl
to these plates compared to the 10µl I added to the no-antibiotic
plates. The third plate has some colonies and is essentially what I
expected to see for all the plates. The last three plates should have
&lt;em&gt;some&lt;/em&gt; growth but do not. My only explanation for these odd results is
that I did insufficient mixing of cells and media, so almost all the
cells were dispensed into the first two plates.&lt;/p&gt;
&lt;p&gt;(I really should have also done a positive control here with
untransformed bacteria on ampicillin plates, but I had already done this
in a previous experiment, so I know that the stocked ampicillin plates
kill this strain of &lt;em&gt;E. coli&lt;/em&gt;. Growth was much weaker in the ampicillin
plates despite dispensing a greater volume, as expected.)&lt;/p&gt;
&lt;p&gt;Overall, the transformation worked well enough to proceed, but there are
some kinks to work out.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_115_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Plates of cells transformed with pUC19 after 18 hours: no antibiotic
(left) and antibiotic (right)&lt;/em&gt;&lt;/p&gt;
&lt;div style="text-align:center;background:#66aa33;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Transformation with assembled product&lt;/div&gt;&lt;p&gt;Since the Gibson assembly and a simple pUC19 transformation seem to
work, I can now attempt a transformation with a fully-assembled
sfGFP-expressing plasmid.&lt;/p&gt;
&lt;p&gt;Apart from the assembled insert, I will also add some IPTG and X-gal to
the plates, so that I can see the successful transformation with a
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Blue_white_screen"&gt;blue–white screen&lt;/a&gt;.
This additional information is useful since if I am transforming with
regular pUC19, which does not contain sfGFP, it would still confer
antibiotic resistance.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="absorbance-and-fluorescence"&gt;
&lt;h2&gt;Absorbance and Fluorescence&lt;/h2&gt;
&lt;p&gt;sfGFP fluoresces best with 485nm excitation / 510nm emission wavelengths
(according to this
&lt;a class="reference external" href="http://www.biotek.com/assets/tech_resources/Filter%20Combinations.pdf"&gt;chart&lt;/a&gt;).
I found that 485/535 worked better at Transcriptic, I assume because 485
and 510 are too similar. I measure the growth of the bacteria at 600nm
(&lt;a class="reference external" href="https://en.wikipedia.org/wiki/OD600"&gt;OD600&lt;/a&gt;).&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_120_0.png" /&gt;
&lt;p&gt;&lt;em&gt;A menagerie of GFP&lt;/em&gt;
(&lt;a class="reference external" href="http://www.biotek.com/assets/tech_resources/Filter%20Combinations.pdf"&gt;biotek&lt;/a&gt;)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="iptg-and-x-gal"&gt;
&lt;h2&gt;IPTG and X-gal&lt;/h2&gt;
&lt;p&gt;My IPTG is at a concentration of 1M and should be used at 1:1000
dilution. My X-gal is at a concentration of 20mg/ml and should be used
at a 1:1000 dilution (20mg/µl). Hence to a 2000µl LB-broth, I add 2µl of
each.&lt;/p&gt;
&lt;p&gt;According to one
&lt;a class="reference external" href="http://www.bios.niu.edu/johns/recdna/blue_white.htm"&gt;protocol&lt;/a&gt; you
should first spread 40µl of X-gal at 20mg/ml and 40µl of IPTG at 0.1mM
(or 4µl of IPTG at 1M) and then dry it for 30 minutes. That procedure
did not work for me, so instead I mix IPTG, X-gal and competent cells,
and spread that mixture directly.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Full Gibson assembly and transformation protocol for sfGFP and pUC19
v1: Spread IPTG and X-gal onto plates, then spread cells
v2: Mix IPTG, X-gal and cells; spread the mixture
v3: exclude X-gal so I can do colony picking better
v4: repeat v3 to try other excitation/emission wavelengths&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;gibson&amp;quot;&lt;/span&gt;          &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# do a new gibson assembly&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;sanger&amp;quot;&lt;/span&gt;          &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# sanger sequence product&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;control_pUC19&amp;quot;&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c1"&gt;# unassembled pUC19&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt;            &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;     &lt;span class="c1"&gt;# excluding X-gal should make the colony picking easier&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_plates_v4&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Inventory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# catalog&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17gmh5wafm5p&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Autoclaved MilliQ H2O; ambient&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;DH5a&amp;quot;&lt;/span&gt;        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs16pbj944fnny&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Zymo DH5α; cold_80&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;Gibson Mix&amp;quot;&lt;/span&gt;  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs16pfatkggmk5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Gibson Mix (2X); cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17bafcbmyrmh&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; LB Broth Miller; cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;Amp 100mgml&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17msfk8ujkca&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Ampicillin 100mg/ml; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;pUC19&amp;quot;&lt;/span&gt;       &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17tcqmncjfsh&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; pUC19; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# my inventory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;puc19_cut_v2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct187v4ea7vvca&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; pUC19 cut with EcoRI; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;IPTG&amp;quot;&lt;/span&gt;        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct18a2r5wn6tqz&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; IPTG at 1M (conc semi-documented); cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt;        &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct18a2r5wp5hcv&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; XGal at 0.1M (conc not documented); cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;sfgfp_pcroe_v8_amplified&amp;quot;&lt;/span&gt;    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct1874zqh22pab&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; sfGFP amplified to 40ng/ul; cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v3_clone&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct188ejywa8jcv&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; assembled sfGFP; cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# kits (must be used differently)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;lb-broth-100ug-ml-amp_6-flat&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ki17sbb845ssx9&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; ampicillin plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;noAB-amp_6-flat&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ki17reefwqq3sq&amp;quot;&lt;/span&gt; &lt;span class="c1"&gt;# catalog; no antibiotic plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Catalog (all to be discarded afterward)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;trn_plate&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;transform_tube&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;39&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# experiment&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;transform_tube_L&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;trn_tubeL&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;transctrl_tube&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;56&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# control&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;trc_tubeL&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Plating according to Tali's protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# http://learn.transcriptic.com/blog/2015/9/9/provisioning-commercial-reagents&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;amp_6_flat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;container_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'6-flat'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;reserve&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'lb-broth-100ug-ml-amp_6-flat'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;store&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;where&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cold_4'&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;noAB_6_flat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;container_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'6-flat'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;noAB_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;noAB_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                   &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;reserve&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'noAB-amp_6-flat'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;store&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;where&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cold_4'&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt; &lt;span class="n"&gt;noAB_6_flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# My inventory: EcoRI-cut pUC19, oePCR'd sfGFP, Gibson-assembled pUC19, IPTG and X-Gal&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;gibson&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;puc19_ecori_v2_puc19_cut&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;puc19_cut_v2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                           &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;sfgfp_pcroe_amp_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_pcroe_v8_amplified&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_pcroe_v8_amplified&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                 &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;clone_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;clone&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;clone_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v3_clone&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_v3_clone&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                         &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;IPTG_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IPTG&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IPTG&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;XGal_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Initialize inventory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;gibson&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;all_inventory_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sfgfp_pcroe_amp_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IPTG_tube&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;66&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;sfgfp_pcroe_amp_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;36&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;sfgfp_pcroe_amp_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;all_inventory_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;IPTG_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;all_inventory_wells&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;XGal_tube&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_inventory_wells&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;init_inventory_well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Inventory: &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;properties&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Provisioning. Water is used all over the protocol. Provision an excess since it's cheap&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Cloning/assembly (see NEBuilder protocol above)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;Optimized efficiency is 50–100 ng of vectors with 2 fold excess of inserts.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# pUC19 is 20ng/ul (78ul total).&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# sfGFP is ~40ng/ul (48ul total)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Therefore 4ul of each gives 80ng and 160ng of vector and insert respectively&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;do_gibson_assembly&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Combine all the Gibson reagents in one tube and thermocycle&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Gibson Mix&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;   &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;puc19_cut_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;       &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sfgfp_pcroe_amp_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                  &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;50:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;16:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]}],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                  &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Dilute assembled plasmid 4X according to the NEB Gibson assembly protocol (20ul-&amp;gt;80ul)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_after&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# --------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Transformation&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;Transform NEB 5-alpha Competent E. coli cells with 2 μl of the&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#  assembled product, following the appropriate transformation protocol.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Mix &amp;amp; Go http://www.zymoresearch.com/downloads/dl/file/id/173/t3015i.pdf&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;[After mixing] Immediately place on ice and incubate for 2-5 minutes&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;The highest transformation efficiencies can be obtained by incubating Mix &amp;amp; Go cells with DNA on&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#  ice for 2-5 minutes (60 minutes maximum) prior to plating.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;It is recommended that culture plates be pre-warmed to &amp;gt;20°C (preferably 37°C) prior to plating.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;Avoid exposing the cells to room temperature for more than a few seconds at a time.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;If competent cells are purchased from other manufacture, dilute assembled products 4-fold&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#  with H2O prior transformation. This can be achieved by mixing 5 μl of assembled products with&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#  15 μl of H2O. Add 2 μl of the diluted assembled product to competent cells.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_do_transformation&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Combine plasmid and competent bacteria in a pcr_plate and shock&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;DH5a&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;dispense_speed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;10:microliter/second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;clone_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'control_pUC19'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;DH5a&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transctrl_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;pUC19&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transctrl_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Heatshock the bacteria to transform using a PCR machine&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="s2"&gt;&amp;quot;4:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;5:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;         &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;37:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;30:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]}],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_transfer_transformed_to_plates&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;num_ab_plates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="c1"&gt;# antibiotic places&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Transfer bacteria to a bigger tube for diluting&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Then spread onto 6-flat plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Generally you would spread 50-100ul of diluted bacteria&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Put more on ampicillin plates for more opportunities to get a colony&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# I use a dilution series since it's unclear how much to plate&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Add all IPTG and XGal to the master tube&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# 4ul (1M) IPTG on each plate; 40ul XGal on each plate&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IPTG_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;num_ab_plates&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'XGal'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;XGal_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;num_ab_plates&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Add the transformed cells and mix (use new mix op in case of different pipette)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'96-pcr'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;transform_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;495&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Spread an average of 60ul on each plate == 480ul total&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_ab_plates&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;noAB_6_flat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;51&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transform_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Controls: include 2 ordinary pUC19-transformed plates as a control&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'control_pUC19'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;num_ctrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;num_ab_plates&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;num_ctrl&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;184&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IPTG_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;num_ctrl&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;XGal_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;num_ctrl&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transctrl_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_ctrl&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_ab_plates&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;spread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;noAB_6_flat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_ab_plates&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;55&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;transctrl_tube_L&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;IPTG_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;808&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;IPTG_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;XGal&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;XGal_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;516&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;XGal_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;do_transformation&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;_do_transformation&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;_transfer_transformed_to_plates&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# ------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Measure growth in plates (photograph)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;measure_growth&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Incubate and photograph 6-flat plates over 18 hours&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# to see blue or white colonies&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;flat_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flat&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;noAB_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;noAB_6_flat&lt;/span&gt;&lt;span class="p"&gt;)]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;timepoint&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;incubate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;warm_37&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;9:hour&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uncover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image_plate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;top&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;_t&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flat_name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timepoint&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Sanger sequencing, TURNED OFF&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Sequence to make sure assembly worked&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 500ng plasmid, 1 µl of a 10 µM stock primer&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;M13_F&amp;quot;       : &amp;quot;rs17tcpqwqcaxe&amp;quot;, # catalog; M13 Forward (-41); cold_20 (1ul = 100pmol)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# &amp;quot;M13_R&amp;quot;       : &amp;quot;rs17tcph6e2qzh&amp;quot;, # catalog; M13 Reverse (-48); cold_20 (1ul = 100pmol)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;do_sanger_seq&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;seq_primers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;M13_F&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;M13_R&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;seq_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;G1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;G2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unseal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq_well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]),(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_primers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;primer_num&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;seq_well&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mix_before&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mix_vol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;water_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;7.5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sangerseq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;seq1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sangerseq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq_wells&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;seq2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Generate protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Skip Gibson since I already did it&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'gibson'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;do_gibson_assembly&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;do_transformation&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;measure_growth&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s1"&gt;'sanger'&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;do_sanger_seq&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Output protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_dict&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{jprotocol}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;transcriptic&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#print(&amp;quot;\nProtocol {}\n\n{}&amp;quot;.format(experiment_name, jprotocol))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;protocol_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.json&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Inventory: IPTG/IPTG/IPTG/IPTG/IPTG/IPTG 832.0:microliter {}
Inventory: sfgfp_puc19_gibson_v3_clone/sfgfp_puc19_gibson_v3_clone/sfgfp_puc19_gibson_v3_clone/sfgfp_puc19_gibson_v3_clone/sfgfp_puc19_gibson_v3_clone 57.0:microliter {}

  warnings.warn(self.msg_depr % (key, alt_key))
✓ Protocol analyzed
  40 instructions
  8 containers
  Total Cost: $53.20
  Workcell Time: $17.35
  Reagents &amp;amp; Consumables: $35.86
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
9379
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Colony picking&lt;/div&gt;&lt;p&gt;Once the colonies are growing on an ampicillin plate, I can &amp;quot;pick&amp;quot;
individual colonies and inoculate wells in a 96-well plate with those
colonies. There is an autoprotocol colony-picking command
(&lt;a class="reference external" href="http://autoprotocol-python.readthedocs.org/en/latest/autoprotocol.html#protocol-autopick"&gt;autopick&lt;/a&gt;)
for this purpose.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Pick colonies from plates and grow in amp media and check for fluorescence.
v2: try again with a new plate (no blue colonies)
v3: repeat with different emission and excitation wavelengths&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_pick_v3&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;plate_expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;refer to the previous plating experiment's outputs&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plate_exp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;sfgfp_puc19_gibson_plates_v4&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plate_exp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# -----------------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Inventory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# catalog&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;water&amp;quot;&lt;/span&gt;         &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17gmh5wafm5p&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Autoclaved MilliQ H2O; ambient&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;     &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17bafcbmyrmh&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; LB Broth Miller; cold_4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;Amp 100mgml&amp;quot;&lt;/span&gt;   &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17msfk8ujkca&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# catalog; Ampicillin 100mg/ml; cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="s2"&gt;&amp;quot;IPTG&amp;quot;&lt;/span&gt;          &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct18a2r5wn6tqz&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; IPTG at 1M (conc semi-documented); cold_20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# plates from previous experiment, must be changed every new experiment&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plate_expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct18snmr9avvg9&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; Ampicillin plates with blue-white screening of pUC19&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plate_expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;noAB_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ct18snmr9dxfw2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# inventory; no AB plates with blue-white screening of pUC19&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Tubes and plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;lb_amp_tubes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;lb_amp_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-2.0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;lb_xab_tube&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;lb_xab&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-2.0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ambient&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;growth&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# My inventory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;IPTG_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IPTG&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;IPTG&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-1.5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# ampicillin plate&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;amp_6_flat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Container&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;container_type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'6-flat'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;refs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;plate_expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plate_expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                                        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;plate_expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp_6_flat&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;store&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;where&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cold_4'&lt;/span&gt;&lt;span class="p"&gt;}},&lt;/span&gt; &lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Use a total of 50 wells&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;BCDEF&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;abs_wells_T&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;BCDEF&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;abs_wells_T&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;prepare_growth_wells&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# To LB, add ampicillin at ~1/1000 concentration&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Mix slowly in case of overflow&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;lb_xab_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1913&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tube&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tubes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Amp 100mgml&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;LB Miller&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;   &lt;span class="n"&gt;lb_amp_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1911&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lb_amp_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repetitions&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Add IPTG but save on X-Gal&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# http://openwetware.org/images/f/f1/Dh5a_sub.pdf&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# &amp;quot;If you are concerned about obtaining maximal levels of expression, add IPTG to a final concentration of 1 mM.&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# 2ul of IPTG in 2000ul equals 1mM&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IPTG_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;lb_xab_tube&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tubes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;one_tip&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Distribute LB among wells, row D is control (no ampicillin)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;cols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;D&amp;quot;&lt;/span&gt; &lt;span class="c1"&gt;# control, no AB&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;cwells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cwells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;issubset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lb_xab_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cwells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;190&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;allow_carryover&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;BCEF&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tube&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;zip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tubes&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;cwells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cwells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;issubset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;distribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lb_amp_tube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cwells&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;µl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;190&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;allow_carryover&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lb_amp_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;lb_xab_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;dead_volume&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'micro-2.0'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tube&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lb_amp_tubes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;measure_growth_wells&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Growth: absorbance and fluorescence over 24 hours&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Absorbance at 600nm: cell growth&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Absorbance at 615nm: X-gal, in theory&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Fluorescence at 485nm/510nm: sfGFP&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# or 450nm/508nm (http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2695656/)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;hr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;hr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;incubate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;warm_37&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;:hour&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hr&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;shaking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uncover&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fluorescence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                       &lt;span class="n"&gt;excitation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;485:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;emission&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;535:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                       &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fl2_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;flashes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fluorescence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                       &lt;span class="n"&gt;excitation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;450:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;emission&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;508:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                       &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fl1_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;flashes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fluorescence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                       &lt;span class="n"&gt;excitation&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;395:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;emission&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;508:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                       &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fl0_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;flashes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;absorbance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;indices&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                     &lt;span class="n"&gt;wavelength&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;600:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                     &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;abs_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;flashes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Protocol steps&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;prepare_growth_wells&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;batch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;autopick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;growth_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_wells_T&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;autopick_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;image_plate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amp_6_flat&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;top&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;autopicked_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;measure_growth_wells&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# ---------------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Output protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_dict&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{jprotocol}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;transcriptic&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;protocol_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.json&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
  warnings.warn(self.msg_depr % (key, alt_key))
✓ Protocol analyzed
  62 instructions
  8 containers
  Total Cost: $66.38
  Workcell Time: $57.59
  Reagents &amp;amp; Consumables: $8.78
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
44488
&lt;/pre&gt;
&lt;div style="text-align:center;background:#d050a0;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Results: Colony picking&lt;/div&gt;&lt;p&gt;The blue–white screening worked beautifully, with mostly white colonies
on the antibiotic plates (1-4) and blue only on the non-antibiotic plate
(5-6). This is exactly what I expect, and I was relieved to see it,
especially since I was using my own IPTG and X-gal that I shipped to
Transcriptic.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_129_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Blue–white screening plates with ampicillin (1-4) and no antibiotic
(5-6)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;However, the colony-picking robot did not work well with these blue and
white colonies. The image below was generated by subtracting successive
plate photographs after each round of plate picking and increasing the
contrast of the differences (using
&lt;a class="reference external" href="http://www.graphicsmagick.org/"&gt;GraphicsMagick&lt;/a&gt;). This way, I can
visualize which colonies were picked (albeit imperfectly since picked
colonies are not completely removed).&lt;/p&gt;
&lt;p&gt;I also annotate the image with the number of colonies reported picked by
Transcriptic. The robot is supposed to pick a maximum of 10 colonies
from the first five plates. However, few colonies were picked overall,
and when they were picked they look to be often blue. The robot only
managed to find ten colonies on a control plate with only blue colonies.
My working theory is that the colony-picking robot preferentially
selected blue colonies since those have the highest contrast.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_132_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Blue–white screening plates with ampicillin (1-4) and no antibiotic
(5-6), annotated with number of colonies picked&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Blue–white screening did serve a purpose in that it showed me that most
of colonies were being correctly transformed, or at least that an
insertion was happening. However, to get better colony picking, I repeat
the experiment without X-gal.&lt;/p&gt;
&lt;p&gt;Given only white colonies to pick, the colony-picking robot successfully
picked 10 colonies from each of the first five plates. I have to assume
most of the picked colonies have successful insertions.&lt;/p&gt;
&lt;img alt="cloning" src="static/Cloning_files/Cloning_135_0.jpe" /&gt;
&lt;p&gt;&lt;em&gt;Colonies growing on ampicillin plates (1-4) and no antibiotic plates
(5-6)&lt;/em&gt;&lt;/p&gt;
&lt;div style="text-align:center;background:#d050a0;padding:40px 10px 40px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Results: Transformation with assembled product&lt;/div&gt;&lt;p&gt;After growing 50 picked colonies in a 96-well plate for 20 hours, I
measure fluorescence to see if sfGFP is being expressed. Transcriptic
uses a &lt;a class="reference external" href="http://lifesciences.tecan.com/products/reader_and_washer/microplate_readers/infinite_200_pro"&gt;Tecan
Infinite&lt;/a&gt;
plate-reader to measure fluorescence and absorbance (and luminescence if
you want that).&lt;/p&gt;
&lt;p&gt;In theory, any well that has growth has an assembled plasmid, since it
needs antibiotic resistance to grow, and every assembled plasmid is
expressing sfGFP. In reality, there are many reasons why that might not
happen, not least of which is that you can lose the sfGFP gene from the
plasmid without losing ampicillin resistance. A bacterium that loses the
sfGFP gene has a selection advantage over its competitors because it is
not wasting energy on that, so given enough generations of growth this
is certain to happen.&lt;/p&gt;
&lt;p&gt;I collect absorbance (OD600) and fluorescence data every four hours for
20 hours (~60 generations).&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;abs_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;glow/sfgfp_puc19_gibson_pick_v3_abs_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.csv&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;index_col&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;flr_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;glow/sfgfp_puc19_gibson_pick_v3_fl2_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;.csv&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;index_col&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;new_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;abs_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flr_data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;new_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rsuffix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;new_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flr_data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rsuffix&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;new_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;OD 600:nanometer_0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Fluorescence_0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;I plot the data at hour 20, and a contrail of previous timepoints. I
only really care about the data at hour 20 since that's approximately
when fluorescence should peak.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;svg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;H&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50000&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_toxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;W&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_x&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_y&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_topt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;_toxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;ab_fls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;new_data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iterrows&lt;/span&gt;&lt;span class="p"&gt;()]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# axes&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;g fill=&amp;quot;#888&amp;quot; font-size=&amp;quot;18&amp;quot; transform=&amp;quot;translate(20,0),scale(.95)&amp;quot;&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;text x=&amp;quot;0&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot;&amp;gt;OD600 →&amp;lt;/text&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;text x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; transform=&amp;quot;rotate(-90),translate(-&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;,-8)&amp;quot;&amp;gt;Fluorescence →&amp;lt;/text&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;line x1=&amp;quot;0&amp;quot; y1=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; x2=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y2=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; style=&amp;quot;stroke:#888;stroke-width:2&amp;quot; /&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;line x1=&amp;quot;0&amp;quot; y1=&amp;quot;0&amp;quot; x2=&amp;quot;0&amp;quot; y2=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; style=&amp;quot;stroke:#888;stroke-width:2&amp;quot; /&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# glow filter&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;lt;filter id=&amp;quot;glow&amp;quot; x=&amp;quot;-200%&amp;quot; y=&amp;quot;-200%&amp;quot; height=&amp;quot;400%&amp;quot; width=&amp;quot;400%&amp;quot;&amp;gt;
&amp;lt;feColorMatrix type=&amp;quot;matrix&amp;quot; values=&amp;quot;0 0 0 0   0 255 0 0 0   0 0 0 0 0   0 0 0 0 1 0&amp;quot;/&amp;gt;
&amp;lt;feGaussianBlur stdDeviation=&amp;quot;10&amp;quot; result=&amp;quot;coloredBlur&amp;quot;/&amp;gt;
&amp;lt;feMerge&amp;gt;&amp;lt;feMergeNode in=&amp;quot;coloredBlur&amp;quot;/&amp;gt;&amp;lt;feMergeNode in=&amp;quot;SourceGraphic&amp;quot;/&amp;gt;&amp;lt;/feMerge&amp;gt;
&amp;lt;/filter&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ab_fls&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;fill&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#444&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;D&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#aaa&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;gfilter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'filter=&amp;quot;url(#glow)&amp;quot;'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;D1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;D3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_toxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'''&amp;lt;g id=&amp;quot;point&lt;/span&gt;&lt;span class="si"&gt;{n:d}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot;&amp;gt;&amp;lt;circle &lt;/span&gt;&lt;span class="si"&gt;{gfilter:s}&lt;/span&gt;&lt;span class="s1"&gt; r=&amp;quot;12&amp;quot; cx=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cx:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; cy=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cy:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; fill=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{fill:s}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; /&amp;gt;
                  &amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cx:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cy:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; font-size=&amp;quot;10&amp;quot; text-anchor=&amp;quot;middle&amp;quot; fill=&amp;quot;#fff&amp;quot;
                   alignment-baseline=&amp;quot;middle&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{txt:s}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/text&amp;gt;&amp;lt;/g&amp;gt;
               '''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gfilter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;gfilter&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;pathd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'M&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt; '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_topt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;pathd&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;L&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_topt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'''&amp;lt;path d=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{pathd:}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; stroke=&amp;quot;#ccc&amp;quot; stroke-width=&amp;quot;.2&amp;quot;
                   fill=&amp;quot;none&amp;quot; id=&amp;quot;path&lt;/span&gt;&lt;span class="si"&gt;{n:d}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot;/&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pathd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;pathd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/g&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# entire chart group&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;object data="static/Cloning_files/Cloning_142_0.svg" type="image/svg+xml"&gt;cloning&lt;/object&gt;
&lt;p&gt;&lt;em&gt;Fluorescence vs OD600: wells with ampicillin are black, control wells
with no ampicillin are grey. A green glow is applied to wells with
plasmids where I have validated the sfGFP protein sequence is correct.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I run a
&lt;a class="reference external" href="https://developers.transcriptic.com/docs/plasmid-mini-prep"&gt;miniprep&lt;/a&gt;
to extract the plasmid DNA, then Sanger sequence using M13 primers.
Unfortunately, for some reason, minipreps are currently only available
via Transcriptic's web-based protocol launcher and not through
autoprotocol. I sequence the three wells with the highest fluorescence
readings (C1, D1, D3), and three others (B1, B3, E1) and align the
(forward and reverse) sequences against sfGFP with
&lt;a class="reference external" href="http://www.drive5.com/muscle/"&gt;muscle&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In wells C1, D3, and D3 there is a perfect match to my original sfGFP
sequence, while in wells B1, B3, and E1, there are gross mutations or
the alignment just fails.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="three-glowing-colonies"&gt;
&lt;h2&gt;Three glowing colonies&lt;/h2&gt;
&lt;p&gt;The results are good, though some aspects are surprising. For example,
the fluorescence reader starts out at a very high reading at timepoint 0
(40,000 units), for no apparent reason. By hour 20, it has settled down
to a more reasonable pattern, with a clear basal correlation between
OD600 and fluorescence (I assume because of a minor overlap in spectra),
plus some outliers with high fluorescence. Eyeballing, it looks like it
could be one, three or perhaps 11-15 outliers.&lt;/p&gt;
&lt;p&gt;Some of the wells showing high fluorescence readings are in control
wells (i.e., no ampicillin, colored grey), which is surprising since in
these wells there is no selection pressure so I expect the plasmid to be
lost.&lt;/p&gt;
&lt;p&gt;Based on the fluorescence data and sequencing results, it appears that
only three out of 50 colonies produce sfGFP and fluoresce. That's not
nearly as many as I expected. However, because there were three separate
growth stages (on the plate, in the growth well, for miniprep), the
cells have undergone about 200 generations of growth by this stage, so
there were quite a lot of opportunities for mutations to occur.&lt;/p&gt;
&lt;p&gt;There must be ways to make this process more efficient, especially since
I am far from an expert on these protocols. Nevertheless, we have
successfully produced transformed cells expressing an engineered GFP
using only Python code!&lt;/p&gt;
&lt;div style="text-align:center;background:#dddd44;padding:120px 10px 120px 10px;color:#ffffff;font-size:2.55em;line-height:1.2em;"&gt;Part Three: Conclusions&lt;/div&gt;&lt;/div&gt;
&lt;div class="section" id="cost"&gt;
&lt;h2&gt;Cost&lt;/h2&gt;
&lt;p&gt;Depending on how you measure it, the cost of this experiment was around
$360, not including the money I spent on debugging:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;$70&lt;/strong&gt; to synthesize the DNA&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$32&lt;/strong&gt; to PCR and add flanks to the insert&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$31&lt;/strong&gt; to cut the plasmid&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$32&lt;/strong&gt; for Gibson assembly&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$53&lt;/strong&gt; for transformation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$67&lt;/strong&gt; for colony picking&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;$75&lt;/strong&gt; for 3 minipreps and sequencing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I think the cost could probably be brought down to $250-300 with some
tweaks. For example, getting a robot to pick 50 colonies is susprisingly
expensive, and probably overkill.&lt;/p&gt;
&lt;p&gt;In my experience, this price seems expensive to some (molecular
biologists) and cheap to others (computational people). Since
Transcriptic basically just charges for reagents at list price, the main
cost difference is in labor. A robot is already pretty cheap per hour,
and doesn't mind getting up in the middle of the night to take a
photograph of a plate. Once the protocols are nailed down, it's hard to
imagine that even a grad student will be cheaper, especially if you
factor in opportunity costs.&lt;/p&gt;
&lt;p&gt;To be clear, I am only talking about replacing routine protocols —
cutting-edge protocol development will still be done by skilled
molecular biologists — but a lot of exciting science uses only boring
protocols. Until recently, many labs manufactured their own oligos, but
now few would bother — it's just not worth anyone's time, even grad
students, when IDT will ship them to you within a couple of days.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="robot-labs-pros-and-cons"&gt;
&lt;h2&gt;Robot labs: pros and cons&lt;/h2&gt;
&lt;p&gt;Obviously, I'm a big believer in robotic labs. There are some really fun
and useful things about doing experiments with robots, especially if
you're primarily a computational scientist and are allergic to latex
gloves and manual labor:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Reproducibility!&lt;/strong&gt; This is probably the biggest advantage. It
includes the consistency of robots and the ability to publish your
protocol in autoprotocol format, instead of awkward English prose
(and the passive voice is not even minded by me...)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Scalability&lt;/strong&gt; You can repeat my experiment 100 times with different
parameters, without too much marginal work.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Arbitrarily complicated protocols&lt;/strong&gt;, for example PCR touchdown.
This might seem minor or even counterproductive, but if a protocol is
going to be run hundreds or thousands of times by different labs, why
not optimize the protocol to a fraction of a degree? Or even use
statistics / machine learning to improve the protocol over time? It
drives me crazy to see a protocol that might be used tens of
thousands of times recommend performing an operation for 2-3 minutes.
Which is it?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fine-tuning&lt;/strong&gt; You can repeat experiments after changing just one
minor detail. It's really hard to &lt;em&gt;ceteris paribus&lt;/em&gt; as a human.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Virtuality&lt;/strong&gt; Run experiments or monitor results while away from the
lab, like &lt;a class="reference external" href="http://www.benmil.es/2015/06/02/biochem-from-vienna/"&gt;in
Vienna&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Expressiveness&lt;/strong&gt; You can use programming syntax to encode
repetitive steps or branching logic. For example, if you wanted to
dispense 1 to 96μl of reagent and (96-x)μl of water into a 96 well
plate this can be concisely written.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Machine-readable data&lt;/strong&gt; Results data is almost always returned as
csv, or something else you can compute on.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Abstraction&lt;/strong&gt; Ideally, you could run the entire protocol above
while remaining agnostic to the reagents or style of cloning used,
and drop in a replacement protocol if it worked better.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are some catches too of course, especially since it's &lt;em&gt;very&lt;/em&gt; early
in the evolution of these tools. If it were the internet it would be
around 1994:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Transporting samples back and forth to Transcriptic is a chore. I'm
not sure how to solve this, though the more you can do at the cloud
lab the less you need to transport. That is partially why synthetic
biology is a good fit for cloud labs over, say, diagnostics with
human samples.&lt;/li&gt;
&lt;li&gt;Debugging protocols remotely is difficult and can be expensive —
especially differentiating between your bugs and Transcriptic's bugs.&lt;/li&gt;
&lt;li&gt;There are lots of experiments you just can't do yet. At the time of
writing, Transcriptic only supports bacterial experiments (no yeast,
no mammalian cells, though these are coming).&lt;/li&gt;
&lt;li&gt;For many labs it may be more expensive to use a cloud lab than just
getting a grad student (marginal cost per hour: ~$0) to do the work.
This depends on how much the lab needs the grad student's hands
compared to their brain.&lt;/li&gt;
&lt;li&gt;Transcriptic doesn't run experiments on the weekend yet.
Understandable, but it can be inconvenient, even when your project is
not so time-sensitive.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="software-is-eating-protein"&gt;
&lt;h2&gt;Software is eating protein&lt;/h2&gt;
&lt;p&gt;Even though there's quite a lot of code here and quite a lot of
debugging, I think it's feasible to produce some software that takes as
input a protein sequence and as output creates bacteria that express
that protein.&lt;/p&gt;
&lt;p&gt;To make that work, a few things need to happen:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;True integration of Twist/IDT/Gen9 with Transcriptic (this will
probably be slow because of low demand currently).&lt;/li&gt;
&lt;li&gt;Very robust versions of the protocols I have outlined above, to
account for differences in protein sequence composition, length,
secondary structure, etc.&lt;/li&gt;
&lt;li&gt;Replacing various custom tools (NEB's Gibson protocol generator,
IDT's codon optimizer) with open-source equivalents (e.g.,
&lt;a class="reference external" href="http://bioinfo.ut.ee/primer3/"&gt;primer3&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For many applications, you also want to purify your protein (using a
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Polyhistidine-tag"&gt;tag and a column&lt;/a&gt;),
or perhaps just get the bacteria to
&lt;a class="reference external" href="http://2014.igem.org/Team:Michigan"&gt;secrete&lt;/a&gt; it. Let's assume that
we can soon do this in a cloud lab too, or that we can do experiments
&lt;em&gt;in vivo&lt;/em&gt; (i.e., within the bacterial cell).&lt;/p&gt;
&lt;p&gt;There are also lots of opportunities to make the protocol actually work
better than a human-run version, for example: design of promoters and
RBSs to optimize expression specific to your sequence; statistics on the
probability of success of the experiment based on comparable
experiments; automated analysis of gels.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="why-bother-with-all-this"&gt;
&lt;h2&gt;Why bother with all this?&lt;/h2&gt;
&lt;p&gt;After all that, it might not be totally clear why you would want to
engineer a protein like this. Here are some ideas:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Make a protein &lt;a class="reference external" href="https://nimasensor.com/"&gt;sensor&lt;/a&gt; to detect
something dangerous/unhealthy/delicious like gluten.&lt;/li&gt;
&lt;li&gt;Make a
&lt;a class="reference external" href="http://www.the-scientist.com/?articles.view/articleNo/26908/title/Synthetic-vaccine-nabs-iGEM-prize/"&gt;vaccine&lt;/a&gt;
by identifying the peptides unique to a pathogen and &lt;a class="reference external" href="http://prosperosworld.com/problem-solving-technique/2012/"&gt;thinking really
hard&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Evaluate protein binding &lt;em&gt;in vivo&lt;/em&gt; by using a &lt;a class="reference external" href="http://www.nature.com/articles/srep02854"&gt;split
GFP&lt;/a&gt; or &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Two-hybrid_screening"&gt;similar
approaches&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Make some &lt;a class="reference external" href="http://2014.igem.org/Team:Michigan"&gt;scFvs&lt;/a&gt; as a sensor
for salmonella. scFvs are like mini-antibodies that &lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pubmed/22230329"&gt;usually fold in
bacteria&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Make a
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Bi-specific_T-cell_engager"&gt;BiTE&lt;/a&gt;
to treat a specific cancer you just sequenced. (This could be
trickier than it sounds).&lt;/li&gt;
&lt;li&gt;Make a topical vaccine that can enter the body &lt;a class="reference external" href="http://blog.booleanbiotech.com/naked%20DNA.html"&gt;via hair
follicles&lt;/a&gt; (I
don't recommend trying this at home).&lt;/li&gt;
&lt;li&gt;Mutagenize your protein 100 different ways and &lt;a class="reference external" href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0147596"&gt;characterize the
changes&lt;/a&gt;.
Then scale it up to 1,000, or 10,000? Maybe characterize the
mutations of GFP?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more ideas on what is possible you only have to look at the hundreds
of &lt;a class="reference external" href="http://blog.booleanbiotech.com/static/igem.html"&gt;iGEM projects&lt;/a&gt;
that are already out there.&lt;/p&gt;
&lt;p&gt;Finally, thanks to &lt;a class="reference external" href="https://twitter.com/BenNMiles"&gt;Ben Miles&lt;/a&gt; at Transcriptic for helping me finish this project.&lt;/p&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="virtual biotech"/><category term="cloud labs"/><category term="data"/><category term="transcriptic"/><category term="robots"/></entry><entry><title>Transcriptic pUC19 PCR Amplification</title><link href="/puc19_pcr_amplification.html" rel="alternate"/><published>2015-08-10T11:00:00-07:00</published><updated>2015-08-10T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-08-10:/puc19_pcr_amplification.html</id><summary type="html">&lt;p class="first last"&gt;Amplifying pUC19 on Transcriptic&lt;/p&gt;
</summary><content type="html">&lt;p&gt;In this experiment I use standard M13 primers to amplify part of the
plasmid, pUC19. In theory, these primers will amplify a ~110bp fragment.&lt;/p&gt;
&lt;p&gt;I evaluate the experiment using a standard qPCR curve (with SYBR), and
then running a gel to check the size of the amplified fragment(s).&lt;/p&gt;
&lt;p&gt;One nice aspect of this experiment is that all of the reagents used are
available in Transcriptic's standard catalog, which means the experiment
can be performed remotely, without shipping anything to Transcriptic. It
could be a nice test-case for a new Taq mastermix, or a new PCR
protocol.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;# (Python 3 setup cell omitted)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# https://developers.transcriptic.com/docs/how-to-write-a-new-protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# https://secure.transcriptic.com/_commercial/resources?q=water&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;autoprotocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;autoprotocol.protocol&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Protocol&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# 3 cols: 0=template+primers+mastermix, 1=primers+mastermix, 2=water&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 3 rows: A, B, C repeated&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;puc19_m13_v1&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'SensiFAST SYBR No-ROX'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17knkh7526ha&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'water'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17gmh5wafm5p&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'M13 Forward (-20)'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17tcpupe7fdh&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'M13 Reverse (-48)'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17tcph6e2qzh&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'pUC19'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;rs17tcqmncjfsh&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Provisioning things for my PCR&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Provision a 96 well PCR plate (https://developers.transcriptic.com/v1.0/docs/containers)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Type      Max       Dead    Safe    Capabilities                                                     Price&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 96-pcr    160 µL    3 µL    5 µL    pipette, sangerseq, spin, thermocycle, incubate, gel_separate    $2.49&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;pcr_plate&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;96-pcr&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# SYBR-including mastermix&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# http://www.bioline.com/us/downloads/dl/file/id/2754/sensifast_sybr_no_rox_kit_manual.pdf&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Instructions: 10ul mastermix + 0.8ul primer (400nM) + 0.8ul primer (400nM) + &amp;lt;=8.4ul template (~100ng) + 20-vol H20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#mastermix_tube = p.ref(&amp;quot;mastermix_tube&amp;quot;, cont_type=&amp;quot;micro-2.0&amp;quot;, storage=&amp;quot;cold_20&amp;quot;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'SensiFAST SYBR No-ROX'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;10:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# M13 primers&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# I choose m13 (-20) and (-48) because of similar Tm. This amplifies ~110bp including primers.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 100pmol == 1ul, since Transcriptic dilutes the 1300-1900pmol into 13-19ul (depending on the primer)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# I want 400nM in the final 20ul according to the SensiFAST documentation (==8pmol in 20ul)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 1ul primer in 12ul total equals 8pmol/ul&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# http://www.idtdna.com/pages/products/dna-rna/readymade-products/readymade-primers&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Name                 sequence                          Tm    Anhyd.  pmoles in 10ug&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# M13 Forward (-20)    GTA AAA CGA CGG CCA GT            53.0  5228.5  1912.6&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# M13 Forward (-41)    CGC CAG GGT TTT CCC AGT CAC GAC   65.5  7289.8  1371.7&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# M13 Reverse (-27)    CAG GAA ACA GCT ATG AC            47.3  5212.5  1918.3&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# M13 Reverse (-48)    AGC GGA TAA CAA TTT CAC ACA GG    57.2  7065.7  1415.2&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;primer_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;primer_tube&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-2.0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'M13 Forward (-20)'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;1:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# fwd -20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'M13 Reverse (-48)'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;1:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# rev -48&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'water'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;10:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# water&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# pUC19&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 1000ug/ml -&amp;gt; 1ul = 1ug == 1000ng. Add 1ul to 49ul to get ~20ng/ul&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Then I can transfer 5ul to get 100ng total&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;template_tube&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;template_tube&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cont_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;micro-2.0&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;storage&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;cold_20&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'pUC19'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;template_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;1:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'water'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;template_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;49:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# water&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Move all the reagents into the pcr plate&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# The &amp;quot;dispense&amp;quot; command does not work because it needs &amp;gt;=10ul per dispense&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# in increments of 5ul&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ul&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;provision&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'water'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;:microliter&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ul&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;5:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transfer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;primer_tube&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;1:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Thermocycle, with a hot start (95C for 2m)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Based on http://www.bioline.com/us/downloads/dl/file/id/2754/sensifast_sybr_no_rox_kit_manual.pdf&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# I also found http://www.environmental-microbiology.de/pdf_files/M13PCR_13jan2014.pdf&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# p.seal before thermocycling is enforced by transcriptic&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;thermocycle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;      &lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;95:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;2:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;      &lt;span class="s2"&gt;&amp;quot;cycles&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;steps&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;95:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;5:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;60:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;20:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;temperature&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;72:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;          &lt;span class="s2"&gt;&amp;quot;duration&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;15:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;read&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;}],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;volume&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;20:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;# volume is optional&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;dataref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;qpcr_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Dyes to use for qPCR must be specified (tells transcriptic what aborbance to use?)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;dyes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;SYBR&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# standard melting curve parameters&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;melting_start&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;65:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;melting_end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;95:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;melting_increment&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;0.5:celsius&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;melting_rate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;5:second&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Run a gel&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# agarose(8,0.8%): 8 lanes, 0.8% agarose 10 minutes recommended&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# 10 microliters is used in the example documentation&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# ladder1: References at 100bp, 250bp, 500bp, 1000bp, and 2000bp.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# The gel already includes SYBR green&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gel_separate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pcr_plate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;A1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;C2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;A3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;B3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="s2"&gt;&amp;quot;10:microliter&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;agarose(8,0.8%)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="s2"&gt;&amp;quot;ladder1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;10:minute&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;gel_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;experiment_name&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="c1"&gt;#--------------------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Analyze and output the protocol&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;as_dict&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;protocol.json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'w'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jprotocol&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Analyze protocol&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;!&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{jprotocol}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;transcriptic&lt;/span&gt; &lt;span class="n"&gt;analyze&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Analyze protocol
----------------
✓ Protocol analyzed
  11 instructions
  3 containers
  $25.94
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;new_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Results&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px;color:#ffffff;font-size:3em;"&gt;Results&lt;/div&gt;&lt;p&gt;After waiting several days in the Transcriptic queue for the experiment
to start, the actual run took just a couple of hours.&lt;/p&gt;
&lt;p&gt;We use 9 wells in total:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Wells [ABC]1, &amp;quot;template&amp;quot;: containing template, primers and mastermix&lt;/li&gt;
&lt;li&gt;Wells [ABC]2, &amp;quot;no template control&amp;quot;: containing primers and mastermix&lt;/li&gt;
&lt;li&gt;Wells [ABC]3, &amp;quot;water&amp;quot;: containing only water&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="column-1-template"&gt;
&lt;h2&gt;Column 1: Template&lt;/h2&gt;
&lt;p&gt;The template appears to be amplified correctly. There is an issue with
the background subtraction in well C1, which has been normalized to
start at about -2000 RFU. Re-graphing the raw data without background
subtracted shows that this is probably a technical artifact.
Unfortunately, because of this issue I do not get a Ct for well C1. The
Cts are reasonably close at 4 and 9, though a &lt;tt class="docutils literal"&gt;&amp;lt;&lt;/tt&gt;0.5 Ct difference
between technical replicates is &lt;a class="reference external" href="http://blog.biosearchtech.com/TheBiosearchTechBlog/bid/63622/qPCR-Troubleshootin"&gt;apparently
desirable&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="column-2-no-template-control"&gt;
&lt;h2&gt;Column 2: No template control&lt;/h2&gt;
&lt;p&gt;We can see from the melting curve and amplification plots below that
there is some signal in the non-template wells, indicating the presence
of some double-stranded DNA. Ideally, since there is no template in
these wells, we expect only single-stranded primer DNA, and no signal.&lt;/p&gt;
&lt;p&gt;I checked the M13 primers for possible primer–dimer problems using IDT's
&lt;a class="reference external" href="https://www.idtdna.com/calc/analyzer"&gt;OligoAnalyzer&lt;/a&gt;. If the problem
were primer–dimers, we would expect the melting curve to peak at a lower
temperature than the template (generally &lt;tt class="docutils literal"&gt;&amp;lt;&lt;/tt&gt;80C), and be at least &lt;a class="reference external" href="http://www.eurogentec.com/uploads/qpcr-guide.pdf"&gt;8
Ct higher than the
template&lt;/a&gt;. We also
generally expect a deltaG below -9 kcal/mole. The lowest deltaG for
these primers was far higher at -4, as you'd expect for commonly used
primers.&lt;/p&gt;
&lt;p&gt;The Ct for this amplification event is very high at 33-35, which
indicates how much effort it was to amplify, and also that I could have
avoided this problem by reducing the number of cycles to 30.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="column-3-water"&gt;
&lt;h2&gt;Column 3: Water&lt;/h2&gt;
&lt;p&gt;All of the water-only wells were blank, as expected. Although this is
more of a sanity check than anything, one possible problem that could
have been revealed is cross-contamination (e.g., due to reused pipette
tips.)&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;Transcriptic plots from qPCR&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h3&amp;gt;No template control (A2, B2, C2) highlighted in blue&amp;lt;/h3&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;Images&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;puc19_melt.png&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;puc19_amp0.png&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Melting curve&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Amplification&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;h1&gt;Transcriptic plots from qPCR&lt;/h1&gt;&lt;h3&gt;No template control (A2, B2, C2) highlighted in blue&lt;/h3&gt;&lt;table style='width:100%'&gt;&lt;tr&gt;&lt;th&gt;Melting curve&lt;/th&gt;&lt;th&gt;Amplification&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;img src='static/pUC19_PCR_files/puc19_melt.png' /&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src='static/pUC19_PCR_files/puc19_amp0.png' /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;div class="section" id="qpcr-transcriptic-data-api"&gt;
&lt;h2&gt;qPCR (Transcriptic Data API)&lt;/h2&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;auth.json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X_User_Email&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X_User_Token&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;api_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;https://secure.transcriptic.com/hgbrian/p16x6gna8f5e9/runs/r17zze6ac3b92/data.json&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;data_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;api_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data_response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;n_w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wellnum&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="s1"&gt;'ABCDEFGH'&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;wellnum&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;wellnum&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;wellnum&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;96&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;w_n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;n_w&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;Ct&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'qpcr_puc19_m13_v1'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'data'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'postprocessed_data'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'amp0'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'SYBR'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'cts'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;table_print&lt;/span&gt;&lt;span class="p"&gt;([[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Ct&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;n_w&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:.3f}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Ct&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])],&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;table&gt;&lt;tr style='font-weight:bold;'&gt;&lt;td&gt;Well&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;td&gt;Ct&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;A1&lt;/td&gt;&lt;td&gt;4.793&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;B1&lt;/td&gt;&lt;td&gt;9.171&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;A2&lt;/td&gt;&lt;td&gt;33.698&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;B2&lt;/td&gt;&lt;td&gt;34.862&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;C2&lt;/td&gt;&lt;td&gt;35.052&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;amp0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'qpcr_puc19_m13_v1'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'data'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'postprocessed_data'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'amp0'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'SYBR'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'baseline_subtracted'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amp0&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;w_n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'A1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'C1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'A2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'C2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'A3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'C3'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Baseline subtracted&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;legend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bbox_to_anchor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;bbox_transform&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gcf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transFigure&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;amp0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'qpcr_puc19_m13_v1'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'data'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'postprocessed_data'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'amp0'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'SYBR'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'no_baseline_subtracted'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;amp0&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;w_n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;]],&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'A1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'C1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'A2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'C2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'A3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'B3'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'C3'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;No Baseline subtracted&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;legend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bbox_to_anchor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;bbox_transform&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;gcf&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transFigure&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;img alt="PCR" src="static/pUC19_PCR_files/pUC19%20PCR_10_0.png" /&gt;
&lt;img alt="PCR" src="static/pUC19_PCR_files/pUC19%20PCR_10_1.png" /&gt;
&lt;/div&gt;
&lt;div class="section" id="gel-transcriptic-data-api"&gt;
&lt;h2&gt;Gel (Transcriptic Data API)&lt;/h2&gt;
&lt;p&gt;After the PCR finishes, we run a gel to see if the amplified product is
the right size (approximately 100bp.)&lt;/p&gt;
&lt;p&gt;I am guessing the gel was done manually, since there was a significant
delay between the qPCR ending and the gel starting. The image also looks
manually taken and is an unusual resolution. Unfortunately, it was not
really possible to tell from the gel if my amplification was clean. The
smallest&amp;nbsp;gel ladder available on Transcriptic is 100bp-2kb, so my 100bp
fragment is difficult to separate out. I can only discriminate four of
the five rungs in the ladder.&lt;/p&gt;
&lt;p&gt;The template itself can be seen at the top of the ladder in wells A1,
B1, C1 (pUC19 is about 2.6kb), and the area around 100bp-250bp is darker
in the wells that contain the template, so the results are reasonable.&lt;/p&gt;
&lt;p&gt;I used SVG to rotate the image a bit, and draw horizontal lines
corresponding to the rungs of the ladder.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;gel_img_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'gel_puc19_m13_v1'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'attachments'&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="s1"&gt;'key'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;auth.json&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X_User_Email&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;X_User_Token&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;gel_img_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;https://secure.transcriptic.com/upload/url_for?key=&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gel_img_path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gel_img_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gel_puc19_m13_v1.jpg&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'wb'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gel_puc19_m13_v1.jpg&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;100%&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;img alt="PCR" src="static/pUC19_PCR_files/pUC19%20PCR_12_0.jpg" /&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;887&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;278&lt;/span&gt; &lt;span class="c1"&gt;# the dimensions of the image&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;box&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;box&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;rect x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; fill=&amp;quot;rgba(&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:f}&lt;/span&gt;&lt;span class="s1"&gt;)&amp;quot; stroke=&amp;quot;none&amp;quot; /&amp;gt;
        '''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;left&amp;quot; font-size=&amp;quot;12&amp;quot; fill=&amp;quot;rgba(&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:f}&lt;/span&gt;&lt;span class="s1"&gt;)&amp;quot;&amp;gt;
              &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/text&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;box&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'''&amp;lt;image xlink:href=&amp;quot;static/pUC19_PCR_files/gel_puc19_m13_v1.jpg&amp;quot; x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot;
        transform=&amp;quot;rotate(-.8)&amp;quot;/&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;108&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;start&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;156&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;2kb&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;193&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;1kb&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;220&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;500bp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;250&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;250bp / 100bp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;object data="static/pUC19_PCR_files/pUC19%20PCR_13_0.svg" type="image/svg+xml"&gt;PCR&lt;/object&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;new_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Conclusions&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px;color:#ffffff;font-size:3em;"&gt;Conclusions&lt;/div&gt;&lt;p&gt;I was pretty happy with the results of this experiment.&lt;/p&gt;
&lt;p&gt;Although I could not totally explain the signal in the &amp;quot;no template
control&amp;quot; wells, nor competely confirm that the expected 100bp fragment
was amplified from the gel image, the data was very consistent across
all wells, and I believe the amplification worked fine.&lt;/p&gt;
&lt;p&gt;This experiment cost less than $26, which is pretty good.
If I could just eliminate the three day wait for the experiment to start,
then this really would be cloud lab computing —
the time to do the experiment is not even so different to running a typical MCMC chain!&lt;/p&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="virtual biotech"/><category term="cloud labs"/><category term="data"/><category term="transcriptic"/><category term="robots"/></entry><entry><title>IPython Notebook Tips</title><link href="/ipython_notebook_tips.html" rel="alternate"/><published>2015-07-16T11:00:00-07:00</published><updated>2015-07-16T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-07-16:/ipython_notebook_tips.html</id><summary type="html">&lt;p class="first last"&gt;Some useful IPython notebook tips.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;IPython notebook is awesome, but it's still pretty immature in many
ways. These are a few functions that I've found help make
it a more pleasant experience.&lt;/p&gt;
&lt;div class="section" id="use-retina-displays"&gt;
&lt;h2&gt;Use retina displays&lt;/h2&gt;
&lt;p&gt;It's great to be able to make use of a retina display, if you have one.
The difference in figure quality is very noticable. To use retina, just
set this flag at the top of your notebook (you probably want inline
plots too).&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'retina'&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="more-prominent-section-breaks"&gt;
&lt;h2&gt;More prominent section breaks&lt;/h2&gt;
&lt;p&gt;IPython notebooks can look messy and disorienting. I like to include
large section breaks using IPython.display.HTML.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;new_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;style&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;text-align:center;background:#66aa33;padding:120px;color:#ffffff;font-size:3em;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;div style=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/div&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;new_section&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;New Section&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;div style="text-align:center;background:#66aa33;padding:120px;color:#ffffff;font-size:3em;"&gt;New Section&lt;/div&gt;&lt;/div&gt;
&lt;div class="section" id="nicer-image-display"&gt;
&lt;h2&gt;Nicer image display&lt;/h2&gt;
&lt;p&gt;The IPython.display.Image function is very useful, but sometimes it's
nice to use more of the horizontal space available. I extended the Image
function to Images to allow for a table-based layout.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;Images&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;100%&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="c1"&gt;# to match Image syntax&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;px&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;table style='width:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;'&amp;gt;&amp;lt;tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;th&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/th&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;image&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;td&amp;gt;&amp;lt;img src='&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;' /&amp;gt;&amp;lt;/td&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;Images&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;images/hanahaus.jpg&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;images/drug_approval.png&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;       &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Hanahaus&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Drug approvals&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;60%&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;table style='width:60%'&gt;&lt;tr&gt;&lt;th&gt;Hanahaus&lt;/th&gt;&lt;th&gt;Drug approvals&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='static/IPython_Notebook_Tips_files/hanahaus.jpg' /&gt;&lt;/td&gt;&lt;td&gt;&lt;img src='static/IPython_Notebook_Tips_files/drug_approval.png' /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;div class="section" id="running-command-line-tools"&gt;
&lt;h2&gt;Running command-line tools&lt;/h2&gt;
&lt;p&gt;What do you do if you want to run a command-line tool from within
IPython notebook? It can get very messy, since you may need to see
stdout, but it may include a lot of unformatted text, which can make
your notebook very unreadable.&lt;/p&gt;
&lt;p&gt;To address this, I created my own wrapper around subprocess. I first
have to set some global CSS for the notebook. There are no really good
ways to do this yet, so I just call a HTML function at the top of the
notebook. I then create a do_call function that runs the command-line
tool (subprocess) and captures the output. The output is hidden but can
be expanded using a CSS trick. It also keeps track of how long each
subprocess took to run. This function also includes your environment
variables from os.environ, which is often important.&lt;/p&gt;
&lt;p&gt;I also include a &amp;#64;contextmanager-based function that allows me to run
command-line tools from within specific directories. This comes up a
&lt;em&gt;lot&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;This system was very useful for me when I was making a &amp;quot;pipeline&amp;quot;
notebook, chaining together different command-line tools.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;
&amp;lt;style&amp;gt;
    .showhide_label { display:block; cursor:pointer; }
    .showhide { position: absolute; left: -999em; }
    .showhide + div { display: none; }
    .showhide:checked + div { display: block; }
    .shown_or_hidden { font-size:85%; }
&amp;lt;/style&amp;gt;
&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;style&gt;
    .showhide_label { display:block; cursor:pointer; }
    .showhide { position: absolute; left: -999em; }
    .showhide + div { display: none; }
    .showhide:checked + div { display: block; }
    .shown_or_hidden { font-size:85%; }
&lt;/style&gt;&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;time&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;os&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;random&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;subprocess&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;contextlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;contextmanager&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;do_call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;base_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;Help call subprocess with some niceties. Output to html.&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="p"&gt;([])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;MAX_OUT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;30000&lt;/span&gt; &lt;span class="c1"&gt;# characters to output to &amp;gt;stdout and &amp;gt;stderr&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;with_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;none&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;random_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;01234567890ABCDEF&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;div&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s2"&gt;&amp;quot;none&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;div&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s2"&gt;&amp;quot;time&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;div style='color:#953'&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s2"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;div style='font-size:125%;padding:5px;color:#6a3;'&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s2"&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;div style='border:2px solid #6a3;padding:5px;color:#555;'&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s2"&gt;&amp;quot;mono&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;div style='font-family:monospace;padding:5px;'&amp;gt;&amp;lt;pre&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="s2"&gt;&amp;quot;hide&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;lt;label class=&amp;quot;showhide_label&amp;quot; for=&amp;quot;showhide_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;gt;▸&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/label&amp;gt;
                      &amp;lt;input type=&amp;quot;checkbox&amp;quot; id=&amp;quot;showhide_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot; class=&amp;quot;showhide&amp;quot;/&amp;gt;
                      &amp;lt;div class=&amp;quot;shown_or_hidden&amp;quot;&amp;gt;&amp;lt;pre&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/pre&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;random_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;random_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;div&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;# Keep track of the amount of time spent in the process&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;start_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;# Treat Nones as empty&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cmd&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# ignore Nones, which otherwise would be &amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;# Optionally, make the command more readable by pretending base_dir is an env&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# To actually make an env requires shell=True and seems worse since this is only cosmetic&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;cmdstr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;base_dir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;$BASE&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;base_dir&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;# Use custom environment variables. os.environ variables are overwritten if duplicated&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;process_env&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;# Use Popen instead of subprocess.call to get stdout, stderr&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;process_env&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p_out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p_err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;communicate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p_rc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;returncode&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p_out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p_out&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p_out&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;[No stdout]&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p_err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p_err&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p_err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;[No stderr]&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;p_out_fmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p_out&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_out&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;MAX_OUT&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_out&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="n"&gt;MAX_OUT&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;[TRUNCATED]&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;p_err_fmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p_err&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;MAX_OUT&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_err&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="n"&gt;MAX_OUT&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;[TRUNCATED]&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;# Output a nicely formatted HTML block&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;with_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Running subprocess&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;with_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cmdstr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;mono&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;with_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_out_fmt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;hide&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;stdout (&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;)&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_out_fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)))]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;with_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_err_fmt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;hide&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;stderr (&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;)&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_err_fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)))]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;with_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;subprocess time : &lt;/span&gt;&lt;span class="si"&gt;{:.2f}&lt;/span&gt;&lt;span class="s2"&gt;s&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;start_time&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;time&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;with_div&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;main&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nd"&gt;&amp;#64;contextmanager&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;using_dir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;old_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getcwd&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old_dir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# The same thing, two ways&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;using_dir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/Users/briann/anaconda&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;do_call&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ls&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;.&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;do_call&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ls&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;/Users/briann/anaconda&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;div style='border:2px solid #6a3;padding:5px;color:#555;'&gt;&lt;div style='font-size:125%;padding:5px;color:#6a3;'&gt;Running subprocess&lt;/div&gt;&lt;div style='font-family:monospace;padding:5px;'&gt;&lt;pre&gt;ls .&lt;/pre&gt;&lt;/div&gt;&lt;label class="showhide_label" for="showhide_6EE3A5AB464A00B8"&gt;▸stdout (20)&lt;/label&gt;
                      &lt;input type="checkbox" id="showhide_6EE3A5AB464A00B8" class="showhide"/&gt;
                      &lt;div class="shown_or_hidden"&gt;&lt;pre&gt;Examples
Launcher.app
bin
conda-meta
docs
envs
imports
include
lib
mkspecs
node-webkit
phrasebooks
pkgs
plugins
python.app
q3porting.xml
share
ssl
tests
translations
&lt;/pre&gt;&lt;/div&gt;&lt;label class="showhide_label" for="showhide_98CCB0CDAA9044FF"&gt;▸stderr (0)&lt;/label&gt;
                      &lt;input type="checkbox" id="showhide_98CCB0CDAA9044FF" class="showhide"/&gt;
                      &lt;div class="shown_or_hidden"&gt;&lt;pre&gt;[No stderr]&lt;/pre&gt;&lt;/div&gt;&lt;div style='color:#953'&gt;subprocess time : 0.01s&lt;/div&gt;&lt;/div&gt;&lt;div style='border:2px solid #6a3;padding:5px;color:#555;'&gt;&lt;div style='font-size:125%;padding:5px;color:#6a3;'&gt;Running subprocess&lt;/div&gt;&lt;div style='font-family:monospace;padding:5px;'&gt;&lt;pre&gt;ls /Users/briann/anaconda&lt;/pre&gt;&lt;/div&gt;&lt;label class="showhide_label" for="showhide_6844185EC5D1EF10"&gt;▸stdout (20)&lt;/label&gt;
                      &lt;input type="checkbox" id="showhide_6844185EC5D1EF10" class="showhide"/&gt;
                      &lt;div class="shown_or_hidden"&gt;&lt;pre&gt;Examples
Launcher.app
bin
conda-meta
docs
envs
imports
include
lib
mkspecs
node-webkit
phrasebooks
pkgs
plugins
python.app
q3porting.xml
share
ssl
tests
translations
&lt;/pre&gt;&lt;/div&gt;&lt;label class="showhide_label" for="showhide_300A360B9F450BBE"&gt;▸stderr (0)&lt;/label&gt;
                      &lt;input type="checkbox" id="showhide_300A360B9F450BBE" class="showhide"/&gt;
                      &lt;div class="shown_or_hidden"&gt;&lt;pre&gt;[No stderr]&lt;/pre&gt;&lt;/div&gt;&lt;div style='color:#953'&gt;subprocess time : 0.01s&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="section" id="nicer-printing"&gt;
&lt;h2&gt;Nicer printing&lt;/h2&gt;
&lt;p&gt;Sometimes the standard print function doesn't cut it. I have a few
helper functions that make printing text a bit more flexible.&lt;/p&gt;
&lt;p&gt;I also generally use &amp;quot;from __future__ import print_function&amp;quot;
everywhere, since print should be a function anyway. I use &amp;quot;from
__future__ import division&amp;quot; since we'll all be on Python 3 soon
enough.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;__future__&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;print_function&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;division&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;itertools&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;yaml&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;hprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;tprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;table&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html_row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;tr style='font-weight:&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;'&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'bold'&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s1"&gt;'normal'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;html_row&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html_row&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;tr style='font-family:monospace;'&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{:}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html_row&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;jprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dict_or_json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;do_print&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;numbered&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;yaml&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;safe_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dict_or_json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default_flow_style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;numbered&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;cnt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;^\-&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cnt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()),&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MULTILINE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;do_print&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Some text&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Normal text&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;hprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;HTML table&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;tprint&lt;/span&gt;&lt;span class="p"&gt;([[&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ACGT&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)])&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Some JSON or a dict&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;jprint&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;a&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;b&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;c&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;d&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;e&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;f&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;g&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;i&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;k&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}}})&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Some text
---------
Normal text
&lt;/pre&gt;
HTML table&lt;table&gt;&lt;tr style='font-weight:bold'&gt;&lt;td&gt;CCC&lt;/td&gt;&lt;td&gt;GGG&lt;/td&gt;&lt;td&gt;TTT&lt;/td&gt;&lt;td&gt;AAA&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;TTT&lt;/td&gt;&lt;td&gt;TTT&lt;/td&gt;&lt;td&gt;CCC&lt;/td&gt;&lt;td&gt;AAA&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;AAA&lt;/td&gt;&lt;td&gt;AAA&lt;/td&gt;&lt;td&gt;CCC&lt;/td&gt;&lt;td&gt;AAA&lt;/td&gt;&lt;/tr&gt;&lt;tr style='font-family:monospace;'&gt;&lt;td&gt;GGG&lt;/td&gt;&lt;td&gt;TTT&lt;/td&gt;&lt;td&gt;CCC&lt;/td&gt;&lt;td&gt;TTT&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;pre class="literal-block"&gt;
Some JSON or a dict
-------------------
a:
  b: c
d: e
f:
  g:
    i: k
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="use-svg-for-plotting"&gt;
&lt;h2&gt;Use SVG for plotting&lt;/h2&gt;
&lt;p&gt;I really like using SVG for custom plots, since it is extremely
flexible. For example, you can combine images/photos and data easily.
Doing this does require learning some SVG, but it's not so complicated —
in many ways matplotlib etc. are much more complex since you often
can't get it to do exactly what you want (at least I can't.)&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_START&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;svg width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{w:}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{h:}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot; xmlns:xlink= &amp;quot;http://www.w3.org/1999/xlink&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_END&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/svg&amp;gt;'&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;SVG_START&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;SVG_END&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;random&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;390&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;box&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;rect x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; fill=&amp;quot;rgba(&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{:f}&lt;/span&gt;&lt;span class="s1"&gt;)&amp;quot; stroke=&amp;quot;rgb(0,0,0)&amp;quot; /&amp;gt;
        '''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;image xlink:href=&amp;quot;static/biospace-news-biogen-idec-2.png&amp;quot; x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot;/&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;140&lt;/span&gt;&lt;span class="p"&gt;),(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;.35&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'''&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{x:d}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{y:d}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;middle&amp;quot; font-size=&amp;quot;28&amp;quot; fill=&amp;quot;rgba(0,255,255,.95)&amp;quot;&amp;gt;
         IMPORTANT!&amp;lt;/text&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;svgs&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;object data="static/IPython_Notebook_Tips_files/IPython_Notebook_Tips_14_0.svg" type="image/svg+xml"&gt;&lt;/object&gt;
&lt;/div&gt;
</content><category term="data"/><category term="python"/><category term="ipython notebook"/><category term="data"/></entry><entry><title>Transcriptic E. coli Transformation</title><link href="/transcriptic_e_coli_transformation.html" rel="alternate"/><published>2015-06-18T11:00:00-07:00</published><updated>2015-06-18T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-06-18:/transcriptic_e_coli_transformation.html</id><summary type="html">&lt;p class="first last"&gt;Transforming an E. coli with luciferase on Transcriptic and measuring the result&lt;/p&gt;
</summary><content type="html">&lt;p&gt;This is a basic analysis of results data I downloaded from Transcriptic.
The protocol for this experiment was generated with &lt;a class="reference external" href="https://wla.bionano.autodesk.com/#/"&gt;Autodesk Wet Lab
Accelerator&lt;/a&gt; (beta).&lt;/p&gt;
&lt;p&gt;An &lt;em&gt;E. coli&lt;/em&gt; strain (Zymo10B) is transformed with a
luciferase- and ampR-expressing plasmid (PVIB) in a 96 well plate.
Each row (A-H) is identical and each column (1-6) is different:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
[A-H]1 : E. coli + PVIB + no amp broth
[A-H]2 : E. coli + no PVIB + no amp broth
[A-H]3 : no amp broth
[A-H]4 : E. coli + PVIB + amp broth (i.e., luciferase expression)
[A-H]5 : E. coli + amp broth
[A-H]6 : amp broth
&lt;/pre&gt;
&lt;p&gt;For rows A-F, absorbance (OD600) and luminescence (to see luciferase
expression) are captured once an hour for 18 hours.&lt;/p&gt;
&lt;p&gt;Rows G and H are transferred to two &amp;quot;6-flat&amp;quot; plates, one without amp
(G), one with amp (H). For each of the two sets of 6 plates a photo is
taken, then the plates are incubated for 18 hours, then another photo is
taken.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;# Setup cell&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;__future__&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;print_function&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;division&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;string&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;mpl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;functools&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_START&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;svg width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{w:}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{h:}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot; xmlns:xlink= &amp;quot;http://www.w3.org/1999/xlink&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;SVG_START&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;astr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/svg&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Plotting style, matplotlib and seaborn&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;axes&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;titlesize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labelsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edgecolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#444444'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;notebook&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font_scale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{})&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'retina'&lt;/span&gt;
&lt;/pre&gt;
&lt;div class="section" id="read-in-files"&gt;
&lt;h2&gt;Read in files&lt;/h2&gt;
&lt;p&gt;Absorbance and luminescence files from all plates were downloaded as csv
files from Transcriptic.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;glob&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;abs_files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;absorbance_*.csv&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;lum_files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;luminescence_*.csv&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; absorbance files:  &amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_files&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;abs_files&lt;/span&gt;&lt;span class="p"&gt;[::&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; luminescence files:&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lum_files&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="n"&gt;lum_files&lt;/span&gt;&lt;span class="p"&gt;[::&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
18 absorbance files:   ['absorbance_18.csv', 'absorbance_43.csv', 'absorbance_68.csv', 'absorbance_93.csv']
18 luminescence files: ['luminescence_19.csv', 'luminescence_44.csv', 'luminescence_69.csv', 'luminescence_94.csv']
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="dataframes"&gt;
&lt;h2&gt;Dataframes&lt;/h2&gt;
&lt;p&gt;Read absorbance and luminescence data into pandas dataframes.&lt;/p&gt;
&lt;p&gt;The time at which readings were taken is not included in the csv files
(these data are in another json file), but since I know readings were taken once per
hour, I can simply increment the time myself.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;datetime&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;abs_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index_col&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;abs_file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;abs_files&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;lum_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lum_file&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index_col&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;lum_file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lum_files&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_data&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# or get the true time from the json file&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Each file is for a specific time. Concatenate all the files and reset the index&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;df_abs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;abs_data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Time&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;df_abs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reset_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;df_lum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lum_data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Time&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;df_lum&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reset_index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_abs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_lum&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tail&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
   Time Well  OD 600:nanometer
0     0   A1          0.047956
1     0   A2          0.049607
2     0   A3          0.046221
3     0   A4          0.047077
4     0   A5          0.048022

     Time Well  Luminescence
643    17   F2             5
644    17   F3            18
645    17   F4            12
646    17   F5             5
647    17   F6            19
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="plot"&gt;
&lt;h2&gt;Plot&lt;/h2&gt;
&lt;p&gt;Plot absorbance and luminescence data for each of the 48 wells using
SVG.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;well_params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E coli&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;PVIB&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E coli&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:[],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;               &lt;span class="s2"&gt;&amp;quot;4&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E coli&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;PVIB&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;5&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;E coli&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;amp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;6&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;amp&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;to_coords&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_x&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_y&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;plot_df&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x_col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;sw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.1&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;# min, max over all plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x_col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;x_col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;y_col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;y_col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;wells&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;num_rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uppercase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;num_cols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;well&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;well&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;wells&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;_to_coords&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;partial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to_coords&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;g&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;groupby&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Well&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;g transform=&amp;quot;translate(&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;)&amp;quot;&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;vals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_df&lt;/span&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;x_col&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y_col&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;cx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;sw&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# well number (1-6) is the column&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;cy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uppercase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# well letter (A-F) is the row&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;circle cx=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cx:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; cy=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cy:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; r=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{r:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; stroke=&amp;quot;rgba(0,0,0,.15)&amp;quot; fill=&amp;quot;none&amp;quot;
                   /&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="c1"&gt;# Text labels for the plates&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cx:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cy:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;middle&amp;quot; font-size=&amp;quot;20&amp;quot; fill=&amp;quot;rgba(0,0,0,.25)&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{text:}&lt;/span&gt;&lt;span class="s1"&gt;
                   &amp;lt;/text&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;E coli&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;well_params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cx:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cy:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;middle&amp;quot; font-size=&amp;quot;12&amp;quot; fill=&amp;quot;rgba(0,200,0,.25)&amp;quot;&amp;gt;E coli
                       &amp;lt;/text&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;PVIB&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;well_params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cx:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cy:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;middle&amp;quot; font-size=&amp;quot;12&amp;quot; fill=&amp;quot;rgba(0,0,200,.25)&amp;quot;&amp;gt;PVIB
                       &amp;lt;/text&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;amp&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;well_params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cx:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{cy:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;middle&amp;quot; font-size=&amp;quot;12&amp;quot; fill=&amp;quot;rgba(200,0,0,.25)&amp;quot;&amp;gt;amp
                       &amp;lt;/text&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="c1"&gt;# Plot the absorbance/luminescence x/y values as a line&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;points&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;','&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_to_coords&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;vals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;g transform=&amp;quot;translate(&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;)&amp;quot;&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cx&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cy&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;polyline points=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{points:}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; style=&amp;quot;fill:none;stroke:rgba(100,140,180,1);stroke-width:2&amp;quot;
                   /&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;points&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;points&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/g&amp;gt;'&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/g&amp;gt;'&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y_col&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssvg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sw&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;num_cols&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;num_rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="absorbance"&gt;
&lt;h2&gt;Absorbance&lt;/h2&gt;
&lt;p&gt;The absorbance data shows the growth of the &lt;em&gt;E. coli&lt;/em&gt; and generally
looks good. We expect growth in columns 1 and 2 for sure, and column 4
if the transformation works.&lt;/p&gt;
&lt;p&gt;We see growth in columns 1 and 2, as expected. In three out of six wells
in column 4 we see growth (i.e., 50% transformation efficiency). In
these wells the &lt;em&gt;E. coli&lt;/em&gt; have taken up PVIB so they can resist
ampicillin.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;plot_df&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_abs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Time&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;OD 600:nanometer&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;h2&gt;OD 600:nanometer&lt;/h2&gt;&lt;object data="static/Transcriptic%20E.%20coli%20transformation_files/Transcriptic%20E.%20coli%20transformation_9_1.svg" type="image/svg+xml"&gt;&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="luminescence"&gt;
&lt;h2&gt;Luminescence&lt;/h2&gt;
&lt;p&gt;The luminescence data show the success of the PVIB plasmid transforming
&lt;em&gt;E. coli&lt;/em&gt; and expressing luciferase. We only expect luminescence in
column 4, since that is the only column with PVIB and ampicillin. We
detect luminescence in only one of three transformed &lt;em&gt;E. coli&lt;/em&gt;.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;plot_df&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df_lum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Time&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Luminescence&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;h2&gt;Luminescence&lt;/h2&gt;&lt;object data="static/Transcriptic%20E.%20coli%20transformation_files/Transcriptic%20E.%20coli%20transformation_11_1.svg" type="image/svg+xml"&gt;&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="image-capture"&gt;
&lt;h2&gt;Image Capture&lt;/h2&gt;
&lt;p&gt;Finally, we take photos of &lt;em&gt;E. coli&lt;/em&gt; growing in plates, before and after
incubation.&lt;/p&gt;
&lt;pre class="literal-block"&gt;
G plates have no amp, H plates have amp
[GH]1 has E. coli and PVIB
[GH]2 has E. coli and no PVIB
[GH]3 has no E. coli and no PVIB
&lt;/pre&gt;
&lt;p&gt;That the H plates are all empty is not surprising because we know from
the experiment above that PVIB transformation is not efficient. There is
something strange going on here with the Gs though, where G3 is showing
growth despite having no &lt;em&gt;E. coli&lt;/em&gt; spread, while G1 has no growth when
it should.&lt;/p&gt;
&lt;p&gt;I am currently assuming the images are reversed from what I expect, but
I don't know why... The Transcriptic UI is quite explicit about which
plate is which.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s1"&gt;'n'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'108'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'desc'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'before incubation, no amp'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'plates'&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s1"&gt;'G1,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G2,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G3,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G1,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G2,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G3,100'&lt;/span&gt;&lt;span class="p"&gt;]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'n'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'112'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'desc'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'after incubation, no amp'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'plates'&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s1"&gt;'G1,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G2,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G3,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G1,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G2,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'G3,100'&lt;/span&gt;&lt;span class="p"&gt;]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'n'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'113'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'desc'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'before incubation, with amp'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'plates'&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s1"&gt;'H1,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H2,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H3,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H1,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H2,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H3,100'&lt;/span&gt;&lt;span class="p"&gt;]},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'n'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'117'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'desc'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'after incubation, with amp'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'plates'&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s1"&gt;'H1,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H2,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H3,50'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H1,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H2,100'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'H3,100'&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;512&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;384&lt;/span&gt; &lt;span class="c1"&gt;# hardcoded image size&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;sw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.02&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.02&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;190&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;py&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;130&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;g transform=&amp;quot;translate(&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;)&amp;quot;&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sw&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;sh&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;image xlink:href=&amp;quot;/static/Transcriptic&lt;/span&gt;&lt;span class="si"&gt;%20E&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="si"&gt;%20c&lt;/span&gt;&lt;span class="s1"&gt;oli%20transformation_files/imagePlate_&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;.png&amp;quot; x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot;
               /&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'n'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;text x=&amp;quot;20&amp;quot; y=&amp;quot;20&amp;quot; fill=&amp;quot;#dd2222&amp;quot; font-size=&amp;quot;20&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/text&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'desc'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pl&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;plates&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; fill=&amp;quot;#2222dd&amp;quot; font-size=&amp;quot;15&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;μl
                   &amp;lt;/text&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mx&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;px&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n2&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;pl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/g&amp;gt;'&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssvg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;800&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;object data="static/Transcriptic%20E.%20coli%20transformation_files/Transcriptic%20E.%20coli%20transformation_13_0.svg" type="image/svg+xml"&gt;&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;I think this experiment was moderately successful. It was not that
expensive at about $20 for labor and $35 for reagents. The
transformation and luciferase expression efficiency was pretty low, but
I don't know what I'd expect if the experiment were performed by a
skilled technician.&lt;/p&gt;
&lt;p&gt;There were a few minor issues on the Transcriptic side:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;The PNG images get downloaded as .raw files. Initially, I thought it was a camera RAW file, which didn't work...&lt;/li&gt;
&lt;li&gt;The UI mixes 0-indexing and 1-indexing, which is a bit confusing. I would enforce 1-indexing.&lt;/li&gt;
&lt;li&gt;The plate images may be reversed compared to the UI? This could be an error on my part though.&lt;/li&gt;
&lt;li&gt;The &amp;quot;Download all&amp;quot; feature did not download all the data (it missed the images).&lt;/li&gt;
&lt;li&gt;The csv files did not include the time at which readings were taken. I'd have to dig into the json files to get that.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><category term="data"/><category term="virtual biotech"/><category term="cloud labs"/><category term="data"/></entry><entry><title>The Modern Virtual Biotech</title><link href="/virtual_biotech.html" rel="alternate"/><published>2015-06-13T11:00:00-07:00</published><updated>2015-06-13T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-06-13:/virtual_biotech.html</id><summary type="html">&lt;p class="first last"&gt;Describing how a modern virtual biotech might work&lt;/p&gt;
</summary><content type="html">&lt;p&gt;It feels apt to write about virtual companies from the beautiful new
&lt;a class="reference external" href="http://hanahaus.com/"&gt;Hanahaus&lt;/a&gt; space in downtown Palo Alto.
$3 an hour for a seat, and coffee by Blue Bottle.
Rent in Palo Alto is actually not so bad if you share...&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="hanahaus *Hanahaus, Palo Alto*" src="/images/hanahaus.jpg" /&gt;
&lt;/div&gt;
&lt;p&gt;My impression of the typical
&amp;quot;&lt;a class="reference external" href="http://www.wsj.com/articles/virtual-biotechs-no-lab-space-few-employees-1401816867"&gt;virtual biotech&lt;/a&gt;&amp;quot;
is a company that is spun out to develop a compound originally discovered in an academic lab,
or licensed from a larger biotech.
There are only a few employees, usually pharma veterans,
whose job is to shepherd the compound from CRO to CRO,
and develop just enough evidence that the compound can be sold.&lt;/p&gt;
&lt;p&gt;Recently, developments in biotech
— analogous to the move to cloud computing in IT —
may allow for a more complete virtual drug development company.
Below I summarize how this might work, and the companies and technologies that enable it.&lt;/p&gt;
&lt;div class="section" id="choose-your-therapy"&gt;
&lt;h2&gt;Choose your therapy&lt;/h2&gt;
&lt;p&gt;Generally, &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Biopharmaceutical"&gt;biologics&lt;/a&gt;
are going to be a better fit for a virtual model than small molecules.&lt;/p&gt;
&lt;p&gt;The chemistry of drug development requires very specialized expertise,
and large pharma/biotech has institutional knowledge that
is extremely difficult to compete with.
Also, because small molecules can be made of anything,
their off-target effects can be difficult to predict
(even aspirin is not &lt;a class="reference external" href="http://www.fda.gov/Drugs/ResourcesForYou/Consumers/QuestionsAnswers/ucm071879.htm#stroke"&gt;completely understood&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Nucleotide-based technologies like
RNAi (&lt;a class="reference external" href="http://www.alnylam.com/"&gt;Alnylam&lt;/a&gt;),
mRNA (&lt;a class="reference external" href="http://www.modernatx.com/"&gt;Moderna&lt;/a&gt;), and
CRISPR/Cas9 (&lt;a class="reference external" href="http://cariboubio.com/"&gt;Caribou&lt;/a&gt;, &lt;a class="reference external" href="http://www.editasmedicine.com"&gt;Editas&lt;/a&gt;)
would be ideal.
Since they are nucleotide-based, binding relies on sequence identity,
so it's much closer to a digital system.
Theoretically, you can change targets simply by changing the nucleotide sequence, which
makes the process much more predictable.
Nucleotide binding is generally easier to predict
because a 1D search space (the human genome, plus perhaps commensal bacterial genomes)
is so much more constrained than a 3D search space (all structures/epitopes present in and on cells).
Of course, these technologies have their own issues in that they are new and untested.&lt;/p&gt;
&lt;p&gt;Protein-based biologics are arguably a good compromise.
For example:
enzymes (&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Enzyme_replacement_therapy"&gt;enzyme replacement therapy&lt;/a&gt; is worth billions of dollars a year),
antibodies (seven of the eight &lt;a class="reference external" href="http://cellculturedish.com/2014/03/top-ten-biologics-2013-us-pharmaceutical-sales-2/"&gt;top selling drugs in 2013&lt;/a&gt; were antibodies),
BiTEs and CAR-Ts (cancer immunotherapy companies like &lt;a class="reference external" href="http://www.junotherapeutics.com"&gt;Juno&lt;/a&gt; are showing extremely promising results).
These technologies provide a more consistent design template than a small molecule (i.e., DNA),
but there is still a lot that remains unpredictable,
such as off-target binding for antibodies,
or even how the protein will fold.&lt;/p&gt;
&lt;div class="section" id="drug-repositioning"&gt;
&lt;h3&gt;Drug repositioning&lt;/h3&gt;
&lt;p&gt;Another reasonable option is to use an existing library of small molecules
(e.g., from &lt;a class="reference external" href="http://www.ncats.nih.gov/ntu/about"&gt;NCATS&lt;/a&gt;)
with some additional data that can be mined (e.g., expression changes in model organisms).
This&amp;nbsp;process is usually called drug repositioning, and there are indeed many such
companies springing up as the amount of available data increases,
and methods for prediction using statistical models (machine learning) improves
(&lt;a class="reference external" href="http://www.twoxar.com"&gt;twoXAR&lt;/a&gt;, &lt;a class="reference external" href="http://www.numedii"&gt;NuMedii&lt;/a&gt;, &lt;a class="reference external" href="http://www.atomwise.com"&gt;AtomWise&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;You can also combine these two concepts,
by applying CRISPR/Cas9 to a model organism to create a disease model,
and then testing that model against a library of compounds
(&lt;a class="reference external" href="http://www.recursionpharma.com"&gt;Recursion Pharma&lt;/a&gt;, &lt;a class="reference external" href="http://www.plab.co/"&gt;Perlstein lab&lt;/a&gt;).
Creating these disease models straightforwardly may be one of the major initial uses of
CRISPR/Cas9 (amazingly, now mainstream enough that you can order yours from
&lt;a class="reference external" href="http://www.genomics.agilent.com/en/SureGuide-gRNA-Synthesis-Kits/SureGuide-gRNA-Synthesis-Kits/?cid=AG-PT-187&amp;amp;tabId=AG-PR-128"&gt;Agilent&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="choose-your-advantage"&gt;
&lt;h2&gt;Choose your advantage&lt;/h2&gt;
&lt;p&gt;Without the resources of a large biotech, how can a virtual company compete?
After all, pharma/biotech has thousands of potential therapies sitting on the shelf.
A therapy that works great in yeast, or even mouse, is not necessarily worth much
because most of the risk in drug development happens after the preclinical research stage
(an orphan disease with no treatments is an easier sell).&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="drug" src="/images/drug_approval.png" /&gt;
&lt;/div&gt;
&lt;!-- http://www.appliedclinicaltrialsonline.com/fda-s-expedited-review-process-need-speed --&gt;
&lt;p&gt;Since the eventual goal is a safe and effective therapy, that means there are three
advantages your therapy could have:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;More Safety&lt;/strong&gt; The therapy has already been shown to be safe in a
clinical trial, or is a generic/off-patent drug (twoXAR, Recursion, NuMedii)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More Efficacy&lt;/strong&gt; The therapy works in multiple distinct organisms, so it should
work in humans (Perlstein lab)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;More Safety and More Efficacy&lt;/strong&gt; The therapy comes directly from a human,
therefore there is some indication that it's safe and effective in a human
(X01, Neurimmune).
Recent applications of human genetics in drug discovery (e.g., PCSK9 inhibitors) rely on a
&lt;a class="reference external" href="http://www.plengegen.com/blog/part-3-single-genes-drug-targets/"&gt;similar concept&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="create-and-test-your-therapy"&gt;
&lt;h2&gt;Create and test your therapy&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Create&lt;/strong&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Design:&lt;/strong&gt; A good example of where protein engineering is important is
&lt;a class="reference external" href="https://en.wikipedia.org/wiki/Bi-specific_T-cell_engager"&gt;BiTEs&lt;/a&gt;.
You can think of two things that should be colocated (like T-cells and cancer cells),
and synthesize a molecule that binds both.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Find:&lt;/strong&gt; A surprising fraction of drugs are still &amp;quot;natural products&amp;quot;,
many discovered through &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Bioprospecting"&gt;bioprospecting&lt;/a&gt;.
Recently, with the incredible amount of sequencing capacity available,
we can do this at scale from microbes (&lt;a class="reference external" href="http://www.warpdrivebio.com/"&gt;Warp Drive Bio&lt;/a&gt;)
or maybe even from humans.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Repurpose:&lt;/strong&gt; You can just try all the compounds in a commercial
&lt;a class="reference external" href="http://www.chembridge.com/screening_libraries/"&gt;screening library&lt;/a&gt;.
They may have already been picked over though!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="figure"&gt;
&lt;img alt="NPs *Percentage of drug approvals that were natural products (&amp;quot;N&amp;quot;)* `Newman &amp;amp; Cragg 2013 &amp;lt;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3721181/&amp;gt;`_" src="/images/natural_products_percentage.jpg" /&gt;
&lt;/div&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Model organism:&lt;/strong&gt; Testing in simple model organisms is great, if you have a good model
(apparently, &lt;a class="reference external" href="https://www.youtube.com/watch?v=OC3l1UI9CZg"&gt;yeast is a good model for Alzheimer's&lt;/a&gt;)
It also helps you parallelize your experiments since you can grow these little
organisms in wells.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Human cells:&lt;/strong&gt; This method becomes especially powerful when combined with CRISPR/Cas9, even with
a relatively &lt;a class="reference external" href="http://www.nature.com/news/chinese-scientists-genetically-modify-human-embryos-1.17378"&gt;low yield&lt;/a&gt; for now.
&lt;a class="reference external" href="http://www.roosterbio.com"&gt;Rooster Bio&lt;/a&gt; and &lt;a class="reference external" href="http://www.extembio.com"&gt;Extem Bio&lt;/a&gt;
are two startups providing MSCs (mesenchymal stem cells — not iPSCs)
at competitive prices
(Extem claims to have the largest stem cell library by several orders of magnitude).
Of course, every large biotech is using stem cells too
(e.g., &lt;a class="reference external" href="http://www.astrazeneca.com/Media/Press-releases/Article/20150129-AstraZeneca-announces-collaborations-CRISPR-technology-genome-editing-drug-discovery-platform"&gt;AstraZeneca&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Animal:&lt;/strong&gt; Mammalian animal models (usually mice or rats) are expensive,
(probably $10k-100k per experiment)
but currently necessary for any kind of serious drug development effort.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="choose-your-development-methods"&gt;
&lt;h2&gt;Choose your development methods&lt;/h2&gt;
&lt;p&gt;Since this company is virtual, there are severe limitations on what is possible,
so the choice of development methods is extremely important.
The experiments must be inherently amenable to virtualization.&lt;/p&gt;
&lt;div class="section" id="synthetic-biology"&gt;
&lt;h3&gt;Synthetic biology&lt;/h3&gt;
&lt;p&gt;If you are going to develop a biologic virtually and on the cheap,
then you'll probably want to use synthetic biology.
The iGEM synthetic biology competition gives some indication of how that might work
(&lt;a class="reference external" href="http://blog.booleanbiotech.com/static/igem.html"&gt;list of iGEM projects&lt;/a&gt;).
iGEM is mostly focused on bacterial sensors and the like, but
when the worlds of iGEM and drug development collide it is
&lt;a class="reference external" href="http://2008.igem.org/Team:Slovenia/Project/Engineered_flagellin_vaccine"&gt;fascinating&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Synthetic biology allows you to iterate on and parallelize your experiments
in ways that are very suited to virtualization.
For example, if you want to do some mutagenesis on your protein, you can use a
&lt;a class="reference external" href="http://www.genomics.agilent.com/en/Site-Directed-Mutagenesis/QuikChange-Lightning/?cid=AG-PT-175&amp;amp;tabId=AG-PR-1162"&gt;kit&lt;/a&gt;
or write some code to edit the sequence directly.
The use of synthetic DNA means you can worry less about the experimental process
(purification of PCR products, general lab hygiene)
and rely less on the hard-won expertise of lab science.
You get increased reproducibility for free.&lt;/p&gt;
&lt;p&gt;Synthesizing DNA is still expensive at 10-20c per base
(that's at least a million times more expensive
&lt;a class="reference external" href="http://www.synthesis.cc/2014/02/time-for-new-cost-curves-2014.html"&gt;than sequencing&lt;/a&gt;)
but companies like
&lt;a class="reference external" href="http://www.gen9bio.com"&gt;Gen9&lt;/a&gt;,
&lt;a class="reference external" href="http://www.twistbioscience.com/"&gt;Twist Bioscience&lt;/a&gt;
and &lt;a class="reference external" href="http://cambriangenomics.com/"&gt;Cambrian Genomics&lt;/a&gt;
should be able to bring the price down an order of magnitude within a few years.
That will mean $10-50 proteins and antibody fragments,
which should enable a lot more kinds of parallel experimentation.&lt;/p&gt;
&lt;p&gt;You can get a bit of help with designing your vector and protein using
software like &lt;a class="reference external" href="http://www.genomecompiler.com"&gt;Genome Compiler&lt;/a&gt; or
&lt;a class="reference external" href="http://www.benchling.com"&gt;Benchling&lt;/a&gt; (as used by Gen9).&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="DNA cost *Rob Carlson's* `DNA synthesis cost curve &amp;lt;http://www.synthesis.cc/2014/02/time-for-new-cost-curves-2014.html&amp;gt;`_" src="/images/Carlson_Price_Seq_Synth_Feb2014.png" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="cloud-labs"&gt;
&lt;h3&gt;Cloud labs&lt;/h3&gt;
&lt;p&gt;The other crucial ingredient in the modern virtual biotech is the cloud lab
(as I've discussed in several previous posts):
&lt;a class="reference external" href="http://www.transcriptic.com"&gt;Transcriptic&lt;/a&gt;,
&lt;a class="reference external" href="https://beta.autodesk.com/callout/?callid=%7B2B4850B9-1044-4B41-8B15-920D8FA3A2DC%7D"&gt;Autodesk Wet Lab Accelerator&lt;/a&gt;
(in beta just this week, and built on top of Transcriptic),
&lt;a class="reference external" href="http://www.arcturus.io"&gt;Arcturus BioCloud&lt;/a&gt;,
&lt;a class="reference external" href="http://www.emeraldcloudlab.com"&gt;Emerald Cloud Lab&lt;/a&gt; (in beta),
&lt;a class="reference external" href="http://www.synthego.com"&gt;Synthego&lt;/a&gt; (not yet live) and
&lt;a class="reference external" href="http://www.riffyn.com"&gt;Riffyn&lt;/a&gt; (not yet live).
None of these companies existed just a year or two ago.&lt;/p&gt;
&lt;p&gt;Just like SnapChat can build a massive messaging app on top of Google App Engine
to compete with Facebook et al.,
and many other lean internet companies build on top of AWS,
the virtual biotech should take advantage of scalable cloud services for experiments too.&lt;/p&gt;
&lt;p&gt;Sadly, you cannot do everything with synthetic biology and cloud labs just yet.
For experiments that don't fit into these boxes, there is always
&lt;a class="reference external" href="http://www.scienceexchange.com"&gt;Science Exchange&lt;/a&gt; and
&lt;a class="reference external" href="http://www.assaydepot.com"&gt;Assay Depot&lt;/a&gt;.
There are also a couple of exciting stealth animal experimentation startups
coming out soon too!
The CRO world, like IT vendors before the era of AWS, is set for disruption.&lt;/p&gt;
&lt;!-- - **Rent:** If you're in the Bay Area, then $3 an hour at @hanahous, plus the price of coffee, --&gt;
&lt;!-- or $100 a month at @hackerdojo or similar. --&gt;
&lt;!-- - **Compute:** In general, you can probably just use your laptop. --&gt;
&lt;!-- If you need to scale up your computation there's --&gt;
&lt;!-- @nimbix, @cyclecomputing, @dominodatalab, @continuumio, --&gt;
&lt;!-- and probably a dozen more. --&gt;
&lt;!-- - **Samples:** $300-$2000 per human sample. --&gt;
&lt;!-- Irreproducible biology research costs put at $28 billion per year --&gt;
&lt;!-- http://www.nature.com/news/irreproducible-biology-research-costs-put-at-28-billion-per-year-1.17711 --&gt;
&lt;!-- Success rate by phase of development and by therapeutic area --&gt;
&lt;!-- http://www.nature.com/nrd/journal/v3/n8/fig_tab/nrd1470_F2.html --&gt;
&lt;!-- Other blogpost about Taxa --&gt;
&lt;!-- Drug Development vs Industrial Applications --&gt;
&lt;!-- =========================================== --&gt;
&lt;!-- There is an argument that the better application for virtualization is industrial --&gt;
&lt;!-- applications of synthetic biology. --&gt;
&lt;!-- The big advantages are that you can do it cheaper, and there are fewer regulations. --&gt;
&lt;!-- The disadvantage is that you cannot virtualize as much as you like. --&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="drugs"/><category term="synthetic biology"/><category term="drug development"/><category term="virtual biotech"/><category term="cloud labs"/></entry><entry><title>Arcturus BioCloud Robot Lab</title><link href="/arcturus_robot_lab.html" rel="alternate"/><published>2015-05-29T11:00:00-07:00</published><updated>2015-05-29T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-05-29:/arcturus_robot_lab.html</id><summary type="html">&lt;p class="first last"&gt;Arcturus' platform for synthetic biology&lt;/p&gt;
</summary><content type="html">&lt;p&gt;I first learned about Arcturus BioCloud a few months ago from their irreverent
&lt;a class="reference external" href="https://www.youtube.com/user/ArcturusBioCloud"&gt;youtube videos&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Arcturus are one of the new crop of robotic labs that allow you to run wet-lab experiments
from a web or command-line interface.
They appear to be smaller and less well funded than
&lt;a class="reference external" href="https://www.transcriptic.com/"&gt;Transcriptic&lt;/a&gt; and
&lt;a class="reference external" href="http://emeraldcloudlab.com/"&gt;Emerald Cloud Lab&lt;/a&gt;,
both of which have opened enormous new lab spaces recently.
Arcturus is much more focused on the biohacker / synthetic biology space,
where Transcriptic and ECL are focused on taking on common wet-lab procedures like
Western blots.
(For completeness, the other robot lab I know about is
&lt;a class="reference external" href="http://www.riffyn.com/"&gt;Riffyn&lt;/a&gt;, though I don't know how that one fits in yet).&lt;/p&gt;
&lt;p&gt;The most impressive aspect of Arcturus to me was that I could create and execute a
synthetic biology project within literally a few minutes.
Granted, the experiment simply grows a bacterium up with one of three available genes and
takes a photograph, but I am still extremely impressed by how easy it was,
and by the $80 price.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="arcturus" src="/images/arcturus.png" /&gt;
&lt;/div&gt;
&lt;p&gt;I'm looking forward to seeing how Arcturus develops their interface to allow for
custom proteins and analyses.&lt;/p&gt;
</content><category term="synthetic biology"/><category term="synthetic biology"/><category term="robot lab"/></entry><entry><title>Natural Knockdowns: myostatin</title><link href="/natural_knockdowns_myostatin.html" rel="alternate"/><published>2015-05-24T11:00:00-07:00</published><updated>2015-05-24T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-05-24:/natural_knockdowns_myostatin.html</id><summary type="html">&lt;p class="first last"&gt;Genetics and myostatin antibodies&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Let's say you want to create an therapeutic antibody against a protein.
Typically, you start by immunizing an animal with the protein (antigen) of interest,
and harvesting the antibodies that the animal creates in response.
Then you &amp;quot;humanize&amp;quot; the antibody (replace parts of animal IgG with human IgG)
and start testing in humans.
Although this method (and many permutations) has been working well for many years,
there are still unpredictable effects, and an antibody developed in this way
is far from assured to be safe and effective.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="myostatin" src="/images/monoclonal_antibody3.png" /&gt;
&lt;/div&gt;
&lt;p&gt;Recently, companies like &lt;a class="reference external" href="http://www.xo1.co.uk/ichorcumab.html"&gt;X01&lt;/a&gt;
have shown the value of using &amp;quot;fully human&amp;quot; antibodies as therapies.
X01 started with an anti-thrombin antibody isolated from a patient with an unusual
clotting phenotype.
They turned this antibody into an anticoagulation therapy and sold it to J&amp;amp;J this year.&lt;/p&gt;
&lt;p&gt;So to generalize, instead of immunizing an animal with your antigen,
you can try to find a human with the unusual phenotype you want and
develop an antibody that way.
The major putative advantage is that you start off with a free n-of-one human experiment
showing that your therapy is safe and effective.
The problem changes from one of biochemistry to bioprospecting.&lt;/p&gt;
&lt;div class="section" id="pcsk9"&gt;
&lt;h2&gt;PCSK9&lt;/h2&gt;
&lt;p&gt;Human genetics is playing an increasingly important role in drug development,
especially in helping determine the best drug targets.
The most famous example of this is the gene &lt;em&gt;PCSK9&lt;/em&gt;, which, when homozygous null,
results in very low LDL, excellent cardiovascular health, and no apparent side-effects.
After its discovery, several pharma companies immediately began developing therapies
against this target.
This discovery also likely played a part in Amgen buying DeCode, Regeneron's huge
human genetics effort, and &lt;a class="reference external" href="http://www.plengegen.com"&gt;Robert Plenge&lt;/a&gt;
(&lt;a class="reference external" href="https://www.twitter.com/rplenge"&gt;&amp;#64;rplenge&lt;/a&gt;) joining Merck.
For an excellent summary of the PCSK9 story,
see this &lt;a class="reference external" href="https://www.lipid.org/node/1212"&gt;excellent talk&lt;/a&gt; by Jonathan Cohen.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="natural-knockdowns"&gt;
&lt;h2&gt;Natural knockdowns&lt;/h2&gt;
&lt;p&gt;So we know that fully human antibodies have very attractive properties,
and we know that human genetics can help us find useful targets. Can we combine the two?
George Church sometimes shows a slide listing many of the known protective mutations.
These genes are mostly full knockouts (nulls)
and, perhaps surprisingly, these broken genes are sometimes beneficial.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="myostatin" src="/images/myostatin_slide.png" /&gt;
&lt;/div&gt;
&lt;p&gt;&lt;em&gt;Knockdowns&lt;/em&gt; are similar to knockouts, except here the protein is made correctly but
then suffocated by something else, like an antibody.
(Knockdowns normally refer to inhibition at the nucleotide level,
but the term seems to fit better than the alternatives.)
&lt;em&gt;Natural knockdowns&lt;/em&gt; would present similarly to human knockouts, except that they
would not be present at birth, but would develop later in life.
In other words, these are unusual autoimmune diseases.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="myostatin"&gt;
&lt;h2&gt;Myostatin&lt;/h2&gt;
&lt;p&gt;After going through various lists of beneficial knockouts, one stands out: myostatin.
Myostatin is an inhibitor of muscle growth, so the knockout results in a muscular phenotype.
There is at least one known
&lt;a class="reference external" href="http://www.nytimes.com/2004/06/24/science/24muscle.html"&gt;homozygous null human&lt;/a&gt;,
an extremely muscular German toddler.
In the animal kingdom, there are several examples, including the
&lt;a class="reference external" href="http://www.pnas.org/content/94/23/12457.full"&gt;Belgian Blue cow&lt;/a&gt;.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="myostatin" src="/images/belgian_blue.jpg" /&gt;
&lt;/div&gt;
&lt;p&gt;A natural knockdown of myostatin would theoretically result in unexpected muscle development,
perhaps late in life, and without a change in lifestyle.&lt;/p&gt;
&lt;p&gt;A myostatin knockdown fulfills my criteria:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;It is an extracellular protein&lt;/strong&gt;
The protein must be accessible by antibodies.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It has an obvious therapeutic application&lt;/strong&gt;
Myostatin antibodies are potentially a treatment for many muscle-wasting diseases.
There are already several in development by a number of companies
(e.g., &lt;a class="reference external" href="http://www.pfizer.com/sites/default/files/product-pipeline/February_27_2015_Pipeline_Update_Final2.pdf"&gt;Pfizer&lt;/a&gt;,
&lt;a class="reference external" href="http://www.bms.com/research/pipeline/pages/default.aspx"&gt;BMS&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;It has a measurable phenotype&lt;/strong&gt;
Greatly increased musculature is pretty easy to measure, perhaps even easier than LDL.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The phenotype is benign&lt;/strong&gt;
This is not completely necessary, but it is an attractive property
in terms of safety that the antibody does not cause another disease.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Of course, it is not trivial to find a person with this unusual phenotype
— if they even exist —
but if we could, then they might by carrying an extremely useful therapy in their blood.
If you know someone who has added a lot of muscle quickly and cannot explain why, let me know!&lt;/p&gt;
&lt;/div&gt;
</content><category term="drugs"/><category term="antibodies"/><category term="genetics"/><category term="drugs"/><category term="knockout"/><category term="knockdown"/></entry><entry><title>Oxford Nanopore Conference 2015</title><link href="/oxford%20nanopore%202015.html" rel="alternate"/><published>2015-05-14T11:00:00-07:00</published><updated>2015-05-14T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-05-14:/oxford nanopore 2015.html</id><summary type="html">&lt;p class="first last"&gt;Some notes on the Oxford Nanopore Conference 2015&lt;/p&gt;
</summary><content type="html">&lt;p&gt;The unveiling of the MinION MkII at the 2015 Oxford Nanopore Conference
may be remembered as a very big deal in the history of genomics.
A number of tweets even compared it to the 2007 iPhone unveiling.
Of course, that's crazy — it's a much bigger deal than a simple Candy Crush vehicle.&lt;/p&gt;
&lt;p&gt;I look forward to reading accounts from people who actually attended the conference,
but I wanted to assemble what I learned from the
&lt;a class="reference external" href="https://twitter.com/search?q=nanoporeconf&amp;amp;src=typd"&gt;#nanoporeconf&lt;/a&gt;
tweets and this great
&lt;a class="reference external" href="https://www.genomeweb.com/sequencing-technology/oxford-nanopore-outlines-specs-new-sequencers-automated-sample-prep-system-pay"&gt;genomeweb article&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="minion-mkii"&gt;
&lt;h2&gt;MinION MkII&lt;/h2&gt;
&lt;p&gt;The major news at the conference was the announcement of a new MinION sequencer, the MkII,
replacing the MkI, itself only available as part of an early-access program.&lt;/p&gt;
&lt;p&gt;The MkII has a new &amp;quot;fast mode&amp;quot; that's about 10X as fast as before and the output is
now an impressively Illumina-like 5GB per hour. The error rates are also apparently improved.&lt;/p&gt;
&lt;p&gt;Apart from its size, one of the most interesting things about the tiny MinION is that it
streams sequence in real-time to your computer (I think it&amp;nbsp;even needs USB 3).
That means you can do things like sequence until you find what you are looking for,
then stop, or, perhaps in the future, leave it on all the time,
monitoring your sewer system etc.&lt;/p&gt;
&lt;p&gt;Because of how the machine works, you are billed by the hour, like an AWS instance.
The new price is $20 an hour, down from about $90 per hour for the MkI.
At that price you really start to think about sequencing in a new way.
This is the most mind-blowing aspect of this machine to me,
and I think it will radically change how sequencing will be used,
especially outside core human genomics applications.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="minion" src="/images/minion_at_home.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="voltrax"&gt;
&lt;h2&gt;Voltrax&lt;/h2&gt;
&lt;p&gt;Voltrax is a lab-on-a-chip that attaches directly to your MinION and does sample prep for you.
That allows you to sequence from samples while you're out and about.
It's programmable in Python (an excellent choice).
Sadly, it's not out yet and they didn't give a timeline for it.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="voltrax" src="/images/voltrax.jpg" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="what-s-minion-for"&gt;
&lt;h2&gt;What's MinION for?&lt;/h2&gt;
&lt;p&gt;Although it's an amazing little machine, MinION doesn't compete with MiSeq/HiSeq for typical human
genomics applications.
This is mainly because the error rate is still very high.
For the MkI the error rate is apparently up to 30%(!)
For the MkII there is talk of getting it down to 5% — still very high compared to Illumina.&lt;/p&gt;
&lt;p&gt;The major applications I've seen proposed so far are around:
genome scaffolding (like PacBio — you just need long reads);
pathogen/environmental sequencing (like &amp;#64;pathogenomenick
&lt;a class="reference external" href="http://www.nature.com/news/pint-sized-dna-sequencer-impresses-first-users-1.17483"&gt;sequencing Ebola&lt;/a&gt;
in Guinea — here you need something fast and portable, and long reads help);
sequencing messy parts of the genome (like HLA and CYP2D6, previously requiring Sanger sequencing or other difficult methods —
here you need long and reasonably accurate reads).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="promethion"&gt;
&lt;h2&gt;PromethIon&lt;/h2&gt;
&lt;p&gt;This is a bigger, benchtop instrument with higher throughput than the MinION (6.4 terabases per run).
It's less obvious to me how this machine will be used, but it's extremely impressive throughput.&lt;/p&gt;
&lt;/div&gt;
</content><category term="genomics"/><category term="sequencing"/><category term="nanopore"/><category term="minion"/></entry><entry><title>Linear Regression Experiments</title><link href="/linear_regression_experiments.html" rel="alternate"/><published>2015-05-09T11:00:00-07:00</published><updated>2015-05-09T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-05-09:/linear_regression_experiments.html</id><summary type="html">&lt;p class="first last"&gt;Comparing some linear regression methods using MCMC&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Some simple experiments in linear regression using scipy, Stan, and PyMC3.&lt;/p&gt;
&lt;p&gt;Take some data from Google spreadsheets
that includes a response variable (y) and one or more
predictors (x1, x2).
I assume that the first column is the response variable and
apply linear regression several different ways.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;__future__&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;print_function&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;division&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;requests&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pymc3&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pm&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pystan&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;mpl&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib.pyplot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;plt&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;StringIO&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pprint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pprint&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sklearn.linear_model&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LinearRegression&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sklearn.preprocessing&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scipy.stats&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;norm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;probplot&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTML&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&amp;lt;center&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/center&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;SVG_START&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;svg width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{w:}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{h:}&lt;/span&gt;&lt;span class="s1"&gt;px&amp;quot; version=&amp;quot;1.1&amp;quot; xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot; xmlns:xlink= &amp;quot;http://www.w3.org/1999/xlink&amp;quot;&amp;gt;'''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;display&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;SVG_START&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;astr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;/svg&amp;gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Plotting style&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;axes&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;titlesize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;labelsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;linewidth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edgecolor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'#444444'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;notebook&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;font_scale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{})&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'retina'&lt;/span&gt;
&lt;/pre&gt;
&lt;div class="section" id="data"&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;Here we load the data into a DataFrame and look at a summary.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;# Read in data from google spreadsheet&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;gsheet_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;1q2xrN2YQ4KrGedaupDX2aM9dWGSmz23v7UF2GxwlO0A&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;gsheet_url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;https://docs.google.com/spreadsheets/d/1q2xrN2YQ4KrGedaupDX2aM9dWGSmz23v7UF2GxwlO0A/edit?usp=sharing&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;csv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;https://docs.google.com/spreadsheets/d/&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;/export?gid=0&amp;amp;format=csv&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gsheet_key&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;from_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StringIO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;index_col&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;Data summary&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;percentiles&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[])&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to_html&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;TEST_LOG&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;TEST_LOG&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;x3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;x3&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;&lt;h1&gt;Data summary&lt;/h1&gt;&lt;/center&gt;&lt;center&gt;&lt;table border="1" class="dataframe"&gt;
  &lt;thead&gt;
    &lt;tr style="text-align: right;"&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;y&lt;/th&gt;
      &lt;th&gt;x1&lt;/th&gt;
      &lt;th&gt;x2&lt;/th&gt;
      &lt;th&gt;x3&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;count&lt;/th&gt;
      &lt;td&gt;100&lt;/td&gt;
      &lt;td&gt;100&lt;/td&gt;
      &lt;td&gt;100&lt;/td&gt;
      &lt;td&gt;100&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;mean&lt;/th&gt;
      &lt;td&gt;0.016842&lt;/td&gt;
      &lt;td&gt;-0.052540&lt;/td&gt;
      &lt;td&gt;-0.027275&lt;/td&gt;
      &lt;td&gt;0.011383&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;std&lt;/th&gt;
      &lt;td&gt;0.092049&lt;/td&gt;
      &lt;td&gt;0.969025&lt;/td&gt;
      &lt;td&gt;0.959984&lt;/td&gt;
      &lt;td&gt;0.375131&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;min&lt;/th&gt;
      &lt;td&gt;-0.204356&lt;/td&gt;
      &lt;td&gt;-2.257561&lt;/td&gt;
      &lt;td&gt;-2.447623&lt;/td&gt;
      &lt;td&gt;-0.859929&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;50%&lt;/th&gt;
      &lt;td&gt;0.012005&lt;/td&gt;
      &lt;td&gt;0.019029&lt;/td&gt;
      &lt;td&gt;-0.072433&lt;/td&gt;
      &lt;td&gt;0.040495&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;max&lt;/th&gt;
      &lt;td&gt;0.252106&lt;/td&gt;
      &lt;td&gt;2.304593&lt;/td&gt;
      &lt;td&gt;2.329134&lt;/td&gt;
      &lt;td&gt;0.934868&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/center&gt;&lt;/div&gt;
&lt;div class="section" id="standardizing-data"&gt;
&lt;h2&gt;Standardizing data&lt;/h2&gt;
&lt;p&gt;By standardizing the data (subtracting the mean and dividing by the
standard deviation), we can avoid some common problems. Specifically,
when variables are on vastly different scales it can cause issues.&lt;/p&gt;
&lt;p&gt;See &lt;a class="reference external" href="http://andrewgelman.com/2009/07/11/when_to_standar/"&gt;http://andrewgelman.com/2009/07/11/when_to_standar/&lt;/a&gt; for a
discussion of standardization.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;df_fits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;col&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;_df_fit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;StandardScaler&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_df_fit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;df_fits&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;col&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_df_fit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inverse_transform&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;Data overview, all-vs-all&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PairGrid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#g.fig.suptitle('Data overview, all-vs-all', y=1.05, fontsize=28)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map_upper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;regplot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map_lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kdeplot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cmap&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Blues_d&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;map_diag&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hist&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;&lt;h1&gt;Data overview, all-vs-all&lt;/h1&gt;&lt;/center&gt;&lt;img alt="linear regression" src="static/Bayesian%20Linear%20Regression_files/Bayesian%20Linear%20Regression_6_1.png" /&gt;
&lt;/div&gt;
&lt;div class="section" id="are-the-data-normal"&gt;
&lt;h2&gt;Are the data normal?&lt;/h2&gt;
&lt;p&gt;Regression performs better if the data are approximately normal.&lt;/p&gt;
&lt;p&gt;It's not uncommon for some data types to be closer to log-normal than
normal, i.e., the data look normal after taking the log. For example,
adult blood pressure is approximately
&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Log-normal_distribution"&gt;log-normal&lt;/a&gt;.
If that is the case, we will use the logged version.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;fig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#fig.suptitle('Compare fits for data vs logged data ', y=1.05, fontsize=28)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;Compare fits for data vs logged data&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots_adjust&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hspace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;eps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1e-4&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ax1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ax2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Original data (no log applied)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_osr&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_slope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_intercept&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_R&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;probplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scatter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_osr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'steelblue'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;_intercept&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_slope&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;_intercept&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_slope&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'seagreen'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;  probability plot (no log) $R^2:&lt;/span&gt;&lt;span class="si"&gt;{:.3f}&lt;/span&gt;&lt;span class="s2"&gt;$&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_R&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Data with log applied&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;log_X_var&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eps&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_osr&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_slope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_intercept&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_Rlog&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;probplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;log_X_var&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scatter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_osr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'steelblue'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;plot&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;_intercept&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_slope&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;_intercept&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_slope&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;_osm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="p"&gt;()],&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'seagreen'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;  probability plot (log) $R^2:&lt;/span&gt;&lt;span class="si"&gt;{:.3f}&lt;/span&gt;&lt;span class="s2"&gt;$&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_Rlog&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;# Decide whether to use original version or the logged version&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;_Rlog&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_R&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;_tmpfn1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_tmpval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df_fits&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;# necessary to avoid recursion problem&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;df_fits&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;_tmpfn1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;_tmpval&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;eps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# change inverse transform&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eps&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;annotate_ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax2&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;annotate_ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ax1&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;annotate_ax&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;annotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Higher $R^2$&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;xytext&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;textcoords&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'axes fraction'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'indianred'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fontsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tight_layout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;&lt;h1&gt;Compare fits for data vs logged data&lt;/h1&gt;&lt;/center&gt;&lt;img alt="linear regression" src="static/Bayesian%20Linear%20Regression_files/Bayesian%20Linear%20Regression_8_1.png" /&gt;
&lt;/div&gt;
&lt;div class="section" id="linear-regression"&gt;
&lt;h2&gt;Linear Regression&lt;/h2&gt;
&lt;p&gt;Apply &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Ordinary_least_squares"&gt;ordinary least-squares linear regression&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;ols&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;LinearRegression&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fit_intercept&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;normalize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n_jobs&lt;/span&gt;&lt;span class="o"&gt;=-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'''
&amp;lt;h1&amp;gt;OLS linear regression results&amp;lt;/h1&amp;gt;
&amp;lt;table&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Intercept&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{intercept:.3f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Coefficients&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{coef:s}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Residual sum of squares&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{rss:.3f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;$R^2$ of the prediction.&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{score:.3f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;'''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;intercept&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;intercept_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;coef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;', '&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:s}&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="si"&gt;{:.3f}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:][&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;coef_&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;coef_&lt;/span&gt;&lt;span class="p"&gt;))),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;rss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ols&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;score&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;
&lt;h1&gt;OLS linear regression results&lt;/h1&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;Intercept&lt;/td&gt;&lt;td&gt;0.000&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Coefficients&lt;/td&gt;&lt;td&gt;x1:0.218, x2:0.163, x3:0.126&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Residual sum of squares&lt;/td&gt;&lt;td&gt;0.911&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;$R^2$ of the prediction.&lt;/td&gt;&lt;td&gt;0.089&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/center&gt;&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;# http://www.stat.columbia.edu/~gelman/presentations/stantalk2014_handout.pdf&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Instead of a gamma use a half-normal, as Gelman recommends (see stan manual &amp;quot;Truncated Priors&amp;quot;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;stan_regress&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;
data {
  int N;
  int K;
  vector[N] y;
  matrix[N,K] X;
}
parameters {
  real intercept;
  vector[K] betas;
  real&amp;lt;lower=0.01&amp;gt; sigma;
}
model {
  sigma ~ normal(0,1);
  y ~ normal(intercept + X*betas, sigma);
}&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;stan_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'X'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'y'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'N'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s1"&gt;'K'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Fit the model&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pystan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model_code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;stan_regress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;stan_data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;iter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;chains&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Inference for Stan model: anon_model_fa066f9745cd16eb2f6cf993e14d51c9.
4 chains, each with iter=1000; warmup=500; thin=1;
post-warmup draws per chain=500, total post-warmup draws=2000.

            mean se_mean     sd   2.5%    25%    50%    75%  97.5%  n_eff   Rhat
intercept 4.0e-3  4.0e-3    0.1  -0.18  -0.06 5.8e-3   0.07   0.19  564.0    1.0
betas[0]    0.22  4.2e-3    0.1 7.6e-3   0.15   0.22   0.29   0.41  587.0    1.0
betas[1]    0.17  4.0e-3    0.1  -0.03    0.1   0.17   0.23   0.37  615.0    1.0
betas[2]    0.13  4.1e-3    0.1  -0.07   0.06   0.13    0.2   0.32  634.0    1.0
sigma       0.98  2.9e-3   0.07   0.85   0.94   0.98   1.03   1.13  562.0    1.0
lp__      -48.43    0.08   1.58 -52.34 -49.28 -48.16 -47.24 -46.26  427.0    1.0

Samples were drawn using NUTS(diag_e) at Mon May  4 11:15:39 2015.
For each parameter, n_eff is a crude measure of effective sample size,
and Rhat is the potential scale reduction factor on split chains (at
convergence, Rhat=1).
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="bayesian-regression-models-mcmc"&gt;
&lt;h2&gt;Bayesian Regression Models (MCMC)&lt;/h2&gt;
&lt;p&gt;Bayesian regression is more flexible than OLS. We can choose priors that
best represent the data.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Tikhonov_regularization"&gt;Ridge regression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Least_squares#Lasso_method"&gt;Lasso&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;burnin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_samples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Add a column for the intercept (x_0)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;X_1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;column_stack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ones&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;shape&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;  &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;beta_names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;intercept&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt; &lt;span class="c1"&gt;#['beta_{}'.format(i) for i in range(X_1.shape[1])]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;regress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ridge&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;normal&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Model&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;# Priors&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;regression&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ols&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;betas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uniform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;beta&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# &amp;gt;10 is really slow...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;regression&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;ridge&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;betas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tau&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;beta&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;regression&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;lasso&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;betas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Laplace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;beta&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="ne"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;No regression of type &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="c1"&gt;# prior on Normal/T error variance. Gamma(1,1) has mean=1, variance=1&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;# HalfCauchy is better...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;tau&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HalfCauchy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'tau'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;testval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;# Likelihood&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;# mu ~ beta0 + beta1 * x1 + beta2 * x2 + beta3 * x3&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;mu&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;betas&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;X_1&lt;/span&gt;&lt;span class="p"&gt;[:,&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;betas&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;normal&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;y_obs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'y_obs'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tau&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tau&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;T&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;y_obs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'y_obs'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;nu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;mu&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lam&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tau&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;observed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="ne"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;No error model of type &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;# Sample&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_MAP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;starting trace at MAP:&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mf"&gt;.01&lt;/span&gt; &lt;span class="c1"&gt;# avoids some corner cases?&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;step&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NUTS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scaling&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;trace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sample&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num_samples&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;progressbar&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;njobs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="n"&gt;burnin&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="c1"&gt;#pm.traceplot(trace)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;Ordinary Least Squares&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'ols'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;regress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ols&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;normal&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'ols'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#pm.traceplot(trace['ols'])&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;&lt;h1&gt;Ordinary Least Squares&lt;/h1&gt;&lt;/center&gt;&lt;pre class="literal-block"&gt;
starting trace at MAP: {'x2': array(0.16259050929728255), 'x3': array(0.12564858828139785), 'x1': array(0.21839587006704464), 'intercept': array(-1.779530779589083e-08), 'tau': array(1.0740140634338355)}
 [-----------------100%-----------------] 200 of 200 complete in 0.5 sec&amp;lt;MultiTrace: 1 chains, 150 iterations, 5 variables&amp;gt;
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;Ridge Regression&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'ridge/T'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;regress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ridge&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;T&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;traceplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'ridge/T'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;&lt;h1&gt;Ridge Regression&lt;/h1&gt;&lt;/center&gt;&lt;pre class="literal-block"&gt;
starting trace at MAP: {'x2': array(0.1778392943710258), 'x3': array(0.08305421591573277), 'x1': array(0.22367363162561957), 'intercept': array(-0.00609829689854981), 'tau': array(1.3774522554543267)}
 [-----------------100%-----------------] 200 of 200 complete in 0.6 sec
&lt;/pre&gt;
&lt;img alt="linear regression" src="static/Bayesian%20Linear%20Regression_files/Bayesian%20Linear%20Regression_16_2.png" /&gt;
&lt;img alt="linear regression" src="static/Bayesian%20Linear%20Regression_files/Bayesian%20Linear%20Regression_16_3.png" /&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;LASSO&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'lasso/T'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;regress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;lasso&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;T&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;traceplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'lasso/T'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;&lt;h1&gt;LASSO&lt;/h1&gt;&lt;/center&gt;&lt;pre class="literal-block"&gt;
starting trace at MAP: {'x2': array(0.17055991944072316), 'x3': array(0.07282629907667493), 'x1': array(0.21454246999666238), 'intercept': array(-0.0002746999774107022), 'tau': array(1.3787986641723053)}
 [-----------------100%-----------------] 200 of 200 complete in 0.6 sec
&lt;/pre&gt;
&lt;img alt="linear regression" src="static/Bayesian%20Linear%20Regression_files/Bayesian%20Linear%20Regression_17_2.png" /&gt;
&lt;img alt="linear regression" src="static/Bayesian%20Linear%20Regression_files/Bayesian%20Linear%20Regression_17_3.png" /&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;#--------------------------------------------&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Compare PyMC models&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quartiles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;regression&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;quartiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;varnames&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;post_quar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_calculate_posterior_quantiles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;qlist&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quartiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;post_quar&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;post_quar&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;post_stats&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_calculate_stats&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;batches&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;post_stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;post_stats&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;# Graph all models&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;min_beta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quartiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;regression&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;trace&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;max_beta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quartiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;regression&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;trace&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;rh&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;rh2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;svgh&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rh2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;svgw&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;min_beta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_beta&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;min_beta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_normw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;svgw&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max_beta&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;min_beta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;colors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;#DD5C5C &amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#54CD7F&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#54BFFF&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;#44dd99&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;beta&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;beta_names&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;regression&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trace&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;quartiles&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'q75'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'q25'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;xj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'q25'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;yj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rh2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;rh&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'mean'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'lo'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'hi'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;line x1=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{x1:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y1=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{y1:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; x2=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{x2:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y2=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{y2:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; stroke=&amp;quot;#777777&amp;quot; stroke-width=&amp;quot;.5&amp;quot;/&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;x1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;y1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yj&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;rh&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;y2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yj&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;rh&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;rect x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{x:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{y:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{w:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{h:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; fill=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{color:s}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; /&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xj&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_normw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;rh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;rect x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{x:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{y:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; width=&amp;quot;2px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{h:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; fill=&amp;quot;#ffffff&amp;quot; /&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;rh&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{x:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{y:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;middle&amp;quot; dy=&amp;quot;0.3em&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{text}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/text&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xj&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yj&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;rh&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;beta&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;ssvg&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'&amp;lt;text x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{x:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{y:f}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; text-anchor=&amp;quot;end&amp;quot; dy=&amp;quot;0.3em&amp;quot; fill=&amp;quot;#ffffff&amp;quot; font-size=&amp;quot;10&amp;quot;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{text}&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;/text&amp;gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_norm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xj&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;yj&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;rh&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;regression&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;show_html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;h1&amp;gt;Analysis of the difference between different regressions&amp;lt;/h1&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;show_svg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ssvg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;svgw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;svgh&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;center&gt;&lt;h1&gt;Analysis of the difference between different regressions&lt;/h1&gt;&lt;/center&gt;&lt;object data="static/Bayesian%20Linear%20Regression_files/Bayesian%20Linear%20Regression_18_1.svg" type="image/svg+xml"&gt;linear regression&lt;/object&gt;
&lt;/div&gt;
</content><category term="data"/><category term="data analysis"/><category term="bayesian"/><category term="ipython"/><category term="regression"/><category term="mcmc"/></entry><entry><title>Kruschke's Doing Bayesian Data Analysis with PyMC3 in an IPython notebook</title><link href="/kruschke_in_pymc3.html" rel="alternate"/><published>2015-04-19T11:00:00-07:00</published><updated>2015-04-19T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-04-19:/kruschke_in_pymc3.html</id><summary type="html">&lt;p class="first last"&gt;Kruschke's Doing Bayesian Data Analysis with PyMC3 in an IPython notebook&lt;/p&gt;
</summary><content type="html">&lt;p&gt;This &lt;a class="reference external" href="https://github.com/aloctavodia/Doing_bayesian_data_analysis"&gt;github repository&lt;/a&gt; has all of the exercises from Kruschke's
Doing Bayesian Data Analysis book translated from R to Python/PyMC3.&lt;/p&gt;
&lt;p&gt;I transferred the code into a giant &lt;a class="reference external" href="http://nbviewer.ipython.org/gist/hgbrian/9290e45b05f68291e545#"&gt;IPython notebook&lt;/a&gt;.&lt;/p&gt;
</content><category term="data"/><category term="data analysis"/><category term="bayesian"/><category term="ipython"/><category term="notebook"/><category term="jupyter"/><category term="kruschke"/><category term="pymc3"/></entry><entry><title>UK Biobank, NIH Data Science</title><link href="/uk_biobank_nih_data_science.html" rel="alternate"/><published>2015-04-14T11:00:00-07:00</published><updated>2015-04-14T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-04-14:/uk_biobank_nih_data_science.html</id><summary type="html">&lt;p class="first last"&gt;News about UK Biobank and NIH's new big data site&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="uk-biobank"&gt;
&lt;h2&gt;UK Biobank&lt;/h2&gt;
&lt;p&gt;UK Biobank now allows researchers to request genotype data for their studies.
Data from the first 150,000 individuals (of 500,000 total) will be released in May,
with the rest coming toward the end of the year.
The data comes from a 800k Affymetrix Axiom chip, which, unlike the Affy chips of old,
produces good quality data. You can also request imputed whole genomes, which will be
huge for many kinds of GWAS.
You can check to see if they have your SNP of interest &lt;a class="reference external" href="http://biobank.ctsu.ox.ac.uk/crystal/gsearch.cgi"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="nih-data-science"&gt;
&lt;h2&gt;NIH Data Science&lt;/h2&gt;
&lt;p&gt;NIH has launched a new &lt;a class="reference external" href="https://datascience.nih.gov/"&gt;data science site&lt;/a&gt;.
This new site incorporates the old BD2K (&amp;quot;Big Data to Knowledge&amp;quot;) site, which is going away.
This seems like a positive indicator for funding opportunities in data science,
though I don't see any direct indication of that on this site.&lt;/p&gt;
&lt;/div&gt;
</content><category term="data"/><category term="biobanks"/><category term="uk biobank"/><category term="big data"/><category term="data science"/><category term="nih"/></entry><entry><title>BIIB037: Analyzing Biogen's Alzheimer's drug data</title><link href="/biib037_analyzing_biogens_alzheimers_drug_data.html" rel="alternate"/><published>2015-03-24T11:00:00-07:00</published><updated>2015-03-24T11:00:00-07:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-03-24:/biib037_analyzing_biogens_alzheimers_drug_data.html</id><summary type="html">&lt;p class="first last"&gt;An IPython notebook exploring some Phase Ib data from Biogen on their Alzheimer's drug.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Last week, Biogen released some Phase Ib data for their Alzheimer's
drug, Aducanumab (BIIB037). I don't know too much about how these
issuances work, but it's bizarre to me that you can show a chart at a
conference, and not the actual data, and yet the information increases
Biogen's value by billions of dollars. Maybe someone has access to the
raw data, but I can't find it --- that sounds illegal for a public
company anyway.&lt;/p&gt;
&lt;p&gt;Since there is a lot of money at stake, there are people on Wall Street
reanalyzing the data, though not publicly. I found an interesting
example from Morgan Stanley here:
&lt;a class="reference external" href="http://www.investorvillage.com/smbd.asp?mb=2793&amp;amp;mn=414&amp;amp;pt=msg&amp;amp;mid=14782583"&gt;http://www.investorvillage.com/smbd.asp?mb=2793&amp;amp;mn=414&amp;amp;pt=msg&amp;amp;mid=14782583&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On Twitter, there was some skepticism about the data that piqued my
interest. Someone said they didn't trust the data because just a few
patients changing tack could change the results. It sounds plausible,
but it's not obvious how to quantify that. Others said the experiment
was underpowered; with about 20 patients per arm of the study, that also
sounds plausible.&lt;/p&gt;
&lt;p&gt;I decided to take a look at the data to see if there is anything more
quantitative to say.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;# This cell is just setup&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;__future__&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;division&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;print_function&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;IPython.display&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;numpy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;np&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pandas&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pd&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;random&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;pprint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pprint&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;matplotlib&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;pyplot&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;seaborn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;sns&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;set_style&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;whitegrid&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;lt;!DOCTYPE svg PUBLIC &amp;quot;-//W3C//DTD SVG 1.1//EN&amp;quot; &amp;quot;http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd&amp;quot;&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;-&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;astr&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;matplotlib&lt;/span&gt; &lt;span class="n"&gt;inline&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="n"&gt;InlineBackend&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;figure_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'retina'&lt;/span&gt;
&lt;/pre&gt;
&lt;div class="section" id="parsing-data-from-slides"&gt;
&lt;h2&gt;Parsing data from slides&lt;/h2&gt;
&lt;p&gt;I found some slides from Biogen's talk here
(&lt;a class="reference external" href="http://www.biospace.com/News/biogen-idec-slides-for-alzheimers-drug-wow/369620/"&gt;http://www.biospace.com/News/biogen-idec-slides-for-alzheimers-drug-wow/369620/&lt;/a&gt;).
They look like they were taken by someone in the audience with a
cellphone.&lt;/p&gt;
&lt;p&gt;I thought the data from a slide on reduction in SUVR (a measure of
plaque volume in the brain) looked the meatiest. They also showed data
from MMSE and CDR-SB (paper-based tests), and a couple of other slides
on plaque volume. For my purposes, I think it's reasonable just to test
the assumption that the drug reduces plaque volume, not that it improves
cognition.&lt;/p&gt;
&lt;p&gt;I used Photoshop's awesome perspective crop tool to&amp;nbsp;correct for the
perspective on these charts. Then I used SVG to manually determine the
values in the chart. Not terribly sophisticated, but I think it works as
well as anything else out there; it's flexible and only a few lines of
code.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;IWH&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;805&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;596&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# image dimensions after crop&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;162&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;242&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;totalwh&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;604&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;238&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;totaly&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;0.3&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;46&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# week, dose, num, xy, wh, se&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;35&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;   &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;81&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;127&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;69&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;173&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;112&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;219&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;162&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;334&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;   &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;380&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;44&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;  &lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;426&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;110&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;472&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;    &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;21&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;518&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;210&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;rect x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; fill=&amp;quot;#ffff00&amp;quot; fill-opacity=&amp;quot;0.05&amp;quot; /&amp;gt;
        '''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;box&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;'''&amp;lt;rect x=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; stroke=&amp;quot;#ff0000&amp;quot; fill=&amp;quot;none&amp;quot; /&amp;gt;
        &amp;lt;line x1=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y1=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; x2=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; y2=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s1"&gt;&amp;quot; stroke=&amp;quot;#00ffff&amp;quot; /&amp;gt;
        '''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                   &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                   &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;xy&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;wh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SVG_HEAD&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;&amp;lt;svg width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s2"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s2"&gt;px&amp;quot; version=&amp;quot;1.1&amp;quot;
     xmlns=&amp;quot;http://www.w3.org/2000/svg&amp;quot; xmlns:xlink= &amp;quot;http://www.w3.org/1999/xlink&amp;quot;&amp;gt;
    &amp;lt;image xlink:href=&amp;quot;biospace-news-biogen-idec-2.png&amp;quot; x=&amp;quot;0&amp;quot; y=&amp;quot;0&amp;quot; width=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s2"&gt;px&amp;quot; height=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{:d}&lt;/span&gt;&lt;span class="s2"&gt;px&amp;quot;/&amp;gt;
    &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/svg&amp;gt;&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IWH&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;IWH&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;IWH&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;IWH&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                          &lt;span class="n"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;totalwh&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;box&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;dat&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="n"&gt;SVG&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;svg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;object data="static/BIIB037_files/BIIB037_3_0.svg" type="image/svg+xml"&gt;&lt;/object&gt;
&lt;/div&gt;
&lt;div class="section" id="data"&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;Now I can map these hand-drawn rectangles onto numbers, using the
transparent yellow box as a reference. Unfortunately, there is no data
for Week 54 / 6 mg/kg.&lt;/p&gt;
&lt;p&gt;Based on these means and standard deviations, I can generate example
values, maximizing the entropy since I want these values to represent
only what I know from the chart. Here, this just means assuming a normal
distribution. In reality, it's unlikely to be normal, since there are
obviously important covariates like APOE e4 status.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;format_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;Week&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;Dose&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;Num&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;Mean&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s2"&gt;SD&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; \
        &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{:.3f}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{:.3f}&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;tdata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;dat&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;totaly&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;totalwh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;sd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mf"&gt;.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nb"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;totaly&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;totalwh&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;tdata&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;dat&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sd&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;tdata&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;format_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Week        Dose    Num     Mean    SD
26  0       34      -0.006  0.110
26  1       26      -0.033  0.096
26  3       27      -0.087  0.098
26  6       23      -0.141  0.103
26  10      27      -0.204  0.105
54  0       21      -0.000  0.098
54  1       21      -0.055  0.104
54  3       26      -0.139  0.103
54  6       0       -0.000  0.000
54  10      21      -0.265  0.098
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;tdata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_gen_random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;normal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;e_vals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;example_vals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tdata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# sd != 0&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;e_vals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_gen_random&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;example_vals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e_vals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Example values generated from chart data&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;pprint&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;example_vals&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;()})&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Example values generated from chart data
----------------------------------------
{(26, 0): array([-0.19925843, -0.17029101,  0.11315593, -0.01056504]),
 (26, 1): array([ 0.03167159, -0.07239358, -0.00892414,  0.07187854]),
 (26, 3): array([-0.10161264, -0.01548505, -0.02418133, -0.00441314]),
 (26, 6): array([-0.14738112, -0.29103252, -0.13790777,  0.11396582]),
 (26, 10): array([-0.11370946, -0.04119348, -0.25958697,  0.06817597]),
 (54, 0): array([ 0.12597653, -0.01024324,  0.08792991, -0.03493747]),
 (54, 1): array([ 0.01815586, -0.18449709, -0.11815812, -0.14284047]),
 (54, 3): array([-0.46736124, -0.15305449, -0.23322862, -0.20419422]),
 (54, 10): array([-0.34687603, -0.23872551, -0.33569562, -0.11804706])}
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="t-test"&gt;
&lt;h2&gt;t-test&lt;/h2&gt;
&lt;p&gt;Now that I have some values, I can run t-tests and see if my p-values
agree with the p-values in the chart. The chart only indicates whether
or not their statistical test produced p-values of less than 0.05 (*),
0.01 (**), or 0.001 (***).&lt;/p&gt;
&lt;p&gt;The results generally agree pretty well with the chart. In fact, the
first time I ran this code, they agreed completely. Again, covariates
are bound to matter here.&lt;/p&gt;
&lt;p&gt;At the bottom of the slide it explains that the data were analyzed with
an ANCOVA (like ANOVA with covariates). Each dose of the drug is also
compared pair-wise to the placebo to get a p-value per dose. The
statistical test they used to get their p-values is not mentioned, but
if were from a two-group ANCOVA, it should produce similar results to a
t-test.&lt;/p&gt;
&lt;p&gt;The big caveats are that I don't have access to the listed covariates
and I don't know the true distribution of effect sizes.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scipy.stats&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;itertools&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;permutations&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_stars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pval&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;stars&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="mf"&gt;.001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;***&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;**&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;*&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inf&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;stars&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;pval&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Pairwise t-test p-values&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;wk&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;uprint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Week &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;dose1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose2&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;permutations&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;wk&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;54&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dose1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt; &lt;span class="c1"&gt;# no data for 54/6&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;_pvals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e_vals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose1&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;e_vals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose2&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;_pvals&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v2&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="n"&gt;pval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_pvals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# arithmetic mean&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt; vs &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{:.4f}&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dose1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dose2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pval&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_stars&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pval&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="literal-block"&gt;
Pairwise t-test p-values
------------------------
Week 26
-------
0 vs 1      0.3751
0 vs 3      0.0497  *
0 vs 6      0.0022  **
0 vs 10     0.0000  ***
1 vs 3      0.1364
1 vs 6      0.0132  *
1 vs 10     0.0000  ***
3 vs 6      0.1619
3 vs 10     0.0032  **
6 vs 10     0.1066
Week 54
-------
0 vs 1      0.1441
0 vs 3      0.0013  **
0 vs 10     0.0000  ***
1 vs 3      0.0411  *
1 vs 10     0.0000  ***
3 vs 10     0.0087  **
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="robustness"&gt;
&lt;h2&gt;Robustness&lt;/h2&gt;
&lt;p&gt;How sensitive are these results to changes in the data? It's not obvious
to me what the best way to test this is, especially without the real
data. One simple way to test robustness is by zeroing some fraction of
the data. In other words, for some fraction of patients, make it so that
the drug has zero effect.&lt;/p&gt;
&lt;p&gt;Here, I artificially zero from 0 to 100% of the plaque volume values,
and plot the p-values for each dose.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;itertools&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;zeros&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;arange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;1.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;wks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;54&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="n"&gt;pvals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wks&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;doses&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;wk&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;54&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;dose&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;zero&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;zeros&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;pvals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;zero&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;v0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e_vals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;e_vals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;vd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;zero&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;vd&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;pvals&lt;/span&gt;&lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;dose&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;zero&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;ttest_ind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vd&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;from_dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pvals&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;color_map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;indianred&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;darkseagreen&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;steelblue&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;purple&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;wk&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;wks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ax&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;subplots&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;figsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Week &lt;/span&gt;&lt;span class="si"&gt;{}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;dose&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;doses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;wk&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;54&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;dose&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tsplot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;dose&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;wk&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;dose&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;condition&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;dose&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;color_map&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ylim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xlabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;fraction zeroed&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ylabel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;log(pvalue)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;axhline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.05&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linestyle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'--'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gray&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;0.05&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.05&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;p=0.05&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;fontsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gray&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;axhline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.01&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linestyle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'--'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gray&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;0.01&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.01&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;p=0.01&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;fontsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gray&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;axhline&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.001&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;linestyle&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'--'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gray&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;0.001&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.01&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;.001&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;p=0.001&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;fontsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;gray&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;img alt="BIIB037" src="static/BIIB037_files/BIIB037_10_0.png" /&gt;
&lt;img alt="BIIB037" src="static/BIIB037_files/BIIB037_10_1.png" /&gt;
&lt;/div&gt;
&lt;div class="section" id="results"&gt;
&lt;h2&gt;Results&lt;/h2&gt;
&lt;p&gt;The results graph shows that you would need to zero out about 20-40% of
the data for the results to move down a p-value category (e.g., from
0.01 to 0.05).&lt;/p&gt;
&lt;p&gt;Another way to think about that is you would have to have 4-10 patients
in an arm of the study who, instead of responding, did not respond at
all.&lt;/p&gt;
&lt;p&gt;While that doesn't seem implausible, if it happened, only one of the
five significant p-values in the graph would be affected. Hence, I think
the results as presented are pretty robust to patients switching to
non-responders.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="power-and-priors"&gt;
&lt;h2&gt;Power and priors&lt;/h2&gt;
&lt;p&gt;Is the study underpowered? Since it's a phase Ib, it's almost by
definition underpowered to detect treatment effects. However, it also
depends a lot on your prior for an Alzheimer's drug working. If these
data were not for Alzheimer's, but something more innocuous, it might
not be called underpowered.&lt;/p&gt;
&lt;p&gt;The prior could include the general lack of success of Alzheimer's
drugs, but also intangibles such as potential data-dredging, unconscious
biases, generally bad science (see Ioannidis), the huge amount of money
at stake, and maybe (as someone suggested) even the age of the CEO.&lt;/p&gt;
&lt;p&gt;The prior could also include investor confidence. A JPM survey gave this
drug about a 35% chance of approval
(&lt;a class="reference external" href="https://twitter.com/TylerHCanalyst/status/578219628054347776/photo/1"&gt;https://twitter.com/TylerHCanalyst/status/578219628054347776/photo/1&lt;/a&gt;),
where the general probability of any drug being approved after phase I
is about 15%
(&lt;a class="reference external" href="http://pharmamarketresearchconference.com/files/Clinical_Development_Success_Rates_for_Investigational_Drugs.pdf"&gt;http://pharmamarketresearchconference.com/files/Clinical_Development_Success_Rates_for_Investigational_Drugs.pdf&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="should-i-buy"&gt;
&lt;h2&gt;Should I buy?&lt;/h2&gt;
&lt;p&gt;Obviously, I have no idea. The stock is already up about 30% since
January though (when preliminary data appeared) and about 10% this week,
so maybe only if you think the probability of approval is well above
35%.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;Image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;biib037_survey.png&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;img alt="BIIB037" src="static/BIIB037_files/BIIB037_13_0.png" /&gt;
&lt;/div&gt;
</content><category term="data"/><category term="data analysis"/><category term="bayesian"/><category term="ipython"/><category term="alzheimer"/><category term="biogen"/><category term="drugs"/></entry><entry><title>Choosing a website PaaS: AWS, Azure, Google, etc.</title><link href="/website_paas.html" rel="alternate"/><published>2015-01-30T12:00:00-08:00</published><updated>2015-01-30T12:00:00-08:00</updated><author><name>Brian Naughton</name></author><id>tag:None,2015-01-30:/website_paas.html</id><summary type="html">&lt;p class="first last"&gt;Choosing a website PaaS: AWS, Azure, Google, etc.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;These days, I think it generally makes sense to put your website on some kind of
PaaS (platform as a service) instead of hosting it yourself.
That way, you don't have to worry so much about security patches, scaling, server uptime, etc.&lt;/p&gt;
&lt;p&gt;I have tried a few PaaS before, but the space has evolved a lot recently,
so I have been reviewing a bit to find the best choice for my needs.&lt;/p&gt;
&lt;p&gt;I am looking for a PaaS that
(a) is cheap to try out so I can get a quick idea of whether I like it;
(b) is mature and supported long-term;
(c) can run any random binary I might need (with which bioinformatics is lousy);
(d) has support for Docker (just in case that becomes more of a standard);
(e) is capable of running on its own hosted platform or my own AWS server.&lt;/p&gt;
&lt;div class="section" id="s3"&gt;
&lt;h2&gt;S3&lt;/h2&gt;
&lt;p&gt;I am including S3 since I've used it for a bunch of websites, including this blog.
It's great — it just sits there hosting your site and never breaking down.
It's also super-cheap, in that you only pay for bandwidth, and it scales as much as you like.
Of course, the catch is that there is no server, so everything has to be static.
However, since you can upload to S3 from JS, static is not that static...
It's also a great place to dump all your static files — there is no point having your webserver
serve those.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="google-app-engine"&gt;
&lt;h2&gt;Google App Engine&lt;/h2&gt;
&lt;p&gt;I think of GAE as being one level up from S3.
GAE is a real pleasure to use, especially for small projects — I think more people should try it.
Snapchat was built on top of GAE, and that seemed to work out ok.
Generally, it's an awesome backend to a mobile app.
As an example, I wrote a webapp on GAE that stores and retrieves images uploaded from a website:
it is free, scales if I need it to, and it's only a hundred lines of Python code!
Another free GAE instance I have handles tens of thousands of requests a day.
The catch with GAE is that you don't have access to the server so you can't run whatever you want.
Basically, you end up only running Python/Java/Go code you wrote yourself.
The other catch is that you have to run your code in an unusual GAE-specific way to make it work efficiently.
That's not so bad, except that this knowledge doesn't really translate to other platforms.
You can now run GAE apps on Google Compute Engine, so it is becoming more flexible, but
I haven't tried that.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="heroku"&gt;
&lt;h2&gt;Heroku&lt;/h2&gt;
&lt;p&gt;I once used heroku for a small &lt;a class="reference external" href="www.emailwhere.com"&gt;experiment&lt;/a&gt; that GAE could not handle
(it had to keep a connection open so it used gunicorn; I also needed ImageMagick).
It was a nice experience — easy to set up and use and you could include
add-ons like redis, sendgrid, etc by just clicking a button.
You can run random binaries if you need them, but it's not officially supported.
Heroku has a free tier but in general it's quite expensive.
Heroku is probably the most popular PaaS, it's owned by VMWare so it's well-supported,
and generally gets excellent reviews.
The biggest problems are cost and lock-in:
ideally, I'd like to be able to deploy the same website on AWS without heroku if I needed to
(for example, let's say you needed your data to be stored in a HIPAA environment on AWS).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="openshift"&gt;
&lt;h2&gt;OpenShift&lt;/h2&gt;
&lt;p&gt;OpenShift is an interesting, new-ish PaaS.
I hadn't heard of it before, and even though both are from RedHat,
it is not really related to OpenStack (which is like an open-source AWS).
OpenShift has a lot going for it:
it's cheap to try out (you get three ''gears'' for free),
it has pretty good &lt;a class="reference external" href="https://blog.openshift.com/the-future-of-openshift-and-docker-containers/"&gt;support for Docker&lt;/a&gt;,
it is open-source (as OpenShift Origin),
and it's run by RedHat, a well-regarded, well-capitalized company.
First impressions are good.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="elastic-beanstalk"&gt;
&lt;h2&gt;Elastic Beanstalk&lt;/h2&gt;
&lt;p&gt;Elastic Beanstalk is AWS' version of a PaaS.
It's one of the thirty or so services you see when you log in to the AWS command center.
It is not as friendly as a true PaaS:
you can't click a button and have a redis instance just appear, for example.
The big advantage of EB is that you're on AWS, so you know it's run properly,
you have a lot of flexibility,
and you benefit from easy integration with AWS' many other services
(their push notification service is great, for example).
However, for me, Elastic Beanstalk looks to be a bit too &lt;a class="reference external" href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/GettingStarted.Walkthrough.html"&gt;heavyweight&lt;/a&gt;.
AWS is also pretty expensive to test out, especially if you've already used up your free
micro instance like I have...&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="azure-websites"&gt;
&lt;h2&gt;Azure websites&lt;/h2&gt;
&lt;p&gt;Microsoft's Azure cloud is actually pretty massive, even though I think of it as a new player.
It's much bigger than Google's cloud business and second only to AWS.
They have an AWS competitor, obviously, but they also have an interesting PaaS
called &lt;a class="reference external" href="http://azure.microsoft.com/en-us/services/websites/"&gt;Azure websites&lt;/a&gt;.
Azure websites was a bit of a revelation:
to create a flask-based website, you just click a couple of buttons.
You can then quickly edit the code in your browser using Visual Studio Online(!),
click &amp;quot;run&amp;quot; and there you have your own website that will scale up as much as you want.
Even though it's a Microsoft product, it has support for Python, node.js, git, etc.
Best of all, it's free for up to ten websites (assuming low bandwidth of course).
Azure websites looks fantastic for simple websites or servers.&lt;/p&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="azure" src="/images/azure.png" style="width: 600px;" /&gt;
&lt;/div&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="azure" src="/images/azure2.png" style="width: 600px;" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="new-fangled-docker-y-paas"&gt;
&lt;h2&gt;New-fangled Docker-y PaaS&lt;/h2&gt;
&lt;p&gt;Apparently, Docker-based PaaS is the &amp;quot;&lt;a class="reference external" href="http://thenewstack.io/docker-is-driving-a-new-breed-of-paas/"&gt;third wave&lt;/a&gt;&amp;quot; of PaaS.
If it's anything like coffee, that will be a very good thing.
The players here (Deis, Flynn, Tsuru, Dawn, Octohost, according to the linked article)
seem to be pretty small and minimalist.
This is more like roll-your-own PaaS, so it's too hands-on for me (Dawn is just a github repository).
For now, these services are too immature for me, but it will be interesting to see if
a new generation of PaaS really emerges.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="so-openshift-then"&gt;
&lt;h2&gt;So... OpenShift then?&lt;/h2&gt;
&lt;p&gt;The above list is just the PaaS I already knew about or thought might work for me.
There are a bunch of other interesting ones out there like Stackato, dotCloud,
Cloud Foundry, etc.&lt;/p&gt;
&lt;p&gt;The PaaS that seems to best fit my criteria is OpenShift, so I'm going to try it out
and see how it goes.&lt;/p&gt;
&lt;/div&gt;
</content><category term="company"/><category term="website"/><category term="PaaS"/><category term="docker"/><category term="GAE"/></entry><entry><title>Human genetics and drug discovery</title><link href="/human%20genetics%20and%20drug%20discovery.html" rel="alternate"/><published>2015-01-25T12:00:00-08:00</published><updated>2015-01-25T12:00:00-08:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2015-01-25:/human genetics and drug discovery.html</id><summary type="html">&lt;p class="first last"&gt;Human genetics and drug discovery&lt;/p&gt;
</summary><content type="html">&lt;p&gt;This &lt;a class="reference external" href="https://twitter.com/eperlste/status/559457044629958656"&gt;twitter conversation&lt;/a&gt; is a nice microcosm of what's going on in drug discovery.
On the human genetics side, we have Robert Plenge, Daniel MacArthur, Amgen and Regeneron,
who believe sequencing humans will be the key to better drugs (a la PCSK9).
On the model organism side, we have Ethan Perlstein
(and certainly others, perhaps Roger Perlmutter from Merck?),
who think that the human sequencing stuff is overblown.&lt;/p&gt;
&lt;p&gt;In the end, there's not too much disagreement:
humans are good for target discovery,
model organisms can be useful models of those targets.&lt;/p&gt;
</content><category term="science"/><category term="twitter"/><category term="genetics"/><category term="drugs"/></entry><entry><title>Biobanks</title><link href="/biobanks.html" rel="alternate"/><published>2015-01-06T12:00:00-08:00</published><updated>2015-01-06T12:00:00-08:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2015-01-06:/biobanks.html</id><summary type="html">&lt;p class="first last"&gt;Biobanks: applying for data and samples&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Over the couple of months I've formally applied to or contacted several biobanks
to inquire about access to data and samples.&lt;/p&gt;
&lt;div class="section" id="kaiser-rpgeh-biobank"&gt;
&lt;h2&gt;Kaiser RPGEH biobank&lt;/h2&gt;
&lt;p&gt;Kaiser's biobank is large, at 200k samples, but only 20k are blood samples, and the rest saliva.
Eventually, they plan to reach 500k, but I assume most of these will be saliva too.
Kaiser has a well-structured application process designed for collaborations.
The one downside is that it's pretty long and complex, as the flowchart below shows.
I submitted a &amp;quot;pre-application&amp;quot;, which is a three or four page form, including
a few thousand words describing the project.
I now have to wait for Kaiser to match me with a researcher on their side.&lt;/p&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="flowchart" src="/images/Summary+Review+Process+Flow+Chart.png" style="width: 400px;" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="vanderbilt-biovu"&gt;
&lt;h2&gt;Vanderbilt BioVU&lt;/h2&gt;
&lt;p&gt;Vanderbilt's biobank is also large at 180k samples and, since it's tied to
Vanderbilt's EMR, the phenotype data is rich.
However, to do any research with BioVU, you need to first identify a collaborator at
Vanderbilt. It seems like one of the major goals of the biobank is to generate
collaborations.
BioVU is part of the &lt;a class="reference external" href="http://emerge.mc.vanderbilt.edu/about-emerge-network#Mount%20Sinai"&gt;eMERGE network&lt;/a&gt;, a group of biobanks that include EMR data
and genotype data.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="mount-sinai-biome"&gt;
&lt;h2&gt;Mount Sinai BioME&lt;/h2&gt;
&lt;p&gt;Mount Sinai has 30k &lt;a class="reference external" href="http://icahn.mssm.edu/research/institutes/institute-for-personalized-medicine/innovation-and-technology/biome-platform/biome-facts"&gt;samples&lt;/a&gt;, and like Vanderbilt, it's part of the eMERGE network.
They have a portal called &lt;a class="reference external" href="https://pmrc.med.mssm.edu/biobank/service/"&gt;BioSERVE&lt;/a&gt;, but it is down at the time of writing.
Like Vanderbilt, you really need a collaborator to help you navigate this one.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="estonian-biobank"&gt;
&lt;h2&gt;Estonian Biobank&lt;/h2&gt;
&lt;p&gt;The Estonian Biobank has 50k samples and the population is skewed quite old
(perhaps 10% over 80). Unfortunately, only 15k of their samples are genotyped.
The Estonians have a refreshingly straightforward application form and process for data access.&lt;/p&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="data" src="/images/estonia_data_release.png" style="width: 400px;" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="china-kadoorie-biobank"&gt;
&lt;h2&gt;China Kadoorie Biobank&lt;/h2&gt;
&lt;p&gt;The China Kadoorie biobank is one of several international biobanks that are
administered from Oxford. The biobank is 500k samples
and they had BGI genotype 100k samples with a 384 SNP panel.
The content of the panel is sadly &lt;a class="reference external" href="http://www.ckbiobank.org/site/Resources/Genotyping+Data"&gt;unspecified&lt;/a&gt;.
The CKB application process is pretty straightforward and they have a lot of
&lt;a class="reference external" href="http://www.ckbiobank.org/site/Research/Projects"&gt;projects&lt;/a&gt; underway. The recommended first step with CKB is an informal inquiry by email,
so that's what I did.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="uk-biobank"&gt;
&lt;h2&gt;UK Biobank&lt;/h2&gt;
&lt;p&gt;The UK biobank is large at 500k samples, and ostensibly open to biotech collaborations.
It's also possibly the best phenotyped, although I believe no EMR data is included.
However, UK Biobank are yet to genotype their samples,
and the oldest participants are only 69 — an odd restriction on an otherwise amazing dataset
and the major reason I have not applied here.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="other-biobanks"&gt;
&lt;h2&gt;Other biobanks&lt;/h2&gt;
&lt;p&gt;There are a number of other biobanks out there, with varying degrees of obfuscation
of what's actually in the bank and how to get access.
I think this will improve over time, but meanwhile, I'd love to figure out which
biobanks are really open and which are not.&lt;/p&gt;
&lt;/div&gt;
</content><category term="data"/><category term="biobank"/></entry><entry><title>BEST Bayesian t-test</title><link href="/best%20t-test.html" rel="alternate"/><published>2015-01-05T12:00:00-08:00</published><updated>2015-01-05T12:00:00-08:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2015-01-05:/best t-test.html</id><summary type="html">&lt;p class="first last"&gt;BEST is a Bayesian t-test&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Kruschke, the author of &lt;a class="reference external" href="https://sites.google.com/site/doingbayesiandataanalysis/"&gt;Doing Bayesian Data Analysis&lt;/a&gt;,
has a Bayesian t-test called &lt;a class="reference external" href="http://www.indiana.edu/~kruschke/BEST/"&gt;BEST&lt;/a&gt;.
There is a really nice implementation of it in &lt;a class="reference external" href="http://www.sumsar.net/best_online/"&gt;javascript&lt;/a&gt; by Rasmus Bååth.&lt;/p&gt;
</content><category term="data"/><category term="statistics"/><category term="bayesian"/></entry><entry><title>OneStart 2015</title><link href="/onestart.html" rel="alternate"/><published>2014-12-24T12:00:00-08:00</published><updated>2014-12-24T12:00:00-08:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-12-24:/onestart.html</id><summary type="html">&lt;p class="first last"&gt;OneStart&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Boolean Biotech was fortunate to have been included as a semi-finalist in
Oxford Biotech Roundtable's OneStart competition.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://onestart.co/update/onestart-2015-semi-finalists-announced"&gt;http://onestart.co/update/onestart-2015-semi-finalists-announced&lt;/a&gt;&lt;/p&gt;
</content><category term="company"/><category term="competition"/><category term="onestart"/></entry><entry><title>Mixture of Gaussians in PyMC3</title><link href="/mixture_of_gaussians_in_pymc3.html" rel="alternate"/><published>2014-11-16T11:00:00-08:00</published><updated>2014-11-16T11:00:00-08:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-11-16:/mixture_of_gaussians_in_pymc3.html</id><summary type="html">&lt;p class="first last"&gt;How to make a Gaussian Mixture Model in PyMC3&lt;/p&gt;
</summary><content type="html">&lt;iframe src="/static/Mixture of Gaussians in PyMC3.html" width="100%" height="13000px"&gt;&lt;/iframe&gt;</content><category term="data"/><category term="data"/><category term="pymc3"/></entry><entry><title>Analyzing Sequencing Read Errors with PyMC3</title><link href="/pymc3_sequencing.html" rel="alternate"/><published>2014-11-11T11:00:00-08:00</published><updated>2014-11-11T11:00:00-08:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-11-11:/pymc3_sequencing.html</id><summary type="html">&lt;p class="first last"&gt;Analyzing sequencing read errors with PyMC3&lt;/p&gt;
</summary><content type="html">&lt;p&gt;I recently watched a couple of videos about the new PyMC (&lt;a class="reference external" href="https://github.com/pymc-devs/pymc/tree/pymc3"&gt;PyMC3&lt;/a&gt;), and they got me
pretty excited about it
(one from &lt;a class="reference external" href="http://vimeo.com/79518830"&gt;Thomas Wiecki&lt;/a&gt; and one from &lt;a class="reference external" href="https://www.youtube.com/watch?v=XbxIo7ScVzc"&gt;Chris Fonnesbeck&lt;/a&gt;, both core developers.)&lt;/p&gt;
&lt;p&gt;I've used PyMC2 a little bit, but this new version is a complete rewrite.
It now uses Theano as a backend, which helps with computing gradients,
but it also means PyMC3 is now pure Python, where previously it had a bunch of Fortran.
It also seems to be better integrated with the current state-of-the-art tools,
like pandas and scikit.&lt;/p&gt;
&lt;p&gt;PyMC 3 is alpha software, so it has bugs and little documentation,
but it's nice to get some exposure to Theano and NUTS
(my favorite Python distribution, &lt;a class="reference external" href="http://continuum.io/"&gt;Anaconda&lt;/a&gt;, includes Theano by default.)&lt;/p&gt;
&lt;p&gt;At the same time, I've was playing around with some example sequencing data from
the &lt;a class="reference external" href="http://clip.med.yale.edu/presto/"&gt;pRESTO&lt;/a&gt; toolkit so I thought I would try to apply PyMC3 to these data.&lt;/p&gt;
&lt;p&gt;Every sequencing read gives you a DNA sequence, but also an estimate of the error for
every nucleotide.
The sequencing read files are in fastq format, which means that the quality information
is encoded like this:&lt;/p&gt;
&lt;blockquote&gt;
?????BBBDDDDHEHHIHHHHCGH?DGHHHEECCEEFECEFEEFFE;&amp;gt;DDD?A:CAEEAE?&lt;/blockquote&gt;
&lt;p&gt;It looks awful, but I guess if you really need to use a text file that's how it has to work.
You can map these characters onto a quality (&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Phred_quality_score"&gt;Phred&lt;/a&gt;) score in Python with a simple ord(c)-33.
You can then map that onto expected number of errors by taking 10^(-v/10).&lt;/p&gt;
&lt;p&gt;I decided to look at read quality as a function of read-length using PyMC3.&lt;/p&gt;
&lt;iframe src="/static/PyMC3 sequencing errors.html" width="100%" height="6000px"&gt;&lt;/iframe&gt;</content><category term="data"/><category term="bayesian"/><category term="pymc"/><category term="sequencing"/></entry><entry><title>SBIR Data</title><link href="/sbir_trends_data.html" rel="alternate"/><published>2014-10-20T11:00:00-07:00</published><updated>2014-10-20T11:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-10-20:/sbir_trends_data.html</id><summary type="html">&lt;p class="first last"&gt;SBIR Data&lt;/p&gt;
</summary><content type="html">&lt;p&gt;I downloaded all SBIR award data using the &lt;a class="reference external" href="http://www.sbir.gov/about/api"&gt;SBIR API&lt;/a&gt;
to see if there are any noteworthy trends.
The examples below are manually cherry-picked after some simple data-analysis.&lt;/p&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="SBIR" src="/images/sbir.HHS.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="SBIR" src="/images/sbir_amounts.HHS.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;p&gt;HHS is the biggest distributor of SBIR grants, followed, perhaps surprisingly,
by the US Air Force, the Navy and the Army.
Anything to do with health is likely to go through HHS.&lt;/p&gt;
&lt;p&gt;There are notable increases in mobile, diabetes, adherence
(&amp;quot;a mobile app that tracks your glucose levels and alerts you...&amp;quot;)
as well as various kinds of sequencing
(&amp;quot;with the explosion in DNA sequencing bandwidth, new opportunities arise in...&amp;quot;).&lt;/p&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="NSF" src="/images/sbir.NSF.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="SBIR" src="/images/sbir_amounts.NSF.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;p&gt;NSF is much much smaller than HHS, and has a greater focus on primary science and
(somewhat contradictorily) commercialization.
According to NSF, they are also apt to fund riskier projects than HHS.&lt;/p&gt;
&lt;p&gt;There is nothing too unexpected here: mobile again, battery technology, imaging
— and everybody loves a platform these days.
I do wonder if the increase in SBIRs mentioning &amp;quot;drug&amp;quot; means anything.&lt;/p&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="SBIR" src="/images/sbir.DOE.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="SBIR" src="/images/sbir_amounts.DOE.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;p&gt;The Department of Energy funds a surprisingly large number of bio- projects.
The most obvious intersection of bio and energy is biofuels, and DoE is obviously
the place to fund that.
DoE also funds quite a lot in primary genomics — for example the JGI.
Energy is such a huge industry that even a small fraction of its research money
can have a big influence.&lt;/p&gt;
&lt;p&gt;Again, I think the keywords are mostly as expected.
I think of sensors as a newish field but even that peaked in 2011.
Biomass is up a lot, which is a little surprising since I don't think of that as a new thing.&lt;/p&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="SBIR" src="/images/sbir.DARPA.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;div class="figure align-center"&gt;
&lt;img alt="SBIR" src="/images/sbir_amounts.DARPA.png" style="width: 800px;" /&gt;
&lt;/div&gt;
&lt;p&gt;DARPA's SBIR program is pretty small compared to the others on this list.
Nevertheless it's probably an interesting place to take a high-risk–high-reward project.
Anecdotally, these guys are looking 10+ years out.&lt;/p&gt;
&lt;p&gt;Visualization and social are both up, which you might expect from an internet-focused
bunch like DARPA. Virtual reality will probably also go up if it hasn't already...&lt;/p&gt;
&lt;p&gt;Perhaps the most interesting result from all of these analyses is that
DNA is up a lot in 2013, which may show that DNA is moving out of &amp;quot;genomics&amp;quot; and into
the broader world.
DARPA will probably not fund uses of genomics for health (that's HHS's job),
but rather for testing infectious agents (along with DHS and DTRA),
forensics, improving soldier performance, etc.
It might be a good time to send a DNA-focused grant to DARPA...&lt;/p&gt;
</content><category term="data"/><category term="sbir"/><category term="sttr"/><category term="grant"/></entry><entry><title>Naming Boolean Biotech</title><link href="/naming_boolean_biotech.html" rel="alternate"/><published>2014-09-24T11:00:00-07:00</published><updated>2014-09-24T11:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-24:/naming_boolean_biotech.html</id><summary type="html">&lt;p class="first last"&gt;Naming Boolean Biotech&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Naming things is always hard work.
I chose the name Boolean Biotech because it contains the word &amp;quot;lean&amp;quot; — as in lean biotech —
and sounds computational.&lt;/p&gt;
&lt;p&gt;I really like Wolfram Alpha, and it turns out it's very useful for this kind of thing.
(&lt;a class="reference external" href="http://www.wolframalpha.com/input/?i=words+containing+lean"&gt;http://www.wolframalpha.com/input/?i=words+containing+lean&lt;/a&gt;)&lt;/p&gt;
&lt;img alt="wolfram" class="align-center" src="/images/wolfram_lean.png" style="width: 600px;" /&gt;
&lt;p&gt;Wolfram Alpha can also help you solve crossword puzzles and other word puzzles.
(&lt;a class="reference external" href="http://www.wolframalpha.com/input/?i=___lean"&gt;http://www.wolframalpha.com/input/?i=___lean&lt;/a&gt;)&lt;/p&gt;
&lt;img alt="wolfram" class="align-center" src="/images/wolfram_lean2.png" style="width: 240px;" /&gt;
</content><category term="data"/><category term="biotech"/><category term="wolfram alpha"/></entry><entry><title>The Africa Soil Property Prediction Challenge</title><link href="/kaggle_africa_soil_prediction.html" rel="alternate"/><published>2014-09-22T11:00:00-07:00</published><updated>2014-09-22T11:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-22:/kaggle_africa_soil_prediction.html</id><summary type="html">&lt;p class="first last"&gt;Kaggle : Africa soil property prediction&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="or-how-to-kaggle"&gt;
&lt;h2&gt;(Or, How To Kaggle)&lt;/h2&gt;
&lt;p&gt;The &lt;a class="reference external" href="https://www.kaggle.com/c/afsis-soil-properties"&gt;Africa Soil Property Prediction Challenge&lt;/a&gt; is a &lt;a class="reference external" href="https://www.kaggle.com"&gt;Kaggle&lt;/a&gt; competition
where you are supposed to try to predict various soil measurements (like Calcium levels)
in various parts of Africa using infrared spectroscopy readings.
Seems like a worthwhile thing to do!&lt;/p&gt;
&lt;p&gt;The Kaggle forums are a great place to pick up information on some of the
practicalities of applied machine learning.
In that spirit I thought I would share the (moderately successful)
IPython/scikit-learn code I used.&lt;/p&gt;
&lt;p&gt;Here is the notebook of code I used to make my predictions:
(&lt;a class="reference external" href="/static/Boolean_Kaggle_Africa_soil.html"&gt;HTML version&lt;/a&gt;,
&lt;a class="reference external" href="/static/Boolean_Kaggle_Africa_soil.ipynb"&gt;IPython notebook&lt;/a&gt;.)
When I originally ran this code it was in the top 10% of entries, but now it's way down
the leaderboard. The winning regression method in my tests, by quite a distance,
was &lt;a class="reference external" href="http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVR.html"&gt;Support Vector Regression&lt;/a&gt;.&lt;/p&gt;
&lt;iframe src="/static/Boolean_Kaggle_Africa_soil.html" width="100%" height="1200px"&gt;&lt;/iframe&gt;&lt;/div&gt;
</content><category term="data"/><category term="open data"/><category term="kaggle"/><category term="data science"/></entry><entry><title>Using IPython with Domino</title><link href="/domino%20and%20ipython.html" rel="alternate"/><published>2014-09-15T11:00:00-07:00</published><updated>2014-09-15T11:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-15:/domino and ipython.html</id><summary type="html">&lt;p class="first last"&gt;Using Domino with iPython&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="ipython-notebook"&gt;
&lt;h2&gt;IPython Notebook&lt;/h2&gt;
&lt;p&gt;Recently, I've been using IPython notebook for some data analysis.
It's pretty janky in places, like most browser-based software,
but it's the closest thing Python has to an interactive environment.
It definitely saves a bunch of time if you have a long series of independent
data transformations and analyses.&lt;/p&gt;
&lt;p&gt;Ideally, I'd be able to work on a notebook locally, but if I have some heavy computation
to do, I could transparently send that to the cloud.
With IPython it's technically possible to do that on a cell by cell basis
using &lt;a class="reference external" href="http://ipython.org/ipython-doc/dev/parallel/parallel_process.html"&gt;ipcluster&lt;/a&gt;, but it would be difficult to integrate that with a third-party cloud
provider.
It's also not an elegant system: for example, you have to manually do imports on each of
your ipcluster nodes.&lt;/p&gt;
&lt;p&gt;A simpler method is just to dump the IPython notebook to a Python file, then
send the entire script to the cloud. Assuming there is one long-running bottleneck
task in there, this should take about the same amount of time to run.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="using-domino-aws-with-ipython"&gt;
&lt;h2&gt;Using Domino/AWS with IPython&lt;/h2&gt;
&lt;p&gt;I'm still not convinced about Domino as an AWS intermediary — for example, once my
free trial ends I think am limited to just one project on there — but that's ok since
the following process has only a few Domino-specific elements.&lt;/p&gt;
&lt;div class="section" id="requirements-txt"&gt;
&lt;h3&gt;requirements.txt&lt;/h3&gt;
&lt;p&gt;I needed to add seaborn since it was not included in Domino's standard set of imports.
For some reason I needed to include numexpr to get pandas to work.
It's probably a good idea to include as little as possible in requirements.txt
(i.e., don't pip freeze) since Domino has to install everything you ask for anew
with each run.&lt;/p&gt;
&lt;pre&gt;
seaborn==0.3.1
numexpr==2.3.1
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="section" id="ipython-setup"&gt;
&lt;h3&gt;IPython setup&lt;/h3&gt;
&lt;p&gt;It's important that I use all available CPUs when I am running on AWS/Domino,
otherwise I am wasting money. I need a few CPUs free on my laptop though...
I test this by just checking if the platform is Linux.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;multiprocessing&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;N_CPUS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;multiprocessing&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cpu_count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;platform&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'Linux'&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="ipython-s-nbconvert-preprocessor"&gt;
&lt;h3&gt;IPython's nbconvert preprocessor&lt;/h3&gt;
&lt;p&gt;IPython's handy nbconvert function converts IPython notebooks into other formats:
most commonly, pure Python, HTML or PDF.&lt;/p&gt;
&lt;p&gt;An IPython preprocessor is a little function that takes the cells in your notebook,
and does something to them before nbconvert gets to them.
Here I am using a preprocessor to do a few little things:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;comment out IPython &amp;quot;magic&amp;quot; commands (these will cause errors if run outside IPython)&lt;/li&gt;
&lt;li&gt;skip cells that have a special &amp;quot;SKIPCELL&amp;quot; comment (surprisingly, there's no IPython magic command for this)&lt;/li&gt;
&lt;li&gt;make the &amp;quot;print&amp;quot; function print to a file. For some reason Domino appears to munge
stdout and stderr into one file. By making the &amp;quot;print&amp;quot; function print to a file I can
separate my results from warnings etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I'd also like to dump all my inline plots to files, but I don't know how to do that.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_config&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#Export all the notebooks in the current directory to the sphinx_howto format.&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NbConvertApp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;notebooks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'kaggle.ipynb'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NbConvertApp&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;export_format&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'python'&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Exporter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;preprocessors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'domino_preprocessor.DominoPreprocessor'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;nbconvert.preprocessors&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;DominoPreprocessor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Preprocessor&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;FIRSTCELL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;print_fn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&amp;quot;
global_out = open(&amp;quot;stdout.ipy.txt&amp;quot;,'w')
def print(*args, **kwargs):
    kwargs['file'] = global_out
    return __builtins__.print(*args, **kwargs)
&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;preprocess_cell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cell_type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'code'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;SKIPCELL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;# SKIPCELL&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;DominoPreprocessor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FIRSTCELL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;DominoPreprocessor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FIRSTCELL&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;            &lt;span class="n"&gt;newlines&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;splitlines&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'%'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;## &amp;quot;&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;SKIPCELL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;# &amp;quot;&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;newlines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;DominoPreprocessor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FIRSTCELL&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;newlines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DominoPreprocessor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print_fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;DominoPreprocessor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FIRSTCELL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newlines&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;resources&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="running-the-code-on-domino"&gt;
&lt;h3&gt;Running the code on Domino&lt;/h3&gt;
&lt;p&gt;Finally, I created a small script that generates the cleaned-up Python file,
sends it to Domino to run
and opens the results page in a browser window.&lt;/p&gt;
&lt;pre class="code python literal-block"&gt;
&lt;span class="ch"&gt;#!/usr/bin/env python&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Create domino-appropriate python file&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;subprocess&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;ipython&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;nbconvert&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;--config&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;domino_config.py&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;out1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;communicate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Upload to Domino&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Popen&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;/Applications/domino/domino&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;run&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;kaggle.py&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;stdin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stderr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;PIPE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;out2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;communicate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Show the results page&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;#&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;re&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;webbrowser&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;rc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'(https://app.dominoup.com/[\S]+)'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;webbrowser&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Using this script I can trivially run my Kaggle script on 32 CPUs without sending my
laptop into paroxysms. All in all it works pretty well.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="domino-pricing-vs-aws"&gt;
&lt;h2&gt;Domino Pricing vs AWS&lt;/h2&gt;
&lt;p&gt;Domino sells standard &amp;quot;Compute Optimized&amp;quot; AWS instances, and marks them up 100%.
It's not a bad deal for light to moderate users,
considering that the AWS environments are already spun up and waiting,
and that Domino charges by the minute instead of by the hour.
For comparison purposes, 32 CPUs costs $1.68 an hour on AWS vs $3.36 on Domino.&lt;/p&gt;
&lt;img alt="domino" src="/images/domino1.png" /&gt;
&lt;img alt="domino" src="/images/domino2.png" /&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="open data"/><category term="domino"/><category term="data science"/><category term="ipython"/></entry><entry><title>Outsourcing Compute</title><link href="/outsourcing%20compute.html" rel="alternate"/><published>2014-09-14T11:00:00-07:00</published><updated>2014-09-14T11:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-14:/outsourcing compute.html</id><summary type="html">&lt;p class="first last"&gt;Paying someone else for their computer time&lt;/p&gt;
</summary><content type="html">&lt;p&gt;I've been messing around in a &lt;a class="reference external" href="http://www.kaggle.com"&gt;Kaggle&lt;/a&gt; competition, and one of the frustrating aspects
is waiting for my laptop to finish running analyses.
It makes sense to me that I should be using someone else's cloud for this, since then
I could get a bigger processor or more processors when I need them.&lt;/p&gt;
&lt;p&gt;There used to be a nice Python-focused platform called &lt;a class="reference external" href="http://www.picloud.com/"&gt;PiCloud&lt;/a&gt; that did this.
Essentially, PiCloud was selling a convenient interface to AWS and taking a cut.
I never really used it but the execution was very nice.
Sadly, I don't think many people used PiCloud, and it has since been bought by Dropbox and
shut down.&lt;/p&gt;
&lt;p&gt;The Python-based options&amp;nbsp;for cloud data-analysis I know about right now are &lt;a class="reference external" href="http://wakari.io/"&gt;Wakari&lt;/a&gt; and
&lt;a class="reference external" href="http://www.dominoup.com/"&gt;Domino&lt;/a&gt;.&lt;/p&gt;
&lt;div class="section" id="wakari"&gt;
&lt;h2&gt;Wakari&lt;/h2&gt;
&lt;p&gt;Wakari is from the awesome &lt;a class="reference external" href="http://continuum.io/"&gt;Continuum Analytics&lt;/a&gt; guys (makers of Anaconda), so it's
Python only.
It's simply an iPython notebook that runs in your browser, and an AWS instance on the
backend. They have an unlimited free tier, which is very nice for testing it out.
It's not too expensive, but there is no pure pay-as-you-go option, which is my preference.
To get more compute power than my laptop (which has good oomph at four 2.7GHz cores
and 16GB of RAM) would be pretty expensive: even the $100/month premium option only has
3GB of RAM.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="domino"&gt;
&lt;h2&gt;Domino&lt;/h2&gt;
&lt;p&gt;Domino appears to be a new company, and is purely focused on &amp;quot;data science&amp;quot;.
It supports Python, R, Julia and Matlab.
It is a great concept, and has some really nice features, such as the ability to
expose your model and results as API endpoints.
There's a lot of scope for Domino to add value on top of the output of your analyses
with UIs, APIs etc..&lt;/p&gt;
&lt;p&gt;Despite its great promise, I found the execution of Domino very offputting:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;it doesn't have seaborn (a Python library) installed. Why not just install every
reasonably common library?&lt;/li&gt;
&lt;li&gt;the introductory/free tier has a two hour limit and a clock counting down at you so you
can't just try it out in peace. This should work more like a cellphone data cap, and
just slow down when you hit the limit. I don't want to start something if I have to
keep watching the clock.&lt;/li&gt;
&lt;li&gt;a minor point, but every running instance has an associated animated loading spinner,
which is just distracting.&lt;/li&gt;
&lt;li&gt;the lowest tier (&amp;quot;hobby&amp;quot;), where you just pay per minute of CPU, is limited to one(!)
project. To have five projects at a time I need to pay an additional $99 per month(!!)
Why would I want to start using something with such restrictive limits?
I would guess that the more projects I have going at the same time, the more I would end
up paying Domino. Bizarre...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So unfortunately, until someone comes up with a good alternative, I am back to putting my
laptop's CPU and noisy fans to work.&lt;/p&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="open data"/><category term="kaggle"/><category term="data science"/></entry><entry><title>Open Data in Neuroscience</title><link href="/open%20data%20in%20neuroscience.html" rel="alternate"/><published>2014-09-13T14:00:00-07:00</published><updated>2014-09-13T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-13:/open data in neuroscience.html</id><summary type="html">&lt;p class="first last"&gt;NRDD paper on open data&lt;/p&gt;
</summary><content type="html">&lt;p&gt;This &lt;a class="reference external" href="http://www.nature.com/nrd/journal/v13/n8/full/nrd4395.html"&gt;Nature Reviews Drug Discovery paper&lt;/a&gt; describes the need for an
&amp;quot;open data culture&amp;quot; to spur drug discovery in neuroscience.
In some ways private industry is ahead of academia here, with pharma companies
increasingly being content to just call some data &amp;quot;precompetitive&amp;quot;.&lt;/p&gt;
&lt;p&gt;The following &amp;quot;open data&amp;quot; projects are mentioned.
None of them has any data available for download, which is sad considering these were
the best examples the authors could come up with of open data in neuroscience.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.biomarkersconsortium.org/"&gt;The Biomarkers Consortium&lt;/a&gt;
somehow facilitates public–private collaborations on biomarker discovery.
No data available.&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.nih.gov/science/amp/index.htm"&gt;Accelerating Medicines Partnership&lt;/a&gt;
is running multi-year pilots in Alzheimer, T2D and RA/lupus with 10 pharmas.
No data available&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.humanconnectomeproject.org/"&gt;Human Connectome Project&lt;/a&gt;
mapped connections in 1200 volunteers' brains.
Data are available but you have to apply for some reason I don't understand:
there's no sensitive data here.&lt;/li&gt;
&lt;li&gt;&lt;a class="reference external" href="http://www.adni-info.org/"&gt;Alzheimer's Disease Neuroimaging Initiative (ADNI)&lt;/a&gt;
has lots of data (including genomic) on 800 patients including Alzheimer cases and controls.
Data are available but you have to apply.&lt;/li&gt;
&lt;/ul&gt;
</content><category term="biotech"/><category term="open data"/><category term="neuroscience"/><category term="drugs"/></entry><entry><title>iGEM Projects</title><link href="/iGem%20Projects.html" rel="alternate"/><published>2014-09-12T14:00:00-07:00</published><updated>2014-09-12T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-12:/iGem Projects.html</id><summary type="html">&lt;p class="first last"&gt;iGem projects&lt;/p&gt;
</summary><content type="html">&lt;p&gt;iGem posts each team's abstract every year (for example, see &lt;a class="reference external" href="http://2013.igem.org/Jamboree/Team_Abstracts"&gt;2013 team abstracts&lt;/a&gt;).
These abstracts are fascinating reading, so I wanted to compile them into one place.&lt;/p&gt;
&lt;p&gt;I first tried to parse the text into a spreadsheet using &lt;a class="reference external" href="http://www.kimonolabs.com"&gt;Kimono&lt;/a&gt;.
I thought this would be pretty easy, but unfortunately Kimono could not resolve the
inconsistent formatting of the page.
Instead I ended up using &lt;a class="reference external" href="http://scrapy.org/"&gt;scrapy&lt;/a&gt; (code included at the end of this blogpost).
Scrapy is a pretty heavyweight program, but it worked.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://docs.google.com/spreadsheets/d/1bzPOB_UpJD4Yf2xjfDAvbC0UjaTfcQB-I1zl8h_hgn4/pubhtml"&gt;iGEM Projects spreadsheet&lt;/a&gt; or &lt;a class="reference external" href="/static/igem.html"&gt;HTML version of the spreadsheet&lt;/a&gt;&lt;/p&gt;
&lt;iframe src="https://docs.google.com/spreadsheets/d/1bzPOB_UpJD4Yf2xjfDAvbC0UjaTfcQB-I1zl8h_hgn4/pubhtml?widget=true&amp;amp;headers=false" width="100%" height="360px"&gt;&lt;/iframe&gt;&lt;pre class="code python literal-block"&gt;
&lt;span class="c1"&gt;# -*- coding: utf-8 -*-&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c1"&gt;# Run with: scrapy crawl test1 -o test1.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;scrapy&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;IgemItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;year&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;subtitle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Field&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;Test1Spider&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scrapy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Spider&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;test1&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="c1"&gt;#allowed_domains = [&amp;quot;igem.org&amp;quot;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="n"&gt;start_urls&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="s1"&gt;'http://2008.igem.org/Jamboree/Project_Abstract/Team_Abstracts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="s1"&gt;'http://2009.igem.org/Jamboree/Project_Abstract/Team_Abstracts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="s1"&gt;'http://2010.igem.org/Jamboree/Project_Abstract/Team_Abstracts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="s1"&gt;'http://2011.igem.org/Jamboree/Team_Abstracts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="s1"&gt;'http://2012.igem.org/Jamboree/Team_Abstracts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="s1"&gt;'http://2013.igem.org/Jamboree/Team_Abstracts'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="c1"&gt;#if len(sel.extract()) == 0:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="c1"&gt;#    return &amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extract&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;: &amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;2008&amp;quot;&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sel&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'//h4/span[contains(&amp;#64;class, &amp;quot;mw-headline&amp;quot;)]'&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;IgemItem&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'year'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'title'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;a/text()&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'subtitle'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'../following-sibling::p[1]/i/text()'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'description'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'../following-sibling::p[2]/text()'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;yr&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;yr&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;2009&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;2010&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;xp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'//span[contains(&amp;#64;class, &amp;quot;mw-headline&amp;quot;)]'&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;xp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'//h4/span[contains(&amp;#64;class, &amp;quot;mw-headline&amp;quot;)]'&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;sel&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;xp&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;IgemItem&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'year'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'title'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;a/text()&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'subtitle'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;text()&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'description'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sel&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;xpath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'../following-sibling::p[1]/text()'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;                &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;
&lt;/pre&gt;
</content><category term="biotech"/><category term="scrapy"/><category term="iGEM"/><category term="synthetic biology"/></entry><entry><title>Open Data</title><link href="/Open%20Data.html" rel="alternate"/><published>2014-09-11T14:00:00-07:00</published><updated>2014-09-11T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-11:/Open Data.html</id><summary type="html">&lt;p class="first last"&gt;Open Data resources&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Health and drug data is increasingly being made available for use by researchers
in academia and in industry.
The following open data projects are just a few interesting examples I've come across recently.&lt;/p&gt;
&lt;div class="section" id="gsk-clinical-trials-data"&gt;
&lt;h2&gt;GSK Clinical Trials Data&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.nejm.org/doi/full/10.1056/NEJMsr1302541"&gt;GSK&lt;/a&gt; is the first pharma company to make a big effort to open up its clinical trials data.
I believe this is part of a general trend in pharma to treat more work as pre-competitive.
I guess teaming up is a natural response when the underlying system is failing?
However, there are a number of restrictions on who can get access to the data. For example:&lt;/p&gt;
&lt;blockquote&gt;
This closed-access system helps protect privacy and ensures that the data are
used solely for approved research purposes.&lt;/blockquote&gt;
&lt;p&gt;There is a rationalization in there about potential harm to the public if the data are
&amp;quot;misinterpreted&amp;quot;.
I don't know where this fear comes from. It just sounds like paternalism.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="uk-biobank"&gt;
&lt;h2&gt;UK Biobank&lt;/h2&gt;
&lt;p&gt;The &lt;a class="reference external" href="http://www.ukbiobank.ac.uk/using-the-resource/"&gt;UK Biobank&lt;/a&gt; is a fascinating resource. It's a government-funded data-collection
initiative, with the unusual and exciting proviso that the data be made available
not only to academics, but to pharma/biotech too.&lt;/p&gt;
&lt;blockquote&gt;
During 2006-2010, UK Biobank conducted its recruitment phase of more than
500,000 participants who gave their consent, answered questions, had
physical measurements and gave samples (blood, urine and saliva) at a
baseline assessment visit. Follow-up of their health is now being conducted
through medical and other health-related records. Access systems have been
developed to facilitate use of the UK Biobank Resource by bona fide researchers
for health-related research that is in the public interest.&lt;/blockquote&gt;
&lt;p&gt;The phenotypic data available is quite broad and the prices are very reasonable:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;£250 + VAT (where applicable) payable upon submission of a preliminary application.&lt;/li&gt;
&lt;li&gt;£1,500 + VAT (where applicable) per application that requires access to data only.&lt;/li&gt;
&lt;li&gt;An additional cost of £1,500 + VAT (where applicable) for bulk data access.&lt;/li&gt;
&lt;li&gt;£bespoke quote for applications that request access to biological samples.&lt;/li&gt;
&lt;li&gt;£bespoke quote for re-contact requests.&lt;/li&gt;
&lt;li&gt;£bespoke quote for particularly time-consuming customisation of datasets.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="openfda"&gt;
&lt;h2&gt;openFDA&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="https://open.fda.gov"&gt;openFDA&lt;/a&gt; is one of a few fancy government projects that use trendy
technologies like github, twitter, bootstrap, etc. (&lt;a class="reference external" href="https://github.com/blue-button"&gt;Blue Button&lt;/a&gt; is another good one).
Their API allows you can ask &lt;a class="reference external" href="https://open.fda.gov/drug/event/"&gt;interesting questions&lt;/a&gt; about adverse drug reaction rates.
For example, how many women reported an adverse reaction to statins in California in 2014?
You don't even need an API key if you are doing &amp;lt;1000 requests a day.
Apparently, openFDA will also cover &amp;quot;Drugs, Devices and Foods&amp;quot; soon.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="large-genomics-projects"&gt;
&lt;h2&gt;Large Genomics Projects&lt;/h2&gt;
&lt;p&gt;There are a bunch of big government-sponsored genomics projects underway.
Some of these projects, like Genomics England, will likely open their data up to
commercial partners over the next couple of years.&lt;/p&gt;
&lt;!-- Figure instead of image here. The indented sentence below is the caption (apparently) --&gt;
&lt;div class="figure"&gt;
&lt;img alt="Databases Source: Gil McVean, Big Data in Biomedicine 2014" src="/images/databases.png" /&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="data"/><category term="open data"/><category term="virtual biotech"/></entry><entry><title>Research Reproducibility</title><link href="/Research%20reproducibility.html" rel="alternate"/><published>2014-09-10T12:00:00-07:00</published><updated>2014-09-10T12:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-10:/Research reproducibility.html</id><summary type="html">&lt;p class="first last"&gt;Robot labs&lt;/p&gt;
</summary><content type="html">&lt;p&gt;It turns out that most research is not terribly reproducible,
and that's a problem when you are trying to turn R into D,
as &lt;a class="reference external" href="http://www.nature.com/nature/journal/v483/n7391/full/483531a.html"&gt;Amgen&lt;/a&gt; and others have discovered.
That's why reproducible research is currently a &lt;a class="reference external" href="http://www.nature.com/nature/focus/reproducibility/"&gt;hot topic&lt;/a&gt; in science —
so hot you can even take &lt;a class="reference external" href="https://www.coursera.org/course/repdata"&gt;a course&lt;/a&gt; on it on Coursera.&lt;/p&gt;
&lt;p&gt;Most reproducible research literature I've seen focuses on the data analysis component,
which makes sense since this is the most straightforward place to start.
Generally, this means that you package your code and data in such a way that others
can rerun your experiment.&lt;/p&gt;
&lt;p&gt;Robotic labs may also help with reproducibility.
What is a robotic lab?
To me, a robotic lab is a lab that is automated enough that
protocols are defined in a machine-readable language.
No research lab looks like this yet (with good reason),
but some commercial labs (&lt;a class="reference external" href="http://www.transcriptic.com/"&gt;Transcriptic&lt;/a&gt; and &lt;a class="reference external" href="http://emeraldcloudlab.com/"&gt;Emerald Cloud Lab&lt;/a&gt;)
are moving quickly in this direction.
It's an awesome trend that could lead to a lot of changes in how science is done,
including the reproducibility of research.&lt;/p&gt;
&lt;img alt="emerald" src="/images/emerald_doe.png" /&gt;
&lt;p&gt;I'll ignore some of the current problems with robots, which are mainly
around manual dexterity, skill and flexibility.
For many experiments, these limitations will be too much to overcome, but
historically, automation and mass production eventually beats manual labor,
starting with the most boring and repeatable tasks.&lt;/p&gt;
&lt;p&gt;The potential advantages of robotic labs are highly analogous to those of cloud computing:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;high scalability&lt;/li&gt;
&lt;li&gt;low cost (thanks to economies of scale and automation)&lt;/li&gt;
&lt;li&gt;protocols can be transferred from lab to lab&lt;/li&gt;
&lt;li&gt;reproducibility within and between labs&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="research-papers"&gt;
&lt;h2&gt;Research Papers&lt;/h2&gt;
&lt;p&gt;The current model of writing research papers dates back to &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Robert_Boyle#Scientific_investigator"&gt;Robert Boyle&lt;/a&gt;
in the 17th century (at least according to a recent episode of &lt;a class="reference external" href="http://www.bbc.co.uk/podcasts/series/iot"&gt;In Our Time&lt;/a&gt;).
A 21st century research paper could look pretty different:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Introduction&lt;/strong&gt;: currently, these are usually just derivative summaries,
so let's replace this with a wikipedia link or one of a standardized set of introductions:
&amp;quot;#34, why cancer research matters&amp;quot;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Methods&lt;/strong&gt;: this is now a machine-readable protocol written in the Wolfram Language
or YAML or Python&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Results&lt;/strong&gt;: analysis and results are in an iPython notebook so you can see exactly
what was done with the data and in what order&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;: here we can go to town describing in free-text what happened in the
experiment and why it matters&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Maybe I am being too harsh on the introduction, but in general this model
makes a lot of sense to me.
(I recently learned that there is a company,
&lt;a class="reference external" href="http://standardanalytics.io/"&gt;Standard Analytics&lt;/a&gt;, trying to help people write papers this way).&lt;/p&gt;
&lt;p&gt;I would guess that currently, most papers cannot be written this way,
because the experimental technique is too temperamental to standardize,
or the code to analyze the data is in flux,
or the analysis only lives in an Excel spreadsheet,
or a hundred other reasons.
However, it's also possible you just shouldn't read these papers
on the grounds that they are likely to contain errors.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;It's unfortunate that even purely computational biology papers usually lack a
simple method for the reader to run the code and reproduce the key results.
Many of these papers could be written up as iPython notebooks instead of as papers.
Of course, this is no way to get tenure, so only people who have nothing to prove,
like &lt;a class="reference external" href="http://nbviewer.ipython.org/url/norvig.com/ipython/xkcd1313.ipynb"&gt;Peter Norvig&lt;/a&gt;, do this.&lt;/p&gt;
&lt;p&gt;(Some experiments rely on proprietary data, and so cannot provide full reproducibility.
However, you can usually at least demonstrate that the method you devised works on
simulated data...)&lt;/p&gt;
&lt;p&gt;One recent project that took a novel approach was the &lt;a class="reference external" href="http://www.genome.gov/encode/"&gt;Encode project&lt;/a&gt;,
where the authors published a &lt;a class="reference external" href="http://scofield.bx.psu.edu/~dannon/encodevm/"&gt;virtual machine image&lt;/a&gt; along with the paper
to help you reproduce many of the key results.
As VMs get simpler and &lt;a class="reference external" href="http://www.docker.com/"&gt;more portable&lt;/a&gt;, we might see more of this too.&lt;/p&gt;
&lt;/div&gt;
</content><category term="outsourcing"/><category term="experiments"/><category term="reproducible research"/></entry><entry><title>Outsourcing Wet-Lab Experiments</title><link href="/Outsourcing%20Experiments.html" rel="alternate"/><published>2014-09-01T14:00:00-07:00</published><updated>2014-09-01T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-09-01:/Outsourcing Experiments.html</id><summary type="html">&lt;p class="first last"&gt;Options for outsourcing&lt;/p&gt;
</summary><content type="html">&lt;p&gt;So you want to do some biological experiments, but you don't own a lab.
Currently, unlike many other technology sectors,
it is not easy to exchange money for a wet-lab experiment.
This post is my interpretation of the evolution and latest developments in
outsourcing wet-lab experiments.&lt;/p&gt;
&lt;div class="section" id="virtual-biotechs-and-cros"&gt;
&lt;h2&gt;Virtual Biotechs and CROs&lt;/h2&gt;
&lt;p&gt;Virtual Biotechs have been around for many years, but are becoming increasingly common.
Basically, a Virtual Biotech is a biotech that outsources its research, usually to a
Contract Research Organization (CRO).
Virtual Biotechs are small: usually between one and twenty people,
and they may not even have office space.
You can tell it's cool to be a Virtual Biotech when you see a &lt;a class="reference external" href="http://online.wsj.com/articles/virtual-biotechs-no-lab-space-few-employees-1401816867"&gt;trend piece&lt;/a&gt; in the WSJ.
Here's a &lt;a class="reference external" href="http://lifescivc.com/2014/06/biotechs-virtual-reality/"&gt;description of one Virtual Biotech&lt;/a&gt; and a &lt;a class="reference external" href="http://lifescivc.com/2014/06/zafgen-supersizes-its-obesity-focused-ipo-an-early-investors-reflections/"&gt;recent success story&lt;/a&gt; from the
excellent &lt;a class="reference external" href="http://lifescivc.com"&gt;Life Science VC blog&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;There are a number of ways a Virtual Biotech can work.
For example: a pharma exec sees value in a compound that the pharma has given up on,
so he spins it out, raises money to pay for a Phase I or Phase II trial (conducted by a CRO),
and if that is successful, he sells it back to the pharma for a profit.
Everybody wins.&lt;/p&gt;
&lt;p&gt;In other words, Virtual Biotech is often about asset arbitrage rather than research,
since developing drugs from scratch is too expensive and slow,
and preclinical work does not generate value quickly enough.&lt;/p&gt;
&lt;p&gt;Interestingly, huge pharma companies are increasingly acting like Virtual Biotechs,
in that they are either using CROs to conduct primary research,
or buying up biotechs that already developed a promising compound.
Less and less R&amp;amp;D is being done in Big Pharma due to a lack of productivity
(see &lt;a class="reference external" href="http://www.nature.com/nrd/journal/v11/n3/fig_tab/nrd3681_F1.html"&gt;Eroom's Law&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Figuring out which CRO to use still seems to be a trial-and-error process,
more like hiring a consultant than buying some compute on Amazon.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="web-2-0-cro"&gt;
&lt;h2&gt;Web 2.0 CRO&lt;/h2&gt;
&lt;p&gt;Academic labs, core labs, CROs and even biotech companies often have excess
lab capacity that they want to utilize.
About 5-10 years ago, &lt;a class="reference external" href="http://www.assaydepot.com"&gt;Assay Depot&lt;/a&gt; and &lt;a class="reference external" href="http://www.scienceexchange.com"&gt;Science Exchange&lt;/a&gt; launched with the
intention of connecting that excess capacity with academic and biotech labs.
Assay Depot and Science Exchange act as clearing houses, connecting you to labs
that can perform experiments for you.
They provide contact information and billing services but not too much else.&lt;/p&gt;
&lt;p&gt;On the positive side, this is often very cost-effective and a great way to leverage
the expertise of (for example) the UC Davis Mouse Biology Program,
but on the downside the service provider is not necessarily set up to act as a CRO,
and you will probably end up having to contract with several labs
to get all your experiments done.
If there is a time-critical step spread over two labs, like RNA sequencing, you may have a problem.&lt;/p&gt;
&lt;img alt="mouse" src="/images/davis_mouse.png" /&gt;
&lt;p&gt;I think the major use-case here is for an academic lab that lacks the ability to
do a certain type of experiment. Instead of finessing a collaboration with another lab,
you just pay a small amount and get your results back fast.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="here-come-the-robots"&gt;
&lt;h2&gt;Here Come the Robots&lt;/h2&gt;
&lt;p&gt;Starting very recently, there is an exciting new trend in wet-lab outsourcing: robots!&lt;/p&gt;
&lt;p&gt;Two Bay Area companies, &lt;a class="reference external" href="http://www.transcriptic.com"&gt;Transcriptic&lt;/a&gt; and &lt;a class="reference external" href="http://www.emeraldcloudlabs.com"&gt;Emerald Cloud Lab&lt;/a&gt;,
decided that they could make the process of outsourced wet-lab research more efficient
and more reproducible by using robots.&lt;/p&gt;
&lt;p&gt;Transcriptic is already up and running, with competitive pricing on cloning, genotyping
and biobanking.
I believe that Transcriptic will already perform many other types of experiment
upon request, and that their advertised experiments are just their foot in the door.
Emerald Cloud Lab will be launching in 2015 with a &lt;a class="reference external" href="http://www.emeraldcloudlab.com/lab-experiments"&gt;large suite&lt;/a&gt; of services.
It is currently in beta.&lt;/p&gt;
&lt;img alt="transcriptic" src="/images/transcriptic.png" /&gt;
&lt;p&gt;The advantages of doing experiments through a lab like this are tantalizing:
&lt;strong&gt;(a)&lt;/strong&gt; it can make experiments cheaper and faster, with economies of scale
and machines running all day and night
&lt;strong&gt;(b)&lt;/strong&gt; it can make your research more reproducible since your protocol will be defined
by a machine-readable script
&lt;strong&gt;(c)&lt;/strong&gt; you can scale up your research from one sample to a huge number,
potentially without changing the protocol of your successful pilot experiment&lt;/p&gt;
&lt;p&gt;Interestingly, Emerald is using the Wolfram Language (very similar to Mathematica).
I would prefer Python or something similar, but clearly the Wolfram Language has some
great capabilities, and seems to be highly expressive for data-analysis
(see the &lt;a class="reference external" href="http://blog.wolfram.com/"&gt;Wolfram Blog&lt;/a&gt; for some great examples).&lt;/p&gt;
&lt;img alt="emerald" src="/images/emerald.png" /&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;We're clearly not yet in a world where companies and academic labs can just
run all their experiments virtually
(as we've seen analogously happen with AWS, Azure, etc for web companies)
and of course there are many types of experiment
that necessitate hands-on time and expertise
(for example, developing a new protocol or technology).&lt;/p&gt;
&lt;p&gt;However, there are also thousands of labs doing their own genotyping,
cloning, sequencing, mass-spec etc.
All of them are doing it slightly differently
and half of them are doing it worse than the median (and none of them think so)...
We know that science is generally not very reproducible at the best of times
(see &lt;a class="reference external" href="http://www.reuters.com/article/2012/03/28/us-science-cancer-idUSBRE82R12P20120328"&gt;Amgen's experiments&lt;/a&gt; reproducing 53 landmark cancer papers
or &lt;a class="reference external" href="http://www.plosmedicine.org/article/info%3Adoi%2F10.1371%2Fjournal.pmed.0020124"&gt;Ioannidis' famous paper&lt;/a&gt;)
so reducing experimental variation must be a good thing long-term.
I really hope to see more competitors to Transcriptic and Emerald soon —
and maybe even new approaches to defining and publishing experiments in a
reproduction-friendly machine-readable format.&lt;/p&gt;
&lt;/div&gt;
</content><category term="outsourcing"/><category term="outsourcing"/><category term="experiments"/><category term="virtual"/><category term="biotech"/></entry><entry><title>GenoCAD</title><link href="/GenoCAD.html" rel="alternate"/><published>2014-08-30T14:00:00-07:00</published><updated>2014-08-30T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-30:/GenoCAD.html</id><summary type="html">&lt;p class="first last"&gt;First look at GenoCAD&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="synthetic-biology-software"&gt;
&lt;h2&gt;Synthetic Biology Software&lt;/h2&gt;
&lt;p&gt;Ideally I would like some software to help me create proteins and expression vectors.&lt;/p&gt;
&lt;p&gt;I have tried Genome Compiler, Benchling and Teselagen before
but I haven't really gotten the hang of any of them.
I don't think they are designed for me, and
I don't really trust that they are doing what I intend them to do.
For example, if I create a promoter–gene–terminator unit, it's often not
clear to me if a Kozak sequence is included.
My ideal software would flag that and other potential issues.&lt;/p&gt;
&lt;p&gt;Generally, the world of synthetic biology is concerned with creating pathways
and circuits to perform tasks like processing chemical A into chemical B.
This makes sense, since metabolic engineering is a huge opportunity.
Large companies like Amyris and Synthetic Genomics spend their time on this stuff.&lt;/p&gt;
&lt;p&gt;I don't really want to do that.
For one thing, it is extremely difficult; there are a lot of ways it can go wrong.
So what do you do if you just want to express a synthetic recombinant protein?
It's not as futuristic or as complex as creating a genetic circuit but it's still
surprisingly difficult using the current crop of software.
(Or perhaps I am just using the wrong software and I really need protein engineering software...)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="genocad-1"&gt;
&lt;h2&gt;GenoCAD&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.genocad.org"&gt;GenoCAD&lt;/a&gt; is open-source synthetic biology software from Virginia Tech.
I stumbled onto GenoCAD after noticing that their intro tutorial is one of the &lt;a class="reference external" href="http://figshare.com/articles/GenoCAD_Training_Set_I/153827"&gt;most
popular shares on figshare&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;GenoCAD is similar to other synthetic biology software in most ways.
However, it also uses the interesting concept of a &amp;quot;grammar&amp;quot;
(which I would have probably called a template)
that allows you to fill-in-the-blanks for a synthetic biology task
(e.g., building an oscillator or repressor).&lt;/p&gt;
&lt;p&gt;I went through the GenoCAD tutorials and found it to be impressive, though
clearly academic software.
GenoCAD has some nice features:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;it's open-source, though&amp;nbsp;it only exists as a zip file hosted on &lt;a class="reference external" href="http://sourceforge.net/projects/genocad/"&gt;sourceforge&lt;/a&gt; — let's put the code on github or bitbucket guys..&lt;/li&gt;
&lt;li&gt;it has comprehensive tutorials (thanks to &lt;a class="reference external" href="http://www.openhelix.com/"&gt;OpenHelix&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;it has a small number of defined grammars for some common synthetic biology tasks.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There aren't many examples of community-defined grammars, but I could see this
eventually growing into a useful library of templates.&lt;/p&gt;
&lt;img alt="genocad" src="/images/genocad_grammar.png" /&gt;
&lt;/div&gt;
</content><category term="synthetic biology"/><category term="synthetic biology"/><category term="genocad"/></entry><entry><title>Hybrid Protein</title><link href="/Hybrid%20protein%20optimization.html" rel="alternate"/><published>2014-08-16T14:00:00-07:00</published><updated>2014-08-16T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-16:/Hybrid protein optimization.html</id><summary type="html">&lt;p class="first last"&gt;Making the hybrid protein&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Starting with a protein sequence, there are several ways to produce a DNA sequence
with codons that are optimized for expression.
I created a DNA sequence for my hybrid flagellin using &lt;a class="reference external" href="http://www.lifetechnologies.com/us/en/home/life-science/cloning/gene-synthesis/geneart-gene-synthesis/geneoptimizer.html"&gt;Life Tech GeneOptimizer&lt;/a&gt;.
I selected &lt;em&gt;Mus musculus&lt;/em&gt; as the target organism and I also selected the option
to add a &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Kozak_consensus_sequence"&gt;Kozak sequence&lt;/a&gt;. Here's what gets spit out.&lt;/p&gt;
&lt;pre&gt;
GCCACCATGGCCCAAGTGATCAACACCAACAGCCTGAGCCTGATCACCCAGAACAACATCAACAAGAACCAGAGCGCCCTGAGCAGCAGCATCGAGAGAC
TGAGCAGCGGCCTGAGAATCAACAGCGCCAAGGACGATGCCGCTGGCCAGGCTATCGCCAACAGATTCACCAGCAACATCAAGGGCCTGACCCAGGCCGC
CAGAAACGCCAACGATGGCATCAGCGTGGCCCAGACAACAGAGGGCGCACTGAGCGAGATCAACAACAACCTGCAGAGAGTGCGCGAGCTGACCGTGCAG
GCCACCACAGGCACAAACAGCGAGAGCGACCTGTCCAGCATCCAGGACGAGATCAAGAGCAGACTGGATGAGATCGACAGAGTGTCCGGCCAGACCCAGT
TCAACGGCGTGAACGTGCTGGCCAAGAACGGCAGCATGAAGATCCAAGTGGGCGCCAACGACAACCAGACCATCACCATCGACCTGAAGCAGATCGACGC
CAAGACCCTGGGCCTGGACGGCTTCTCTGTGAAGGCCCTGATCACAGCCAGCGGCGACATCAGCCTGACCTTCAAACAGGTGGACGGCGTGAACGACGTG
ACCCTGGAAAGCGTGAAGGTGTCCAGCTCTGCCGGCACAGGCATCGGCGTGCTGGCTGAAGTGATTAACAAGAACAGCAACAGGACCGGCGTGAAGGCCT
ACGCCAGCGTGATCACCACAAGCGACGTGGCCGTGCAGAGCGGCAGCCTGTCTAACCTGACCCTGAACGGCATCCACCTGGGCAATATCGCCGATATCAA
GAAGAACGACAGCGACGGCAGACTGGTGGCCGCCATCAACGCCGTGACAAGCGAGACAGGCGTGGAAGCCTACACCGACCAGAAGGGCAGACTGAACCTG
AGATCCATCGACGGCAGGGGCATCGAAATCAAGACCGACAGCGTGTCCAACGGCCCCTCCGCCCTGACAATGGTCAACGGCGGACAGGACCTGACCAAGG
GCAGCACCAACTACGGCAGGCTGTCCCTGACAAGACTGGACGCCAAGTCCATCAACGTGGTGTCCGCCAGCGACTCCCAGCACCTGGGCTTTACAGCTAT
CGGCTTCGGCGAGAGCCAGGTGGCCGAGACTACCGTGAATCTGAGGGACGTGACCGGCAACTTCAACGCTAACGTGAAGTCCGCCTCCGGCGCTAACTAC
AACGCTGTGATCGCCTCTGGCAACCAGAGCCTGGGAAGCGGCGTGACCACACTGAGAGCTGTGGCCAACGGCAAGACCACCGACCCCCTGAAGGCTCTGG
ACGACGCTATCGCCTCCGTGGACAAGTTCAGATCCAGCCTGGGCGCTGTGCAGAACAGACTGGACAGCGCCGTGACCAACCTGAACAACACCACCACCAA
CCTGTCCGAGGCCCAGAGCAGAATCCAGGATGCCGACTACGCCACCGAGGTGTCCAACATGAGCAAGGCCCAGATCATCCAGCAGGCCGGCAACTCTGTG
CTGGCTAAGGCCAACCAGGTGCCCCAGCAGGTGCTGAGTCTGCTGCAGGGA
&lt;/pre&gt;&lt;p&gt;When I align my sequence with the original BioBrick created for the
Slovenian iGem project, the two DNA sequences are only about 75% concordant
(the protein sequences were identical).
I expected some differences but not this many.
My best guess is that the Slovenian BioBrick is not intended for use in mouse,
but I really don't know what is going on.
It would be interesting to test the difference in expression between the two
sequences in a mouse.&lt;/p&gt;
&lt;pre&gt;
CLUSTAL O(121) multiple sequence alignment

LifeTech              GCCACCATGGCCCAAGTGATCAACACCAACAGCCTGAGCCTGATCACCCAGAACAACATC
Slovenia              ------atggcacaagtcattaataccaacagcctctcgctgatcactcaaaataatatc
                            ***** ***** ** ** ***********    ******** ** ** ** ***

LifeTech              AACAAGAACCAGAGCGCCCTGAGCAGCAGCATCGAGAGACTGAGCAGCGGCCTGAGAATC
Slovenia              aacaagaaccagtctgcgctgtcgagttctatcgagcgtctgtcttctggcttgcgtatt
                      ************   ** ***   **    ****** * ***      *** ** * **

LifeTech              AACAGCGCCAAGGACGATGCCGCTGGCCAGGCTATCGCCAACAGATTCACCAGCAACATC
Slovenia              aacagcgcgaaggatgacgcagcgggtcaggcgattgctaaccgtttcacctctaacatt
                      ******** ***** ** ** ** ** ***** ** ** *** * ******   *****

LifeTech              AAGGGCCTGACCCAGGCCGCCAGAAACGCCAACGATGGCATCAGCGTGGCCCAGACAACA
Slovenia              aaaggcctgactcaggcggcccgtaacgccaacgacggtatctccgttgcgcagaccacc
                      ** ******** ***** *** * *********** ** ***  *** ** ***** **

LifeTech              GAGGGCGCACTGAGCGAGATCAACAACAACCTGCAGAGAGTGCGCGAGCTGACCGTGCAG
Slovenia              gaaggcgcgctgtccgaaatcaacaacaacttacagcgtgtgcgtgaactgacggtacag
                      ** ***** ***  *** ************ * *** * ***** ** ***** ** ***

LifeTech              GCCACCACAGGCACAAACAGCGAGAGCGACCTGTCCAGCATCCAGGACGAGATCAAGAGC
Slovenia              gccactaccggtactaactctgagtctgatctgtcttctatccaggacgaaattaaatcc
                      ***** ** ** ** ***   ***   ** *****    *********** ** **   *

LifeTech              AGACTGGATGAGATCGACAGAGTGTCCGGCCAGACCCAGTTCAACGGCGTGAACGTGCTG
Slovenia              cgtctggatgaaattgaccgcgtatctggtcagacccagttcaacggcgtgaacgtgctg
                      * ******** ** *** * ** ** ** ******************************

LifeTech              GCCAAGAACGGCAGCATGAAGATCCAAGTGGGCGCCAACGACAACCAGACCATCACCATC
Slovenia              gcaaaaaatggctccatgaaaatccaggttggcgcaaatgataaccagactatcactatc
                      ** ** ** ***  ****** ***** ** ***** ** ** ******** ***** ***

LifeTech              GACCTGAAGCAGATCGACGCCAAGACCCTGGGCCTGGACGGCTTCTCTGTGAAGGCCCTG
Slovenia              gatctgaagcagattgatgctaaaactcttggccttgatggttttagcgttaaagcgtta
                      ** *********** ** ** ** ** ** ***** ** ** **    ** ** **  *

LifeTech              ATCACAGCCAGCGGCGACATCAGCCTGACCTTCAAACAGGTGGACGGCGTGAACGACGTG
Slovenia              atcacggcttctggggatattagcttgacttttaaacaagtggatggcgtgaatgatgta
                      ***** **    ** ** ** *** **** ** ***** ***** ******** ** **

LifeTech              ACCCTGGAAAGCGTGAAGGTGTCCAGCTCTGCCGGCACAGGCATCGGCGTGCTGGCTGAA
Slovenia              actttagagagcgtaaaagtttctagttcagcaggcacggggatcggtgtgttagcggaa
                      **  * ** ***** ** ** ** ** ** ** ***** ** ***** *** * ** ***

LifeTech              GTGATTAACAAGAACAGCAACAGGACCGGCGTGAAGGCCTACGCCAGCGTGATCACCACA
Slovenia              gtgattaacaaaaattctaaccgaacaggggttaaagcttatgcgagcgttatcaccacg
                      *********** **    *** * ** ** ** ** ** ** ** ***** ********

LifeTech              AGCGACGTGGCCGTGCAGAGCGGCAGCCTGTCTAACCTGACCCTGAACGGCATCCACCTG
Slovenia              agcgatgtggcggtccaatcaggaagtttgagtaatttaactttaaatgggatccatttg
                      ***** ***** ** **    ** **  **  ***  * **  * ** ** *****  **

LifeTech              GGCAATATCGCCGATATCAAGAAGAACGACAGCGACGGCAGACTGGTGGCCGCCATCAAC
Slovenia              ggtaatatcgcagatattaagaaaaatgactcagacggaaggttagtcgcagcgatcaat
                      ** ******** ***** ***** ** ***   ***** **  * ** ** ** *****

LifeTech              GCCGTGACAAGCGAGACAGGCGTGGAAGCCTACACCGACCAGAAGGGCAGACTGAACCTG
Slovenia              gcggttacttcagaaaccggcgtggaagcttatacggatcaaaaagggcgcttgaatttg
                      ** ** **    ** ** *********** ** ** ** ** ** **  *  ****  **

LifeTech              AGATCCATCGACGGCAGGGGCATCGAAATCAAGACCGACAGCGTGTCCAACGGCCCCTCC
Slovenia              cgcagtatagatggtcgtgggattgaaatcaaaaccgatagcgtcagtaatgggcctagt
                      *    ** ** **  * ** ** ******** ***** *****    ** ** **

LifeTech              GCCCTGACAATGGTCAACGGCGGACAGGACCTGACCAAGGGCAGCACCAACTACGGCAGG
Slovenia              gctttaacgatggtcaatggcggtcaggatttaacaaaaggttctactaactatgggagg
                      **  * ** ******** ***** *****  * ** ** **    ** ***** ** ***

LifeTech              CTGTCCCTGACAAGACTGGACGCCAAGTCCATCAACGTGGTGTCCGCCAGCGACTCCCAG
Slovenia              ctttctctcacacgcttagacgctaaaagcatcaatgtcgtttcggcttctgattcgcaa
                      ** ** ** *** *  * ***** **   ****** ** ** ** **    ** ** **

LifeTech              CACCTGGGCTTTACAGCTATCGGCTTCGGCGAGAGCCAGGTGGCCGAGACTACCGTGAAT
Slovenia              catttaggtttcacagcgattggttttggggaatctcaagtggcagaaaccacggtgaat
                      **  * ** ** ***** ** ** ** ** **    ** ***** ** ** ** ******

LifeTech              CTGAGGGACGTGACCGGCAACTTCAACGCTAACGTGAAGTCCGCCTCCGGCGCTAACTAC
Slovenia              ttgcgcgatgttactgggaattttaacgctaatgtcaaatcagccagtggcgcgaactat
                      ** * ** ** ** ** ** ** ******** ** ** ** ***   ***** *****

LifeTech              AACGCTGTGATCGCCTCTGGCAACCAGAGCCTGGGAAGCGGCGTGACCACACTGAGAGCT
Slovenia              aacgccgtgatcgctagcggtaaccaaagcttgggatctggggttacaaccttaagagct
                      ***** ********    ** ***** *** *****   ** ** ** **  * ******

LifeTech              GTGGCCAACGGCAAGACCACCGACCCCCTGAAGGCTCTGGACGACGCTATCGCCTCCGTG
Slovenia              gttgcaaatggtaaaaccacggatccgctgaaagcgctggacgatgctatcgcatctgta
                      ** ** ** ** ** ***** ** ** ***** ** ******** ******** ** **

LifeTech              GACAAGTTCAGATCCAGCCTGGGCGCTGTGCAGAACAGACTGGACAGCGCCGTGACCAAC
Slovenia              gacaaattccgttcttccctcggtgcggtgcaaaaccgtctggattccgcggttaccaac
                      ***** *** * **   *** ** ** ***** *** * *****   *** ** ******

LifeTech              CTGAACAACACCACCACCAACCTGTCCGAGGCCCAGAGCAGAATCCAGGATGCCGACTAC
Slovenia              ctgaacaacaccactaccaacctgtctgaagcgcagtcccgtattcaggacgccgactat
                      ************** *********** ** ** ***  * * ** ***** ********

LifeTech              GCCACCGAGGTGTCCAACATGAGCAAGGCCCAGATCATCCAGCAGGCCGGCAACTCTGTG
Slovenia              gcgaccgaagtgtccaatatgtcgaaagcgcagatcatccagcaggccggtaactccgtg
                      ** ***** ******** ***   ** ** ******************** ***** ***

LifeTech              CTGGCTAAGGCCAACCAGGTGCCCCAGCAGGTGCTGAGTCTGCTGCAGGGA---------
Slovenia              ttggcaaaagctaaccaggtaccgcagcaggttctgtctctgttacagggttactagagc
                      **** ** ** ******** ** ******** ***  **** * *****

LifeTech              -----------------------------
Slovenia              gaggagaccaccaccaccaccaccactag
&lt;/pre&gt;&lt;p&gt;There are fewer restriction sites in the sequence generated by GeneOptimizer.
I don't think that's proof of anything, but seems generally positive.
(The images below are from the &lt;a class="reference external" href="http://tools.neb.com/NEBcutter2"&gt;NEBcutter&lt;/a&gt; online tool.)&lt;/p&gt;
&lt;img alt="NEB 1" src="/images/NEB1.png" /&gt;
&lt;img alt="NEB 2" src="/images/NEB2.png" /&gt;
&lt;div class="section" id="comparing-codon-optimizers"&gt;
&lt;h2&gt;Comparing Codon Optimizers&lt;/h2&gt;
&lt;p&gt;I compared three methods of codon optimization: &lt;a class="reference external" href="http://www.jcat.de/Result.jsp"&gt;JCAT&lt;/a&gt;, &lt;a class="reference external" href="http://www.idtdna.com/CodonOpt"&gt;IDT&lt;/a&gt; and &lt;a class="reference external" href="http://www.lifetechnologies.com/us/en/home/life-science/cloning/gene-synthesis/geneart-gene-synthesis/geneoptimizer.html"&gt;GeneOptimizer&lt;/a&gt;.
In all three cases I select for &lt;em&gt;Mus musculus&lt;/em&gt; as the target organism.
There is good concordance between all three, with LifeTech and JCAT at over 90% condordance.
Note the addiitonal leader sequence in the LifeTech version — that's the added Kozak sequence.&lt;/p&gt;
&lt;pre&gt;
CLUSTAL O(1.2.1) multiple sequence alignment


IDT           ------ATGGCACAGGTCATTAATACTAATAGTCTGAGTCTGATCACTCAGAATAACATC
LifeTech      GCCACCATGGCCCAAGTGATCAACACCAACAGCCTGAGCCTGATCACCCAGAACAACATC
JCAT          ------ATGGCCCAGGTGATCAACACCAACAGCCTGAGCCTGATCACCCAGAACAACATC
                    *****.**.** ** ** ** ** ** ***** ******** ***** ******

IDT           AACAAAAACCAATCAGCCCTGTCAAGTTCCATAGAGAGGCTGAGTAGCGGACTGAGGATA
LifeTech      AACAAGAACCAGAGCGCCCTGAGCAGCAGCATCGAGAGACTGAGCAGCGGCCTGAGAATC
JCAT          AACAAGAACCAGAGCGCCCTGAGCAGCAGCATCGAGAGGCTGAGCAGCGGCCTGAGGATC
              *****.*****.: .******: .** : ***.*****.***** *****.*****.**.

IDT           AACTCAGCAAAAGATGATGCTGCTGGTCAGGCTATAGCCAACCGGTTCACGTCTAACATA
LifeTech      AACAGCGCCAAGGACGATGCCGCTGGCCAGGCTATCGCCAACAGATTCACCAGCAACATC
JCAT          AACAGCGCCAAGGACGACGCCGCCGGCCAGGCCATCGCCAACAGGTTCACCAGCAACATC
              ***: .**.**.** ** ** ** ** ***** **.******.*.***** :  *****.

IDT           AAAGGATTGACCCAGGCTGCCCGGAACGCTAATGATGGAATCAGCGTGGCCCAGACTACA
LifeTech      AAGGGCCTGACCCAGGCCGCCAGAAACGCCAACGATGGCATCAGCGTGGCCCAGACAACA
JCAT          AAGGGCCTGACCCAGGCCGCCAGGAACGCCAACGACGGCATCAGCGTGGCCCAGACCACC
              **.**. ********** ***.*.***** ** ** **.***************** **.

IDT           GAAGGCGCTTTGAGTGAAATCAACAATAACCTCCAAAGAGTGAGAGAATTGACTGTGCAG
LifeTech      GAGGGCGCACTGAGCGAGATCAACAACAACCTGCAGAGAGTGCGCGAGCTGACCGTGCAG
JCAT          GAGGGCGCCCTGAGCGAGATCAACAACAACCTGCAGAGGGTGAGGGAGCTGACCGTGCAG
              **.*****  **** **.******** ***** **.**.***.* **. **** ******

IDT           GCTACTACTGGAACAAATAGCGAGTCCGATCTGTCTAGCATCCAGGATGAAATTAAATCC
LifeTech      GCCACCACAGGCACAAACAGCGAGAGCGACCTGTCCAGCATCCAGGACGAGATCAAGAGC
JCAT          GCCACCACCGGCACCAACAGCGAGAGCGACCTGAGCAGCATCCAGGACGAGATCAAGAGC
              ** ** ** **.**.** ******: *** ***:  *********** **.** **.: *

IDT           AGACTGGATGAAATCGATCGCGTGAGCGGACAAACTCAGTTTAACGGAGTGAATGTTCTG
LifeTech      AGACTGGATGAGATCGACAGAGTGTCCGGCCAGACCCAGTTCAACGGCGTGAACGTGCTG
JCAT          AGGCTGGACGAGATCGACAGGGTGAGCGGCCAGACCCAGTTCAACGGCGTGAACGTGCTG
              **.***** **.***** .* ***: ***.**.** ***** *****.***** ** ***

IDT           GCTAAAAATGGCAGTATGAAGATCCAGGTCGGAGCCAACGACAACCAGACAATTACAATC
LifeTech      GCCAAGAACGGCAGCATGAAGATCCAAGTGGGCGCCAACGACAACCAGACCATCACCATC
JCAT          GCCAAGAACGGCAGCATGAAGATCCAGGTGGGCGCCAACGACAACCAGACCATCACCATC
              ** **.** ***** ***********.** **.*****************.** **.***

IDT           GACCTCAAGCAAATCGACGCAAAGACGCTGGGCCTGGATGGATTTTCTGTGAAGGCATTG
LifeTech      GACCTGAAGCAGATCGACGCCAAGACCCTGGGCCTGGACGGCTTCTCTGTGAAGGCCCTG
JCAT          GACCTGAAGCAGATCGACGCCAAGACCCTGGGCCTGGACGGCTTCAGCGTGAAGGCCCTG
              ***** *****.********.***** *********** **.** :  ********. **

IDT           ATAACCGCCTCCGGCGATATTTCTTTGACTTTCAAACAGGTCGACGGGGTCAACGACGTC
LifeTech      ATCACAGCCAGCGGCGACATCAGCCTGACCTTCAAACAGGTGGACGGCGTGAACGACGTG
JCAT          ATCACCGCCAGCGGCGACATCAGCCTGACCTTCAAGCAGGTGGACGGCGTGAACGACGTG
              **.**.***: ****** ** :   **** *****.***** ***** ** ********

IDT           ACCTTGGAAAGCGTAAAAGTGTCATCATCAGCAGGCACAGGGATTGGCGTGCTGGCTGAG
LifeTech      ACCCTGGAAAGCGTGAAGGTGTCCAGCTCTGCCGGCACAGGCATCGGCGTGCTGGCTGAA
JCAT          ACCCTGGAGAGCGTGAAGGTGAGCAGCAGCGCCGGCACCGGCATCGGCGTGCTGGCCGAG
              *** ****.*****.**.***: .: .:  **.*****.** ** *********** **.

IDT           GTGATCAACAAGAATTCCAATAGGACCGGAGTGAAGGCCTATGCATCAGTGATAACTACC
LifeTech      GTGATTAACAAGAACAGCAACAGGACCGGCGTGAAGGCCTACGCCAGCGTGATCACCACA
JCAT          GTGATCAACAAGAACAGCAACAGGACCGGCGTGAAGGCCTACGCCAGCGTGATCACCACC
              ***** ******** : *** ********.*********** **.: .*****.** **.

IDT           TCCGATGTGGCTGTCCAGTCCGGGTCCCTGAGCAATCTGACCCTGAACGGCATTCACCTG
LifeTech      AGCGACGTGGCCGTGCAGAGCGGCAGCCTGTCTAACCTGACCCTGAACGGCATCCACCTG
JCAT          AGCGACGTGGCCGTGCAGAGCGGCAGCCTGAGCAACCTGACCCTGAACGGCATCCACCTG
              : *** ***** ** ***: *** : ****:  ** ***************** ******

IDT           GGCAACATCGCAGATATTAAAAAGAACGACTCTGACGGACGCCTTGTGGCAGCAATCAAT
LifeTech      GGCAATATCGCCGATATCAAGAAGAACGACAGCGACGGCAGACTGGTGGCCGCCATCAAC
JCAT          GGCAACATCGCCGACATCAAGAAGAACGACAGCGACGGCAGGCTGGTGGCCGCCATCAAC
              ***** *****.** ** **.*********:  *****..* ** *****.**.*****

IDT           GCTGTCACATCCGAGACTGGAGTGGAAGCCTACACTGATCAGAAAGGCCGACTTAACTTG
LifeTech      GCCGTGACAAGCGAGACAGGCGTGGAAGCCTACACCGACCAGAAGGGCAGACTGAACCTG
JCAT          GCCGTGACCAGCGAGACCGGCGTGGAGGCCTACACCGACCAGAAGGGCAGGCTGAACCTG
              ** ** **.: ****** **.*****.******** ** *****.***.*.** *** **

IDT           AGGTCTATCGACGGAAGAGGTATCGAAATCAAGACCGATAGTGTGTCCAATGGCCCCTCC
LifeTech      AGATCCATCGACGGCAGGGGCATCGAAATCAAGACCGACAGCGTGTCCAACGGCCCCTCC
JCAT          AGGAGCATCGACGGCAGGGGCATCGAGATCAAGACCGACAGCGTGAGCAACGGCCCCAGC
              **.:  ********.**.** *****.*********** ** ***: *** ******: *

IDT           GCACTTACTATGGTGAACGGGGGACAGGATCTCACCAAAGGGAGCACCAACTATGGCAGA
LifeTech      GCCCTGACAATGGTCAACGGCGGACAGGACCTGACCAAGGGCAGCACCAACTACGGCAGG
JCAT          GCCCTGACCATGGTGAACGGCGGCCAGGACCTGACCAAGGGCAGCACCAACTACGGCAGG
              **.** ** ***** ***** **.***** ** *****.** *********** *****.

IDT           CTGTCATTGACTAGACTGGATGCTAAGAGCATCAATGTTGTGTCTGCTTCTGACTCCCAA
LifeTech      CTGTCCCTGACAAGACTGGACGCCAAGTCCATCAACGTGGTGTCCGCCAGCGACTCCCAG
JCAT          CTGAGCCTGACCAGGCTGGACGCCAAGAGCATCAACGTGGTGAGCGCCAGCGACAGCCAG
              ***: . **** **.***** ** ***: ****** ** ***:  ** :  ***: ***.

IDT           CATCTGGGCTTCACCGCCATTGGTTTCGGCGAGTCCCAGGTCGCCGAAACTACTGTAAAT
LifeTech      CACCTGGGCTTTACAGCTATCGGCTTCGGCGAGAGCCAGGTGGCCGAGACTACCGTGAAT
JCAT          CACCTGGGCTTCACCGCCATCGGCTTCGGCGAGAGCCAGGTGGCCGAGACCACCGTGAAC
              ** ******** **.** ** ** *********: ****** *****.** ** **.**

IDT           TTGCGAGATGTGACCGGAAATTTTAATGCCAACGTCAAATCAGCCAGTGGCGCAAACTAC
LifeTech      CTGAGGGACGTGACCGGCAACTTCAACGCTAACGTGAAGTCCGCCTCCGGCGCTAACTAC
JCAT          CTGAGGGACGTGACCGGCAACTTCAACGCCAACGTGAAGAGCGCCAGCGGCGCCAACTAC
              **.*.** ********.** ** ** ** ***** **.: .***:  ***** ******

IDT           AATGCTGTGATCGCTAGTGGAAACCAATCTCTTGGCAGTGGGGTAACTACTCTGAGGGCT
LifeTech      AACGCTGTGATCGCCTCTGGCAACCAGAGCCTGGGAAGCGGCGTGACCACACTGAGAGCT
JCAT          AACGCCGTGATCGCCAGCGGCAACCAGAGCCTGGGCAGCGGCGTGACCACCCTGAGGGCC
              ** ** ******** :  **.*****.:  ** **.** ** **.** ** *****.**

IDT           GTGGCCAACGGCAAGACCACAGATCCCCTGAAGGCCCTCGATGACGCAATAGCCTCTGTG
LifeTech      GTGGCCAACGGCAAGACCACCGACCCCCTGAAGGCTCTGGACGACGCTATCGCCTCCGTG
JCAT          GTGGCCAACGGCAAGACCACCGACCCCCTGAAGGCCCTGGACGACGCCATCGCCAGCGTG
              ********************.** *********** ** ** ***** **.***:  ***

IDT           GATAAATTTAGAAGTAGCCTTGGAGCCGTGCAGAATCGACTCGATAGCGCTGTTACAAAT
LifeTech      GACAAGTTCAGATCCAGCCTGGGCGCTGTGCAGAACAGACTGGACAGCGCCGTGACCAAC
JCAT          GACAAGTTCAGGAGCAGCCTGGGCGCCGTGCAGAACAGGCTGGACAGCGCCGTGACCAAC
              ** **.** **.:  ***** **.** ******** .*.** ** ***** ** **.**

IDT           CTGAATAACACCACCACAAATCTGTCTGAAGCACAGTCACGCATTCAGGATGCTGATTAT
LifeTech      CTGAACAACACCACCACCAACCTGTCCGAGGCCCAGAGCAGAATCCAGGATGCCGACTAC
JCAT          CTGAACAACACCACCACCAACCTGAGCGAGGCCCAGAGCAGGATCCAGGACGCCGACTAC
              ***** ***********.** ***:  **.**.***: ..* ** ***** ** ** **

IDT           GCAACAGAAGTTAGCAATATGTCCAAGGCCCAAATCATCCAACAGGCTGGGAACAGCGTC
LifeTech      GCCACCGAGGTGTCCAACATGAGCAAGGCCCAGATCATCCAGCAGGCCGGCAACTCTGTG
JCAT          GCCACCGAGGTGAGCAACATGAGCAAGGCCCAGATCATCCAGCAGGCCGGCAACAGCGTG
              **.**.**.** : *** ***: *********.********.***** ** ***:  **

IDT           CTTGCCAAAGCTAATCAGGTACCACAGCAGGTATTGTCCCTGCTTCAGGGG
LifeTech      CTGGCTAAGGCCAACCAGGTGCCCCAGCAGGTGCTGAGTCTGCTGCAGGGA
JCAT          CTGGCCAAGGCCAACCAGGTGCCCCAGCAGGTGCTGAGCCTGCTGCAGGGC
              ** ** **.** ** *****.**.********. **:  ***** *****
&lt;/pre&gt;&lt;/div&gt;
</content><category term="biotech"/><category term="DNA vaccine"/></entry><entry><title>DNA Vaccine Dosing</title><link href="/DNA%20vaccine%20dosing.html" rel="alternate"/><published>2014-08-13T14:00:00-07:00</published><updated>2014-08-13T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-13:/DNA vaccine dosing.html</id><summary type="html">&lt;p class="first last"&gt;How much DNA do you need to use in a DNA vaccine?&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Aldevron, which seems like an awesome company,
is giving away &lt;a class="reference external" href="http://www.aldevron.com/products/dnas/plasmids/"&gt;free samples&lt;/a&gt; of 2µg of DNA vaccine.
I could grow that up to make more of course, but how much DNA do I actually need to
inject to elicit a reasonable humoral response?
The answer is not straightforward. &lt;a class="reference external" href="http://en.wikipedia.org/wiki/DNA_vaccination"&gt;Wikipedia says&lt;/a&gt; the following:&lt;/p&gt;
&lt;blockquote&gt;
Saline injections require variable amounts of DNA,
from 10μg-1 mg, whereas gene gun deliveries require
100 to 1000 times less DNA than intramuscular saline
injection to raise an effective immune response.
Generally, 0.2μg to 20μg are required, although
quantities as low as 16ng have been reported.&lt;/blockquote&gt;
&lt;p&gt;One &lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pubmed/18257910"&gt;paper on DNA tattooing&lt;/a&gt; used 50μg of DNA per injection.&lt;/p&gt;
&lt;p&gt;For DNA vaccines, it seems like more DNA is always better.
Thankfully, 500μg of DNA is a reasonable amount of DNA to grow up since,
for example, this &lt;a class="reference external" href="http://www.qiagen.com/products/catalog/sample-technologies/dna-sample-technologies/plasmid-dna/qiagen-plasmid-maxi-kit"&gt;Qiagen Plasmid Maxi Kit&lt;/a&gt; or this
&lt;a class="reference external" href="https://www.lifetechnologies.com/order/catalog/product/K210006"&gt;PureLink HiPure Plasmid Maxiprep Kit&lt;/a&gt; each yield 500μg.&lt;/p&gt;
</content><category term="biotech"/><category term="DNA vaccine"/></entry><entry><title>pVAX1</title><link href="/2014-08-13%20pVAX1.html" rel="alternate"/><published>2014-08-13T13:00:00-07:00</published><updated>2014-08-13T13:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-13:/2014-08-13 pVAX1.html</id><summary type="html">&lt;p class="first last"&gt;pVAX1&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Via &lt;a class="reference external" href="http://tools.lifetechnologies.com/content/sfs/vectors/pvax1_seq.txt"&gt;Life Technologies website&lt;/a&gt;, the pVAX1 vector sequence. It's 2999nt long.&lt;/p&gt;
&lt;pre&gt;
GACTCTTCGCGATGTACGGGCCAGATATACGCGTTGACATTGATTATTGACTAGTTATTAATAGTAATCAATTACGGGGTCATTAGTTCATAGCCCATAT
ATGGAGTTCCGCGTTACATAACTTACGGTAAATGGCCCGCCTGGCTGACCGCCCAACGACCCCCGCCCATTGACGTCAATAATGACGTATGTTCCCATAG
TAACGCCAATAGGGACTTTCCATTGACGTCAATGGGTGGACTATTTACGGTAAACTGCCCACTTGGCAGTACATCAAGTGTATCATATGCCAAGTACGCC
CCCTATTGACGTCAATGACGGTAAATGGCCCGCCTGGCATTATGCCCAGTACATGACCTTATGGGACTTTCCTACTTGGCAGTACATCTACGTATTAGTC
ATCGCTATTACCATGGTGATGCGGTTTTGGCAGTACATCAATGGGCGTGGATAGCGGTTTGACTCACGGGGATTTCCAAGTCTCCACCCCATTGACGTCA
ATGGGAGTTTGTTTTGGCACCAAAATCAACGGGACTTTCCAAAATGTCGTAACAACTCCGCCCCATTGACGCAAATGGGCGGTAGGCGTGTACGGTGGGA
GGTCTATATAAGCAGAGCTCTCTGGCTAACTAGAGAACCCACTGCTTACTGGCTTATCGAAATTAATACGACTCACTATAGGGAGACCCAAGCTGGCTAG
CGTTTAAACTTAAGCTTGGTACCGAGCTCGGATCCACTAGTCCAGTGTGGTGGAATTCTGCAGATATCCAGCACAGTGGCGGCCGCTCGAGTCTAGAGGG
CCCGTTTAAACCCGCTGATCAGCCTCGACTGTGCCTTCTAGTTGCCAGCCATCTGTTGTTTGCCCCTCCCCCGTGCCTTCCTTGACCCTGGAAGGTGCCA
CTCCCACTGTCCTTTCCTAATAAAATGAGGAAATTGCATCGCATTGTCTGAGTAGGTGTCATTCTATTCTGGGGGGTGGGGTGGGGCAGGACAGCAAGGG
GGAGGATTGGGAAGACAATAGCAGGCATGCTGGGGATGCGGTGGGCTCTATGGCTTCTACTGGGCGGTTTTATGGACAGCAAGCGAACCGGAATTGCCAG
CTGGGGCGCCCTCTGGTAAGGTTGGGAAGCCCTGCAAAGTAAACTGGATGGCTTTCTCGCCGCCAAGGATCTGATGGCGCAGGGGATCAAGCTCTGATCA
AGAGACAGGATGAGGATCGTTTCGCATGATTGAACAAGATGGATTGCACGCAGGTTCTCCGGCCGCTTGGGTGGAGAGGCTATTCGGCTATGACTGGGCA
CAACAGACAATCGGCTGCTCTGATGCCGCCGTGTTCCGGCTGTCAGCGCAGGGGCGCCCGGTTCTTTTTGTCAAGACCGACCTGTCCGGTGCCCTGAATG
AACTGCAAGACGAGGCAGCGCGGCTATCGTGGCTGGCCACGACGGGCGTTCCTTGCGCAGCTGTGCTCGACGTTGTCACTGAAGCGGGAAGGGACTGGCT
GCTATTGGGCGAAGTGCCGGGGCAGGATCTCCTGTCATCTCACCTTGCTCCTGCCGAGAAAGTATCCATCATGGCTGATGCAATGCGGCGGCTGCATACG
CTTGATCCGGCTACCTGCCCATTCGACCACCAAGCGAAACATCGCATCGAGCGAGCACGTACTCGGATGGAAGCCGGTCTTGTCGATCAGGATGATCTGG
ACGAAGAGCATCAGGGGCTCGCGCCAGCCGAACTGTTCGCCAGGCTCAAGGCGAGCATGCCCGACGGCGAGGATCTCGTCGTGACCCATGGCGATGCCTG
CTTGCCGAATATCATGGTGGAAAATGGCCGCTTTTCTGGATTCATCGACTGTGGCCGGCTGGGTGTGGCGGACCGCTATCAGGACATAGCGTTGGCTACC
CGTGATATTGCTGAAGAGCTTGGCGGCGAATGGGCTGACCGCTTCCTCGTGCTTTACGGTATCGCCGCTCCCGATTCGCAGCGCATCGCCTTCTATCGCC
TTCTTGACGAGTTCTTCTGAATTATTAACGCTTACAATTTCCTGATGCGGTATTTTCTCCTTACGCATCTGTGCGGTATTTCACACCGCATACAGGTGGC
ACTTTTCGGGGAAATGTGCGCGGAACCCCTATTTGTTTATTTTTCTAAATACATTCAAATATGTATCCGCTCATGAGACAATAACCCTGATAAATGCTTC
AATAATAGCACGTGCTAAAACTTCATTTTTAATTTAAAAGGATCTAGGTGAAGATCCTTTTTGATAATCTCATGACCAAAATCCCTTAACGTGAGTTTTC
GTTCCACTGAGCGTCAGACCCCGTAGAAAAGATCAAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCTTGCAAACAAAAAAACCACCG
CTACCAGCGGTGGTTTGTTTGCCGGATCAAGAGCTACCAACTCTTTTTCCGAAGGTAACTGGCTTCAGCAGAGCGCAGATACCAAATACTGTCCTTCTAG
TGTAGCCGTAGTTAGGCCACCACTTCAAGAACTCTGTAGCACCGCCTACATACCTCGCTCTGCTAATCCTGTTACCAGTGGCTGCTGCCAGTGGCGATAA
GTCGTGTCTTACCGGGTTGGACTCAAGACGATAGTTACCGGATAAGGCGCAGCGGTCGGGCTGAACGGGGGGTTCGTGCACACAGCCCAGCTTGGAGCGA
ACGACCTACACCGAACTGAGATACCTACAGCGTGAGCTATGAGAAAGCGCCACGCTTCCCGAAGGGAGAAAGGCGGACAGGTATCCGGTAAGCGGCAGGG
TCGGAACAGGAGAGCGCACGAGGGAGCTTCCAGGGGGAAACGCCTGGTATCTTTATAGTCCTGTCGGGTTTCGCCACCTCTGACTTGAGCGTCGATTTTT
GTGATGCTCGTCAGGGGGGCGGAGCCTATGGAAAAACGCCAGCAACGCGGCCTTTTTACGGTTCCTGGGCTTTTGCTGGCCTTTTGCTCACATGTTCTT
&lt;/pre&gt;</content><category term="biotech"/><category term="synthetic biology"/><category term="DNA vaccine"/><category term="vector"/></entry><entry><title>2014-08-13 Progress Report</title><link href="/2014-08-13%20progress%20report.html" rel="alternate"/><published>2014-08-13T12:00:00-07:00</published><updated>2014-08-13T12:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-13:/2014-08-13 progress report.html</id><summary type="html">&lt;p class="first last"&gt;Finding a vector&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="aldevron"&gt;
&lt;h2&gt;Aldevron&lt;/h2&gt;
&lt;p&gt;Aldevron posted about offering &amp;quot;open-source&amp;quot; vectors on &lt;a class="reference external" href="https://www.facebook.com/aldevron/posts/219455174821285"&gt;facebook&lt;/a&gt;.
Aldevron links to their &lt;a class="reference external" href="http://www.aldevron.com/products/dnas/plasmids/"&gt;plasmid page&lt;/a&gt;, which offers 2µg of two
&amp;quot;plasmids for vaccine validation&amp;quot; for free! Awesome!&lt;/p&gt;
&lt;blockquote&gt;
pCMV-S (also known as pRc/CMV-HBs) is widely used to validate DNA vaccine delivery
and formulation strategies. This plasmid expresses the hepatitis B surface
antigen (HBsAg) under the control of the CMV immediate-early promoter.
pCMVHB-S2.S expresses the small and middle forms of recombinant HBsAg.
The plasmid can be used to generate anti-HBsAg antibodies like pCMV-S.
It is also used to fuse other sequences to the S form of HBsAg.&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="section" id="pvax1"&gt;
&lt;h2&gt;pVAX1&lt;/h2&gt;
&lt;p&gt;The &lt;a class="reference external" href="http://tools.lifetechnologies.com/content/sfs/manuals/pvax1_man.pdf"&gt;pVAX1 technical specification document&lt;/a&gt; says you can find the sequence online.
It also says that pVAX1 is based on pcDNA&lt;/p&gt;
&lt;blockquote&gt;
pVAX1™ was constructed by modifying the vector, pcDNA™3.1, to
accommodate the following considerations put forth by the FDA Center for
Biologics Evaluation and Research (CBER) in its document, “Points to
Consider on Plasmid DNA Vaccines for Preventive Infectious Diseases
Indications” (Docket no. 96N-0400).
- Sequences not necessary for replication in E. coli or for expression of
recombinant protein in mammalian cells were removed to limit DNA
sequences with possible homology to the human genome and to minimize
the possibility of chromosomal integration.
- The kanamycin resistance gene was substituted for the ampicillin
resistance gene because aminoglycoside antibiotics are less likely to elicit
allergic responses in humans.&lt;/blockquote&gt;
&lt;p&gt;A database of DNA vaccines, &lt;a class="reference external" href="http://www.violinet.org/dnavaxdb/plasmid_detail.php?c_dv_plasmid_id=17"&gt;DNAVaxDB&lt;/a&gt; shows pcDNA3.1 as the most commonly used vector,
but pVAX1 is also popular.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="biobricks"&gt;
&lt;h2&gt;BioBricks&lt;/h2&gt;
&lt;p&gt;BioBricks has some &lt;a class="reference external" href="http://parts.igem.org/Plasmid_backbones"&gt;plasmid backbones&lt;/a&gt; but nothing obviously useful as a DNA vaccine
vector.&lt;/p&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="synthetic biology"/><category term="DNA vaccine"/><category term="vector"/></entry><entry><title>2014-08-12 Progress Report</title><link href="/vector.html" rel="alternate"/><published>2014-08-12T14:00:00-07:00</published><updated>2014-08-12T14:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-12:/vector.html</id><summary type="html">&lt;p class="first last"&gt;Finding a vector&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="more-vectors"&gt;
&lt;h2&gt;More Vectors&lt;/h2&gt;
&lt;p&gt;I am still looking for a DNA vaccine vector that I'm comfortable with.
It may be impossible to choose perfectly, but at least I should be able to justify
the choice of vector to myself.
It's also best if the vector is open-source, or at least cheap.&lt;/p&gt;
&lt;div class="section" id="williams"&gt;
&lt;h3&gt;Williams&lt;/h3&gt;
&lt;p&gt;There are a couple of very informative papers by James Williams from
&lt;a class="reference external" href="http://www.natx.com/"&gt;Nature Technology Corporation&lt;/a&gt; (NTC): (&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2693335/"&gt;Williams et al. 2009&lt;/a&gt;, &lt;a class="reference external" href="http://www.mdpi.com/2076-393X/1/3/225/pdf"&gt;Williams 2013&lt;/a&gt;).
For some reason the 2013 paper (&amp;quot;Vector Design for Improved DNA Vaccine
Efficacy, Safety and Production&amp;quot;) is not on pubmed so I am including the title here.&lt;/p&gt;
&lt;p&gt;Williams points to &lt;a class="reference external" href="http://www.lifetechnologies.com/order/catalog/product/V26020"&gt;pVAX1&lt;/a&gt; and &lt;a class="reference external" href="http://www.genlantis.com/gwiz-vectors.html"&gt;gWIZ&lt;/a&gt; as &amp;quot;first-generation&amp;quot; DNA vaccine vectors.
pVAX1 an extremely minimalist vector, much more so than other &amp;quot;expression vectors&amp;quot;
I've seen for sale. It's basically the vector I've been expecting but unable to find.
However, Williams claims that the performance of first-generation vectors
is poor due to several poor design choices.
Williams' company (NTC) makes a &amp;quot;&lt;a class="reference external" href="http://natx.com/assets/nanoplasmidbroch2014pg1-2final.pdf"&gt;third-generation&lt;/a&gt;&amp;quot; vector that has a number
of claimed advantages: mainly increased expression but also
adherence to regulatory guidelines.&lt;/p&gt;
&lt;p&gt;One modification NTC has made is that their vector is not selected for using
antibiotics like pVAX1. There is a good reason for this (see below),
but it means that the vector apparently must be grown up in a specialized &lt;em&gt;E. coli&lt;/em&gt;...&lt;/p&gt;
&lt;blockquote&gt;
The European Medicines Agency (EMA) has further concluded that kanamycin and
neomycin are of importance for veterinary and human use and cannot be classified
as having minor therapeutic relevance due to current use in critical clinical
settings. To address these regulatory concerns, alternative non-antibiotic selection
methods are needed.&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="section" id="software"&gt;
&lt;h3&gt;Software&lt;/h3&gt;
&lt;p&gt;I went back to &lt;a class="reference external" href="www.teselagen.com"&gt;Teselagen&lt;/a&gt; and &lt;a class="reference external" href="www.benchling.com"&gt;Benchling&lt;/a&gt; to see if either had a straightforward
way to embed a protein in a pre-defined expression vector.
If there was, I did not find it...
(In retrospect, &lt;a class="reference external" href="www.genomecompiler.com"&gt;Genome Compiler&lt;/a&gt; may be better at this.)
I think the problem is that these programs are really designed for operating at a
lower level than I want.
If I want to manipulate DNA sequence, I'm not sure I want to use a GUI at all.
Rather, I want something more like a wizard that solves my specific use-case and
assures me that all the hard-to-check things (protein phase, RNA secondary structure)
are ok. I'm sure I'll come back to try these programs again though...&lt;/p&gt;
&lt;p&gt;The best software I have found so far for my needs is &lt;a class="reference external" href="www.dna20.com"&gt;DNA 2.0's website&lt;/a&gt;.
Unfortunately, to my knowledge, DNA 2.0 does not have a DNA vaccine vector and the
cost per base is prohibitively high.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="commercial-vectors"&gt;
&lt;h3&gt;Commercial vectors&lt;/h3&gt;
&lt;p&gt;Most vectors seem to be designed for producing and harvesting recombinant protein,
so there's a focus on tagging and protein recovery.
I don't need that, and it could even be detrimental to protein function.
After reading Williams' paper, it turns out these are just the wrong vectors and
that there are better choices.&lt;/p&gt;
&lt;p&gt;These &lt;a class="reference external" href="http://www.sigmaaldrich.com/life-science/molecular-biology/cloning-and-expression/vector-systems/stable-expression.html"&gt;Sigma Aldrich vectors&lt;/a&gt;, which are a good example of the typical vector
product page. Confusingly, there are &amp;quot;transient&amp;quot; or &amp;quot;stable&amp;quot; types —
the &amp;quot;stable&amp;quot; expression vectors have an additional neo gene (neomycin),
which allows you to select cells where rare integrations have occurred. Every vector
has 1-3 N- or C-terminus FLAG peptides (22-66 amino acids) and/or &lt;em&gt;c-Myc&lt;/em&gt; to
allow for protein purification.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://www.dna20.com/products/expression-vectors/mammalian"&gt;DNA 2.0&lt;/a&gt; also has a nice tool to select from their mammalian expression vectors.
These vectors are very inexpensive at $200 but again they are not designed for
use as DNA vaccines.&lt;/p&gt;
&lt;p&gt;One commenter &lt;a class="reference external" href="http://www.structuralbiology.eu/support/forums/networks/p4eu/recommendation-vector-transient-transfection-mammalian-cells"&gt;notes&lt;/a&gt; that he does not like Life's pSecTag vector because it includes
NcoI cleavage sites, which means he cannot use this restriction enzyme to clone into
the MCS. That's something I didn't think about...&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="next-steps"&gt;
&lt;h3&gt;Next steps&lt;/h3&gt;
&lt;p&gt;I'll need to reread the Williams papers, and then pick one of the few available
DNA vaccine-specific vectors, and see if it's possible to use it in combination
with my protein.&lt;/p&gt;
&lt;!-- How much plasmid DNA do I need? --&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="synthetic biology"/><category term="DNA vaccine"/><category term="vector"/></entry><entry><title>Protein Design</title><link href="/protein%20design.html" rel="alternate"/><published>2014-08-12T13:00:00-07:00</published><updated>2014-08-12T13:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-12:/protein design.html</id><summary type="html">&lt;p class="first last"&gt;What is the flagellin DNA sequence?&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Here I describe the design of the flagellin I am using for my DNA vaccine and
double-check the sequence.
Quoting from the &lt;a class="reference external" href="http://2008.igem.org/Team:Slovenia"&gt;2008 Slovenian iGEM team&lt;/a&gt;'s webpage&lt;/p&gt;
&lt;blockquote&gt;
N terminus (from 1 to 176 AA) and C terminus (from 401 to 498 AA) from
E. coli FliC and variable domain from H. pylori FlaA (from 178 to 418 AA)
were amplified and joined with PCR ligation&lt;/blockquote&gt;
&lt;p&gt;1-176 (176 aas) from BAA85088.1 (&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/protein/BAA85088.1"&gt;http://www.ncbi.nlm.nih.gov/protein/BAA85088.1&lt;/a&gt;)&lt;/p&gt;
&lt;blockquote&gt;
&lt;tt class="docutils literal"&gt;MAQVINTNSLSLITQNNINKNQSALSSSIERLSSGLRINSAKDDAAGQAIANRFTSNIKGLTQAARN
ANDGISVAQTTEGALSEINNNLQRVRELTVQATTGTNSESDLSSIQDEIKSRLDEIDRVSGQTQFNG
VNVLAKNGSMKIQVGANDNQTITIDLKQIDAKTLGLDGFSVK&lt;/tt&gt;&lt;/blockquote&gt;
&lt;p&gt;178-418 (241 aas) from EJC28917 (&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/protein/EJC28917.1"&gt;http://www.ncbi.nlm.nih.gov/protein/EJC28917.1&lt;/a&gt;)&lt;/p&gt;
&lt;blockquote&gt;
&lt;tt class="docutils literal"&gt;alitasgdisltfkqvdgvndvtlesvkvsssagtgigvlaevinknsnrtgvkayasvittsdvav
qsgslsnltlngihlgniadikkndsdgrlvaainavtsetgveaytdqkgrlnlrsidgrgieikt
dsvsngpsaltmvnggqdltkgstnygrlsltrldaksinvvsasdsqhlgftaigfgesqvaettv
nlrdvtgnfnanvksasganynaviasgnqslgsgvttlr&lt;/tt&gt;&lt;/blockquote&gt;
&lt;p&gt;401-498 (98 aas) from BAA85088.1 (&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/protein/BAA85088.1"&gt;http://www.ncbi.nlm.nih.gov/protein/BAA85088.1&lt;/a&gt;)&lt;/p&gt;
&lt;blockquote&gt;
&lt;tt class="docutils literal"&gt;AVANGKTTDPLKALDDAIASVDKFRSSLGAVQNRLDSAVTNLNNTTTNLSEAQSRIQDADYATEVSN
MSKAQIIQQAGNSVLAKANQVPQQVLSLLQG&lt;/tt&gt;&lt;/blockquote&gt;
&lt;p&gt;Combined protein (516 aas)&lt;/p&gt;
&lt;blockquote&gt;
&lt;tt class="docutils literal"&gt;MAQVINTNSLSLITQNNINKNQSALSSSIERLSSGLRINSAKDDAAGQAIANRFTSNIKGLTQAARN
ANDGISVAQTTEGALSEINNNLQRVRELTVQATTGTNSESDLSSIQDEIKSRLDEIDRVSGQTQFNG
VNVLAKNGSMKIQVGANDNQTITIDLKQIDAKTLGLDGFSVKalitasgdisltfkqvdgvndvtle
svkvsssagtgigvlaevinknsnrtgvkayasvittsdvavqsgslsnltlngihlgniadikknd
sdgrlvaainavtsetgveaytdqkgrlnlrsidgrgieiktdsvsngpsaltmvnggqdltkgstn
ygrlsltrldaksinvvsasdsqhlgftaigfgesqvaettvnlrdvtgnfnanvksasganynavi
asgnqslgsgvttlrAVANGKTTDPLKALDDAIASVDKFRSSLGAVQNRLDSAVTNLNNTTTNLSEA
QSRIQDADYATEVSNMSKAQIIQQAGNSVLAKANQVPQQVLSLLQG&lt;/tt&gt;&lt;/blockquote&gt;
&lt;p&gt;For reference, we can compare this sequence to the BioBrick from iGEM team
(1583bp &lt;a class="reference external" href="http://parts.igem.org/Part:BBa_K133038"&gt;http://parts.igem.org/Part:BBa_K133038&lt;/a&gt;)&lt;/p&gt;
&lt;blockquote&gt;
&lt;tt class="docutils literal"&gt;atggcacaagtcattaataccaacagcctctcgctgatcactcaaaataatatcaacaagaaccagt
ctgcgctgtcgagttctatcgagcgtctgtcttctggcttgcgtattaacagcgcgaaggatgacgc
agcgggtcaggcgattgctaaccgtttcacctctaacattaaaggcctgactcaggcggcccgtaac
gccaacgacggtatctccgttgcgcagaccaccgaaggcgcgctgtccgaaatcaacaacaacttac
agcgtgtgcgtgaactgacggtacaggccactaccggtactaactctgagtctgatctgtcttctat
ccaggacgaaattaaatcccgtctggatgaaattgaccgcgtatctggtcagacccagttcaacggc
gtgaacgtgctggcaaaaaatggctccatgaaaatccaggttggcgcaaatgataaccagactatca
ctatcgatctgaagcagattgatgctaaaactcttggccttgatggttttagcgttaaagcgttaat
cacggcttctggggatattagcttgacttttaaacaagtggatggcgtgaatgatgtaactttagag
agcgtaaaagtttctagttcagcaggcacggggatcggtgtgttagcggaagtgattaacaaaaatt
ctaaccgaacaggggttaaagcttatgcgagcgttatcaccacgagcgatgtggcggtccaatcagg
aagtttgagtaatttaactttaaatgggatccatttgggtaatatcgcagatattaagaaaaatgac
tcagacggaaggttagtcgcagcgatcaatgcggttacttcagaaaccggcgtggaagcttatacgg
atcaaaaagggcgcttgaatttgcgcagtatagatggtcgtgggattgaaatcaaaaccgatagcgt
cagtaatgggcctagtgctttaacgatggtcaatggcggtcaggatttaacaaaaggttctactaac
tatgggaggctttctctcacacgcttagacgctaaaagcatcaatgtcgtttcggcttctgattcgc
aacatttaggtttcacagcgattggttttggggaatctcaagtggcagaaaccacggtgaatttgcg
cgatgttactgggaattttaacgctaatgtcaaatcagccagtggcgcgaactataacgccgtgatc
gctagcggtaaccaaagcttgggatctggggttacaaccttaagagctgttgcaaatggtaaaacca
cggatccgctgaaagcgctggacgatgctatcgcatctgtagacaaattccgttcttccctcggtgc
ggtgcaaaaccgtctggattccgcggttaccaacctgaacaacaccactaccaacctgtctgaagcg
cagtcccgtattcaggacgccgactatgcgaccgaagtgtccaatatgtcgaaagcgcagatcatcc
agcaggccggtaactccgtgttggcaaaagctaaccaggtaccgcagcaggttctgtctctgttaca
gggttactagagcgaggagaccaccaccaccaccaccactag&lt;/tt&gt;&lt;/blockquote&gt;
&lt;p&gt;BBa_K133038 translated&lt;/p&gt;
&lt;blockquote&gt;
&lt;tt class="docutils literal"&gt;MAQVINTNSLSLITQNNINKNQSALSSSIERLSSGLRINSAKDDAAGQAIANRFTSNIKGLTQAARN
ANDGISVAQTTEGALSEINNNLQRVRELTVQATTGTNSESDLSSIQDEIKSRLDEIDRVSGQTQFNG
VNVLAKNGSMKIQVGANDNQTITIDLKQIDAKTLGLDGFSVKALITASGDISLTFKQVDGVNDVTLE
SVKVSSSAGTGIGVLAEVINKNSNRTGVKAYASVITTSDVAVQSGSLSNLTLNGIHLGNIADIKKND
SDGRLVAAINAVTSETGVEAYTDQKGRLNLRSIDGRGIEIKTDSVSNGPSALTMVNGGQDLTKGSTN
YGRLSLTRLDAKSINVVSASDSQHLGFTAIGFGESQVAETTVNLRDVTGNFNANVKSASGANYNAVI
ASGNQSLGSGVTTLRAVANGKTTDPLKALDDAIASVDKFRSSLGAVQNRLDSAVTNLNNTTTNLSEA
&lt;span class="pre"&gt;QSRIQDADYATEVSNMSKAQIIQQAGNSVLAKANQVPQQVLSLLQGY-SEETTTTTTT&lt;/span&gt;&lt;/tt&gt;&lt;/blockquote&gt;
&lt;p&gt;Finally, I align translated BBa_K133038 to my protein,
and the two are identical, apart from the final &amp;quot;Y-SEETTTTTTT&amp;quot; in BBa_K133038.
I do not know why this is, but I don't believe it's important.&lt;/p&gt;
</content><category term="biotech"/><category term="synthetic biology"/><category term="vaccine"/></entry><entry><title>Transdermal Drug Delivery</title><link href="/transdermal%20drug%20delivery.html" rel="alternate"/><published>2014-08-12T12:00:00-07:00</published><updated>2014-08-12T12:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-12:/transdermal drug delivery.html</id><summary type="html">&lt;p class="first last"&gt;How do you get drugs into the blood.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Vaccines and biologics would be much more convenient if you did not have to inject them.
I found two interesting reviews on this topic,
&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3419303/"&gt;Kim et al.&lt;/a&gt; &lt;em&gt;Microneedles for drug and vaccine delivery&lt;/em&gt;
and &lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2700785/"&gt;Prausnitz and Langer&lt;/a&gt; &lt;em&gt;Transdermal drug delivery&lt;/em&gt;.&lt;/p&gt;
&lt;div class="section" id="kim-et-al"&gt;
&lt;h2&gt;Kim et al.&lt;/h2&gt;
&lt;p&gt;Microneedles are an effective compromise between topical application and injection.&lt;/p&gt;
&lt;blockquote&gt;
Drug delivery into the skin for local or systemic effects is extremely difficult
due to the highly effective barrier properties of skin’s outer layer, the stratum
corneum. The human stratum corneum is only 10-15 μm thick, but precludes
absorption of most drugs at therapeutic levels. The approximately 20 drugs with
approval from the Food and Drug Administration (FDA) as transdermal patches all
have molecular weights below 400 Da, are relatively lipophilic and require low doses.
Because the barrier layer of skin is just microns thick, microneedles have been
developed to cross the stratum corneum without going deeply into the skin, thereby
avoiding pain and bleeding. By by-passing the stratum corneum barrier, microneedles
have been shown to dramatically increase the number of compounds that can be
administered across the skin, including low molecular weight drugs, biotherapeutics,
vaccines and other materials.&lt;/blockquote&gt;
&lt;p&gt;Interestingly, you can buy several types of &lt;a class="reference external" href="http://www.amazon.com/Microneedle-System-NEW-SPA-1-50mm/dp/B002F4Z18A/ref=sr_1_3?s=beauty&amp;amp;ie=UTF8&amp;amp;qid=1402513139&amp;amp;sr=1-3&amp;amp;keywords=dermaroller+fda"&gt;dermaroller&lt;/a&gt; (some say &amp;quot;FDA listed&amp;quot;)
from amazon (or a similar &lt;a class="reference external" href="http://www.amazon.com/MEDca-Derma-Micro-Needle-Stamp/dp/B00A3J80PK/ref=sr_1_1?ie=UTF8&amp;amp;qid=1402510181&amp;amp;sr=8-1&amp;amp;keywords=derma+stamp"&gt;microneedle stamp&lt;/a&gt;) for under $30.
They are sold as cosmetic devices, e.g., for the treatment of acne scars.
In general, skin damage (including skin tattooing) seems to help with evoking
an immune response.&lt;/p&gt;
&lt;blockquote&gt;
While the above studies employed microneedles fabricated as research prototypes,
the Dermaroller® and other similar FDA-registered devices are sold commercially
for cosmetic purposes and have also been investigated a transdermal drug delivery
tool by pretreating the skin with microneedle punctures generated by a cylindrical
roller of metal microneedles. Microneedle rollers have also been applied to
enhance optical skin clearing by glycerol and increased skin permeability to
chondroitin sulfate.&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div class="section" id="prausnitz-and-langer"&gt;
&lt;h2&gt;Prausnitz and Langer&lt;/h2&gt;
&lt;p&gt;This paper summarizes several ways to achieve transdermal delivery.&lt;/p&gt;
&lt;blockquote&gt;
The third generation of transdermal delivery systems is poised to make significant
impact on drug delivery because it targets its effects to the stratum corneum.
This targeting enables stronger disruption of the stratum corneum barrier, and
thereby more effective transdermal delivery, while still protecting deeper tissues.
In this way, novel chemical enhancers, electroporation, cavitational ultrasound and
more recently microneedles, thermal ablation and microdermabrasion
(Arora, Prausnitz and Mitragotri31) have been shown to deliver macromolecules,
including therapeutic proteins and vaccines, across the skin in human clinical trials.&lt;/blockquote&gt;
&lt;p&gt;One delivery method that is missing from the list, since it's not strictly transdermal,
is sublingual delivery (see &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Thin-film_drug_delivery"&gt;thin film drug delivery&lt;/a&gt;, which can also be buccal).
For example, you can buy TheraFlu as &amp;quot;thin strips&amp;quot; that dissolve in your mouth.
Listerine breath strips apparently use the same polymer as many thin film drugs.&lt;/p&gt;
&lt;p&gt;Sublingual delivery is more like injection than ingestion, since it delivers drugs
into the bloodstream without first passing through the liver (first-pass metabolism).
I don't know if there are limitations on the size of molecule that can be delivered
this way, though there are vaccines in development.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="wang-et-al"&gt;
&lt;h2&gt;Wang et al.&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://drugdelivery.chbe.gatech.edu/Papers/2014/Wang%20JCR%202014.pdf"&gt;Wang et al.&lt;/a&gt;, linked from Prausnitz, is an example of using microneedles to
inject an influenza vaccine.
The authors of the paper made their own microneedle array using an infrared laser!&lt;/p&gt;
&lt;blockquote&gt;
After electropolishing, the thickness of the microneedles reduced to 50 μm, and
each microneedle in the array measured 700 μm in length and 160 μm in width at the base,
tapering to a sharp tip.&lt;/blockquote&gt;
&lt;p&gt;Dermarollers actually have similar dimensions to the Wang et al. microneedle array,
though definitely thicker (according to the product page, &lt;a class="reference external" href="_http://www.amazon.com/Microneedle-Conditions-Stimulating-Production-Yorktek/dp/B009653PPW/ref=pd_sim_bt_5?ie=UTF8&amp;amp;refRID=1Y31JMSTWAP6X62PNDVG"&gt;one dermaroller&lt;/a&gt;'s needles
are 0.5mm to 1.5mm in length and 0.2mm thick)&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="bachy-et-al"&gt;
&lt;h2&gt;Bachy et al.&lt;/h2&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pubmed/23386724"&gt;Bachy et al.&lt;/a&gt; also have an interesting paper on creating microneedle arrays for the
delivery of a vaccine. The microneedle array is made of Na-CMC-sucrose (Na-CMC is
mechanically strong and sucrose is a protein stabilizer). The needles dissolve
after 5 minutes in contact with the mouse's skin.
Apparently, the desiccated virus did not lose immunogenicity.
This is pretty amazing...&lt;/p&gt;
&lt;!-- Flu shot --&gt;
&lt;!-- - - - - - - - - --&gt;
&lt;!-- How does the current flu shot work? --&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="vaccine"/></entry><entry><title>2014-08-11 Progress Report</title><link href="/progress%202014-08-11.html" rel="alternate"/><published>2014-08-11T12:00:00-07:00</published><updated>2014-08-11T12:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-11:/progress 2014-08-11.html</id><summary type="html">&lt;p class="first last"&gt;Progress report&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="choosing-a-vector"&gt;
&lt;h2&gt;Choosing a Vector&lt;/h2&gt;
&lt;p&gt;The second component of the vaccine is the vector (plasmid backbone).
The one major criterion here is that the vector must be strongly and constitutively
expressed in mammals.&lt;/p&gt;
&lt;p&gt;Ideally, the vector is specifically designed for protein expression in mammals:
i.e., it has a leader (signal) peptide, a Kozak sequence,
a transcription termination signal, and optimizations to
improve expression, such as enhancers.&lt;/p&gt;
&lt;p&gt;Many vectors include &lt;em&gt;myc&lt;/em&gt; epitopes and/or polyhistidine tags to enable you to
recover the recombinant protein.
With a DNA vaccine, we are not attempting to harvest the recombinant protein
so this stuff is unnecessary, and may even be detrimental.&lt;/p&gt;
&lt;p&gt;I first looked around for a suitable BioBrick vector, but I could not find one.
I found a &lt;a class="reference external" href="http://www.researchgate.net/post/Can_anyone_recommend_a_good_source_for_purchasing_plasmids"&gt;reference&lt;/a&gt; to &lt;a class="reference external" href="http://www.addgene.org/empty_backbones/#host"&gt;addgene.org&lt;/a&gt; that seemed promising, but the plasmids
I found there were limited to non-commercial use.&lt;/p&gt;
&lt;p&gt;Although I'd prefer not to use a commercial vector, there are a few that
seemed promising.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Invitrogen/Life Technologies &lt;a class="reference external" href="http://tools.lifetechnologies.com/content/sfs/manuals/psectag2_man.pdf"&gt;pSecTag2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;clonTech &lt;a class="reference external" href="http://www.clontech.com/xxclt_ibcGetAttachment.jsp?cItemId=17708"&gt;pIRES&lt;/a&gt;: The main advantage of this vector is that it can express two
proteins from one CMV promoter thanks to an IRES&lt;/li&gt;
&lt;li&gt;NEB &lt;a class="reference external" href="https://www.neb.com/products/n9317-pmcp-tagm-vector"&gt;pMCP&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="next-steps"&gt;
&lt;h3&gt;Next Steps&lt;/h3&gt;
&lt;p&gt;I am still working on choosing a vector. I need to look more into BioBricks, DNA 2.0's
Electra system, and commercial vectors.
There may be some useful information in gene design software too
(Teselagen, Benchling, Genome Compiler...)&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="progress"/></entry><entry><title>Mammalian Promoter Strength</title><link href="/promoters.html" rel="alternate"/><published>2014-08-11T11:00:00-07:00</published><updated>2014-08-11T11:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-11:/promoters.html</id><summary type="html">&lt;p class="first last"&gt;What is the strongest mammalian promoter?&lt;/p&gt;
</summary><content type="html">&lt;p&gt;What is the strongest mammalian promoter?
Cytomegalovirus (CMV) appears to be the &lt;em&gt;de facto&lt;/em&gt; standard, but how close
is it to the true maximum promoter strength?
An iGEM team from &lt;a class="reference external" href="http://2009.igem.org/Team:Heidelberg/Project_Measurement"&gt;Heidelberg&lt;/a&gt; built a mammalian system for characterizing
promoter strength. They show that CMV is a strong promoter relative to a baseline (JeT)
but they do not get as far as &lt;a class="reference external" href="http://2009.igem.org/Team:Heidelberg/Project_Synthetic_promoters"&gt;developing&lt;/a&gt; a new constitutive synthetic promoter
to replace CMV.
The team does seem to think that there is room for improvement over CMV though.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="http://www.pnas.org/content/107/6/2538.full"&gt;Schlabach et al.&lt;/a&gt; had a paper in 2010 where they investigated all possible 10-mers as
possible enhancers to a minimal CMV promoter:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We have taken a synthetic biology approach to the generation and screening of
transcription factor binding sites for activity in human cells. All possible
10-mer DNA sequences were printed on microarrays as 100-mers containing 10 repeats
of the same sequence in tandem, yielding an oligonucleotide library of 52,429 unique
sequences. This library of potential enhancers was introduced into a retroviral
vector and screened in multiple cell lines for the ability to activate GFP
transcription from a minimal CMV promoter.
[...]&lt;/p&gt;
&lt;p&gt;None of the elements were capable of achieving the same levels of transcriptional
enhancement across all tested cell lines as the CMV enhancer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A stronger-than-CMV mammalian promoter would be extremely useful for many applications.&lt;/p&gt;
</content><category term="biotech"/><category term="synthetic biology"/></entry><entry><title>2014-08-10 Progress Report</title><link href="/progress%202014-08-10.html" rel="alternate"/><published>2014-08-10T12:00:00-07:00</published><updated>2014-08-10T12:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-10:/progress 2014-08-10.html</id><summary type="html">&lt;p class="first last"&gt;Progress report&lt;/p&gt;
</summary><content type="html">&lt;!--  --&gt;
&lt;!-- Testing png vs svg for images --&gt;
&lt;!-- For exporting svg, first do Object/Artboards/Fit to Artwork Bounds --&gt;
&lt;!-- Note that the format is different between png and svg --&gt;
&lt;!-- Modifiers (scale, align, etc) don't seem to really work. Height, width work. --&gt;
&lt;!--  --&gt;
&lt;!-- .. image:: {static}/images/dna_vaccine.png --&gt;
&lt;!-- .. image:: /images/dna_vaccine.svg --&gt;
&lt;div class="section" id="protein-design"&gt;
&lt;h2&gt;Protein Design&lt;/h2&gt;
&lt;p&gt;Like the &lt;a class="reference external" href="http://2008.igem.org/Team:Slovenia"&gt;Slovenian iGEM entry&lt;/a&gt; from 2008, I decided to use flagellin as my
antigenic protein.&lt;/p&gt;
&lt;p&gt;The Slovenian team were attempting to elicit a humoral response to &lt;em&gt;H. pylori&lt;/em&gt;
flagellin — a protein that normally evades the mammalian immune system — by creating
a hybrid flagellin that is part &lt;em&gt;E. coli&lt;/em&gt; and part &lt;em&gt;H. pylori&lt;/em&gt;.
This would then allow for the creation of a vaccine against &lt;em&gt;H. pylori&lt;/em&gt;.
At least half the world's population is &lt;a class="reference external" href="http://en.wikipedia.org/wiki/Helicobacter_pylori#Epidemiology"&gt;infected&lt;/a&gt; with &lt;em&gt;H. pylori&lt;/em&gt;,
famously discovered as the cause of stomach ulcers.&lt;/p&gt;
&lt;p&gt;Flagellin is about 400 amino acids long, which turns out to be helpful
since it's still a little complex to synthesize anything longer than 2000 nucleotides.
For example, &lt;a class="reference external" href="http://www.idtdna.com/pages/products/genes/gblocks-gene-fragments"&gt;IDT's gBlocks&lt;/a&gt;, which are very inexpensive and commonly used,
max out at 2000 nucleotides.
It's not particularly difficult to combine fragments to make longer genes,
but it's also not off-the-shelf.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;E. coli&lt;/em&gt; flagellin is highly immunogenic, as you might expect from a common and
abundant bacterial protein.
There's even a specific innate immune receptor, &lt;a class="reference external" href="http://en.wikipedia.org/wiki/TLR5"&gt;Toll-like receptor 5&lt;/a&gt;,
that recognizes flagellins.&lt;/p&gt;
&lt;p&gt;So as a short-ish protein that evokes a strong immune response, flagellin is a
reasonable choice for my experiment.&lt;/p&gt;
&lt;div class="section" id="codon-optimization"&gt;
&lt;h3&gt;Codon optimization&lt;/h3&gt;
&lt;p&gt;For most amino acids, there is more than one corresponding codon.
These codons vary in their efficiency of translation,
and different organisms prefer different codons.
The difference in the total amount of protein you get can be vast, so
to maximize expression of my protein, I need to choose my codons carefully.
There are many tools to help with this problem, including tools from
&lt;a class="reference external" href="http://www.idtdna.com/CodonOpt"&gt;IDT&lt;/a&gt;, &lt;a class="reference external" href="https://www.dna20.com/resources/genedesigner"&gt;DNA 2.0&lt;/a&gt; and &lt;a class="reference external" href="http://www.genscript.com/codon_opt.html"&gt;GenScript&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Apart from choosing the most highly expressed codons for your organism, the major
thing these methods do is avoid motifs that lead to unwanted secondary effects,
such as restriction sites, rho-independent termination or internal translation (&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Internal_ribosome_entry_site"&gt;IRES&lt;/a&gt;).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="next-steps"&gt;
&lt;h3&gt;Next steps&lt;/h3&gt;
&lt;p&gt;It seems like it should be obvious, but I am still unsure which restriction sites
I need to avoid in my protein sequence.
&lt;em&gt;E. coli&lt;/em&gt; methylates its genome to protect itself from self-cleaving and
plasmid DNA is also apparently methylated, so the plasmid should be safe from
&lt;em&gt;E. coli&lt;/em&gt; restriction enzymes. However, I don't know which restriction enzyme
will be used to clone my protein into its vector, so for now I am assuming I
need to avoid any restriction sites contained in the multiple cloning site (&lt;a class="reference external" href="http://en.wikipedia.org/wiki/Multiple_cloning_site"&gt;MCS&lt;/a&gt;)
of the vector.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="progress"/></entry><entry><title>iGEM</title><link href="/iGEM%202014-08-10.html" rel="alternate"/><published>2014-08-10T11:00:00-07:00</published><updated>2014-08-10T11:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-10:/iGEM 2014-08-10.html</id><summary type="html">&lt;p class="first last"&gt;iGEM links&lt;/p&gt;
</summary><content type="html">&lt;p&gt;iGEM is a fantastic synthetic biology competition for undergrads and grad students.
The competition has been running since 2004, and attracts teams from all over the world.
iGEM is notable for the ambition of its entries, I think at least partially
because undergrads aren't afraid to try wacky ideas.&lt;/p&gt;
&lt;p&gt;The iGEM site is a great place to look for new ideas in synthetic biology.
I found a long list of abstracts from each team, linked from
&lt;a class="reference external" href="http://igem.org/Previous_iGEM_Competitions"&gt;http://igem.org/Previous_iGEM_Competitions&lt;/a&gt;.
There are probably 100 startup ideas in here...&lt;/p&gt;
&lt;p&gt;For example, here are the 2013 team abstracts:
&lt;a class="reference external" href="http://2013.igem.org/Jamboree/Team_Abstracts"&gt;http://2013.igem.org/Jamboree/Team_Abstracts&lt;/a&gt;&lt;/p&gt;
</content><category term="biotech"/><category term="synthetic biology"/></entry><entry><title>Naked DNA and Hair Follicles</title><link href="/naked%20DNA.html" rel="alternate"/><published>2014-08-09T16:00:00-07:00</published><updated>2014-08-09T16:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-09:/naked DNA.html</id><summary type="html">&lt;p class="first last"&gt;Naked DNA can sometimes enter the body through hair follicles&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Surprisingly, topically applying naked DNA to skin or exposed mucus membranes
actually has some precedent and some interesting successes.&lt;/p&gt;
&lt;p&gt;In 2000, &lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pubmed/10625389"&gt;Alexeev et al.&lt;/a&gt; demonstrated that topical application of an
RNA-DNA oligonucleotide could partially reverse a mouse's albinism!
The albinism was due to a point mutation that the oligo reversed.
In other words, by topically applying a substance to the mouse's skin they
changed the genome of the mouse.
I always thought that this would be a cool way to dye your hair.&lt;/p&gt;
&lt;p&gt;There are limitations when applying drugs transdermally:
&amp;quot;The approximately 20 drugs with approval from the Food and Drug Administration (FDA) as
transdermal patches all have molecular weights below 400 Da, are relatively lipophilic
and require low doses&amp;quot; (&lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3419303/"&gt;Kim et al.&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;This &lt;a class="reference external" href="http://www.ncbi.nlm.nih.gov/pubmed/21235583"&gt;2011 paper&lt;/a&gt; by Yu et al. goes into more detail about plasmid uptake
through hair follicles. As you may expect, damaging the skin
(e.g., chemically or by hair plucking) improves plasmid uptake.&lt;/p&gt;
&lt;img alt="naked dna" class="align-center" src="/images/nbt0406-416-F1.gif" style="width: 400px; height: 484px;" /&gt;
&lt;p&gt;In this &lt;a class="reference external" href="http://www.nature.com/nbt/journal/v24/n4/full/nbt0406-416.html"&gt;2006 review&lt;/a&gt;, they describe a very nice experiment to find the peptide that
best overcomes the skin barrier in mice. As shown in the diagram above, they simply
apply a phage library to the mouse, harvest the phage most successful at crossing the skin
barrier and entering the blood. The winning peptide is a simple 11mer: ACSSSPSKHCG!&lt;/p&gt;
&lt;p&gt;It's intriguing to think about combining these methods to improve the efficiency
of DNA vaccine uptake transdermally.&lt;/p&gt;
</content><category term="biotech"/><category term="nakeddna"/><category term="synthetic biology"/></entry><entry><title>2014-08-09 Progress Report</title><link href="/progress%202014-08-09.html" rel="alternate"/><published>2014-08-09T12:00:00-07:00</published><updated>2014-08-09T12:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-09:/progress 2014-08-09.html</id><summary type="html">&lt;p class="first last"&gt;Progress report&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="latex"&gt;
&lt;h2&gt;LaTex&lt;/h2&gt;
&lt;p&gt;I started a LaTex document to describe my first DNA vaccine experiment in detail.
It may also potentially be usable as part of an SBIR grant.
My hope is that the LaTex document will be a more formal summary of information
written up for this blog.&lt;/p&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="progress"/></entry><entry><title>2014-08-08 Progress Report</title><link href="/progress%202014-08-08.html" rel="alternate"/><published>2014-08-08T12:00:00-07:00</published><updated>2014-08-08T12:00:00-07:00</updated><author><name>Boolean Biotech</name></author><id>tag:None,2014-08-08:/progress 2014-08-08.html</id><summary type="html">&lt;p class="first last"&gt;Progress report&lt;/p&gt;
</summary><content type="html">&lt;div class="section" id="experiment-1"&gt;
&lt;h2&gt;Experiment #1&lt;/h2&gt;
&lt;p&gt;I think I have finalized a simple design for my first experiment.
The experiment has to be very simple since I will be attempting to outsource
all of the steps.&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Design and synthesize an immunogenic protein (e.g., flagellin) that can be expressed
in a plasmid (i.e., a DNA vaccine)&lt;/li&gt;
&lt;li&gt;Inject mice with the DNA vaccine using an immunostimulating method
(probably skin tattooing)&lt;/li&gt;
&lt;li&gt;Draw blood from the mice (a) before DNA vaccine injection, (b) after 7 days, and
(c) after 28 days. Sequence the VDJ region from immunoglobulin and T-cell receptors
in peripheral blood.&lt;/li&gt;
&lt;li&gt;Determine which antibodies or TCRs have shown the greatest response to the expressed
protein, and look for common patterns of immune response among the mice.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The ideal outcome of this experiment is that several mice injected with the same
vaccine produce similar humoral (antibody) responses.
Then I could say with some certainty that these antibodies are emerging
in response to my vaccine.&lt;/p&gt;
&lt;p&gt;My original depiction of a DNA vaccine experiment is below.
The numbers are probably best ignored, since many caveats apply to each.
Nevertheless, the general concept of an inexpensive iteration on DNA vaccine design
still seems reasonable.
This experiment also takes some inspiration and cues from the excellent
&lt;a class="reference external" href="http://2008.igem.org/Team:Slovenia"&gt;Slovenian iGEM entry&lt;/a&gt; from 2008.&lt;/p&gt;
&lt;object data="/images/dna_vaccine.svg" type="image/svg+xml"&gt;&lt;/object&gt;
&lt;/div&gt;
</content><category term="biotech"/><category term="progress"/></entry></feed>