Repository navigation
Indexing reference genomes
You can first check if any of the available indexes here works for you. Otherwise, if you have your own set of references, or if you are targeting another domain than the available indexes, follow the steps below.
Given a set of reference genomes and optionally a backbone tree, krepp can build an LSH index with colored k-mers by running
krepp index -o /path/to/index -i /path/to/input.tsv -t /path/to/tree.nwk --num-threads 16where
-
--num-threadsis simply the number of threads, -
-ois the directory where the index will be stored, -
-iis a tab-separated file where the first column is for the IDs of references, i.e., leaves of the tree, and the second column is for the paths (or the URLs) to corresponding reference genomes (e.g., FASTA), -
-tis the optional backbone tree in Newick format matching the genome IDs (i.e., leaf labels) given.
Run krepp index --help to see more options and details.
If you do not have a tree, or if you are mainly interested in estimating distances, run krepp index without the -t option (with the side effect of potentially making the color index slightly larger).
An index constructed without a backbone cannot be used for phylogenetic placement without providing a tree later, but distance estimates stay the same. You can always specify a backbone with the krepp place subcommand, using the -t (--nwk-file) option. Note that the tip labels of the phylogeny have to match the reference IDs given in /path/to/input.tsv.
We note that memory use increases almost linearly with --num-threads for the index subcommand, and hence, you may want to decrease it if you run out of memory.
This is not the case for dist, place, and seek commands; feel free to use all cores available during the query time.
A straightforward way of making the index smaller is increasing the minimizer window size (-w) with respect to -k.
This may cost you some accuracy as fewer k-mers will be indexed, but shouldn't be an issue as long as it is not too aggressive (e.g., w < k+9).
The peak memory usage during the index construction could also be reduced to the memory level available by partitioning the index into smaller pieces. This is done by a variation of FracMinHash, controlled by options -m and -r.
krepp partitions the index into -m (more or less) equally sized pieces, and these partitions could be built independently, but one can query them together.
The -r option determines the partition that is going to be constructed: if --no-frac is given, only the -rth partition, otherwise all partitions from 0th to -rth, will be constructed and saved (see krepp index --help for details).
You don't need to construct all partitions; krepp will search in whatever is available, and these partitions can be distributed independently.
The default is -m 4 -r 1 --frac, so 50% (0th and 1st of 4 partitions) of the minimized k-mers will be indexed.
The only requirement is keeping the -m value (and of course -i and -t) fixed across all partitions.
For instance, one can index 3% of the reference k-mers and construct a lightweight index by running:
krepp index -o /path/to/index -i /path/to/input.tsv -t /path/to/tree.nwk --num-threads 8 -m 100 -r 0 --no-frac
krepp index -o /path/to/index -i /path/to/input.tsv -t /path/to/tree.nwk --num-threads 8 -m 100 -r 1 --no-frac
krepp index -o /path/to/index -i /path/to/input.tsv -t /path/to/tree.nwk --num-threads 8 -m 100 -r 2 --no-fracor, alternatively
krepp index -o /path/to/index -i /path/to/input.tsv -t /path/to/tree.nwk --num-threads 4 -m 100 -r 2 --fracThis would be faster, but with increased memory use during the index construction, despite resulting in an index of the same size.
If you have a small memory machine, you can iterate over partitions and build the entire index in a more scalable manner:
seq 0 9 | xargs -I{} -P2 bash -c "krepp index -o /path/to/index -i /path/to/input.tsv -t /path/to/tree.nwk --num-threads 8 -m 10 -r {} --no-frac"