Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs regarding bootstraps #1456

Open
jameshadfield opened this issue Apr 29, 2024 · 0 comments
Open

Add docs regarding bootstraps #1456

jameshadfield opened this issue Apr 29, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@jameshadfield
Copy link
Member

We have scant documentation about bootstraps - it's mentioned in a single changelog entry and a one line comment here:

Bootstrap values are allowed, and should be parsed correctly by augur refine.

It'd be good to expand on this a little, including covering:

  • Where are bootstraps in the final tree (dataset)?
    • currently under a colouring "confidence"
  • Why are some internal nodes missing bootstraps?
    • If augur refine resolves polytomies the newly created internal nodes will be missing bootstraps. A solution is to run with --keep-polytomies
  • It's more typical to display bootstraps as branch labels rather than colours. A small script will transfer them over for you:
import argparse
import json

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--input', type = str, required = True, metavar='JSON', help = "Input dataset JSON with 'confidence' node attrs")
    parser.add_argument('--output', type = str, required = True, metavar='JSON', help = "Output JSON with bootstrap branch labels")
    args = parser.parse_args()

    with open(args.input) as fh:
        dataset = json.load(fh)
    
    nodes = [dataset['tree']]

    while len(nodes):
        node = nodes.pop(0)
        for child in node.get('children', []):
            nodes.append(child)
        bootstrap = node.get('node_attrs', {}).get('confidence', {}).get('value', False)
        if bootstrap is not False:
            if 'branch_attrs' not in node: node['branch_attrs'] = {}
            if 'labels' not in node['branch_attrs']: node['branch_attrs']['labels'] = {}
            node['branch_attrs']['labels']['bootstrap'] = f"{bootstrap:.2f}"

    with open(args.output, 'w') as fh:
        dataset = json.dump(dataset, fh)    

This issue was prompted by this email exchange (private link)

@jameshadfield jameshadfield added the documentation Improvements or additions to documentation label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant