hodcroftlab / covariants

Real-time updates and information about key SARS-CoV-2 variants, plus the scripts that generate this information.
https://covariants.org/
GNU Affero General Public License v3.0
316 stars 111 forks source link

sort coutries alphabetically on case page #317

Closed umaxyon closed 2 years ago

umaxyon commented 2 years ago

issue #315

image

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
covariants ✅ Ready (Inspect) Visit Preview Jun 15, 2022 at 4:42AM (UTC)
emmahodcroft commented 2 years ago

Hi @umaxyon - thanks for this! However, the current way that countries are sorted is based on the number of sequences, which provides a nice top-to-bottom gradient of (generally) how confident we can be in the patterns we see. I would be happy to have an option to change this sorting to alphabetical, but it should be a button or slider on the web-page that allows this view to change depending on what the user wants to see (either by sequence count or alphabetically). I'd be happy to integrate something like this, if that's something you're able to do!

umaxyon commented 2 years ago

Hi @emmahodcroft 😃 I gave up because I did not know the original sort order criteria. It is neither the number of "distribution" arrays nor the sum of "total_sequences", but a subtle difference.

USA            :     distribution size: 55: sum totla_sequence: 3168562
United Kingdom :     distribution size: 55: sum totla_sequence: 2637606
Germany        :     distribution size: 54: sum totla_sequence: 632128
Denmark        :     distribution size: 55: sum totla_sequence: 509391
France         :     distribution size: 55: sum totla_sequence: 285611
Canada         :     distribution size: 55: sum totla_sequence: 316619  <-- ? 
Japan          :     distribution size: 55: sum totla_sequence: 298010
Sweden         :     distribution size: 54: sum totla_sequence: 186642
Switzerland    :     distribution size: 55: sum totla_sequence: 129169
...

I used the following debugging code

// CasesPage.tsx  line 41
  withClustersFiltered.forEach(d => {
    const total = d.distribution.map(d => d.total_sequences).reduce((a, b) => a + b, 0);
    console.log(`${d.country.padEnd(15, ' ')}:\t distribution size: ${d.distribution.length}:\tsum totla_sequence: ${total}`)
  });

sorry. good luck!

emmahodcroft commented 2 years ago

Hmm, that's interesting. I'll have to double-check how this is calculated. In fairness, I think I may 'steal' the order from the Per Country page, and it's possible that if we don't have case data to match the same time periods, some sequences are 'excluded' and thus the counts don't technically match. But I'll try to look into this!