C. Titus Brown
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
[TOC] # Annotate the eukaryotic and bacterial taxonomy of a metagenome using sourmash C. Titus Brown Aug 5, 2025 DRAFT tutorial; updates &c will happen here: [sourmash#3765](https://github.com/sourmash-bio/sourmash/issues/3765). ## Description This tutorial demonstrates how to use sourmash to search a metagenome signature against a combined database of GTDB+NCBI eukaryote genomes. This addresses a challenge in metagenomics where people may want to use the GTDB database of genomes and/or the GTDB taxonomy, but also want to discover eukaryotic organisms that are not in GTDB. At the end, this tutorial provides several visualizations of taxonomic composition as well. ## Compute requirements You'll need about 70 GB of disk space to run this tutorial, including the software install. The memory and CPU requirements are minimal (1 GB RAM, ~2 minutes on one CPU). ## Install sourmash, taxburst, and the betterplot plugin for sourmash Install [sourmash](https://sourmash.readthedocs.io/), [taxburst](https://taxburst.github.io/taxburst/), and [sourmash betterplot](https://github.com/sourmash-bio/sourmash_plugin_betterplot/). Create a new conda environment with sourmash installed: ``` conda create -n smash-euk-tutorial -y 'sourmash >= 4.9.3' python=3.12 ``` Activate, and then install some pure Python packages: ``` conda activate smash-euk-tutorial pip install sourmash_plugin_betterplot taxburst ``` ## Download databases We need two of the [sourmash indexed RocksDB databases](https://sourmash.readthedocs.io/en/latest/databases.html) - the GTDB RS226 entire database, and the NCBI Eukaryotic dindexed database. Download the indexed GTDB RS226 database (Bacteria and Archaea). This requires 35 GB of disk space. ``` curl -L https://farm.cse.ucdavis.edu/~ctbrown/sourmash-db.new/gtdb-rs226/gtdb-rs226-k51.dna.rocksdb.tar.gz | tar xzf - ``` Download and unpack the Jan 2025 NCBI eukaryotes database. This requires 23 GB of disk space. ``` curl -L https://farm.cse.ucdavis.edu/~ctbrown/sourmash-db.new/ncbi-euks-2025.01/ncbi-euks-all-2025.01-k51.dna.rocksdb.tar.gz | tar xzf - ``` You should now have two directories, both ending in ``.rocksdb`: ``` ls -FC ``` >gtdb-rs226-k51.dna.rocksdb/ >ncbi-euks-all-2025.01-k51.dna.rocksdb/ ## Download a metagenome to analyze Grab a metagenome sig from our repository of all public SRA data sets: ``` curl -L https://wort.sourmash.bio/v1/view/sra/SRR11125891 -o SRR11125891.sig ``` You can replace `SRR11125891` with any public SRA accession you're interested in, [or sketch your own](https://sourmash.readthedocs.io/en/latest/sourmash-sketch.html). ## Run `sourmash gather` to select overlapping genomes Now run sourmash gather to search the downloaded metagenome against both databases: ``` sourmash gather SRR11125891.sig \ gtdb-rs226-k51.dna.rocksdb \ ncbi-euks-all-2025.01-k51.dna.rocksdb \ -o SRR11125891.x.gtdb+euks.csv \ -k 51 --scaled 10_000 ``` This will take ~1-2 min and require 1 GB of RAM. The output of this command will be a CSV file that contains a [minimum metagenome cover](https://www.biorxiv.org/content/10.1101/2022.01.11.475838v2) listing a short list of known genomes that are present. ## Annotate the sourmash gather results with GTDB and NCBI eukaryote taxonomies. Next we will generate a taxonomic summary based on the matching genomes. For this we will need to combine the GTDB taxonomy (for bacteria and archaea) with the NCBI eukaryotic taxonomy. Start by downloading gtdb-rs226.lineages.csv and ncbi-eukaryotes.2025.01.lineages.csv, again, from the [prepared databases page](https://sourmash.readthedocs.io/en/latest/databases.html): ``` curl -JLO https://farm.cse.ucdavis.edu/~ctbrown/sourmash-db.new/gtdb-rs226/gtdb-rs226.lineages.csv curl -JLO https://farm.cse.ucdavis.edu/~ctbrown/sourmash-db.new/ncbi-euks-2025.01/ncbi-eukaryotes.2025.01.lineages.csv ``` Then, use `sourmash tax` to annotate the gather output with taxonomy: ``` sourmash tax annotate -g SRR11125891.x.gtdb+euks.csv \ -t gtdb-rs226.lineages.csv \ ncbi-eukaryotes.2025.01.lineages.csv ``` Notes: * you could also use the NCBI taxonomy instead of the GTDB taxonomy for the bacterial and archaeal matches, since every GTDB genome is also in NCBI. * if you plan to run `sourmash tax` multiple times, you should use `sourmash tax prepare` to combine the CSV files into a SQLite database, which will be much faster! ## Create a taxburst taxonomy of the results [taxburst](https://taxburst.github.io/) (a fork of [Krona](https://github.com/marbl/Krona)) is a nice way to explore taxonomic results. Note the presence of some putative host contamination in this pig metagenome - the eukaryote 'Sus scrofa' is pig :). Run: ``` taxburst -F tax_annotate SRR11125891.x.gtdb+euks.with-lineages.csv \ -o SRR11125891.x.gtdb+euks.taxburst.html ``` <iframe src="https://farm.cse.ucdavis.edu/~ctbrown/2025-euk-tax-tutorial-files/SRR11125891.x.gtdb+euks.taxburst.html" width="1200" height="800" frameborder="1" allowfullscreen></iframe> (If anyone has better ideas for the iframe embedding, please let me know!) ## Generate a Sankey flow diagram of the results Sankey flow diagrams are nice ways to view hierarchical decompositions! This is a nice interactive one, produced by [the betterplot plugin for sourmash](https://github.com/sourmash-bio/sourmash_plugin_betterplot/). ``` sourmash scripts sankey \ --annotate-csv SRR11125891.x.gtdb+euks.with-lineages.csv \ -o SRR11125891.x.gtdb+euks.sankey.html ``` <iframe src="https://farm.cse.ucdavis.edu/~ctbrown/2025-euk-tax-tutorial-files/SRR11125891.x.gtdb+euks.sankey.html" width="1200" height="800" frameborder="1" allowfullscreen></iframe> ## Generate a treemap of the results Last but not least, here is a proportional representation of species detected in the metagenome. This is a 'treemap', which does a nice job of showing the content weighting. First we need a new format for the taxonomic summary: ``` sourmash tax metagenome -F csv_summary \ -o SRR11125891.x.gtdb+euks \ -g SRR11125891.x.gtdb+euks.csv \ -t gtdb-rs226.lineages.csv \ ncbi-eukaryotes.2025.01.lineages.csv ``` and then we run treemap (again from [the betterplot plugin for sourmash](https://github.com/sourmash-bio/sourmash_plugin_betterplot/): ``` sourmash scripts treemap \ SRR11125891.x.gtdb+euks.summarized.csv \ -o SRR11125891.x.gtdb+euks.treemap.png \ -r species ``` The file `SRR11125891.x.gtdb+euks.treemap.png` will contain the following image: ![a treemap of the metagenome content at species level](https://farm.cse.ucdavis.edu/~ctbrown/2025-euk-tax-tutorial-files/SRR11125891.x.gtdb+euks.treemap.png) ## Additional notes and discussion points ### Why are we using k=51? K=51 is a very stringent match, and we are certainly missing some bacterial content here. However, we've found that lower k-mer sizes introduce too many false positives with large eukaryotic genomes. We're working on it! ### Can we do a simultaneous search for viruses? We do have viral databases [for sourmash](https://sourmash.readthedocs.io/en/latest/databases.html), but the search parameters are incompatible with k=51/scaled=10_000. We're working on it :). See [sourmash-bio/sourmash#1340](https://github.com/sourmash-bio/sourmash/issues/1340).

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully