Masking repeats with RepeatMasker

Overview

Questions:
  • How to mask repeats in a genome?

  • What is the difference between hard and soft-masking?

Objectives:
  • Use Red and RepeatMasker to soft-mask a newly assembled genome

Requirements:
Time estimation: 1 hour
Level: Introductory Introductory
Supporting Materials:
Last modification: Sep 23, 2022
License: Tutorial Content is licensed under Creative Commons Attribution 4.0 International License The GTN Framework is licensed under MIT

Introduction

When you assemble a new genome, you get its full sequence in FASTA format, in the form of contigs, scaffolds, or even whole chromosomes if you are lucky. However genomes, in particular for eukaryote organisms, contain a varying but significant proportion of repeated elements all along the sequence. These elements belong to different classes, including:

  • Tandem repeats: small sequences (<60 base pairs) repeated next to each other, found in many places in the genome, in particular centromeres and telomeres
  • Interspersed repeats: sequences repeated in distant positions, including transposons, Short Interspersed Nuclear Elements (SINEs) or Long Interspersed Nuclear Elements (LINEs)

These repeats are interesting on their own: they can originate from transposons or viral insertions, and they can have direct effects on the expression of genes. But they are also the source of a lot of trouble when you work on genomics data. First when sequencing a genome, assembly tools often have problems reconstructing the genome sequence in regions containing repeats (in particular when repeats are longer than the read size). Then, when you have a good assembly, you want to annotate it to find the location of genes. Unfortunately annotation tools have trouble identifying gene locations in regions rich in repeats.

The aim of repeat masking is to identify the location of all repeated elements along a genome sequence. Other tools (like annotation pipelines) can then take this information into account when producing their results.

The output of repeat masking tools is most often composed of a fasta file (with sometimes a GFF file containing the position of each repeat). There is two types of masking, producing slightly different fasta output:

  • Soft-masking: repeat elements are written in lower case
  • Hard-masking: repeat elements are replaced by stretches of the letter N

Normal (non-repeated) sequences are always kept in uppercase. Doing hard-masking is destructive because you lose large parts of the sequence which are replaced by stretches of N. If you want to perform an annotation, it is best to choose soft-masking.

We call this operation “masking” because, by making repeats lowercase, or replacing them with Ns, you make them “invisible” by annotation tools (they are written to mostly ignore the regions marked like this).

Multiple tools exist to perform the masking: RepeatMasker, RepeatModeler, REPET, … Each one have specificities: some can be trained on specific genomes, some rely on existing databases of repeated elements signatures (Dfam, RepBase).

In this tutorial you will learn how to soft-mask the genome sequence of a small eukaryote: Mucor mucedo (a fungal plant pathogen). You can learn how this genome sequence was assembled by following the Flye assembly tutorial. We will use two different tools, Red and RepeatMasker, which are probably two of the simplest solutions giving an acceptable result before annotating the genome in the Funannotate annotation tutorial.

Agenda

In this tutorial, we will cover:

  1. Introduction
  2. Get data
  3. Soft-masking using Red
  4. Soft-masking using RepeatMasker
  5. Conclusion

Get data

hands_on Hands-on: Data upload

  1. Create a new history for this tutorial

  2. Import the files from Zenodo or from the shared data library (GTN - Material -> genome-annotation -> Masking repeats with RepeatMasker):

      https://zenodo.org/api/files/debdbbfd-4739-4f2d-bb79-814ac032c8b5/genome_raw.fasta
      https://zenodo.org/api/files/debdbbfd-4739-4f2d-bb79-814ac032c8b5/Muco_library_RM2.fasta
      https://zenodo.org/api/files/debdbbfd-4739-4f2d-bb79-814ac032c8b5/Muco_library_EDTA.fasta
    
    • Copy the link location
    • Open the Galaxy Upload Manager (galaxy-upload on the top-right of the tool panel)

    • Select Paste/Fetch Data
    • Paste the link into the text field

    • Press Start

    • Close the window

    Tip: Importing data from a data library

    As an alternative to uploading the data from a URL or your computer, the files may also have been made available from a shared data library:

    • Go into Shared data (top panel) then Data libraries
    • Navigate to the correct folder as indicated by your instructor
    • Select the desired files
    • Click on the To History button near the top and select as Datasets from the dropdown menu
    • In the pop-up window, select the history you want to import the files to (or create a new one)
    • Click on Import

Soft-masking using Red

