<p>In one of its possible output modes, kraken2 will give you read-level and kmer-level information about how it came to its conclusions about taxonomic assignment. You've provided a lot of detail in your question about your process of generating the data, and the taxon assignment table, but I expect your specific question will best be answered by digging deeper into your own data.</p>
<p>To explain a bit further, individual reads are assigned to a taxon based on the kmer assignments for that read (i.e. each kmer within a read essentially votes for the read taxon). The behaviour of assignment after changing the database is unpredictable at a read level because the kmer assignments will change. Even if diversity is increased, that increased diversity will alter the &quot;votes&quot; from the kmers, and could result in a particular taxon crossing a threshold (and increasing in apparent abundance) because other taxa now have fewer votes.</p>
<p>In any case, Kraken2 is known to assign taxa in a way that is not necessarily a good representation of the actual content. If you want to make statements about the proportion of different taxa in your samples, I'd recommend that you try out using Bracken on your Kraken2 results. It will correct some assignments based on sequence similarities in the database:</p>
<blockquote>
<p>Bracken is a companion program to Kraken 1, KrakenUniq, or Kraken 2 While Kraken classifies reads to multiple levels in the taxonomic tree, Bracken allows estimation of abundance at a single level using those classifications (e.g. Bracken can estimate abundance of species within a sample).</p>
</blockquote>
<p><a href="https://github.com/jenniferlu717/Bracken?tab=readme-ov-file#step-1-generate-the-bracken-database-file-databasexmerskmer_distrib" rel="nofollow noreferrer">https://github.com/jenniferlu717/Bracken?tab=readme-ov-file#step-1-generate-the-bracken-database-file-databasexmerskmer_distrib</a></p>

