1 of 25

Anna Lorenc

Immunogenomics, Gosia Trynka

al16@sanger.ac.uk

Bioinformatics for immunology

2 of 25

14:30 – 15:30

Bioinformatics tools and resources for immunology

Anna Lorenc

15:30 – 16:00

Networking break

16:00 – 18:00

R/Python intro

Marta Perez-Alcantara, Elena Lukyanova, Anna Lorenc

3 of 25

genome

Technology

Bioinformatics tools and resources for immunology

transcriptome

proteome

TCRs/BCRs

epitopes

open chromatin

HLA

scRNAseq

scATACseq

CITEseq...

Bulk RNAseq

Bulk proteome

Bulk Chipseq

Flow cytometry

CYTOF

TCR/BCR

bulk/sc

RNA/DNA

Image analysis

Databases and datasets

Reference sequences for HLA/TCR/BCR

Aggregation of experimental datasets

(TCRs, flow cytometry, gene expression)

Topic databases of experimental data (TCR-antigen, antibody-epitope)

Specific experiments

proteome

4 of 25

5 of 25

TCR/BCR

5

VDJdb

ImmuneACCESS

McPass-TCR

TCRdb

iReceptor

VDJserver

OAS

6 of 25

Tools, references

Receptors

(tools + references)

MHC

(references + tools)

TRUST4

arcasHLA

R packages

Immunotation (Convert HLA alleles)

IgGeneUsage(bayesian tests for allele usage)

COMPASS (bayesian test for cell subset differences)

immunarch (CRAN)

Olga

(probability of generation)

TCRdist3

7 of 25

www.scrna-tools.org

github.com/seandavi/awesome-single-cell

8 of 25

R CRAN

Bioconductor

packages, vignettes, workflow examples, past courses, books...

Python

Where to look for help

stackoverflow

Biostars

Bioc list

github

scikit-learn

Scverse

single cell Python packages

Where to look for inspiration

rstats.wtf (also youtube)

www.r-bloggers.com

Advanced R https://adv-r.hadley.nz/

Package/framework – specific sites

(often github)

9 of 25

Organising tools into workflows:

Shell scripts

Snakemake

Nextflow

Installing & organising tools

Conda (package manager) with thousands of biology relevant packages. Recipes to install ‘complicated’ software

Run a ready docker container – where all the software is already installed. Grab results

10 of 25

What shape?

What slots?

How to put/ access/ change the data in a container?

Input data?

Parameters?

Default values?

Methods implemented?

Type of output?

formatted

data

functions

results

raw data

11 of 25

AnnData <-> SingleCellExperiment<-> Seurat

SingleCellExperiment

AnnData

R object used by Bioconductor packages��Rows contain features and columns contain cells

Python object used by Scanpy and related packages��Rows contain observations (cells) and columns contain variables (features)

IMPLEMENTED

Each element is a matrix of expression values with the same dimensions

SimpleList of matrices

assays

X

Numpy array

Primary matrix of expression data

layers

Dictionary of arrays

Dictionary-like object where each element is an array of expression values with the same dimensions as X

Any unstructured data

list

metadata

uns

OrderedDict

Unstructured annotation

Names of rows (cells)

vector

colnames

obs_names

Pandas index

Names of observations (cells)

Columns describe annotations of the columns (cells)

DataFrame

colData

obs

Pandas DataFrame

One-dimensional annotations of the observations (cells)

Each element is a matrix where the number of rows is equal to the number of cells and each column is a dimension

List of matrices

reducedDims

obsm

Dictionary of arrays

Dictionary-like object where each element is an array where the number of rows is equal to the number of observations (cells)

Relationships between columns (cells)

List of SelfHits

colPairs

obsp

Dictionary of arrays

Dictionary-like object where each element is a square array containing annotations between observations (cells)

Names of rows (features)

vector

rownames

var_names

Pandas index

Names of variables (features)

Columns describe annotations of the rows (features)

DataFrame

rowData

vars

Pandas DataFrame

One-dimensional annotations of the variables (features)

varm

Dictionary of arrays

Dictionary-like object where each element is an array where the number of rows is equal to the number of variables (features)

Relationships between rows (features)

List of SelfHits

rowPairs

varp

Dictionary of arrays

Dictionary-like object where each element is a square array containing annotations between variables (features)

NOT IMPLMENTED

Nested SingleCellExperiments with information about alternative feature sets

List of SingleCellExperiments

altExp

raw

AnnData

Raw version of X and var prior to any filtering. Is not indexed as part of the object.

Internal unstructured data that is not meant to be modified by users

list

int_metadata

Internal annotation for columns (cells) that is not meant to be modified by users

DataFrame

int_colData

Internal annotation for rows (features) that is not meant to be modified by users

DataFrame

int_elementMetadata

12 of 25

data in containers

functions

results

data saved for a future analysis

plots

numerical/

tabular results

interactive presentations

your code

raw data

13 of 25

your code

raw data

14 of 25

your code

raw data

data saved for a future analysis

plots

numerical/

tabular results

interactive presentations

15 of 25

Raw data

Document!

For collaborators

For posteriority

For yourself

For publication

#Comment code

Comment choice of methods, parameters

Note software and references versions

Notebooks, markdown files – analysis narrative + code

RProjects

Git (+GitHub) - for version control and as a repository

