Pangenome analysis with Roary

Overview
Creative Commons License: CC-BY Questions:
  • How can we identify core and accessory genes across multiple bacterial strains?

  • How do we generate a pangenome using Prokka and Roary?

  • How can we infer the evolutionary relationship of these strains?

Objectives:
  • Annotate genomes using Prokka.

  • Use Roary to identify core and accessory genes.

  • Construct a phylogenetic tree of core genes with IQ-TREE.

Requirements:
Time estimation: 1 hour
Level: Introductory Introductory
Supporting Materials:
Published: Jul 21, 2026
Last modification: Jul 21, 2026
License: Tutorial Content is licensed under Creative Commons Attribution 4.0 International License. The GTN Framework is licensed under MIT
version Revision: 1

Pangenomics

When the sequencing era truly began in the 1970s with the establishment of Sanger sequencing, it laid the foundation for the Human Genome Project, which in turn led to the human reference genome used widely today.

In traditional bioinformatic workflows, a single, linear reference genome (like the human reference genome) is dominantly used as the standard approach for comparative genomics. While this has driven great advancements in genetics, it suffers from a fundamental limitation known as reference bias (Ballouz et al. 2019). Because a single reference genome only represents the genetic assembly of one individual (or a mosaic of a few), it fails to capture the broader genetic profile of an entire species. Consequently, structural variations or novel sequences present in other strains are often misaligned, unaligned, or completely discarded during mapping (Matthews et al. 2024). Therefore, linear reference genomes are insufficient to represent true genetic diversity.

To overcome this, pangenomes can be used. The field of Pangenomics is an approach that captures the natural genomic variation within a species far better than a single linear reference genome (Liao et al. 2023). Ideally, it represents the entire genomic repertoire of a species. By capturing all of this information, the pangenomic approach aims to eliminate reference bias, ensuring that no genetic information is ignored during mapping simply because it does not exist in a single reference assembly (see Figure 1).

Comparison of a pangenome approach with traditional reference approach
Figure 1: Comparison of a pangenome approach with a traditional reference approach (Matthews et al. 2024). With a traditional reference approach, any sample reads that cannot be mapped to the reference are discarded. A pangenomic approach solves this limitation by capturing a wider range of genetic diversity. This allows a higher percentage of sample reads to map, meaning more of the actual sample genome can be used for downstream analysis.

The concept of a pangenome is not novel. However, when the term “Pangenome” was born, it was not financially or computationally feasible to pursue it further. “Pangenome” was first used by Sigaux 2000 to describe a database of genomic and transcriptomic alterations found in tumor cells versus normal cells. Tettelin et al. 2005 also brought the concept of pangenomics into the spotlight while sequencing multiple strains of Group B Streptococcus (GBS) to help develop a vaccine. During this process, they noticed that with every new strain they sequenced, they continued to identify novel genes absent from previously sequenced strains. They concluded that a single reference genome was insufficient to capture the full genetic diversity of a species. If they had used the first sequenced strain as their sole reference, all the novel genes from the new strains would have been unmapped and discarded during analysis.

With the advent of Next-Generation Sequencing technologies around 2010, sequencing became significantly faster and more affordable. Today, the reduced sequencing costs, combined with increased computational resources compared to the early 2000s, make it possible to properly realize true pangenomes. This technological leap led to the release of the first human pangenome draft in 2023 (Liao et al. 2023).

According to Matthews et al. 2024, there exist three major types of pangenomes. Here we focus on the Presence-Absence Variation Pangenome (see Figure 2) that was originally introduced by Tettelin et al. 2005 and whose description has been expanded by others over the years. This consists of:

  • The Core Genome: Set of genes shared by all individuals of a species. This is sometimes strictly defined as 100% presence, or more loosely as a “soft-core” with 95% or 99% presence.
  • And the Accessory Genome: Set of genes present in only a subset of individuals. This is further divided into
    • Shell Genome: Set of genes present in 1% to 99% of individuals
    • and the Cloud Genome: Set of genes present in less than 1%.
Presence-Absence Variation Pangenome
Figure 2: A Presence-Absence Variation Pangenome (Modified after Matthews et al. 2024). (A) A comparative genomic analysis of four related sequences is shown, utilizing one reference genome alongside three variants from the same population. Genetic variations from the reference are highlighted in color, and specific genes are denoted by black shapes. (B) The total pool of genes is divided into two distinct groups in a Presence-Absence Variation Pangenome: the core genes and accessory genes.
Agenda