First let’s try Red, a tool than can mask repeats de novo. For that, select the input assembly in fasta format.

comment Ab initio tool

Red is an ab initio tool, it means that it will try to predict repeat elements using only the genomic sequence. It’s perfect when you know nothing about the organism that you are working on.

hands_on Hands-on

  1. Red Tool: toolshed.g2.bx.psu.edu/repos/iuc/red/red/2018.09.10+galaxy1 with the following parameters:
    • param-file “Genome sequence to mask”: genome_raw.fasta (Input dataset)

Red produces 2 output files :

  • A fasta file: this is the soft-masked genome that you can use for future analysis. If you display it, you will notice that some portions of the sequence are in lowercase: these are the regions that were identified as repeats
  • A bed file: this one contains the coordinates on the genome of each repeated loci

question Question

What proportion of the whole genome sequence is masked?

solution Solution

You need to click on the galaxy-info on one of the output. You should find it at the end of the extended Tool Standard Output in Job Information. It should be ~ 30.62%

question Question

How to hard-mask a genome with Red ?

solution Solution

As you can see Red has no option to hard-mask your genome. However, one of the output is a bed file, so you can use bedtools MaskFastaBed to replace repeated regions with stretches of N:

hands_on Hands-on

  1. bedtools MaskFastaBed Tool: toolshed.g2.bx.psu.edu/repos/iuc/bedtools/bedtools_maskfastabed/2.30.0 with the following parameters:
    • param-file BED/bedGraph/GFF/VCF/EncodePeak file”: Red on data (bed file produced by red)
    • param-file “FASTA file”: genome_raw.fasta

Red uses only the sequence of the genome to detect repeated regions, and does not provide a detailed classification of the detected repeats. Let’s use another tool that works differently: RepeatMasker.

Soft-masking using RepeatMasker

Let’s run RepeatMasker, by selected the input assembly in fasta format. We select the soft-masking option, and we choose to use the Dfam database.

comment Choosing the right species

We select the Human (Homo sapiens) species here, even though we are masking a fungi genome. It means RepeatMasker will identify very common repeats found in many organisms. For more precise results, you can consider selecting a species closer to the one you analyse in the drop down list, or using other more advanced tools like RepeatModeler.

hands_on Hands-on

  1. RepeatMasker Tool: toolshed.g2.bx.psu.edu/repos/bgruening/repeat_masker/repeatmasker_wrapper/4.1.2-p1+galaxy1 with the following parameters:
    • param-file “Genomic DNA: genome_raw.fasta (Input dataset)
    • “Repeat library source”: DFam (curated only, bundled with RepeatMasker)
    • “Select species name from a list?”: Yes
      • “Species”: Human (Homo sapiens) - “Output annotation of repeats in GFF format”: Yes - “Perform soft-masking instead of hard-masking”: Yes

RepeatMasker produces 4 output files:

  • masked sequence: this is the fasta file that you will use for future analysis. If you display it, you will notice that some portions of the sequence are in lowercase: these are the regions that were identified as repeats.
  • repeat statistics: this one contains some statistics on the number of repeats found in each category, and the total number of base pairs masked.
  • output log: this is a tabular file listing all repeats.
  • repeat catalogue: this one contains the list of all repeat sequences that were identified, with their position, and their similarity with known repeats from the Dfam database.
  • repeat annotation : this one contains the coordinate of each repeat element in GFF2 format.

question Question

What proportion of the whole genome sequence is masked?

solution Solution

You should find it in the repeat statistics output. It should be ~2.41%.

As we have used a generic species (Human), we only identified the most common and simple repeats, not very specific to this species. If you compare with Red results, your are missing at least ~28% of repeated content in the genome. However, RepeatMasker gives interesting information about repeat classification which could be interesting for future analysis.

To boost RepeatMasker performance, we need a tailored repeat library for Mucor mucedo. This step can take from a few hours to a few days and a large number of tools could be used. We pre-computed two librairies :

hands_on Hands-on

  1. RepeatMasker Tool: toolshed.g2.bx.psu.edu/repos/bgruening/repeat_masker/repeatmasker_wrapper/4.1.2-p1+galaxy1 with the following parameters:
    • param-file “Genomic DNA: genome_raw.fasta (Input dataset)
    • “Repeat library source”: Custom library of repeats
    • “Custom library of repeats”
      • “One of the two pre-computed libraires”: Muco_library_RM2.fasta or Muco_library_EDTA.fasta - “Output annotation of repeats in GFF format”: Yes - “Perform soft-masking instead of hard-masking”: Yes