Structure your working directories

README files

your code

raw data

16 of 25

Working with R projects

  • A way of keeping together all files related to a project: code files, results, notes, history etc.
  • Easy for version control

Start an Rproject for a project

Rproject <= scientific project

17 of 25

When you reopen an R project

  • A new R session (process) is started
  • The .Rprofile file in the project's main directory (if any) is sourced by R
  • The .RData file in the project's main directory is loaded (if project options indicate that it should be loaded).
  • The .Rhistory file in the project's main directory is loaded into the RStudio History pane (and used for Console Up/Down arrow command history).
  • The current working directory is set to the project directory.
  • Previously edited source documents are restored into editor tabs
  • Other RStudio settings (e.g. active tabs, splitter positions, etc.) are restored to where they were the last time the project was closed.

Not recommended

18 of 25

GitHub/GitLab

local machine

online repo

git clone https://github.com/SomeUser/SomeRepo.git

git clone https://github.com/AnnaLorenc/tutorials22.git

Commandline, git managers

RStudio has a version control interface too

time

Git

19 of 25

├── .git

├── .gitignore

├── README

├── analysis

│   ├── R

│   │   ├── 01.summarise_genotypes.Rmd

│   │   └── 02.summarise_expression.Rmd

│   ├── eqtl

│   │   └── 04.tensor_flow

│   └── python

│       └── 03.join_expression_to_genotypes.ipynb

├── doc

│   ├── manuscript.md

│   └── notebook.md

├──external_data

│   ├──DICE_expression�│   └──README

├── raw_data

│   ├── expression

│   ├── genotypes

│   └── meta_data

└── results

    ├── eqtl_tensor_flow

    └── plots

20 of 25

├── README.md

├── analysis

├── cellranger

├── count_tables

├── cytoimmgen-phase-2-env-spec-list.txt

├── jupyter_files

├── logs

├── metadata

├── plots

├── README.md

├── cellDeconvolution

│   ├── genotypingData

│   └── vireoOutput

├── colocalization

│   ├── Biogen_coloc_results

│   ├── README.md

│   ├── coloc_config_file.json

│   ├── colocalizing-snps_pp0.6_immune-traits_pseudobulked-time-points.tsv

│   ├── cytoimmgen_ld_calculations

│   ├── downstream_analysis

│   └── results

├── eQTL_mapping

│   ├── cytoimmgen-phase2-genotypes-rsids-dbSNP-v151-grch38-collapsed.tsv

│   ├── cytoimmgen-phase2-genotypes-rsids-dbSNP-v151-grch38.txt

│   ├── eQTL_catalogue_files

│   ├── eqtl_file_list.txt

│   ├── eqtl_groups_list.txt

│   ├── eqtl_sample_sizes.tsv

│   ├── lead_signals_with_q_value

│   ├── median_expression_file_list.txt

│   └── qtl_number.csv

└── scRNAseq_data_analysis

    ├── Activation-time-course-CD4-T-cells_farm.Rmd

    ├── EDA_resting_T_cells.ipynb

    ├── Effectorness_analysis_resting_CD4_cells.Rmd

.git

.gitignore

raw data

R

python

21 of 25

Shade A, Teal TK (2015) Computing

Workflows for Biologists: A Roadmap. PLoS Biol

Raw data + metadata safely backed up

Considering & trying many possible tools and workflows

Optimising parameters for the tools

Extracted final version of the analysis

22 of 25

Shade A, Teal TK (2015) Computing

Workflows for Biologists: A Roadmap. PLoS Biol

23 of 25

Wilson G, Bryan J, Cranston K, Kitzes J,

Nederbragt L, Teal TK (2017) Good enough

practices in scientific computing

PLoS Comput Biol

Box 1. Summary of practices

  1. Data management
    1. Save the raw data.
    2. Ensure that raw data are backed up in more than one location.
    3. Create the data you wish to see in the world.
    4. Create analysis-friendly data
    5. Record all the steps used to process data.
    6. Anticipate the need to use multiple tables, and use a unique identifier for every record.
    7. Submit data to a reputable DOI-issuing repository so that others can access and cite it.
  2. Software
    • Place a brief explanatory comment at the start of every program.
    • Decompose programs into functions.
    • Be ruthless about eliminating duplication.
    • Always search for well-maintained software libraries that do what you need.
    • Test libraries before relying on them.
    • Give functions and variables meaningful names.
    • Make dependencies and requirements explicit.
    • Do not comment and uncomment sections of code to control a program’s behavior.
    • Provide a simple example or test data set.
    • Submit code to a reputable DOI-issuing repository.

....

A lot of biologists suffered when testing essentiality of these rules!

24 of 25

Anna Lorenc

Marta Alcantara

Elena Lukyanova

Immunogenomics, Gosia Trynka

al16@sanger.ac.uk

R, Python intro

25 of 25

Exercise 1

Open exercises description in exercises.html

Activate conda

Start RStudio and navigate to a work directory

Start jupyter notebook

Create directory structure for your work

Exercise 2

Python with jupyter notebook

Exercise 3

tidyverse

Exercise 4

Working out an unknown package

/home/training/Bioinfo-T-Cell-Immunology-July22/Day1/tutorials22

Conda: group2_training_env

Change directory

cd

Display directory content

ls

Make directory DIR

mkdir DIR