Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subsampling command with YAML config, basic weighted sampling #1444

Closed
wants to merge 18 commits into from

Conversation

victorlin
Copy link
Member

This builds on @jameshadfield's initial prototype. PR is largely incomplete, but I've been working on this for a while and want to open for discussion on where to take things next.

A summary in the form of Q&A:

Q: Why add this command when augur filter already has sampling capabilities?

A subsampling-specific command is meant to extend beyond the current capabilities of augur filter with a more intuitive config interface (YAML file instead of command line arguments). We and other users have hit this limitation on most pathogen workflows - the new command aims to replace the subsampling baked within the Snakemake logic of those workflows.

Q: What do you mean by basic weighted sampling?

Basic weighted sampling allows defining a top-level sample size and a list of intermediate samples with weights on how to distribute the sample size. It is inspired by the ncov workflow's subsampling schemes each having a target total size and intermediate sample weights (but only intermediate sample sizes can be encoded in the config schema).

This is maybe the simplest new feature that is enabled by the shift to a YAML config.

Q: What is an intermediate sample?

With the PR's implementation, it is an augur filter call much like how existing pathogen workflows make multiple augur filter calls and combine them using a final call.

Q: What should I review in this PR?

Mostly looking for feedback on whether the config schema is intuitive, and if it seems flexible enough to future directions.

The PR's implementation is a bit hacky and leaves much to be desired (see "not in PR scope" section), but the shift to using YAML config should broaden the possibilities.

Q: What does the YAML config schema look like in practice?

See YAML configs from nextstrain/ncov#1102. There, I've tested that this new command can replace ncov's complex subsampling logic, so it should be straightforward to do the same in other pathogen workflows.

Not in PR scope

  1. Exposing subsampling functions from augur filter to be called directly instead of through a subprocess. Once this is done, we should shift all subsampling-related development to this new command and only keep the subsampling-related options in augur filter around for backwards compatibility.
  2. Allowing priorities with filters. This should be achievable with the existing implementation by creating a filter-only sample (no limit on # of sequences) passed into a priorities sample, and excluding the filter-only sample from output.
  3. Weighted sampling within a sample. This is where data such as case count TSVs can be used for weighting.
  4. Recursive sample definitions. We explored this a bit in the subsampling doc. Seems to be the only way to decouple the weight interaction between partitions of data (e.g. 4:1 local:global x 4:1 recent:early)

Links

jameshadfield and others added 18 commits February 25, 2024 11:37
Lots of TODOs and nothing is actually _run_, but the config parsing
and general structure is working
Priorities not working
For subsampling purposes we want to take the n closest strains _per
focal sequence_, rather than computing the smallest hamming distance for
each sample against any of the focal seqs.
Useful for reproducibility in tests.
There is a related TODO there.
Benefits:

1. Improves distinction between samples and outputs.
2. Removes the need to restrict a sample from being named "outputs".
3. Makes it easier to add future subsampling options such as total size.
A logfile would be inaccessible if it lives under a temporary directory.

As an alternative, the temporary directory could be kept around, but I
don't think we want to complicate existing workflows by having another
layer of log files one level lower than Snakemake's.
Global --include/--exclude are necessary to support ncov's
config.files.include/exclude
@victorlin victorlin mentioned this pull request Apr 30, 2024
12 tasks
@victorlin
Copy link
Member Author

Update: putting this on hold while weighted sampling is being implemented within augur filter (#1454).

@victorlin victorlin closed this May 23, 2024
@victorlin victorlin self-assigned this May 23, 2024
@victorlin victorlin added the revisit sometime Useful to address but no bandwidth at the moment label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
revisit sometime Useful to address but no bandwidth at the moment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants