Calculate within-host Fws from a VCF via moimix
Source:R/calculate_fws_from_vcf.R
calculate_fws_from_vcf.RdConverts the VCF to GDS with SeqArray when the GDS is missing, older
than the VCF, or overwrite is TRUE, then runs moimix::getFws().
The VCF must carry per-sample allelic depths (FORMAT/AD).
Usage
calculate_fws_from_vcf(
vcf,
output = "fws_result.tsv",
gds = NULL,
population_name = NULL,
overwrite = FALSE,
verbose = FALSE
)Arguments
- vcf
Input VCF path. See Inputs.
- output
Output TSV path. Defaults to
"fws_result.tsv".- gds
Optional GDS path. If
NULL, derived from the VCF path.- population_name
Optional population label added as a column.
- overwrite
If
TRUE, rebuild the GDS even when it is up to date.- verbose
If
TRUE, print progress messages.
Details
Multi-allelic sites
moimix::getFws() is biallelic-only and does not check: on a record with
more than one ALT it reads only the first two AD columns while dividing by
the depth over all of them, and its MAF becomes the rarest allele's
frequency, so function filters to biallelic only before passing to moimix::getFws()
Outputs
output: Fws TSV with columnsspecimen_name,fws, and optionallypopulation_name. Defaults to"fws_result.tsv".gds(optional): GDS path used/created beside the VCF. IfNULL, derived by replacing.vcf/.vcf.gzwith.gds.
Running
calculate_fws_from_vcf(
vcf = "calls.vcf.gz",
output = "fws_result.tsv"
)Requires moimix and SeqArray (Suggests). moimix is installed from
GitHub (bahlolab/moimix), not CRAN.