In this tutorial, you will apply the pangenomic approach to your own data. You are going to analyze five Listeria monocytogenes strains by first annotating their genomes with Prokka. Afterward, you will build a Presence-Absence Variation Pangenome using Roary to identify the core genes and the accessory genes. To finish, you will use IQ-TREE on the core genes to construct a phylogenetic tree, showing how these five strains are evolutionarily related.

  1. Pangenomics
  2. Data upload
  3. Annotate the Strains with Prokka
    1. Examine the Output
  4. Calculate the Pangenome with Roary
    1. Examine the Output
  5. Construct the Phylogenetic Tree with IQ-TREE
    1. Examine the Output
    2. Visualize the Phylogenetic Tree
  6. Conclusion

Data upload

To identify core and accessory genes across multiple bacterial strains, you will need the genome sequences in FASTA format of each strain.

Hands On: Data upload
  1. Create a new history for this tutorial. Give it a name like Pangenome Analysis.

    To create a new history simply click the new-history icon at the top of the history panel:

    UI for creating new history

    1. Click on galaxy-pencil (Edit) next to the history name (which by default is “Unnamed history”)
    2. Type the new name
    3. Click on Save
    4. To cancel renaming, click the galaxy-undo “Cancel” button

    If you do not have the galaxy-pencil (Edit) next to the history name (which can be the case if you are using an older version of Galaxy) do the following:

    1. Click on Unnamed history (or the current name of the history) (Click to rename history) at the top of your history panel
    2. Type the new name
    3. Press Enter

  2. Import the following files from Zenodo.

    https://zenodo.org/records/21339041/files/10403S.fasta
    https://zenodo.org/records/21339041/files/AUF.fasta
    https://zenodo.org/records/21339041/files/EGD-e.fna
    https://zenodo.org/records/21339041/files/EGD.fasta
    https://zenodo.org/records/21339041/files/F6900.fna
    
    • Copy the link location
    • Click galaxy-upload Upload at the top of the activity panel

    • Select galaxy-wf-edit Paste/Fetch Data
    • Paste the link(s) into the text field

    • Press Start

    • Close the window

    Galaxy upload link

  3. Create a dataset collection containing the uploaded FASTA files. Give it a name like Assemblies.

    • Click on galaxy-selector Select Items at the top of the history panel Select Items button
    • Check all the datasets in your history you would like to include
    • Click n of N selected and choose Advanced Build List

      build list collection menu item

    • You are in collection building wizard. Choose Flat List and click ‘Next’ button at the right bottom corner.

      collection building wizard flat list

    • Double clcik on the file names to edit. For example, remove file extensions or common prefix/suffixes to cleanup the names.

      edit and build a list collection

    • Enter a name for your collection
    • Click Build to build your collection
    • Click on the checkmark icon at the top of your history again

Annotate the Strains with Prokka

You will use Prokka to annotate all bacterial strains simultaneously using the dataset collection. Prokka analyzes the DNA sequences to identify genomic features, such as genes, and assigns each a name and predicted biological function.

Hands On: Annotate Strains
  1. Select Tools in the left sidebar and search for Prokka ( Galaxy version 1.14.6+galaxy2) in the list that appears. Select it to open the tool.

  2. Within Prokka, select the following parameters (leave everything else unchanged):
    • param-file “Contigs to annotate”: Click on the “Dataset collection” icon and select your Assemblies dataset collection
    • “Genus name”: Enter Listeria
    • “Species name”: Enter monocytogenes
    • “Additional outputs”: Deselect all options except Annotation in GFF3 format, containing both sequences and annotations (.gff)
  3. Run the tool.

Examine the Output

Once Prokka has finished, two new dataset collections will appear in your history:

  • One containing the GFF3 output files for each strain. This is the dataset collection you will use further on. Examine each output file in this collection.
  • One containing the logs of each run.

GFF3 stands for General Feature Format (version 3). It is a plain text file used in bioinformatics to describe the exact locations of genomic features. The file contains 9 tab-separated columns that provide information for each feature (official specification).

