Skip to content

Commit

Permalink
Revision lowpass main - 2 (#124)
Browse files Browse the repository at this point in the history
* Update URL to LowPass in dadi readthedocs

* Update code strings

* Update LowPass readme text
  • Loading branch information
tjstruck authored Nov 21, 2024
1 parent ec18455 commit 969ddec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
37 changes: 20 additions & 17 deletions docs/userguide/lowpass.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
# dadi.LowPass Integration

dadi-cli can utilize the LowPass module of dadi (url). This enables the ability to correct models based on the coverage each sample has.
dadi-cli can utilize the [Low-Pass module of dadi](https://dadi.readthedocs.io/en/latest/user-guide/low-pass/). This enables the ability to correct models based on the coverage each sample has.

## GenerateFs Input

Before you use LowPass you'll want to make sure your VCF has the allele depth (AD) entry.
Before you use Low-Pass you'll want to make sure your VCF has the allele depth (AD) entry.
<pre>
FORMAT
GT:<b>AD</b>:DP:GQ:PL
</pre>
The information from the AD entry is used for generating a Demographic model. Users can save the information in a pickled dictionary when running `GenerateFs` with the `--calc-coverage`:
<pre>
The information from the AD entry is used when generating a demographic model. Users can save the information in a pickled dictionary when running `GenerateFs` with the `--calc-coverage`:
<code><pre>
# Generate synonymous SFS
dadi-cli GenerateFs --vcf examples/data/mus.syn.subset.vcf.gz --pop-info examples/data/mouse.popfile.txt --pop-ids Mmd_IRA Mmd_FRA --projections 4 8 --polarized --output examples/results/lowpass/mus.syn.fs <b>--calc-coverage</b>

# Generate nonsynonymous SFS
dadi-cli GenerateFs --vcf examples/data/mus.nonsyn.subset.vcf.gz --pop-info examples/data/mouse.popfile.txt --pop-ids Mmd_IRA Mmd_FRA --projections 4 8 --polarized --output examples/results/lowpass/mus.nonsyn.fs <b>--calc-coverage</b>
</pre>
In addition to the `mus.syn.fs` and `mus.nonsyn.fs` SFS files, `mus.syn.fs.coverage.pickle` and `mus.nonsyn.fs.coverage.pickle` are generated. These files will be used for `InferDM` and `InferDFE` to preform the LowPass model correction.
</code></pre>
In addition to the `mus.syn.fs` and `mus.nonsyn.fs` SFS files, `mus.syn.fs.coverage.pickle` and `mus.nonsyn.fs.coverage.pickle` are generated. These files will be used for `InferDM` and `InferDFE` to preform the Low-Pass model correction.

## InferDM with LowPass
## InferDM with Low-Pass

LowPass will correct the demographic and DFE models based on the coverage of samples, to use it users will need to use the `--coverage-model` flag, which `--coverage-model` takes the `.coverage.pickle` file and total number of haplotypes in the data for each population. There were 10 Mmd_IRA samples and 16 Mmd_FRA samples being requested from the `--pop-info` file from `GenerateFs`.
<pre>
dadi-cli InferDM --fs examples/results/lowpass/mus.syn.fs --model split_mig --p0 4.5 0.8 0.8 0.36 0.01 --lbounds 1e-5 1e-5 1e-5 1e-5 1e-5 --ubounds 10 10 1 10 1 --output-prefix examples/results/lowpass/mus.split_mig.lowpass --optimizations 20 --check-convergence 5 --grids 50 60 70 <b>--coverage-model examples/results/lowpass/mus.syn.fs.coverage.pickle 10 16<b>
</pre>
Low-Pass will correct the demographic and DFE models based on the coverage of samples, to use it users will need to use the `--coverage-model` flag, which takes the `.coverage.pickle` file and total number of haplotypes in the data for each population. There were 10 Mmd_IRA samples and 16 Mmd_FRA samples being requested from the `--pop-info` file from `GenerateFs`. So, to add the correction to the demographic mode, users would include `--coverage-model examples/results/lowpass/mus.syn.fs.coverage.pickle 10 16` in their `InferDM` command.
<code><pre>
dadi-cli InferDM --fs examples/results/lowpass/mus.syn.fs --model split_mig --p0 4.5 0.8 0.8 0.36 0.01 --lbounds 1e-5 1e-5 1e-5 1e-5 1e-5 --ubounds 10 10 1 10 1 --output-prefix examples/results/lowpass/mus.split_mig.lowpass --optimizations 20 --check-convergence 5 --grids 50 60 70 <b>--coverage-model examples/results/lowpass/mus.syn.fs.coverage.pickle 10 16</b>
</code></pre>

There are no extra parameters for the LowPass model correction, so results can look similar to non-LowPass corrected results.
There are no extra parameters for the Low-Pass model correction, so results can look similar to non-Low-Pass corrected results.

## InferDFE with LowPass
## InferDFE with Low-Pass

InferDFE is largely the same as InferDM. When users run `GenerateCache`, user's will want to use the number of haplotypes in the data for `--sample-sizes` instead of the sample sizes in the SFS file. Given that there were 10 Mmd_IRA samples and 16 Mmd_FRA haplotypes users would use `--sample-sizes 10 16` instead of `--sample-sizes 4 8`:
<pre>
<code><pre>
dadi-cli GenerateCache --model split_mig_sel_single_gamma <b>--sample-sizes 10 16</b> --grids 50 60 70 --gamma-pts 20 --gamma-bounds 1e-4 100 --demo-popt examples/results/lowpass/mus.split_mig.lowpass.InferDM.bestfits --output examples/results/lowpass/mus.1d.cache
</pre>
</code></pre>

When users run InferDFE they should use the `--coverage-model` flag with the similar inputs as `InferDM`, except using the `.coverage.pickle` file for the nonsynonymous data.
<pre>
<code><pre>
dadi-cli InferDFE --fs examples/results/lowpass/mus.nonsyn.fs --demo-popt examples/results/lowpass/mus.split_mig.lowpass.InferDM.bestfits --cache1d examples/results/lowpass/mus.1d.cache --pdf1d lognormal --ratio 2.31 --p0 1 1 0.01 --lbounds 1e-5 1e-5 1e-5 --ubounds 30 10 1 --optimizations 20 --check-convergence 5 --output-prefix examples/results/lowpass/mus.lognormal.lowpass <b>--coverage-model examples/results/lowpass/mus.nonsyn.fs.coverage.pickle 10 16</b>
</pre>
</code></pre>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "dadi-cli"
version = "0.9.8"
version = "0.9.9"
requires-python = ">=3.9"
description = "A command line interface for dadi"
readme = "README.md"
Expand Down

0 comments on commit 969ddec

Please # to comment.