Estimate multilocus prevalence and frequency with variantstring
Source:R/multilocus_prevfreq_naive_variantstring.R
multilocus_prevfreq_naive_variantstring.RdConverts amino acid calls to variant strings, extracts unambiguous component genotypes, and estimates prevalence and frequency of each component against the full dataset.
Details
Inputs
aa_calls: AA calls (specimen_name,gene_id,aa_position,reads,aa). Seevignette("input-formats", package = "PGEcore").loci_groups: Loci groups (group_id,gene_id,aa_position). See the same vignette.
Outputs
output(optional): Prev/freq TSV with columnsgroup_id,variant,prev,freq, andsample_total. IfNULL, results are returned without writing.
Running
multilocus_prevfreq_naive_variantstring(
aa_calls = "aa_calls.tsv",
loci_groups = "loci_groups.tsv",
output = "multilocus_prevfreq.tsv"
)Rscript exec/multilocus_prevfreq_naive_variantstring \
--aa_calls aa_calls.tsv \
--loci_groups loci_groups.tsv \
--output multilocus_prevfreq.tsvRequires the optional variantstring package (Suggests). It is not installed automatically with PGEcore.
Examples
aa_path <- system.file(
"extdata", "example_aa_calls.tsv",
package = "PGEcore"
)
groups_path <- system.file(
"extdata", "example_loci_groups.tsv",
package = "PGEcore"
)
multilocus_prevfreq_naive_variantstring(aa_path, groups_path)
#> # A tibble: 12 × 5
#> group_id variant prev freq sample_total
#> <chr> <chr> <dbl> <dbl> <int>
#> 1 pfdhfr_pfdhps PF3D7_0417200.1:51_59_108:N_R_N;PF3D… 0.333 0.333 3
#> 2 pfdhfr_pfdhps PF3D7_0417200.1:51_59_108:N_C_S;PF3D… 0.333 0.267 3
#> 3 pfdhfr_pfdhps PF3D7_0417200.1:51_59_108:N_R_S;PF3D… 0.333 0.0667 3
#> 4 pfdhfr PF3D7_0417200.1:51_59_108:N_R_N 0.333 0.333 3
#> 5 pfdhfr PF3D7_0417200.1:51_59_108:N_C_S 0.333 0.267 3
#> 6 pfdhfr PF3D7_0417200.1:51_59_108:N_R_S 0.333 0.0667 3
#> 7 pfdhfr PF3D7_0417200.1:51_59_108:I_C_S 0.333 0.133 3
#> 8 pfdhfr PF3D7_0417200.1:51_59_108:I_R_S 0.333 0.2 3
#> 9 pfdhps PF3D7_0810800.1:437_540:A_E 0.333 0.333 3
#> 10 pfdhps PF3D7_0810800.1:437_540:G_E 0.333 0.333 3
#> 11 pfdhps PF3D7_0810800.1:437_540:A_K 0.333 0.0667 3
#> 12 pfdhps PF3D7_0810800.1:437_540:G_K 0.333 0.267 3