Type: Package
Title: Process and Visualize Evolve & Resequence Experiments
Version: 1.0.0
Date: 2025-07-29
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.
URL: https://github.com/csoeder/PopPsiSeq, https://github.com/csoeder/PopPsiSeqR
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.2
Imports: rtracklayer, GenomicRanges, ggplot2, dplyr, S4Vectors, magrittr, ggbio, withr, utils, patchwork, tidyr, rlang, devtools
Suggests: knitr, rmarkdown, testthat (≥ 3.0.0)
VignetteBuilder: knitr
Config/testthat/edition: 3
BugReports: https://github.com/csoeder/PopPsiSeqR/issues
NeedsCompilation: no
Packaged: 2025-08-18 14:01:53 UTC; csoeder
Author: Charles Soeder [aut, cre, cph]
Maintainer: Charles Soeder <csoeder@email.unc.edu>
Repository: CRAN
Date/Publication: 2025-08-20 17:40:06 UTC

PopPsiSeqR: 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.

Author(s)

Maintainer: Charles Soeder csoeder@email.unc.edu [copyright holder]

See Also

Useful links:


Pipe operator

Description

See magrittr::%>% for details.

Usage

lhs %>% rhs

Arguments

lhs

A value or the magrittr placeholder.

rhs

A function call using the magrittr semantics.

Value

The result of calling 'rhs(lhs)'.


Save the shifted frequencies

Description

Save the shifted frequencies

Usage

export.freqshft(frequency_shifts, output_file)

Arguments

frequency_shifts

table of allele frequency shifts, as output by freqShifter()

output_file

path to savefile

Value

nothing

Examples


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())


Frequency Shift Calculator

Description

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.

Usage

freqShifter(freqbed_in)

Arguments

freqbed_in

in goes the file containing the grouped frequency measurements (extended bed format)

Value

per-site PopPsiSeq frequency shifts

polarization of alleles

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.

putting the offspring in context

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)

Examples


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)


Load Merged Allele Frequency Table

Description

This function accepts as input a path to a BED file containing allele frequency and returns a GRanges object ready for the freqShifter function.

Usage

import.freqtbl(freqtbl_filename)

Arguments

freqtbl_filename

file containing the allele frequencies as an extended BED6+ file

Value

frequency table as bedgraph

input format

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

Examples


merged_frequencies.filename <- system.file("extdata",
"merged_frequencies.example_data.tbl", package = "PopPsiSeqR")
frequencies.bg <- import.freqtbl(merged_frequencies.filename)


Load Smoothed Frequency Shift

Description

Load Smoothed Frequency Shift

Usage

import.smvshift(filename, selected_parent = "sim", backcrossed_parent = "sec")

Arguments

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)

Value

loaded data as a bedgraph

Examples


windowed_shifts.filename <- system.file("extdata",
"windowed_shifts.example_data.bed", package = "PopPsiSeqR")
windowed_shifts.bg <- import.smvshift(windowed_shifts.filename)


Subtractor

Description

Subtractor

Usage

subTractor(
  data_one,
  data_two,
  treament_name = "pseudoparent",
  field = "avg_simward_AFshift",
  hoarder = FALSE
)

Arguments

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

Value

GRanges of the difference

Examples

 lab_sechellia.filename <- system.file("extdata",
"wild_sechellia.example_data.bed", package = "PopPsiSeqR")
lab.bg <- import.smvshift(lab_sechellia.filename)
lab.bg$sechellia <- "lab"
wild_sechellia.filename <- system.file("extdata",
"lab_sechellia.example_data.bed", package = "PopPsiSeqR")
wild.bg <- import.smvshift(wild_sechellia.filename)
wild.bg$sechellia <- "wild"
sub.traction <- subTractor(lab.bg, wild.bg ,treament_name = "sechellia")


Data displayer

Description

Data displayer

Usage

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()
)

Arguments

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

Value

a ggbio plot object

Examples


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)