Runs a reciprocal all-against-all BLAST search to look for similarity of proteins within and across genomes. The main job is done by the BLAST+ software.
blastAllAll(in.files, out.folder, e.value = 1, job = 1, threads = 1, verbose = T)
A text vector with the names of the FASTA files where the protein sequences of each genome is found.
The name of the folder where the result files should end up.
The chosen E-value threshold in BLAST. Default is e.value=1, a smaller value will speed up the search at the cost of less sensitivity.
An integer to separate multiple jobs. You may want to run several jobs in parallell, and each job should have different number here to avoid confusion on databases. Default is job=1.
The number of CPU's to use.
A basic step in pangenomics and many other comparative studies is to cluster proteins into groups or families. One commonly used approach is based on reciprocal BLASTing. This function uses the BLAST+ software available for free from NCBI (Camacho et al, 2009).
A vector listing FASTA files of protein sequences is given as input in in.files. These files
must have the GID-tag in the first token of every header, and in their filenames as well, i.e. all input
files should first be prepared by
panPrep to ensure this. Note that only protein sequences
are considered here. If your coding genes are stored as DNA, please translate them to protein prior to
using this function, see
A BLAST database is made from each genome in turn. Then all genomes are queried against this database, and for every pair of genomes a result file is produced. If two genomes have GID-tags GID111, and GID222 then both result file GID111_vs_GID222.txt and GID222_vs_GID111.txt will be found in out.folder after the completion of this search. This reciprocal (two-way) search is required because of the heuristics of BLAST.
The out.folder is scanned for already existing result files, and
overwrites an existing result file. If a file with the name GID111_vs_GID222.txt already exists in
the out.folder, this particular search is skipped. This makes it possible to run multiple jobs in
parallell, writing to the same out.folder. It also makes it possible to add new genomes, and only
BLAST the new combinations without repeating previous comparisons.
This search can be slow if the genomes contain many proteins and it scales quadratically in the number of
input files. It is best suited for the study of a smaller number of genomes (less than say 100). By
starting multiple R sessions, you can speed up the search by running
blastAllAll from each R
session, using the same out.folder but different integers for the
job option. If you are
using a computing cluster you can also increase the number of CPUs by increasing
The result files are text files, and can be read into R using
readBlastTable, but more
commonly they are used as input to
bDist to compute distances between sequences for subsequent
The function produces N*N result files if in.files lists N sequence files.
These result files are located in
out.folder. Existing files are never overwritten by
blastAllAll, if you want to re-compute something, delete the corresponding result files first.
The BLAST+ software must be installed on the system for this function to work, i.e. the commands system("makeblastdb") and system("blastp") must be recognized as valid commands if you run them in the Console window.
Lars Snipen and Kristian Hovde Liland.
Camacho, C., Coulouris, G., Avagyan, V., Ma, N., Papadopoulos, J., Bealer, K., Madden, T.L. (2009). BLAST+: architecture and applications. BMC Bioinformatics, 10:421.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Using FASTA files in this package. # We need to uncompress them first... ## Not run: extdata.path <- file.path(path.package("micropan"),"extdata") filenames <- c("Mpneumoniae_M129_GID1.fsa", "Mpneumoniae_309_GID2.fsa", "Mpneumoniae_FH_GID3.fsa") pth <- lapply( file.path( extdata.path, paste( filenames, ".xz", sep="" ) ), xzuncompress ) #...blasting, assuming the BLAST+ software is properly installed # NB! This will take some minute(s)! blastAllAll(in.files=file.path(extdata.path,filenames),out.folder=".") # ...and compressing the FASTA files again... pth <- lapply( file.path( extdata.path, filenames ), xzcompress ) ## End(Not run)