Standard GFF3 files only contain the coordinates of genomic features. However, Prokka attaches the raw DNA sequence in FASTA format at the bottom of the GFF3 file (starting with a ##FASTA line in the file). This is exactly what the next tool requires to build the pangenome.

Calculate the Pangenome with Roary

Now you will run Roary to compare the genes identified across all strains by Prokka. Roary clusters the genes according to sequence similarity, thereby identifying the core and accessory genes that constitute the pangenome.

Hands On: Identify Core and Accessory Genes
  1. Select Tools in the left sidebar and search for Roary ( Galaxy version 3.13.0+galaxy3) in the list that appears. Select it to open the tool.

  2. Within Roary, select the following parameters (leave everything else unchanged):
    • “Individual gff files or a dataset collection”: Select Collection in the dropdown
      • param-file “Dataset collection to submit to Roary”: Select the collection containing the GFF3 output files from the previous step.
    • “Additional outputs”: Tick Accessory binary genes in newick format
  3. Run the tool.

Examine the Output

Once Roary has finished, four different output files will appear in your history. Examine each output file:

  • param-file Summary statistics file: Gives you a quick overview of how many genes belong to the core genome and the accessory genome.
  • param-file Gene Presence Absence file: Shows which genes are found in which strains.
  • param-file Core Gene Alignment file: Contains the aligned sequences of the core genes in FASTA format.
  • param-file Accessory Binary Genes (Newick) file: Contains a phylogenetic tree based on the presence and absence of the accessory genes.
Question
  1. How many genes are in the pangenome in total and how many of them are shell genes?
  2. In which strains can the gene for the Putative Cyclic di-GMP Phosphodiesterase PdeC be found?
  1. There are 3417 genes in total in the pangenome and, of these, 829 are shell genes. You can see this by viewing the param-file Summary statistics file. You will see that Roary defines the shell genome as a set of genes present in 15% to 95% of individuals and the cloud genome as a set of genes present in less than 15% of individuals.
  2. PdeC can be found in all five strains: 10403S, AUF, EGD, F6900, and EGD-e. You can see this by viewing the param-file Gene Presence Absence file. Each row corresponds to an annotated gene and provides information on how many isolates contain it. At the very end of the row, you can identify the specific strains by the presence of their locus tags. For the full view of the file, you may need to download the file and view it on your computer.

Construct the Phylogenetic Tree with IQ-TREE

You can now use the param-file Core Gene Alignment file to build a phylogenetic tree from it. This will show you the evolutionary relationship between all strains based on their shared genetic backbone. For this, you will use IQ-TREE.

Hands On: Build a phylogenetic tree
  1. Select Tools in the left sidebar and search for IQ-TREE ( Galaxy version 2.4.0+galaxy2) in the list that appears. Select it to open the tool.

  2. Within IQ-TREE, select the following parameters (leave everything else unchanged):
    • param-file “Specify input alignment file in PHYLIP, FASTA, NEXUS, CLUSTAL or MSF format.”: Select the Core Gene Alignment file
  3. Run the tool.

Examine the Output

Once IQ-TREE has finished, five different output files will appear in your history:

  • param-file BIONJ Tree file: This is an initial draft tree.
  • param-file MaxLikelihood Tree file: Your main result. It contains the final phylogenetic tree in Newick format.
  • param-file MaxLikelihood Distance Matrix file: Shows the calculated evolutionary distance between every possible pair of your strains.
  • param-file Occurrence Frequencies in Bootstrap Trees file: Contains the statistical support for the tree’s branches.
  • param-file Report and Final Tree file: A summary of the entire run and a text-based visual of the tree.

Visualize the Phylogenetic Tree

Now that you have a phylogenetic tree from your bacterial strains, you can view it visually.

Hands On: Visualize the Phylogenetic Tree
  1. Select the param-file MaxLikelihood Tree file in your history and click the galaxy-eye View icon.

  2. By default, the file is displayed in galaxy-eye Preview mode. In the top tab bar, select galaxy-barchart Visualize.

  3. Select the Phylogenetic Tree Browser

The resulting phylogenetic tree should resemble Figure 3. Zoom in to examine individual branches.

Phylogenetic tree of the five analyzed bacterial strains based on core genome
Figure 3: Phylogenetic tree of the five analyzed bacterial strains based on the core genome. Visualization of the evolutionary relationship and genetic divergence among the selected strains. The topology reveals two distinct groupings: (A) Strains 10403S, AUF, and EGD cluster closely together (their short branch lengths confirm that they share a near-identical core genome), and (B) Strains F6900 and EGD-e, which branch off into a separate cluster. This demonstrates a higher genetic distance and evolutionary divergence, both from the first group and from one another.
Comment: What can we deduce from these results?
  • Strains that appear highly similar in this tree may nonetheless differ substantially in phenotype. This is because variations can exist within their accessory genes.
  • For example, one strain might carry plasmids with antibiotic resistance, while another might harbor toxin genes introduced by phages.
  • These differences are hidden in this specific phylogenetic tree because it was built on core genes.
  • A core genome tree is precise for tracing evolutionary descent and relatedness, but it does not reveal the complete individual genetic repertoire.

Conclusion

This tutorial provided a step-by-step guide on how to construct a bacterial Presence-Absence Variation Pangenome by annotating the genomes with Prokka and extracting the core and accessory genes with Roary. Additionally, it provided a guide for creating a phylogenetic tree with IQ-TREE based on the core genes. By following these steps, you should be able to identify core and accessory genes, and uncover the evolutionary relationships among your own bacterial strains.