PoonLab / covizu

Rapid analysis and visualization of coronavirus genome variation
https://filogeneti.ca/CoVizu/
MIT License
45 stars 20 forks source link

Tips in timetree are being rendered outside of panel #512

Closed ArtPoon closed 4 months ago

ArtPoon commented 6 months ago
Screenshot 2024-02-20 at 9 59 43 AM
ArtPoon commented 6 months ago

Looks like this problem is at the level of generating the timetree (visualizing timetree.nwk below):

Screenshot 2024-02-20 at 10 41 42 AM
ArtPoon commented 6 months ago

@GopiGugan I'm running some tests on Paphlagon

ArtPoon commented 6 months ago

Using the following script to extract by_lineage.json file from latest provision:

import covizu
from covizu.utils import gisaid_utils
from covizu.utils.progress_utils import Callback
from covizu.utils.batch_utils import *
import os

cb = Callback()

infile = "data/provision.2024-02-17T00:00:21.json.xz"
ref_file = os.path.join(covizu.__path__[0], "data/NC_045512.fa")
vcf_file = os.path.join(
    covizu.__path__[0],
    "data/ProblematicSites_SARS-CoV2/problematic_sites_sarsCov2.vcf")

loader = gisaid_utils.load_gisaid(infile, minlen=29000, mindate="2019-12-01",
                                  debug=None) #100)
batcher = gisaid_utils.batch_fasta(loader, size=2000)
aligned = gisaid_utils.extract_features(
    batcher, ref_file=ref_file, binpath="minimap2", nthread=16, minlen=29000)
filtered = gisaid_utils.filter_problematic(
    aligned, vcf_file=vcf_file, cutoff=0.001, callback=cb.callback)
by_lineage = gisaid_utils.sort_by_lineage(filtered, callback=cb.callback)

with open("iss512.json", 'w') as outfile:
    json.dump(by_lineage, outfile)
ArtPoon commented 6 months ago

Screenshot from 2024-02-22 14-01-45 Reproduced the tree. Looks like this is not a backend problem.

GopiGugan commented 6 months ago

Reproduced the tree. Looks like this is not a backend problem.

I'll take a look at the front end

GopiGugan commented 5 months ago

I believe the issue is that we aren't scaling the nwk tree itself. Branch lengths are being assigned with the values in the nwk file:

https://github.com/PoonLab/covizu/blob/10a40174019acf76ce417631a495dcba83da4908/server/phylo.js#L59-L71

ArtPoon commented 5 months ago

I believe the issue is that we aren't scaling the nwk tree itself. Branch lengths are being assigned with the values in the nwk file:

I don't think this is the problem, the branch lengths in this tree are scaled in units of time (years), which is what we want to display. I think the problem is that we are not calculating the maximum tip to root distance in this tree correctly, which would be needed to scale to the horizontal dimension of this panel.

ArtPoon commented 5 months ago

I suspect the problem is somewhere here: https://github.com/PoonLab/covizu/blob/10a40174019acf76ce417631a495dcba83da4908/js/drawtree.js#L122-L138

ArtPoon commented 5 months ago

More problems:

GopiGugan commented 5 months ago

I suspect the problem is somewhere here:

https://github.com/PoonLab/covizu/blob/10a40174019acf76ce417631a495dcba83da4908/js/drawtree.js#L122-L138

Yes, it looks like this was the issue. The domain was not set correctly. Working on a fix for this

GopiGugan commented 5 months ago
  • The box for a given lineage has incorrect horizontal coordinates relative to the timetree axis.

image

In this case the tree is being drawn correctly, however the earliest collection date that we have is in 2020-11-14. This is the earliest collection date for variants that are being displayed

ArtPoon commented 5 months ago

An easy fix would be to change the label in the tooltip to read "Collection dates (displayed):", which would imply that we are showing the range of collection dates for the subset of variants in the beadplot.