This 2-hour, hands-on workshop explores the Python data visualization ecosystem, focusing on the relationship between Matplotlib Figure/Axes objects and Seaborn's high-level statistical plotting functions. Working with a real bulk RNA-seq dataset, we build quality-control plots, distributions, volcano and MA plots, heatmaps and PCA/t-SNE/UMAP embeddings, and then assemble them into a multi-panel, publication-ready figure exported at high resolution.
By the end of this workshop, you should be able to:
- Explain the Matplotlib Figure/Axes model and use the object-oriented interface to build and customise plots.
- Reshape data into tidy (long) format and choose between axes-level and figure-level Seaborn functions.
- Create common biological visualizations: distributions, strip/box plots, volcano and MA plots, (clustered) heatmaps and PCA/t-SNE/UMAP embeddings.
- Assemble a multi-panel figure at journal column width with consistent colours, fonts and panel labels.
- Export figures as editable vector (PDF/SVG) and ≥300 dpi raster files ready for post-processing.
- Basic Python: variables, lists/dictionaries, loops, calling functions.
- Basic pandas: reading a CSV into a DataFrame, selecting rows and columns.
- To run the exercises, either:
- (Preferred) a Google account to run the notebook in Google Colab – nothing to install; or
- a local Python ≥ 3.10 installation with Jupyter (JupyterLab, VS Code or PyCharm).
- (For the rest of the bootcamp: Inkscape installed and a free Overleaf account.)
- Click the Student version badge above (you may need to sign in to Google).
- Run the first code cell. It detects Colab, installs the two packages Colab is missing (
umap-learn,adjustText) and reads the data directly from this repository – no download needed. - Optional: File → Save a copy in Drive to keep your work.
git clone https://github.com/QLS-MiCM/DataVisualizationInPython.git
cd DataVisualizationInPython
python -m pip install -r requirements.txt # or: conda install -c conda-forge --file requirements.txt
jupyter lab Exercises/scripts/DataVisualizationInPython.ipynbPackages used: NumPy, pandas, Matplotlib (≥ 3.8), Seaborn (≥ 0.13), SciPy, scikit-learn, umap-learn and adjustText.
Run the notebook from inside
Exercises/scripts/so that the relative data path../data/works. Exported figures are written to afigures/folder next to the notebook.
| Module | Topic | Time | Exercise |
|---|---|---|---|
| 0 | Setup & the dataset | 10 min | – |
| 1 | Anatomy of a Matplotlib figure (Figure vs Axes, OO interface) | 15 min | Horizontal bar chart |
| 2 | Seaborn, tidy data & distributions | 20 min | Small multiples with catplot |
| 3 | Relationships: scatter, volcano & MA plots | 20 min | MA plot |
| 4 | Heatmaps & clustered heatmaps | 15 min | Heatmap of top DE genes |
| 5 | Dimensionality reduction: PCA, t-SNE, UMAP | 15 min | t-SNE perplexity |
| 6 | Multi-panel figures & high-resolution export | 20 min | Build & export your own figure |
| – | Wrap-up: publication-figure checklist & feedback | 5 min | – |
The full outline is in Outline/ and the slides in Slides/.
├── README.md
├── requirements.txt
├── Exercises
│ ├── data # input data (see below)
│ ├── data_scripts # scripts that generate the data, notebooks and outline
│ ├── scripts # STUDENT notebook (fill in the ___ blanks)
│ ├── solutions # SOLUTIONS notebook (executed, with outputs)
│ └── results # example exported figures (PDF / SVG / PNG)
├── Slides
│ ├── QLS-MiCM_DataVisualizationInPython.pptx / .pdf
│ └── feedback-qr.png
└── Outline
├── MiCM - Data Visualization in Python Workshop Outline.docx / .pdf
└── Outline.md
Bulk RNA-seq of post-mortem human cornea, limbus and sclera infected ex vivo with SARS-CoV-2 or mock (3 tissues × 2 conditions × 3 donors = 18 samples; GEO GSE164073). The count matrix is the one used in the QLS-MiCM Differential Gene Expression Analysis workshop.
| File | Description |
|---|---|
Exercises/data/sample_metadata.csv |
sample, tissue, condition for the 18 samples |
Exercises/data/GSE164073_Eye_count_matrix.tsv |
raw read counts (27,946 genes × 18 samples) |
Exercises/data/log2cpm_filtered.csv |
log2(CPM + 1) of 13,422 genes with ≥ 1 CPM in ≥ 3 samples |
Exercises/data/de_cornea_CoV2_vs_mock.csv |
differential expression in cornea, CoV2 vs mock (PyDESeq2) |
All derived files are regenerated with python Exercises/data_scripts/prepare_data.py.
The notebooks are generated from a single source with python Exercises/data_scripts/build_notebooks.py.
- Eriksen AZ, et al. (2021). SARS-CoV-2 infects human adult donor eyes and hESC-derived ocular epithelium. Cell Stem Cell. doi:10.1016/j.stem.2021.04.028
- Muzellec B, et al. (2023). PyDESeq2: a python package for bulk RNA-seq differential expression analysis. Bioinformatics. doi:10.1093/bioinformatics/btad547
- Rougier NP, Droettboom M, Bourne PE (2014). Ten simple rules for better figures. PLoS Comput Biol.
- Crameri F, Shephard GE, Heron PJ (2020). The misuse of colour in science communication. Nat Commun.
- Weissgerber TL, et al. (2015). Beyond bar and line graphs: time for a new data presentation paradigm. PLoS Biol.
- Matplotlib documentation & cheatsheets · Seaborn tutorial
This workshop builds on the QLS-MiCM Data Processing in Python, Advanced Data Visualization and Differential Gene Expression Analysis workshops.
Workshop created as part of the McGill Initiative in Computational Medicine (QLS-MiCM). For more information, visit https://www.mcgill.ca/micm/. Questions: workshop-micm@mcgill.ca