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.
- 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, thenconda activate rnaseq. - Run
which python3before and afterconda activate rnaseq- where does it point each time, and why? - Install a compiled tool that pip could never give you:
conda install -c bioconda samtools, thensamtools --version. That is the conda difference. - Record the environment:
conda env export --from-history > environment.yml. Open the file and skim what it captured - why is--from-historyshorter than a full export? - The real test of the record:
conda deactivate, remove the environment withconda env remove -n rnaseq, then rebuild it withconda env create -f environment.ymland activate it again. The environment is disposable; the text file is the asset. - 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 willgit clonethis straight onto Talapas.) - 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 toenvironment.yml? - A taste of
renv: in a scratch R project runrenv::init(), install one package,renv::snapshot(), and read therenv.lockit wrote. Same idea, R dialect. - 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.