Homework 2 - Computational Tools for Bioengineers 2026

Due: Submit your work via Canvas by the end of the day (midnight) on Monday, November 30th, 2026.

Note

Assigned Monday, November 16, 2026 - and posted early so you can plan ahead. Parts 1 and 2 use material you already have (Weeks 5-7); Part 3 uses the Week 8 lecture (Git and GitHub); Part 4 uses the Week 9 lecture on software environments (Nov 23). Do the parts in order as the lectures land, and the whole assignment stays comfortable.

Learning Objectives

By completing this homework, you will demonstrate that you can:

  • Write a complete, re-runnable analysis script in R or Python that reads, reshapes, summarizes and visualizes a real dataset
  • Author a Quarto report in which the prose, code, figures and even the numbers in your sentences regenerate from the data on every render
  • Put the whole project under version control with Git, with a meaningful commit history and a README, and publish it to GitHub
  • Create and record a software environment (environment.yml), rebuild it from that record, and show your analysis runs inside it
  • Assemble all of the above into one repository that another scientist could clone and re-run from scratch

Background

This is the full loop of modern computational science, in miniature: analyze locally, document reproducibly, record the environment, and publish it so it travels. (The last piece - scaling it to Talapas - arrives in Week 10 and belongs to your term project.) You will use the course stickleback RNA-seq dataset (Stickle_RNAseq.tsv: 80 fish, 2 host genotypes × 2 microbiota treatments, 600 genes). Everything you need appeared in Lectures 05-09, the Week 6 companion notebooks, and Exercises 6-9 - this assignment asks you to put the pieces together yourself. The term project (due December 11) follows exactly this shape, so treat HW2 as its dress rehearsal.

Part 1: The analysis script

Task 1.1: Set up the project

Create a clean project folder with the course layout (data/, scripts/, results/), and put Stickle_RNAseq.tsv in data/.

Task 1.2: Write scripts/analyze_stickleback.R (or .py)

Your script must run top to bottom with Rscript / python3 from the project root, and:

  1. Read the dataset and reshape it to long format (one row per fish × gene)
  2. Choose four genes (not Gene1-Gene4!) and justify your choice in a comment - e.g., the four most variable genes, or the four with the largest genotype difference
  3. Write a per-group summary table (mean, median and sd of counts per genotype × microbiota group, for your four genes) to results/
  4. Compute the mean and variance of every one of the 600 genes and write that table to results/
  5. Save two figures to results/ as SVG and 300-dpi PNG:
    • the faceted violin-plus-points panel of your four genes (the Lecture 06 “destination figure”)
    • the mean-variance plot of all 600 genes, on log scales, with the variance-equals-mean line
  6. Fail politely: check that the input file exists and exit with a non-zero status if not

Part 2: The Quarto report

Task 2.1: Author report.qmd

Write a short (1-2 page) report around your analysis, with:

  • A YAML header (title, your name, format: html) and a setup chunk
  • Inline code so the fish count, gene count, and your four gene names in the prose come from the data, not your keyboard
  • Both figures as labelled chunks with captions, each cross-referenced from the text (@fig-...)
  • One displayed LaTeX equation (for example, the standard error or the Poisson mass function you are comparing the mean-variance plot against)
  • A short Methods paragraph stating where the analysis ran and naming the two things that make it reproducible: environment.yml and the Git history of your GitHub repository (give its URL here)

Task 2.2: Render it cleanly

Restart R/Python, clear everything, and render from scratch. A report that only renders because of leftovers in your console is not reproducible.

Part 3: Under version control, onto GitHub

Task 3.1: Make the project a repository

git init your project folder before you write much code, and commit as you work - at least five meaningful commits with messages that say why, not just what. Add a .gitignore that excludes data/ (large raw files do not belong in Git; your script and README say where the data come from).

Task 3.2: Publish it

Create a repository on GitHub, connect it, and push. Add a README.md modeled on the example README: what the project is, where the data live, the repository layout, and how to reproduce the results.

(Stretch goal, not graded: render your report into docs/, push, and flip on GitHub Pages - your HW2 as a live website, exactly as we did in Lecture 08.)

Part 4: The environment that makes it travel

Task 4.1: Create and record the environment (laptop)

Create a conda environment containing exactly what your script needs, and record it portably:

conda env export --from-history | sed '/prefix:/d' > environment.yml

Task 4.2: Prove it rebuilds

The test of the record is the rebuild: remove the environment (conda env remove -n ...), recreate it with conda env create -f environment.yml, activate it, re-run your Part 1 script inside it, and re-render the report. Commit environment.yml to the repository - code and environment, versioned together. (In Week 10 you will rebuild this same file on Talapas for your term project.)

(Using R for Part 1? You may instead pin your packages with renv and commit renv.lock - say so in your Methods paragraph. The conda route is still required for Task 4.1, with your four favorite Python packages, so you have practiced it.)

What to submit (one zip on Canvas)

hw2_yourname/
├── report.qmd  +  report.html      # Part 2, with your GitHub URL in Methods
├── README.md                       # Part 3
├── scripts/analyze_stickleback.R   # or .py        (Part 1)
├── environment.yml                 # Part 4
└── results/                        # the tables and figures your script produced

Also paste your GitHub repository URL into the Canvas submission comment.

What we grade (30% of course grade): the script runs top-to-bottom (8%); the report renders cleanly with working inline code and cross-references (8%); the GitHub repository has a sensible .gitignore, a real commit history and a README another scientist could follow (7%); the environment record rebuilds and the analysis runs inside it (5%); organization and professionalism (2%).

Tip

Stuck? Ex 6-9 walk through every individual step; the Week 6 companion notebooks and working scripts on the Examples page cover Part 1; and office hours are Friday 11:00-12:00 in the KC2 Computational Suite.