Exercise 19 of 19
The largest branches below BA.2
BA.2 has many direct sublineages. For each of them, count the sequences that belong to it or to any of its descendants. Return the 10 direct sublineages with the most sequences, highest first.
The output should have this shape:
child | count
------- | -----
BA.2.86 | 1234
BA.2.12 | 987Write a query and run it. The result is compared with the reference answer without considering row order.
Explanation
The lineage table pangoLineage lists every lineage with its parent. Filter it to the children of BA.2 and rename their lineage column. Join them with the transitive closure from parent to lineage, including each lineage itself, to pair every child with all its descendants. Join the descendants with the lineages of the sequences, group by child to count them, order the rows by their counts and keep the first 10.
Reference answer
pangoLineage
.filter(parent = 'BA.2')
.map({child := lineage})
.project({child})
.join(pangoLineage.transitiveClosure(parent, lineage, includeVertices := true), child = from)
.join(data.map({lineageName := pangoLineage}).project({lineageName}), to = lineageName)
.group(by := {child}, aggs := {count := count()})
.order(by := {count.desc()})
.limit(10)