Skip to content

Genome alignment using MUMmer ​

This tutorial guides you through the process of performing genome alignments using MUMmer, an alignment tool widely used for comparing genomic sequences. As an example we will align the plasmids from several species of B. thuringiensis. Following the alignment, we'll show you how to visualize the results using geneviewer.

Materials ​

The .gbk files can be downloaded directly from GenBank using accession numbers CP000486.1, CP009599.1, CP003188.1 and CP009638.1. Alternatively, you can obtain the GenBank files including all alignment files directly from the geneviewer-tutorials repository.

MUMmer alignment ​

MUMmer needs to be installed on your local machine to execute alignments. For detailed installation instructions, visit the MUMmer website. Once MUMmer is installed, you can perform the alignment using geneviewer with the mummer_alignment() function. By default it will run the alignment in order of the files in the folder.

Important MUMmer requires file paths without spaces. From geneviewer 0.2.1, the folder of the files may have spaces; the names of the files and the folder the alignment runs in (output_dir, by default a temporary folder) must still be without spaces.

r
library(geneviewer)
# Change the path to the folder where the .gbk files are saved
folder_path <- "~/path/to/folder/"

By default, the mummer_alignment() function will perform pairwise alignments starting with the first file in the folder. To adjust the order in which files are aligned, assign a vector of file names to the cluster variable. By default nucleotide sequences are translated into proteins using "promer" and a "many-to-many" mapping alignment is performed. For the most suitable alignment method for your project, please carefully review the MUMmer documentation. To learn how to modify the default settings, consult the documentation by running ?mummer_alignment().

r
alignment <- 
  mummer_alignment(
    path = folder_path,
    cluster = NULL,
    maptype = "many-to-many",
    seqtype = "protein"
  )

The alignment generates a data frame that details the start and end positions of each aligned region between the reference (cluster1) and query (cluster2), along with identity and similarity scores. This data frame can be directly loaded into the GC_links() function.

start1end1start2end2length1length2identitysimilaritystopframe1frame2tag1tag2cluster1cluster2
1_CP000486.1.13515425154015154051540100.00100.005.533-2CP000486.1CP009599.11_CP000486.12_CP009599.1
1_CP000486.1.25593951545515435593743954395100.00100.006.01-13CP000486.1CP009599.11_CP000486.12_CP009599.1
2_CP009599.1.11013320247346451572190219092.3394.386.372-3CP009599.1CP003188.12_CP009599.13_CP003188.1
2_CP009599.1.233544118449954426776572957.9874.322.333-2CP009599.1CP003188.12_CP009599.13_CP003188.1
2_CP009599.1.34113904144270393424929492994.8396.414.663-1CP009599.1CP003188.12_CP009599.13_CP003188.1
2_CP009599.1.497721080338441374221032102061.7872.700.291-1CP009599.1CP003188.12_CP009599.13_CP003188.1

Synteny gene cluster chart ​

To map the alignment onto the genome, we must first load the cluster information from the .gbk files. For detailed instructions, please refer to the tutorial Loading gene clusters from GenBank files.

r
folder_path <- "~/path/to/folder/"
gbk <- read_gbk(folder_path)
cds_df <- gbk_features_to_df(
  gbk, 
  feature = "CDS",
  keys = c("region", "gene", "protein_id", "note", "product")
  )
regiongeneprotein_idproductnoteclusterstrandstartend
complement(665..1603)terSABK88159.1phage terminase small subunitNA1_CP000486.1complement6651603
complement(2151..2975)uvrCABK88160.1possible excinuclease ABC subunitNA1_CP000486.1complement21512975
complement(2988..3599)resABK88161.1resolvaseNA1_CP000486.1complement29883599
complement(4075..4305)NAABK88162.1conserved hypothetical proteinpossible phage-related protein, N-terminal region1_CP000486.1complement40754305
complement(4394..4720)NAABK88163.1hypothetical proteinNA1_CP000486.1complement43944720
complement(5796..6185)NAABK88164.1phage-related proteinNA1_CP000486.1complement57966185

We can load the cluster data into the GC_chart() and the alignment data into the GC_links() function. Links run from nearly white at an identity of vmin (0 by default) to the full colour at vmax (100); setting vmin to the lowest identity in the alignment spreads the colours over the data. In addition, we change the axis_type to "range", make the genes a little smaller, add cluster labels and use the "publication" theme. For more customization options see Get started.

Important: The gene cluster data like the alignment data is loaded in the order of the files in the folder. If a custom order was used for the MUMmer alignment make sure to sort the "cluster" column in the cluster data in the same way.

r
GC_chart(cds_df, strand = "strand", cluster = "cluster") %>%
  GC_links(data = alignment, measure = "identity", vmin = floor(min(alignment$identity))) %>%
  GC_scale(axis_type = "range") %>%
  GC_cluster(separate_strands = TRUE) %>%
  GC_genes(marker_size = "small") %>%
  GC_clusterLabel(
    title = c("pALH1", "pBFQ", "F837_55", "pBFI_4"),
    width = "75px",
    fontSize = "12px"
  ) %>%
  GC_tooltip(formatter = "<b>{protein_id}</b><br>{start} - {end}") %>%
  GC_legend(FALSE) %>%
  GC_theme("publication")