CC BY-SA 4.0
2024-07-27T21:01:50.507Z
Thanks for the ref to bracken. You wrote "I expect your specific question will best be answered by digging deeper into your own data.". Note that the puzzling observation I made is actually not dependent on my data, since it seems to stem from some effect at database construction.
bli
CC BY-SA 4.0
2024-07-28T01:11:55.903Z
@bli I've added a bit more detail to explain my reasoning. The main thing is that database changes lead to unpredictable effects. You can't always assume that class assignment fractions will go down when database diversity is increased. That's why it's important to use tools like Bracken that take this kmer weirdness into account.
gringer
CC BY-SA 4.0
2024-07-26T22:11:45.567Z
2024-07-28T04:18:27.793Z
2024-07-28T04:18:27.793Z
gringer
<p>I built a protozoa kraken 2 database (&quot;db1&quot;), from which I further built two other databases (&quot;db2&quot; and &quot;db3&quot;) by adding extra genomes in the Leishmania sub-genus<sup>*</sup>.</p>
<p>When comparing results obtained when analyzing sequencing data using these databases, I noticed a strange increase in the number of reads assigned to the Leishmania chagasi species (which is a terminal node in the taxonomy for both databases) when going from db2 to db3.</p>
<p>According to my superficial understanding of kraken, I didn't expect this to happen, because <strong>db3 was built using a higher diversity of genomes outside the L. chagasi species than db2</strong>. If I expected any effect, this should have reduced the number of k-mers that are found specifically in L. chagasi, because some of these k-mers in db2 could have been present in the new genomes added to db3.</p>
<p>This increase in analysis reports parallels an increase in the number of minimizers as reported by <code>kraken2-inspect</code>. Below is a table comparing the <code>kraken2-inspect</code> reports for db2 and db3.</p>
<p>I only show the lines corresponding to Leishmania subgenus and its parents.</p>
<p>Compared to the <code>kraken2-inspect</code> output, I removed the taxid and re-ordered columns, for readability. <code>nb_min</code> and <code>nb_min_lvl</code> correspond to the number of minimizers reported on columns 2 and 3 of the <code>kraken2-inspect</code> default output (See <a href="https://github.com/DerrickWood/kraken2/blob/master/docs/MANUAL.markdown#inspecting-a-kraken-2-databases-contents" rel="nofollow noreferrer">https://github.com/DerrickWood/kraken2/blob/master/docs/MANUAL.markdown#inspecting-a-kraken-2-databases-contents</a>).</p>
<p>The line for L. chagasi is in bold, and shows <strong>a substantial increase (more than 20-fold)</strong> from 63874 minimizers in db2 to 1389504 in db3:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>taxname</th>
<th style="text-align: right;">lvl</th>
<th style="text-align: right;">% (db2)</th>
<th style="text-align: right;">nb_min (db2)</th>
<th style="text-align: right;">nb_min_lvl (db2)</th>
<th style="text-align: right;">% (db3)</th>
<th style="text-align: right;">nb_min (db3)</th>
<th style="text-align: right;">nb_min_lvl (db3)</th>
</tr>
</thead>
<tbody>
<tr>
<td>root</td>
<td style="text-align: right;">R</td>
<td style="text-align: right;">100.0</td>
<td style="text-align: right;">228330589</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">100</td>
<td style="text-align: right;">254009353</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>cellular organisms</td>
<td style="text-align: right;">R1</td>
<td style="text-align: right;">100.0</td>
<td style="text-align: right;">228330589</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">100</td>
<td style="text-align: right;">254009353</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Eukaryota</td>
<td style="text-align: right;">D</td>
<td style="text-align: right;">100.0</td>
<td style="text-align: right;">228330589</td>
<td style="text-align: right;">4685</td>
<td style="text-align: right;">100</td>
<td style="text-align: right;">254009353</td>
<td style="text-align: right;">6669</td>
</tr>
<tr>
<td>Discoba</td>
<td style="text-align: right;">D1</td>
<td style="text-align: right;">23.4</td>
<td style="text-align: right;">53431766</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">31.14</td>
<td style="text-align: right;">79110530</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Euglenozoa</td>
<td style="text-align: right;">P</td>
<td style="text-align: right;">23.4</td>
<td style="text-align: right;">53431766</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">31.14</td>
<td style="text-align: right;">79110530</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Kinetoplastea</td>
<td style="text-align: right;">C</td>
<td style="text-align: right;">23.4</td>
<td style="text-align: right;">53431766</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">31.14</td>
<td style="text-align: right;">79110530</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Metakinetoplastina</td>
<td style="text-align: right;">C1</td>
<td style="text-align: right;">23.4</td>
<td style="text-align: right;">53431766</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">31.14</td>
<td style="text-align: right;">79110530</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Trypanosomatida</td>
<td style="text-align: right;">O</td>
<td style="text-align: right;">23.4</td>
<td style="text-align: right;">53431766</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">31.14</td>
<td style="text-align: right;">79110530</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Trypanosomatidae</td>
<td style="text-align: right;">F</td>
<td style="text-align: right;">23.4</td>
<td style="text-align: right;">53431766</td>
<td style="text-align: right;">1645</td>
<td style="text-align: right;">31.14</td>
<td style="text-align: right;">79110530</td>
<td style="text-align: right;">2029</td>
</tr>
<tr>
<td>Leishmaniinae</td>
<td style="text-align: right;">F1</td>
<td style="text-align: right;">19.87</td>
<td style="text-align: right;">45358915</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">27.97</td>
<td style="text-align: right;">71037679</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Leishmania</td>
<td style="text-align: right;">G</td>
<td style="text-align: right;">19.87</td>
<td style="text-align: right;">45358915</td>
<td style="text-align: right;">259764</td>
<td style="text-align: right;">27.97</td>
<td style="text-align: right;">71037679</td>
<td style="text-align: right;">305088</td>
</tr>
<tr>
<td>Leishmania</td>
<td style="text-align: right;">G1</td>
<td style="text-align: right;">14.67</td>
<td style="text-align: right;">33503508</td>
<td style="text-align: right;">4587885</td>
<td style="text-align: right;">23.3</td>
<td style="text-align: right;">59182271</td>
<td style="text-align: right;">12771940</td>
</tr>
<tr>
<td>Leishmania donovani species complex</td>
<td style="text-align: right;">G2</td>
<td style="text-align: right;">3.61</td>
<td style="text-align: right;">8243592</td>
<td style="text-align: right;">6215217</td>
<td style="text-align: right;">5.01</td>
<td style="text-align: right;">12729716</td>
<td style="text-align: right;">1378715</td>
</tr>
<tr>
<td>Leishmania donovani</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">0.63</td>
<td style="text-align: right;">1439307</td>
<td style="text-align: right;">1439307</td>
<td style="text-align: right;">3.71</td>
<td style="text-align: right;">9428437</td>
<td style="text-align: right;">8055955</td>
</tr>
<tr>
<td>Leishmania donovani Ld 2001</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">0.48</td>
<td style="text-align: right;">1207432</td>
<td style="text-align: right;">1207432</td>
</tr>
<tr>
<td>Leishmania donovani Ld 39</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">0.06</td>
<td style="text-align: right;">165050</td>
<td style="text-align: right;">165050</td>
</tr>
<tr>
<td><strong>Leishmania chagasi</strong></td>
<td style="text-align: right;"><strong>S</strong></td>
<td style="text-align: right;"><strong>0.03</strong></td>
<td style="text-align: right;"><strong>63874</strong></td>
<td style="text-align: right;"><strong>63874</strong></td>
<td style="text-align: right;"><strong>0.55</strong></td>
<td style="text-align: right;"><strong>1389504</strong></td>
<td style="text-align: right;"><strong>1389504</strong></td>
</tr>
<tr>
<td>Leishmania infantum</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">0.23</td>
<td style="text-align: right;">525194</td>
<td style="text-align: right;">520206</td>
<td style="text-align: right;">0.21</td>
<td style="text-align: right;">533060</td>
<td style="text-align: right;">528882</td>
</tr>
<tr>
<td>Leishmania infantum JPCM5</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;">0.0</td>
<td style="text-align: right;">4988</td>
<td style="text-align: right;">4988</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">4178</td>
<td style="text-align: right;">4178</td>
</tr>
<tr>
<td>Leishmania mexicana species complex</td>
<td style="text-align: right;">G2</td>
<td style="text-align: right;">4.39</td>
<td style="text-align: right;">10033887</td>
<td style="text-align: right;">4875993</td>
<td style="text-align: right;">4.18</td>
<td style="text-align: right;">10626363</td>
<td style="text-align: right;">5076482</td>
</tr>
<tr>
<td>Leishmania amazonensis</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">1.22</td>
<td style="text-align: right;">2782684</td>
<td style="text-align: right;">2782684</td>
<td style="text-align: right;">1.23</td>
<td style="text-align: right;">3123079</td>
<td style="text-align: right;">3123079</td>
</tr>
<tr>
<td>Leishmania mexicana</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">1.04</td>
<td style="text-align: right;">2375210</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0.96</td>
<td style="text-align: right;">2426802</td>
<td style="text-align: right;">2191283</td>
</tr>
<tr>
<td>Leishmania mexicana MHOM/GT/2001/U1103</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;">1.04</td>
<td style="text-align: right;">2375210</td>
<td style="text-align: right;">2375210</td>
<td style="text-align: right;">0.09</td>
<td style="text-align: right;">235519</td>
<td style="text-align: right;">235519</td>
</tr>
<tr>
<td>Leishmania martiniquensis</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">3.44</td>
<td style="text-align: right;">8749402</td>
<td style="text-align: right;">8749402</td>
</tr>
<tr>
<td>Leishmania major species complex</td>
<td style="text-align: right;">G2</td>
<td style="text-align: right;">2.49</td>
<td style="text-align: right;">5691012</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">5980712</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Leishmania major</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">2.49</td>
<td style="text-align: right;">5691012</td>
<td style="text-align: right;">5634913</td>
<td style="text-align: right;">2.35</td>
<td style="text-align: right;">5980712</td>
<td style="text-align: right;">5350171</td>
</tr>
<tr>
<td>Leishmania major strain LV39c5</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">0.17</td>
<td style="text-align: right;">419323</td>
<td style="text-align: right;">419323</td>
</tr>
<tr>
<td>Leishmania major strain SD 75.1</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">0.08</td>
<td style="text-align: right;">192440</td>
<td style="text-align: right;">192440</td>
</tr>
<tr>
<td>Leishmania major strain Friedlin</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;">0.02</td>
<td style="text-align: right;">56099</td>
<td style="text-align: right;">56099</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">18778</td>
<td style="text-align: right;">18778</td>
</tr>
<tr>
<td>Leishmania tropica species complex</td>
<td style="text-align: right;">G2</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">1.89</td>
<td style="text-align: right;">4803669</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Leishmania tropica</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">1.89</td>
<td style="text-align: right;">4803669</td>
<td style="text-align: right;">4796954</td>
</tr>
<tr>
<td>Leishmania tropica L590</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">6715</td>
<td style="text-align: right;">6715</td>
</tr>
<tr>
<td>Leishmania aethiopica species complex</td>
<td style="text-align: right;">G2</td>
<td style="text-align: right;">2.17</td>
<td style="text-align: right;">4947132</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1.39</td>
<td style="text-align: right;">3520469</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Leishmania aethiopica</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">2.17</td>
<td style="text-align: right;">4947132</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1.39</td>
<td style="text-align: right;">3520469</td>
<td style="text-align: right;">3057668</td>
</tr>
<tr>
<td>Leishmania aethiopica L147</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;">2.17</td>
<td style="text-align: right;">4947132</td>
<td style="text-align: right;">4947132</td>
<td style="text-align: right;">0.18</td>
<td style="text-align: right;">462801</td>
<td style="text-align: right;">462801</td>
</tr>
<tr>
<td>Viannia</td>
<td style="text-align: right;">G1</td>
<td style="text-align: right;">5.08</td>
<td style="text-align: right;">11595643</td>
<td style="text-align: right;">5588978</td>
<td style="text-align: right;">4.55</td>
<td style="text-align: right;">11550320</td>
<td style="text-align: right;">5553385</td>
</tr>
<tr>
<td>Leishmania braziliensis species complex</td>
<td style="text-align: right;">G2</td>
<td style="text-align: right;">1.33</td>
<td style="text-align: right;">3037436</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1.19</td>
<td style="text-align: right;">3032336</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Leishmania braziliensis</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">1.33</td>
<td style="text-align: right;">3037436</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1.19</td>
<td style="text-align: right;">3032336</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Leishmania braziliensis MHOM/BR/75/M2904</td>
<td style="text-align: right;">S1</td>
<td style="text-align: right;">1.33</td>
<td style="text-align: right;">3037436</td>
<td style="text-align: right;">3037436</td>
<td style="text-align: right;">1.19</td>
<td style="text-align: right;">3032336</td>
<td style="text-align: right;">3032336</td>
</tr>
<tr>
<td>Leishmania guyanensis species complex</td>
<td style="text-align: right;">G2</td>
<td style="text-align: right;">1.3</td>
<td style="text-align: right;">2969229</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1.17</td>
<td style="text-align: right;">2964599</td>
<td style="text-align: right;">0</td>
</tr>
<tr>
<td>Leishmania panamensis</td>
<td style="text-align: right;">S</td>
<td style="text-align: right;">1.3</td>
<td style="text-align: right;">2969229</td>
<td style="text-align: right;">2969229</td>
<td style="text-align: right;">1.17</td>
<td style="text-align: right;">2964599</td>
<td style="text-align: right;">2964599</td>
</tr>
</tbody>
</table></div>
<p>My question: <strong>How is such an increase possible, when the only genomes added are outside the clade?</strong></p>
<p>I don't know if this can help understanding what happens, but L. chagasi could actually be considered a sub-clade of L. infantum (chagasi is the descendant of infantum brought to the New world by European conquistadores), but in the NCBI taxonomy used to build the databases, they are sister S-level taxa within the G2 &quot;L. donovani species complex&quot; (together with the L. donovani species, that has two S1-level strains added in db3 compared to db2).</p>
<p><sup>*</sup> Here is how I built the databases</p>
<pre><code>kraken2-build --download-taxonomy --db protozoa
kraken2-build --download-library protozoa --db protozoa
cp -r protozoa db2
cp -r protozoa db3
mv protozoa db1
kraken2-build --build --threads 16 --db db1
# Download genomes
# Add genomes to db2 using `kraken2-build --add-to-library &lt;genome&gt;/*.fna --db db2`
kraken2-build --build --threads 16 --db db2
# Add even more genomes do db3 using `kraken2-build --add-to-library &lt;genome&gt;/*.fna --db db3`
kraken2-build --build --threads 16 --db db3
</code></pre>

CC BY-SA 4.0
2024-07-28T02:31:50.470Z
I will look at this question over the next week. There's clearly a lot going on here. What I need to think about is "outside the clade" ... I'm not sure about that.
M__
CC BY-SA 4.0
2024-07-29T13:20:31.107Z
To elaborate: If I had added genomes belonging to L. chagasi (for instance, at the S1 level), it would not have surprised me to see a larger number of k-mers associated to L. chagasi at the species level. New genomes should give a better idea of the diversity observable within a given clade. However, with genomes only added elsewhere, I don't get it. Maybe something to do with the distinction between k-mers and minimizers?
bli
<metagenome><k-mer><kraken>
How adding genomes to a kraken database can increase the number of minimizers associated with a leaf of the taxonomy?
# How adding genomes to a kraken database can increase the number of minimizers associated with a leaf of the taxonomy?

(Asked by: username_0 on 2024-07-26)

I built a protozoa kraken 2 database ("db1"), from which I further built two other databases ("db2" and "db3") by adding extra genomes in the Leishmania sub-genus*.
When comparing results obtained when analyzing sequencing data using these databases, I noticed a strange increase in the number of reads assigned to the Leishmania chagasi species (which is a terminal node in the taxonomy for both databases) when going from db2 to db3.
According to my superficial understanding of kraken, I didn't expect this to happen, because db3 was built using a higher diversity of genomes outside the L. chagasi species than db2. If I expected any effect, this should have reduced the number of k-mers that are found specifically in L. chagasi, because some of these k-mers in db2 could have been present in the new genomes added to db3.
This increase in analysis reports parallels an increase in the number of minimizers as reported by kraken2-inspect. Below is a table comparing the kraken2-inspect reports for db2 and db3.
I only show the lines corresponding to Leishmania subgenus and its parents.
Compared to the kraken2-inspect output, I removed the taxid and re-ordered columns, for readability. nb_min and nb_min_lvl correspond to the number of minimizers reported on columns 2 and 3 of the kraken2-inspect default output (See https://github.com/DerrickWood/kraken2/blob/master/docs/MANUAL.markdown#inspecting-a-kraken-2-databases-contents).
The line for L. chagasi is in bold, and shows a substantial increase (more than 20-fold) from 63874 minimizers in db2 to 1389504 in db3:



taxname
lvl
% (db2)
nb_min (db2)
nb_min_lvl (db2)
% (db3)
nb_min (db3)
nb_min_lvl (db3)




root
R
100.0
228330589
0
100
254009353
0


cellular organisms
R1
100.0
228330589
0
100
254009353
0


Eukaryota
D
100.0
228330589
4685
100
254009353
6669


Discoba
D1
23.4
53431766
0
31.14
79110530
0


Euglenozoa
P
23.4
53431766
0
31.14
79110530
0


Kinetoplastea
C
23.4
53431766
0
31.14
79110530
0


Metakinetoplastina
C1
23.4
53431766
0
31.14
79110530
0


Trypanosomatida
O
23.4
53431766
0
31.14
79110530
0


Trypanosomatidae
F
23.4
53431766
1645
31.14
79110530
2029


Leishmaniinae
F1
19.87
45358915
0
27.97
71037679
0


Leishmania
G
19.87
45358915
259764
27.97
71037679
305088


Leishmania
G1
14.67
33503508
4587885
23.3
59182271
12771940


Leishmania donovani species complex
G2
3.61
8243592
6215217
5.01
12729716
1378715


Leishmania donovani
S
0.63
1439307
1439307
3.71
9428437
8055955


Leishmania donovani Ld 2001
S1



0.48
1207432
1207432


Leishmania donovani Ld 39
S1



0.06
165050
165050


Leishmania chagasi
S
0.03
63874
63874
0.55
1389504
1389504


Leishmania infantum
S
0.23
525194
520206
0.21
533060
528882


Leishmania infantum JPCM5
S1
0.0
4988
4988
0
4178
4178


Leishmania mexicana species complex
G2
4.39
10033887
4875993
4.18
10626363
5076482


Leishmania amazonensis
S
1.22
2782684
2782684
1.23
3123079
3123079


Leishmania mexicana
S
1.04
2375210
0
0.96
2426802
2191283


Leishmania mexicana MHOM/GT/2001/U1103
S1
1.04
2375210
2375210
0.09
235519
235519


Leishmania martiniquensis
S



3.44
8749402
8749402


Leishmania major species complex
G2
2.49
5691012
0
2.35
5980712
0


Leishmania major
S
2.49
5691012
5634913
2.35
5980712
5350171


Leishmania major strain LV39c5
S1



0.17
419323
419323


Leishmania major strain SD 75.1
S1



0.08
192440
192440


Leishmania major strain Friedlin
S1
0.02
56099
56099
0.01
18778
18778


Leishmania tropica species complex
G2



1.89
4803669
0


Leishmania tropica
S



1.89
4803669
4796954


Leishmania tropica L590
S1



0
6715
6715


Leishmania aethiopica species complex
G2
2.17
4947132
0
1.39
3520469
0


Leishmania aethiopica
S
2.17
4947132
0
1.39
3520469
3057668


Leishmania aethiopica L147
S1
2.17
4947132
4947132
0.18
462801
462801


Viannia
G1
5.08
11595643
5588978
4.55
11550320
5553385


Leishmania braziliensis species complex
G2
1.33
3037436
0
1.19
3032336
0


Leishmania braziliensis
S
1.33
3037436
0
1.19
3032336
0


Leishmania braziliensis MHOM/BR/75/M2904
S1
1.33
3037436
3037436
1.19
3032336
3032336


Leishmania guyanensis species complex
G2
1.3
2969229
0
1.17
2964599
0


Leishmania panamensis
S
1.3
2969229
2969229
1.17
2964599
2964599



My question: How is such an increase possible, when the only genomes added are outside the clade?
I don't know if this can help understanding what happens, but L. chagasi could actually be considered a sub-clade of L. infantum (chagasi is the descendant of infantum brought to the New world by European conquistadores), but in the NCBI taxonomy used to build the databases, they are sister S-level taxa within the G2 "L. donovani species complex" (together with the L. donovani species, that has two S1-level strains added in db3 compared to db2).
* Here is how I built the databases
kraken2-build --download-taxonomy --db protozoa
kraken2-build --download-library protozoa --db protozoa
cp -r protozoa db2
cp -r protozoa db3
mv protozoa db1
kraken2-build --build --threads 16 --db db1
# Download genomes
# Add genomes to db2 using `kraken2-build --add-to-library /*.fna --db db2`
kraken2-build --build --threads 16 --db db2
# Add even more genomes do db3 using `kraken2-build --add-to-library /*.fna --db db3`
kraken2-build --build --threads 16 --db db3

**Tags:** metagenome, k-mer, kraken
> **Comments:**
> **username_1**: I will look at this question over the next week. There's clearly a lot going on here. What I need to think about is "outside the clade" ... I'm not sure about that.  
> **username_0**: To elaborate: If I had added genomes belonging to L. chagasi (for instance, at the S1 level), it would not have surprised me to see a larger number of k-mers associated to L. chagasi at the species level. New genomes should give a better idea of the diversity observable within a given clade. However, with genomes only added elsewhere, I don't get it. Maybe something to do with the distinction between k-mers and minimizers?  

---

## 1 answers

### Answer by username_2 on 2024-07-26. Score: 1

In one of its possible output modes, kraken2 will give you read-level and kmer-level information about how it came to its conclusions about taxonomic assignment. You've provided a lot of detail in your question about your process of generating the data, and the taxon assignment table, but I expect your specific question will best be answered by digging deeper into your own data.

To explain a bit further, individual reads are assigned to a taxon based on the kmer assignments for that read (i.e. each kmer within a read essentially votes for the read taxon). The behaviour of assignment after changing the database is unpredictable at a read level because the kmer assignments will change. Even if diversity is increased, that increased diversity will alter the "votes" from the kmers, and could result in a particular taxon crossing a threshold (and increasing in apparent abundance) because other taxa now have fewer votes.

In any case, Kraken2 is known to assign taxa in a way that is not necessarily a good representation of the actual content. If you want to make statements about the proportion of different taxa in your samples, I'd recommend that you try out using Bracken on your Kraken2 results. It will correct some assignments based on sequence similarities in the database:

> Bracken is a companion program to Kraken 1, KrakenUniq, or Kraken 2 While Kraken classifies reads to multiple levels in the taxonomic tree, Bracken allows estimation of abundance at a single level using those classifications (e.g. Bracken can estimate abundance of species within a sample).

<https://github.com/jenniferlu717/Bracken?tab=readme-ov-file#step-1-generate-the-bracken-database-file-databasexmerskmer_distrib>

> **Comments:**
> **username_0**: Thanks for the ref to bracken. You wrote "I expect your specific question will best be answered by digging deeper into your own data.". Note that the puzzling observation I made is actually not dependent on my data, since it seems to stem from some effect at database construction.  
> **username_2**: @bli I've added a bit more detail to explain my reasoning. The main thing is that database changes lead to unpredictable effects. You can't always assume that class assignment fractions will go down when database diversity is increased. That's why it's important to use tools like Bracken that take this kmer weirdness into account.  

---