question Question

Compare the different repeat statistics files produced, what is the highest library for RepeatMasker?

solution Solution

The RepeatModeler library seems to have the highest percentage of repeats found with ~ 34.89%. It could be explained as RepeatModeler is specifically made to work with RepeatMasker.

Other tools might mask a greater proportion of the genome, at the cost of a more complex workflow with training steps. But masking more isn’t always a positive results! In fact, large family of genes could be considered as a repeat by some tools or certain library. Only a manual curation can correct those mistakes, but this result is sufficient to perform an annotation by following the Funannotate annotation tutorial.

Conclusion

By following this tutorial you have learn how to mask an eukaryotic genome using Red and RepeatMasker, after assembling (Flye assembly tutorial) and before annotating it (Funannotate annotation tutorial).

Often times, annotation tools prefer to use soft-masked genomes, as they primarily search for genes in non repeated regions, but tolerate that some genes overlap partially with these regions.

Key points

  • RepeatMasker can be used to soft-mask a genome

  • It is an essential first step before running structural annotation pipelines

Frequently Asked Questions

Have questions about this tutorial? Check out the tutorial FAQ page or the FAQ page for the Genome Annotation topic to see if your question is listed there. If not, please ask your question on the GTN Gitter Channel or the Galaxy Help Forum

Glossary

LINEs
Long Interspersed Nuclear Elements
SINEs
Short Interspersed Nuclear Elements

Feedback

Did you use this material as an instructor? Feel free to give us feedback on how it went.
Did you use this material as a learner or student? Click the form below to leave feedback.

Click here to load Google feedback frame

Citing this Tutorial

  1. Anthony Bretaudeau, Alexandre Cormier, Laura Leroi, Erwan Corre, Stéphanie Robin, Erasmus+ Programme, Jonathan Kreplak, 2022 Masking repeats with RepeatMasker (Galaxy Training Materials). https://training.galaxyproject.org/training-material/topics/genome-annotation/tutorials/repeatmasker/tutorial.html Online; accessed TODAY
  2. Batut et al., 2018 Community-Driven Data Analysis Training for Biology Cell Systems 10.1016/j.cels.2018.05.012

details BibTeX

@misc{genome-annotation-repeatmasker,
author = "Anthony Bretaudeau and Alexandre Cormier and Laura Leroi and Erwan Corre and Stéphanie Robin and Erasmus+ Programme and Jonathan Kreplak",
title = "Masking repeats with RepeatMasker (Galaxy Training Materials)",
year = "2022",
month = "09",
day = "23"
url = "\url{https://training.galaxyproject.org/training-material/topics/genome-annotation/tutorials/repeatmasker/tutorial.html}",
note = "[Online; accessed TODAY]"
}
@article{Batut_2018,
    doi = {10.1016/j.cels.2018.05.012},
    url = {https://doi.org/10.1016%2Fj.cels.2018.05.012},
    year = 2018,
    month = {jun},
    publisher = {Elsevier {BV}},
    volume = {6},
    number = {6},
    pages = {752--758.e1},
    author = {B{\'{e}}r{\'{e}}nice Batut and Saskia Hiltemann and Andrea Bagnacani and Dannon Baker and Vivek Bhardwaj and Clemens Blank and Anthony Bretaudeau and Loraine Brillet-Gu{\'{e}}guen and Martin {\v{C}}ech and John Chilton and Dave Clements and Olivia Doppelt-Azeroual and Anika Erxleben and Mallory Ann Freeberg and Simon Gladman and Youri Hoogstrate and Hans-Rudolf Hotz and Torsten Houwaart and Pratik Jagtap and Delphine Larivi{\`{e}}re and Gildas Le Corguill{\'{e}} and Thomas Manke and Fabien Mareuil and Fidel Ram{\'{\i}}rez and Devon Ryan and Florian Christoph Sigloch and Nicola Soranzo and Joachim Wolff and Pavankumar Videm and Markus Wolfien and Aisanjiang Wubuli and Dilmurat Yusuf and James Taylor and Rolf Backofen and Anton Nekrutenko and Björn Grüning},
    title = {Community-Driven Data Analysis Training for Biology},
    journal = {Cell Systems}
}
                

Congratulations on successfully completing this tutorial!