Week 9 Exercises - Software Environments

Short, ungraded practice tasks - about 35 minutes, all on your laptop. Companion reading: the environments sections of Ch. 12 and Ch. 20. These tasks set up the toolchain your term project should finish inside - and next week the same environment travels to Talapas.

  1. Make your first conda environment on your laptop (no conda yet? Install Miniforge - the link and the why are in Ch. 12): conda create -n rnaseq python=3.12 pandas matplotlib, then conda activate rnaseq.
  2. Run which python3 before and after conda activate rnaseq - where does it point each time, and why?
  3. Install a compiled tool that pip could never give you: conda install -c bioconda samtools, then samtools --version. That is the conda difference.
  4. Record the environment: conda env export --from-history > environment.yml. Open the file and skim what it captured - why is --from-history shorter than a full export?
  5. The real test of the record: conda deactivate, remove the environment with conda env remove -n rnaseq, then rebuild it with conda env create -f environment.yml and activate it again. The environment is disposable; the text file is the asset.
  6. Reproducibility = code + environment, versioned together: git add environment.yml && git commit -m "Add project environment" in the repository you made last week, and push. (Next week you will git clone this straight onto Talapas.)
  7. A taste of venv (deactivate conda first): python3 -m venv ~/scratch_env && source ~/scratch_env/bin/activate, pip install requests, pip freeze. How does the record (pip freeze) compare to environment.yml?
  8. A taste of renv: in a scratch R project run renv::init(), install one package, renv::snapshot(), and read the renv.lock it wrote. Same idea, R dialect.
  9. For your term project: create the project’s own environment now, export its environment.yml, and commit it next to the project code. All remaining project computing happens inside it - and next week it travels with you to Talapas.