One potential use for Metaxa (paper) is to include it in a pipeline for classification of SSU rRNA in metagenomic data (or other environmental sequencing sets). However, as Metaxa is provided from this site, it only classifies SSUs to the domain level (archaea, bacteria and eukaryotes, with the addition of chloroplasts and mitochondria). It is also able to do some (pretty rough) species guesses using the “--guess_species T” option. An easy solution to implement would be to pass the Metaxa output, e.g. “metaxa_output.bacteria.fasta” to BLAST, and compare all these sequences to the sequences in e.g. the SILVA or GreenGenes database. There is, however, a way to improve this, which uses Metaxa’s ability to compares sequences to custom databases. In this tutorial, I will show you how to achieve this.

Before we start, you will of course need to download and install Metaxa, and its required software packages (BLAST, HMMER, MAFFT). When you have done this, we can get going with the database customization. I will in this tutorial use the SILVA database for SSU classification. However, the basic idea for the tutorial should be easily applicable to GreenGenes and other rRNA databases as well.

  1. Visit SILVA through this link, and download the file named “SSURef_106_tax_silva.fasta.tgz”. The file is pretty big so it may take a while to download it. If you’re running Metaxa on a server, you’ll have to get the SILVA-file to the server somehow.
  2. Unzip and untar the file (Mac OS X makes this neatly by doubleclicking the file, on linux you can do it on the command line by typing “tar -xvzf SSURef_106_tax_silva.fasta.tgz“). This will give you a FASTA-file.
  3. The FASTA-file needs to be prepared a bit for Metaxa usage. First, we need to give Metaxa identifiers it can understand. Metaxa identifies sequences’ origins by the last character in their identifier, e.g. “>A16379.1.1496.B”. Here, “.B” indicates that this is a bacterial sequence. We are now going to use the unix command sed to process the file and insert the appropriate identifiers.
    1. We begin with the archaeal sequences. To get those straight, we type:
      sed "s/ Archaea;/.A - Archaea;/" SSURef_106_tax_silva.fasta > temp1
      Notice that we direct the output to a temporary file. It is bad practice to replace the input file with the output file, so we work with two temp-files instead.
    2. The next step is also easy, now we find all eukaryote sequences and add E:s to the identifiers:
      sed "s/ Eukaryota;/.E - Eukaryota;/" temp1 > temp2
    3. Now it becomes a little more complicated, as SILVA classes mitochondrial and chloroplast SSU sequences as subclasses of bacteria. However, there is a neat little trick we can use. First we do the same with the bacterial sequences as with the archaeal and eukaryote:
      sed "s/ Bacteria;/.B - Bacteria;/" temp2 > temp1
    4. Now, we can use two a little more complicated commands to annotate the mitochondrial and chloroplast sequences:
      sed "s/\.B - \(Bacteria;.*;[Mm]itochondria;\)/.M - \1/" temp1 > temp2
      sed "s/\.B - \(Bacteria;.*;[Cc]hloroplast;\)/.C - \1/" temp2 > temp1
    5. We also need to get “rid” of the unclassified sequences, by assigning them to the “other” origin (O):
      sed "s/ Unclassified;/.O - Unclassified;/" temp1 > temp2
  4. That wasn’t too complicated, was it? We can now check the number of different sequences in the file by typing the pretty complicated command:
    grep ">" temp2 | cut -f 1 -d " " | rev | cut -f 1 -d "." | sort | uniq -c
    If you have been working with the same files as me, you should now see the following numbers:
    23172 A
    471949 B
    3712 C
    55937 E
    534 M
    226 O
  5. At this stage, we need to remove the full taxonomy from the FASTA headers, as Metaxa cannot handle species names of this length. We do this by typing:
    sed "s/ - .*;/ - /" temp2 > temp1
  6. We can now change the temp-file into a FASTA file, and delete the other temp-file:
    mv temp1 SSURef.fasta
    rm temp2
  7. We now need to configure Metaxa to use the database. First, we format a BLAST-database from the FASTA-file we just created:
    formatdb -i SSURef.fasta -t "SSURef Metaxa DB" -o T -p F
  8. With that done, we can now run Metaxa using this database instead of the classification database that comes with the program. By specifying that we want to guess the species origin of sequences, we can get (as accurate as SILVA lets us be) which species each sequence in our set come from. We do this by using the -d and the --guess_species options:
    metaxa -i test.fasta -d SSURef.fasta -o TEST --guess_species T --cpu 2
    The input in this case was the test file that comes with Metaxa. Note also that we’re using two CPUs to get multithreaded speeds. Remember that you must provide the full (or relative) path to the database files we just created, if you are not running Metaxa from the same directory as the database resides in.
  9. The output should now look like this (taken from the bacterial file):
    >coryGlut_Bielefeld_dna Bacterial 16S SSU rRNA, best species guess: Corynebacterium glutamicum
    CGAACGCTG...
    >gi|116668568:792344-793860 Bacterial 16S SSU rRNA, best species guess: Arthrobacter sp. J3.40
    TGAACGCTG...
    >gi|117927211:c1399163-1397655 Bacterial 16S SSU rRNA, best species guess: Acidothermus cellulolyticus
    >CGAACGCTG...

    And so on. As you can see the species names are now located at the end of each definition line, and can easily be extracted using sed, e.g. “grep ">" TEST.bacteria.fasta | sed "s/.*: //"“.

And that’s it. It’s pretty simple, and can easily be scripted. In fact, I have already made the bash script for you. That means that the short version is, download the script, download the sequence file from SILVA, move into the directory you have downloaded the file to and run the script by typing: ./prepare_silva_for_metaxa.sh

A few notes at the end. The benefit of using this approach is that we maintain the sorting capabilities, marking of uncertain sequences and error checking of Metaxa, but we don’t have to add another BLAST step after Metaxa has finished. However, as this database we create is a lot bigger than the database that comes with Metaxa, the running time of the classification step will be substantially longer. This is in most cases acceptable, as that time is the same as the time it would have taken to run BLAST on the Metaxa output. It should also be noted that this approach limits Metaxa’s ability of classifying 12S sequences, as there are no such sequences in SILVA. Good luck with classifying your metagenome SSUs (and if you use Metaxa in your research, remember to cite the paper)!