---
tags: JPL-HBCU
---
# Example bracken combining outputs and adding lineage info
## Conda install if needed
Program is in my [`bit`](https://github.com/AstrobioMike/bioinf_tools#bioinformatics-tools-bit) toolkit, can be installed in a new environment like so if needed:
```bash
conda create -y -n bit -c conda-forge -c bioconda -c defaults -c astrobiomike bit=1.8.08
```
## Getting example data
```bash
curl -L -o example-bracken-output-1.tsv https://ndownloader.figshare.com/files/24086822
curl -L -o example-bracken-output-2.tsv https://ndownloader.figshare.com/files/24086822
```
## Combining outputs and adding full lineage info
Script is `bit-combine-bracken-and-add-lineage`. There is a help menu with `-h`. It takes as input (`-i`) a file either with 1 column of input file names only, or 2 tab-delimited columns with input file name in column 1 and the desired sample name in column 2, e.g.:
```bash
paste <( ls ex*bracken*.tsv ) <( printf "sample-1\nsample-2\n" ) > bracken-sample-name-map.tsv
cat bracken-sample-name-map.tsv
```
```
example-bracken-output-1.tsv sample-1
example-bracken-output-2.tsv sample-2
```
Running the script:
```bash
bit-combine-bracken-and-add-lineage -i bracken-sample-name-map.tsv -o Combined-taxonomy.tsv
```
This has a few things in it, but can be chopped down to what you want:
```bash
head Combined-taxonomy.tsv | column -ts $'\t'
```
```
domain phylum class order family genus species tax_id tax_level sample-1_num sample-1_frac sample-2_num sample-2_frac
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria monocytogenes 1639 S 399031 0.10780 399031 0.10780
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria grayi 1641 S 204 0.00006 204 0.00006
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria ivanovii 1638 S 555 0.00015 555 0.00015
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria welshimeri 1643 S 92 0.00002 92 0.00002
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria innocua 1642 S 53 0.00001 53 0.00001
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria seeligeri 1640 S 30 0.00001 30 0.00001
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria sp. PSOL-1 1844999 S 28 0.00001 28 0.00001
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Listeria Listeria weihenstephanensis 1006155 S 15 0.00000 15 0.00000
Bacteria Firmicutes Bacilli Bacillales Listeriaceae Brochothrix Brochothrix thermosphacta 2756 S 4 0.00000 4 0.00000
```