Pangenome Analysis
Overview
After annotating multiple bacterial genomes, we can compare their gene content using pangenome analysis.
The pangenome represents the full set of genes found across a group of genomes. It includes:
- core genes: genes shared by most or all samples
- accessory genes: genes present in some samples
- unique genes: genes found in only one sample
In this lesson, we will use Panaroo to perform pangenome analysis using .gff files from eight samples.
Learning objectives
By the end of this lesson, you should be able to:
- explain what a pangenome is
- distinguish between core and accessory genes
- activate the
pangenomeenvironment - run
Panaroousing multiple.gfffiles - identify important Panaroo output files
- prepare the core gene alignment for phylogenetic analysis
Input files
In the previous lessons, we prepared annotation files for eight samples.
The input files for Panaroo are:
annotation/S1.gff
annotation/S2.gff
annotation/S3.gff
annotation/S4.gff
annotation/S5.gff
annotation/S6.gff
annotation/S7.gff
annotation/S8.gff
Check that the files are present:
ls annotation/*.gffCount the number of GFF files:
ls annotation/*.gff | wc -lThe expected number is:
8
Panaroo uses .gff files as input.
For this lesson, we will use:
annotation/*.gff
Activate the pangenome environment
Activate the pangenome environment:
conda activate pangenomeCheck that panaroo is available:
panaroo --versionRun Panaroo
Run Panaroo using all .gff files:
panaroo \
-t 4 \
-o pangenome \
--core_threshold 0.95 \
-a core \
--input annotation/*.gff \
--clean-mode strictUnderstanding the Panaroo command
| Option | Meaning |
|---|---|
panaroo |
Runs the Panaroo pangenome tool |
-t 4 |
Uses 4 CPU threads |
-o pangenome |
Output directory |
--core_threshold 0.95 |
Core gene threshold |
-a core |
Generates a core gene alignment |
--input annotation/*.gff |
Uses all GFF files in the annotation folder |
--clean-mode strict |
Uses strict cleaning mode |
The value of --core_threshold defines the core gene threshold.
For example:
--core_threshold 0.95
means genes present in at least 95% of genomes are considered core genes.
You may choose a different value depending on the analysis goal.
Check Panaroo outputs
After Panaroo finishes, list the output directory:
ls pangenomeYou should see several output files.
Important files may include:
gene_presence_absence.csv
gene_presence_absence.Rtab
core_gene_alignment.aln
core_gene_alignment_filtered.aln
summary_statistics.txt
Important Panaroo output files
| File | Description |
|---|---|
gene_presence_absence.csv |
Main gene presence/absence table |
gene_presence_absence.Rtab |
Gene presence/absence matrix |
core_gene_alignment.aln |
Core gene alignment |
core_gene_alignment_filtered.aln |
Filtered core gene alignment |
summary_statistics.txt |
Summary of pangenome results, if produced |
View gene presence/absence table
Check the first few lines:
head pangenome/gene_presence_absence.csvThis file shows which genes are present or absent across the samples.
Gene,Non-unique Gene name,Annotation,S1,S2,S3,S4,S5,S6,S7,S8
group_1515,,hypothetical protein,S1_03472,S2_03486,S3_03567,S4_03467,S5_03504,S6_03533,S7_03454,S8_03471
group_1514,,hypothetical protein,S1_03471,S2_03487,S3_03566,S4_03466,S5_03503,S6_03532,S7_03453,S8_03470
tacT,tacT,tRNA-acetylating toxin,S1_03465,S2_03485,S3_03562,S4_03461,S5_03516,S6_03517,S7_03444,S8_03465
group_1507,,hypothetical protein,S1_03464,S2_03484,S3_03561,S4_03460,S5_03517,S6_03518,S7_03443,S8_03466
tufB,tufB,Elongation factor Tu 2,S1_03462,S2_03513,S3_03558,S4_03457,S5_03512,S6_03513,S7_03439,S8_03462
group_1492,,hypothetical protein,S1_03430,S2_03525,S3_03526,S4_03434,S5_01638,S6_03538,S7_03388,S8_03430
rimI_5,rimI_5;,[Ribosomal protein bS18]-alanine N-acetyltransferase;hypothetical protein,S1_03431,S2_03524,S3_03527,S4_03435,S5_01637,S6_03537,S7_03387,S8_03429
group_1488,,hypothetical protein,S1_03420,S2_03475,S3_03577,S4_03421,S5_03487,5_refound_27,6_refound_32,S8_03407
group_1483,,hypothetical protein,S1_03413,S2_03514,S3_03529,S4_03384,S5_03513,S6_03475,S7_03465,S8_03437
Interpreting the output
The file gene_presence_absence.csv shows which genes are present or absent across all genomes included in the pangenome analysis.
| Column | Meaning |
|---|---|
Gene |
Gene cluster name assigned by Panaroo |
Non-unique Gene name |
Gene name, if available |
Annotation |
Functional annotation of the gene |
S1 to S8 |
Gene ID found in each sample |
How to read the table
Each row represents one gene cluster.
For example:
tacT
is annotated as:
tRNA-acetylating toxin
It is present in all eight samples:
S1
S2
S3
S4
S5
S6
S7
S8
The sample columns contain gene identifiers such as:
S1_03465
S2_03485
S3_03562
This means Panaroo found a corresponding gene in those samples.
Core genes
If a gene is present in all samples, it is part of the core genome for this dataset.
In this example, the genes shown are present in all eight samples, so they are examples of core gene clusters.
Examples include:
tacT
tufB
rimI_5
Refound genes
Some entries may include names such as:
5_refound_27
6_refound_32
This means Panaroo recovered or refound a gene that may have been missed or fragmented during annotation.
In this example, group_1488 includes refound genes in samples S6 and S7.
Questions
What does each row in gene_presence_absence.csv represent?
Each row represents one gene cluster across the genomes included in the pangenome analysis.
What does it mean if a gene has entries in all samples from S1 to S8?
It means the gene is present in all samples.
For this dataset, that gene is part of the core genome.
Which gene is annotated as tRNA-acetylating toxin?
The gene is:
tacT
Which gene is annotated as Elongation factor Tu 2?
The gene is:
tufB
Check core gene alignment
Check the core alignment files:
ls -lh pangenome/*alignment*You should see files such as:
core_gene_alignment.aln
core_gene_alignment_filtered.aln
Which Panaroo output file will be used later for phylogenetic tree construction?
The filtered core gene alignment will be used for phylogenetic analysis:
pangenome/core_gene_alignment_filtered.aln
Core and accessory genome
Panaroo helps identify genes shared across all or most genomes, as well as genes found in only some samples.
| Gene category | Meaning |
|---|---|
| Core genes | Present in most or all genomes |
| Accessory genes | Present in some genomes |
| Unique genes | Present in only one genome |
Why are core genes useful for phylogenetic analysis?
Core genes are shared across samples, so they can be aligned and compared across all genomes. This makes them useful for estimating evolutionary relationships.
Optional: inspect summary statistics
If Panaroo creates a summary statistics file, view it using:
cat pangenome/summary_statistics.txtyou may see output like this:
Core genes (99% <= strains <= 100%) 3075
Soft core genes (95% <= strains < 99%) 0
Shell genes (15% <= strains < 95%) 728
Cloud genes (0% <= strains < 15%) 228
Total genes (0% <= strains <= 100%) 4031
Interpreting the pangenome summary
| Category | Definition | Number of genes |
|---|---|---|
| Core genes | Present in 99% to 100% of strains | 3,075 |
| Soft core genes | Present in 95% to less than 99% of strains | 0 |
| Shell genes | Present in 15% to less than 95% of strains | 728 |
| Cloud genes | Present in 0% to less than 15% of strains | 228 |
| Total genes | All genes detected across all strains | 4,031 |
What does this mean?
In this dataset, most genes are part of the core genome.
Core genes = 3075
Total genes = 4031
This means many genes are shared across almost all samples.
The remaining genes are part of the accessory genome:
Shell genes = 728
Cloud genes = 228
These genes vary between samples and may represent differences in gene content, mobile genetic elements, virulence factors, resistance genes, or other accessory functions.
Pangenome categories
| Category | Simple meaning |
|---|---|
| Core genome | Genes found in almost all samples |
| Soft core genome | Genes found in most samples |
| Shell genome | Genes found in several, but not all, samples |
| Cloud genome | Rare genes found in only a few samples |
| Pangenome | Total set of all genes found in all samples |
Download pangenome outputs from the server
If you are working on a remote server, download the pangenome output folder to your local computer.
From your local desktop terminal, run:
scp -r genomevm@172.28.28.12:~/tanzim/pangenome .scp -r genomevm@172.28.28.12:~/tanzim/`pangenome` .This downloads the full pangenome directory.
If you only want the main gene presence/absence table, run:
From your local desktop terminal, run:
scp -r genomevm@172.28.28.12:~/tanzim/pangenome/gene_presence_absence.csv .scp -r genomevm@172.28.28.12:~/tanzim/pangenome/`gene_presence_absence.csv` .Final directory structure
At the end of this lesson, your directory should look like this:
.
├── annotation
│ ├── S1.gff
│ ├── S2.gff
│ ├── S3.gff
│ ├── S4.gff
│ ├── S5.gff
│ ├── S6.gff
│ ├── S7.gff
│ └── S8.gff
└── pangenome
├── gene_presence_absence.csv
├── gene_presence_absence.Rtab
├── core_gene_alignment.aln
├── core_gene_alignment_filtered.aln
└── summary_statistics.txt
Practical exercise
Complete the following tasks:
- Activate the
pangenomeenvironment. - Confirm that eight
.gfffiles are present inannotation. - Run
Panaroousing all.gfffiles. - Open
gene_presence_absence.csv. - Identify the core gene alignment file.
- Record which file will be used for phylogenetic analysis.
Create a small table in your notes:
| Item | File or value |
|---|---|
| Number of input GFF files | |
| Panaroo output directory | pangenome |
| Gene presence/absence table | |
| Core gene alignment | |
| Filtered core gene alignment |
Fill in the table using the files inside the pangenome directory.
Key points
- Pangenome analysis compares gene content across multiple genomes.
- Panaroo uses
.gffannotation files as input. - Core genes are shared across most or all samples.
- Accessory genes are present in only some samples.
core_gene_alignment_filtered.alnwill be used for phylogenetic tree construction.
Next step
In the next lesson, we will use the filtered core gene alignment to construct a phylogenetic tree.