-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pre-filter the inputs to the 21L-rooted builds with a custom rule
Filter rules in the config are applied _after_ subsampling, which poses issues with reliably getting the desired number of sequences. As @trvrb wrote¹: > In the workflow, the filter rule happens after the subsampling rules. > This makes it so that if we ask for say 2560 in a sampling bucket, we'll > lose >50% due to filtering out non-21L-descending clades. > > This could be solved by padding count targets to compensate, but this is > hacky and the numbers will change as time goes on. Or the filter rule > could be placed again before subsample, but we moved it afterwards for > good reasons. A few custom rules for the builds allows us to prefilter the full dataset before subsampling. Currently these rules are specific to our GISAID data source, but they could be easily expanded to our Open data sources too. In the future we might also provide clade-partitioned subsets from ncov-ingest², which we could use here instead with some adaptation of the build config. ¹ <#1029 (comment)> ² e.g. <nextstrain/ncov-ingest#398>
- Loading branch information
Showing
3 changed files
with
98 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
nextstrain_profiles/nextstrain-gisaid-21L/exclude-clades.tsv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
clade | ||
19A | ||
19B | ||
20A | ||
20B | ||
20C | ||
20D | ||
20E (EU1) | ||
20F | ||
20G | ||
20H (Beta, V2) | ||
20I (Alpha, V1) | ||
20J (Gamma, V3) | ||
21A (Delta) | ||
21B (Kappa) | ||
21C (Epsilon) | ||
21D (Eta) | ||
21E (Theta) | ||
21F (Iota) | ||
21G (Lambda) | ||
21H (Mu) | ||
21I (Delta) | ||
21J (Delta) | ||
21K (Omicron) | ||
21M (Omicron) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
rule gisaid_21L_metadata: | ||
input: | ||
metadata = path_or_url("s3://nextstrain-ncov-private/metadata.tsv.zst", keep_local=True), | ||
exclude_clades = "nextstrain_profiles/nextstrain-gisaid-21L/exclude-clades.tsv", | ||
output: | ||
metadata = "results/gisaid_21L_metadata.tsv.zst", | ||
log: "logs/gisaid_21L_metadata.txt" | ||
benchmark: "benchmarks/gisaid_21L_metadata.txt" | ||
conda: config["conda_environment"] | ||
threads: 8 | ||
shell: | ||
r""" | ||
exec 2> {log:q} | ||
< {input.metadata:q} \ | ||
unzstd \ | ||
| tsv-join \ | ||
--header \ | ||
--exclude \ | ||
--filter-file {input.exclude_clades:q} \ | ||
--key-fields clade \ | ||
--data-fields Nextstrain_clade \ | ||
| zstd -T$(({threads} - 2)) \ | ||
> {output.metadata:q} | ||
""" | ||
|
||
|
||
rule gisaid_21L_strains: | ||
input: | ||
metadata = "results/gisaid_21L_metadata.tsv.zst", | ||
output: | ||
strains = "results/gisaid_21L_strains.txt", | ||
log: "logs/gisaid_21L_strains.txt" | ||
benchmark: "benchmarks/gisaid_21L_strains.txt" | ||
conda: config["conda_environment"] | ||
shell: | ||
r""" | ||
exec 2> {log:q} | ||
< {input.metadata:q} \ | ||
unzstd \ | ||
| tsv-select --header -f strain \ | ||
| sed 1d \ | ||
> {output.strains:q} | ||
""" | ||
|
||
|
||
rule gisaid_21L_aligned: | ||
input: | ||
aligned = path_or_url("s3://nextstrain-ncov-private/aligned.fasta.zst", keep_local=True), | ||
strains = "results/gisaid_21L_strains.txt", | ||
output: | ||
aligned = "results/gisaid_21L_aligned.fasta.zst", | ||
log: "logs/gisaid_21L_aligned.txt" | ||
benchmark: "benchmarks/gisaid_21L_aligned.txt" | ||
conda: config["conda_environment"] | ||
threads: 8 | ||
shell: | ||
r""" | ||
exec 2> {log:q} | ||
< {input.aligned:q} \ | ||
unzstd \ | ||
| seqkit grep --by-name -f {input.strains:q} \ | ||
| zstd -T$(({threads} - 2)) \ | ||
> {output.aligned:q} | ||
""" |