| Title: | Process and Visualize Evolve & Resequence Experiments |
|---|---|
| Description: | Handle data from evolve and resequence experiments. Measured allele frequencies (e.g., from variants called from high-throughput sequencing data) are compared using an update of the PsiSeq algorithm (Earley, Eric and Corbin Jones (2011) <doi:10.1534/genetics.111.129445>). Functions for saving and loading important files are also included, as well as functions for basic data visualization. |
| Authors: | Charles Soeder [aut, cre, cph] |
| Maintainer: | Charles Soeder <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-13 06:48:05 UTC |
| Source: | https://github.com/csoeder/poppsiseqr |
Save the shifted frequencies
export.freqshft(frequency_shifts, output_file)export.freqshft(frequency_shifts, output_file)
frequency_shifts |
table of allele frequency shifts, as output by freqShifter() |
output_file |
path to savefile |
nothing
merged_frequencies.filename <- system.file("extdata", "merged_frequencies.example_data.tbl", package = "PopPsiSeqR") frequencies.bg <- import.freqtbl(merged_frequencies.filename) frequency_shifts.bg <- freqShifter(frequencies.bg) export.freqshft(frequency_shifts.bg , tempfile())merged_frequencies.filename <- system.file("extdata", "merged_frequencies.example_data.tbl", package = "PopPsiSeqR") frequencies.bg <- import.freqtbl(merged_frequencies.filename) frequency_shifts.bg <- freqShifter(frequencies.bg) export.freqshft(frequency_shifts.bg , tempfile())
This function accepts a GRanges object containing allele frequencies from two parental populations and an offspring population. It then polarizes each variant site and calculates how the offspring has shifted from equilibrium.
freqShifter(freqbed_in)freqShifter(freqbed_in)
freqbed_in |
in goes the file containing the grouped frequency measurements (extended bed format) |
per-site PopPsiSeq frequency shifts
At each variant site, either the selected parent or the backcrossed parent might have the alternate allele at a higher frequency than the other (sites in which they have the same allele frequency are not informative and are assumed to have been filtered out). To regularize the data, each site was independently polarized, which is to say, the alternate and reference alleles were reassigned ad hoc to make the selected parent population have the higher frequency.
At each site, the offspring's allele frequency is compared to the hypothetical equilibrium frequency expected by simply averaging the parents' frequencies. This is reported as the mean_oriented_shift; also reported is the distance to fixation in each direction (max_oriented_shift, min_oriented_shift), and the difference between parental allele frequencies (AF_difference)
merged_frequencies.filename <- system.file("extdata", "merged_frequencies.example_data.tbl", package = "PopPsiSeqR") frequencies.bg <- import.freqtbl(merged_frequencies.filename) frequency_shifts.bg <- freqShifter(frequencies.bg)merged_frequencies.filename <- system.file("extdata", "merged_frequencies.example_data.tbl", package = "PopPsiSeqR") frequencies.bg <- import.freqtbl(merged_frequencies.filename) frequency_shifts.bg <- freqShifter(frequencies.bg)
This function accepts as input a path to a BED file containing allele frequency and returns a GRanges object ready for the freqShifter function.
import.freqtbl(freqtbl_filename)import.freqtbl(freqtbl_filename)
freqtbl_filename |
file containing the allele frequencies as an extended BED6+ file |
frequency table as bedgraph
This function accepts as input a path to a file in an extended BED6+ format; specifically,
'chrom start end name score strand reference_allele alternate_allele selected_parent_count selected_parent_allele_frequency backcrossed_parent_count backcrossed_parent_allele_frequency offspring_count offspring_allele_frequency'
eg,
'chr2L 8517 8518 0 0 + G A 8 0 16 0.25 8 0.25'
Some of these fields (name, score, strand, reference_allele, alternate_allele, selected_parent_count, backcrossed_parent_count, offspring_count) are required as placeholders but not used in the current PopPsiSeq algorithm This format is the output of joining and filtering the output of vcftools' –freq output; see vignette for details
merged_frequencies.filename <- system.file("extdata", "merged_frequencies.example_data.tbl", package = "PopPsiSeqR") frequencies.bg <- import.freqtbl(merged_frequencies.filename)merged_frequencies.filename <- system.file("extdata", "merged_frequencies.example_data.tbl", package = "PopPsiSeqR") frequencies.bg <- import.freqtbl(merged_frequencies.filename)
Load Smoothed Frequency Shift
import.smvshift(filename, selected_parent = "sim", backcrossed_parent = "sec")import.smvshift(filename, selected_parent = "sim", backcrossed_parent = "sec")
filename |
file containing the allele frequencies as an extended BED6+ file; see vignette for formatting |
selected_parent |
name of the First Parent (that which is Selected for) |
backcrossed_parent |
name of the Second Parent (that which is Backcrossed to) |
loaded data as a bedgraph
windowed_shifts.filename <- system.file("extdata", "windowed_shifts.example_data.bed", package = "PopPsiSeqR") windowed_shifts.bg <- import.smvshift(windowed_shifts.filename)windowed_shifts.filename <- system.file("extdata", "windowed_shifts.example_data.bed", package = "PopPsiSeqR") windowed_shifts.bg <- import.smvshift(windowed_shifts.filename)
Subtractor
subTractor( data_one, data_two, treament_name = "pseudoparent", field = "avg_simward_AFshift", hoarder = FALSE )subTractor( data_one, data_two, treament_name = "pseudoparent", field = "avg_simward_AFshift", hoarder = FALSE )
data_one |
first bedfile |
data_two |
second bedfile |
treament_name |
what column is the independent variable |
field |
what column is the variable being compared |
hoarder |
whether or not to retain the other data |
GRanges of the difference
Data displayer
windowedFrequencyShift.plotter( windowed_shift, selected_parent = "sim", backcrossed_parent = "sec", contigs = c("chr2L", "chr2R", "chr3L", "chr3R"), main_title = "popPsiSeq results", ref_gen = "droSim1", primary_aesthetic = ggplot2::aes(), envelope_aesthetic = ggplot2::aes(), ancestral_aesthetic = ggplot2::aes() )windowedFrequencyShift.plotter( windowed_shift, selected_parent = "sim", backcrossed_parent = "sec", contigs = c("chr2L", "chr2R", "chr3L", "chr3R"), main_title = "popPsiSeq results", ref_gen = "droSim1", primary_aesthetic = ggplot2::aes(), envelope_aesthetic = ggplot2::aes(), ancestral_aesthetic = ggplot2::aes() )
windowed_shift |
GRanges containing windowed data (as loaded by import.smvshft) |
selected_parent |
Name of the selected-for population |
backcrossed_parent |
Name of the backcrossed-too population |
contigs |
What contigs to display |
main_title |
What to call the plot |
ref_gen |
Name of the reference genome |
primary_aesthetic |
Primary aesthetic |
envelope_aesthetic |
envelope aesthetic |
ancestral_aesthetic |
ancestral aesthetic |
a ggbio plot object
windowed_shifts.filename <- system.file("extdata", "windowed_shifts.example_data.bed", package = "PopPsiSeqR") windowed_shifts.bg <- import.smvshift(windowed_shifts.filename) windowedFrequencyShift.plotter(windowed_shifts.bg)windowed_shifts.filename <- system.file("extdata", "windowed_shifts.example_data.bed", package = "PopPsiSeqR") windowed_shifts.bg <- import.smvshift(windowed_shifts.filename) windowedFrequencyShift.plotter(windowed_shifts.bg)