# Digging into the ½ million sequences with javascript + filtering + dynamic nextstrain tree

**URL:** <https://nextstrain.discourse.group/t/digging-into-the-million-sequences-with-javascript-filtering-dynamic-nextstrain-tree/349>\
**Category:** Uncategorized\
**Created:** [February 17, 2021, 2:35pm UTC](https://nextstrain.discourse.group/t/digging-into-the-million-sequences-with-javascript-filtering-dynamic-nextstrain-tree/349 "2021-02-17T14:35:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![babarlelephant](https://avatars.discourse-cdn.com/v4/letter/b/8e8cbc/32.png) [@babarlelephant](https://nextstrain.discourse.group/u/babarlelephant)\
**Post date:** [February 17, 2021, 2:35pm UTC](https://nextstrain.discourse.group/t/digging-into-the-million-sequences-with-javascript-filtering-dynamic-nextstrain-tree/349/1 "2021-02-17T14:35:18Z")

</div>

Hi, I made a demo [there](http://babarlelephant.free-hoster.net/cov2/) showing that it is possible, once extracted the SNP of the 500000 sequences, to run in a web page a filtering script selecting a few thousand of sequences, then to add those to a small precomputed nextstrain (divergence) tree.

Obviously the tree I am generating is NOT quite a maximum likelihood phylogenetic tree, [the algorithm](http://babarlelephant.free-hoster.net/cov2/addOneByOne_web2.js) to add the sequences to the tree is the simplest and the fastest one you can imagine: for each sequence, if a mutation in a branch is not in the sequence then skip the subtree (thus the reversions and missing data generate some duplicated parasite lineages).

The main difficulty I am encountering:

- optimizing everything to make it faster,

- finding an algorithm to generate a dynamic timetree,

- the map works but then it gets buggy, auspice is a bit hard to customize, all I did was to add

[Nextclade](https://clades.nextstrain.org/) (the ‘show tree’ button) is implementing something closely related, though the algorithm to create the [dynamic tree](https://github.com/nextstrain/nextclade/blob/master/packages/web/src/algorithms/tree/treeFindNearestNodes.ts) seems to be trying every node for the closest one, and it is not using the dynamically created nodes.
