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
    • Invite by email
      Invitee

      This note has no invitees

    • 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
    • Note Insights
    • 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 Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
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
  • Invite by email
    Invitee

    This note has no invitees

  • 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
    # spacegraphcats ho! lab meeting what we're doing, and some associated chopportunities. (Oct 19, 2020 lab meeting) github.com/spacegraphcats/spacegraphcats/ :warning: here be dragons... and maybe (ok, definitely!) some technical debt --- ![](https://i.imgur.com/FImHSsM.png) --- ![](https://i.imgur.com/dYt9Ak1.png) --- ## background: motivation for graph-based approaches in metagenomics --- ![](https://i.imgur.com/KDnDxM7.png) --- ![](https://i.imgur.com/raLyeIJ.png) --- ## MAPPING AND ASSEMBLY BAD Because communities are a diverse mix of strains, * cannot reliably use reference genomes from other samples; * cannot reliably use references from the same sample, w/o haplotype-level resolution; * cannot reliably co-assemble samples (will merge/collapse strains) This is also true of metatranscriptomes and ~RNAseq... --- reads -> k-mers/De Bruijn graph -> compact De Bruijn graph (cDBG) ![](https://i.imgur.com/dpie2B4.png) --- spacegraphcats indexes cDBGs and partitions them into pieces, based around "dominating nodes" that cover the cDBG at some radius r. ![](https://i.imgur.com/VtXnKza.png) --- "piecing the graph" -> every cDBG node (blue) belongs to a dom node (purple) ![](https://i.imgur.com/SCukfgH.png) --- This is easy for small graphs, but... ![](https://i.imgur.com/8F3Usvy.png) --- so, Taylor and I have been experimenting with "pulling" annotations (gene names; abundances; taxonomy) from cDBG nodes "up" to the pieces. ![](https://i.imgur.com/ljs4ESi.png) --- This means every purple dominating node (== piece) gets annotated with all of the features under it. ![](https://i.imgur.com/ljs4ESi.png) --- ## what does this do? why do we do it? --- This is a first step to interpreting k-mers/sequence NOT in reference genome, but graph-adjacent to it. ![](https://i.imgur.com/WD64XuY.png) --- we think we're mostly looking at minor variants (gene A) but :shrug: ![](https://i.imgur.com/w0jr8A2.png) --- ## benchmarking considerations... how do we evaluate the biological plausibility of this!? ...some tests are under way... cc taylor ;) some preliminary results from taxonomy -- --- ## taxonomy results for r=1 on mock community data: 88512 dom nodes have no sourmash hashes 903 dom nodes have exactly one sourmash hash 37 dom nodes have two or more sourmash hashes ``` rank of dom node lca count of dom nodes with that rank -------------------- --------------------------------- strain 35 species 2 ``` --- ## taxonomy results for r=5 on mock community data: 14149 dom nodes have no sourmash hashes 796 dom nodes have exactly one sourmash hash 86 dom nodes have two or more sourmash hashes ``` rank of dom node lca count of dom nodes with that rank -------------------- --------------------------------- strain 76 species 10 ``` --- side note: this also lets us measure abundances directly on the graph... :grin: ![](https://i.imgur.com/ljs4ESi.png) --- ## how do we do it, code-wise? (and where are there ...chopportunities!) --- ## expanding annotations from cDBG nodes to dom nodes ```python= for cdbg_node in cdbg_nodes: # v--- the tricky bit is building cdbg_annots! annots = cdbg_annots.get(cdbg_node, []) dom_id = catlas.cdbg_to_dom[cdbg_node] dom_annots[dom_id].update(annots) ``` --- ## building cdbg_annots often relies on k-mers ```python= cdbg_annots = defaultdict(set) for gene_name, gene_seq in screed.open(gene_sequences): kmers = khmer.sequence_to_kmers(gene_seq) # do the search - the tricky bit, in more detail cdbg_nodes = catlas.nodes_by_kmers(kmers) # save annotations for cdbg_node_id in cdbg_nodes: cdbg_annots[cdbg_node_id].add(gene_name) ``` --- ## nodes_by_kmers relies on trickiness to *scale* to build a fast mapping `{ k-mer: cdbg_node_id }` for billions of k-mers, we take advantage of a feature of cDBGs: each k-mer is present in no more than one cDBG node. we then use minimal perfect hash functions (MPHF) to map `{ kmer: offset }` and use `offset` to index into an linear array. --- this is how we use the minimal perfect hash functions (MPHF): ```python= mphf = mphf_build_table(all_kmers) lookups = {} for cdbg_node_id, sequence in cdbg_nodes.items(): for kmer in khmer.sequence_to_kmers(sequence): mphf_id = mphf.kmer_to_hash(kmer) lookups[mphf_id] = cdbg_node_id ``` * this could maybe be replaced by using the MQF (Mostafa and Tamer's work). * other thoughts? --- ## retrieving reads for cDBG contigs another important thing spacegraphcats does is retrieve the underlying *reads* that match to any given query. steps: * find IDs of cDBG contigs containing query k-mers * extract dom nodes for those cDBG contigs * extract cDBG IDs under those dom nodes * find read IDs that share k-mers with those cDBG IDs --- ## building a read index for the last step, we need a many-to-many mapping: `{ cdbg_id : read_id }`. this is many to many because each read may overlap with multiple cDBG nodes, and each cDBG node will usually contain many reads. what's a good way to do this for 100s of millions of reads, and 10s of millions of cDBG nodes?? --- ## current strategy * currently relies on a janky minimizer-like strategy using khmer tagging (pls no) * not actually 100% sure how it works, upon reading code 😱 * very slow, & definitely non-optimal in any way you care to name 😂 --- ## future strategies?? * cannot use MPHF because it only enables a one-to-many mapping. * can we use better minimizers, maybe? * one observation: all multi-cDBG-node reads must overlap with k-mers at an end of the cDBG node... can we use that? cc camille for insights. --- ## thanks! fini. ![](https://i.imgur.com/0DMy0rR.png)

    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