Tip frequencies loading error

I’m getting the error “Failed to fetch frequencies” when I run the nextstrain server. I have a _tip-frequencies.json file in the same folder as the main JSON file and can see that the server logs are catching the file. Upon opening the console logs in Inspect mode, I get the error Failed to fetch frequencies e.values is undefined. How can I debug this error?

Hi @syaffers – it looks like auspice is unable to parse the tip-frequencies file. While we don’t have a schema for that file type, you could try comparing your file contetnts to a file which is working, such as influenza / seasonal / yam / na / 2y.

If that’s not helpful, you can run auspice develop ... instead of auspice view ... which should give you a more helpful error message in the console which may help us debug further.

Ah, I think I see the issue. My _tip-frequencies file contain the key global instead of frequencies as in the examples that you showed. This is generated through the following Snakefile rule:

rule frequencies:
    message: "Generating frequencies plot"
    input:
        tree = rules.refine.output.tree,
        metadata = input_metadata
    params:
        method = "diffusion",
        stiffness = 3.0,
        min_date = "2020-03-01",
        max_date = "2021-02-14",
        pivot_interval = 1,
        pivot_interval_units = "weeks"
    output:
        frequencies = "auspice/qc10Feb_blastMar3_k30_mm15_tip-frequencies.json"
    shell:
        """
        augur frequencies \
            --tree {input.tree} \
            --metadata {input.metadata} \
            --method {params.method}  \
            --stiffness {params.stiffness}  \
            --max-date {params.max_date}  \
            --min-date {params.min_date}  \
            --pivot-interval {params.pivot_interval} \
            --pivot-interval-units {params.pivot_interval_units} \
            --output {output.frequencies}
        """

Is this the correct way to generate the frequencies panel?

That looks similar to the rule we use for ncov, but i’ll tag @jlhudd as he will know more.

1 Like

Changing the method to kde generated the frequencies key in the JSON. Now I can view the frequencies panel in the auspice server. Just for my reference, I’ve got a few questions:

  • Is this the expected way to do it?
  • What the difference between KDE and diffusion?
  • Also, what’s the global key for if we set the method to diffusion?

Hi @syaffers!

Is this the expected way to do it?

Yes, this is the standard way we calculate tip frequencies for most of our pathogen analyses.

What the difference between KDE and diffusion?

The short answer is that KDE estimation uses a “bottom-up” approach assigning frequencies to tips in the tree and summing these to calculate internal node frequencies while diffusion estimation uses a “top-down” approach assigning 100% frequency to the root node of the tree and partitioning this total frequency to calculate internal node frequencies down to the tips.

For an example of how KDE frequencies work, check out our draft guide of how to calculate your own clade frequencies for SARS-CoV-2. We don’t have a similar guide for diffusion frequencies yet.

Also, what’s the global key for if we set the method to diffusion ?

The diffusion frequencies were originally developed to work with an older version of Auspice that expected frequencies to be reported in a different data structure (i.e., grouped by region). These frequencies and the corresponding data structure are still useful when we analyze regional clade frequencies for seasonal influenza, but we don’t use diffusion frequencies as much elsewhere.

1 Like