turn the LTEE data into a report that rebuilds itself
compute every number, table and figure when the report renders
change a report with parameters and formats, not edits
The copy-paste problem
analysis.py ──► results.csv ──► (copy) ──► Figure 2 in report.docx
▲
data changes ─────────┘ the report does not notice
Which version of the data made Figure 2? Nobody knows.
Literate programming
“Let us concentrate rather on explaining to human beings what we want a computer to do.” — Donald Knuth, 1984
Text and code in one document
The document is rendered by running the code
The output is always in sync with the code and the data
Quarto connects code with results
Figure: NBIS, Tools for Reproducible Research, CC BY 4.0
A Quarto document holds the code and the text about its results, and makes the results by running the code.
Quarto in one picture
ltee-report.qmd ──quarto render──► runs Python ──► ltee-report.html
text (Markdown) (fresh session, ltee-report.pdf
code cells top to bottom) slides, Word, websites
settings (YAML)
This website and these slides are Quarto documents too.
What a cell looks like
```{python}#| label: tbl-samples#| tbl-cap: "The three LTEE clones in this project."samples = pd.read_csv("metadata/samples.tsv", sep="\t")samples[["sample", "strain", "generation"]]```Clones were frozen at generations `{python} ", ".join(map(str, samples["generation"]))`(@tbl-samples).
---title: "Mutations in the LTEE"author: "Ada Lovelace"format: html: code-fold: true---## QuestionHow many mutations did *E. coli*accumulate over 50,000 generations?
YAML header: title, format, options
Markdown text
Code cells: run when you render
One command, many outputs
pixi run quarto render reports/ltee-report.qmd # HTMLpixi run quarto render reports/ltee-report.qmd --to typst # PDFpixi run quarto render reports/ltee-report.qmd -P max_reads:2000 # other parameter
Rendering
quarto render report.qmd # the formats listed in the headerquarto render report.qmd --to pdf # one specific formatquarto preview report.qmd # re-render on every save
In this course: pixi run quarto render ..., so the report uses the project’s Python. VS Code, Positron and RStudio also have a Render button.
Output formats
Documents: HTML, PDF (Typst or LaTeX), Word, Jupyter notebooks