Title: | What the Package Does (One Line, Title Case) |
---|---|
Description: | What the package does (one paragraph). |
Authors: | First Last [aut, cre] (YOUR-ORCID-ID) |
Maintainer: | First Last <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9000 |
Built: | 2024-11-21 03:04:39 UTC |
Source: | https://github.com/leospeidel/relater |
This function filters out selection pvalues on bad trees using summary statistics on tree quality stored in qual.
filter.allele_ages(allele_ages, qual)
filter.allele_ages(allele_ages, qual)
allele_ages |
data.table. Obtained from get.allele_ages() |
qual |
data.frame. qual file |
Returns a data table.
# get allele ages mut <- read.mut(system.file("extdata/example.mut.gz", package = "relater"), CHR = 1) sele <- read.sele(system.file("extdata/example.sele.gz", package = "relater"), CHR = 1) freq <- read.freq(system.file("extdata/example.freq.gz", package = "relater"), CHR = 1) allele_ages <- get.allele_ages(mut, freq, sele) # read quality file qual <- read.qual(system.file("extdata/example.qual.gz", package = "relater"), CHR = 1) filter.allele_ages(allele_ages, qual)
# get allele ages mut <- read.mut(system.file("extdata/example.mut.gz", package = "relater"), CHR = 1) sele <- read.sele(system.file("extdata/example.sele.gz", package = "relater"), CHR = 1) freq <- read.freq(system.file("extdata/example.freq.gz", package = "relater"), CHR = 1) allele_ages <- get.allele_ages(mut, freq, sele) # read quality file qual <- read.qual(system.file("extdata/example.qual.gz", package = "relater"), CHR = 1) filter.allele_ages(allele_ages, qual)
This function extracts the haplotype matrix from .haps data frames
get_hap_matrix(haps)
get_hap_matrix(haps)
haps |
data.table. |
Returns a matrix.
haps <- read.haps(system.file("extdata/example.haps.gz", package = "relater")) get_hap_matrix(haps)
haps <- read.haps(system.file("extdata/example.haps.gz", package = "relater")) get_hap_matrix(haps)
This function aggregates mut, freq, and sele files inferred by Relate into an allele_ages file.
get.allele_ages(mut, freq, sele)
get.allele_ages(mut, freq, sele)
mut |
data.table. mut file |
freq |
data.frame. freq file |
sele |
data.frame. sele file |
Returns a data table.
mut <- read.mut(system.file("extdata/example.mut.gz", package = "relater"), CHR = 1) sele <- read.sele(system.file("extdata/example.sele.gz", package = "relater"), CHR = 1) freq <- read.freq(system.file("extdata/example.freq.gz", package = "relater"), CHR = 1) get.allele_ages(mut, freq, sele)
mut <- read.mut(system.file("extdata/example.mut.gz", package = "relater"), CHR = 1) sele <- read.sele(system.file("extdata/example.sele.gz", package = "relater"), CHR = 1) freq <- read.freq(system.file("extdata/example.freq.gz", package = "relater"), CHR = 1) get.allele_ages(mut, freq, sele)
Tests for evidence of polygenic selection by matching SNPs by DAF and using a one-sided Wilcoxon rank sum test.
PolyTest(DAFs, pvalues, quantiles, allele_ages_quantiles)
PolyTest(DAFs, pvalues, quantiles, allele_ages_quantiles)
DAFs |
1d array. Derived allele frequencies of trait associations |
pvalues |
1d array. Selection pvalues of trait associations |
quantiles |
data frame. Obtained from PolyTest_Init. |
allele_ages_quantiles |
List of data tables. Obtained from PolyTest_Init. |
Returns a pvalue.
# Example analysis: # read files mut <- read.mut(system.file("extdata/example.mut.gz", package = "relater"), CHR = 1) sele <- read.sele(system.file("extdata/example.sele.gz", package = "relater"), CHR = 1) freq <- read.freq(system.file("extdata/example.freq.gz", package = "relater"), CHR = 1) qual <- read.qual(system.file("extdata/example.qual.gz", package = "relater"), CHR = 1) # Obtain allele_ages data table allele_ages <- get.allele_ages(mut, freq, sele) allele_ages <- filter.allele_ages(allele_ages, qual) ######### Polygenic selection test ######### # Initialise quant <- PolyTest_Init(allele_ages) # Make a fake polygenic trait df <- allele_ages[!is.na(allele_ages$pvalue),] df <- df[sample(1:nrow(df), 50, replace = FALSE),] # Run polygenic test PolyTest(df$DAF, df$pvalue, quant$quantiles, quant$allele_ages_quantiles)
# Example analysis: # read files mut <- read.mut(system.file("extdata/example.mut.gz", package = "relater"), CHR = 1) sele <- read.sele(system.file("extdata/example.sele.gz", package = "relater"), CHR = 1) freq <- read.freq(system.file("extdata/example.freq.gz", package = "relater"), CHR = 1) qual <- read.qual(system.file("extdata/example.qual.gz", package = "relater"), CHR = 1) # Obtain allele_ages data table allele_ages <- get.allele_ages(mut, freq, sele) allele_ages <- filter.allele_ages(allele_ages, qual) ######### Polygenic selection test ######### # Initialise quant <- PolyTest_Init(allele_ages) # Make a fake polygenic trait df <- allele_ages[!is.na(allele_ages$pvalue),] df <- df[sample(1:nrow(df), 50, replace = FALSE),] # Run polygenic test PolyTest(df$DAF, df$pvalue, quant$quantiles, quant$allele_ages_quantiles)
This function initialises the polygenic selection test.
PolyTest_Init(allele_ages)
PolyTest_Init(allele_ages)
allele_ages |
data.table. Obtained from get.allele_ages() |
Returns a list containing a data frame (quantiles) and a list of data tables (allele_ages_quantiles).
## Not run: PolyTest_Init(allele_ages) ## End(Not run)
## Not run: PolyTest_Init(allele_ages) ## End(Not run)
Given DAF, resample 20 selection p-values of SNPs selected uniformly at random with matching DAF
PolyTest_ResampleSNPs(DAF, quantiles, allele_ages_quantiles)
PolyTest_ResampleSNPs(DAF, quantiles, allele_ages_quantiles)
DAF |
int. Derived allele frequency |
quantiles |
data frame. Obtained from PolyTest_Init. |
allele_ages_quantiles |
List of data tables. Obtained from PolyTest_Init. |
Returns a numeric 1x20 matrix.
## Not run: PolyTest_ResampleSNPs(DAF, quantiles, allele_ages_quantiles) ## End(Not run)
## Not run: PolyTest_ResampleSNPs(DAF, quantiles, allele_ages_quantiles) ## End(Not run)
This function parses a *_avg.rate file, which stores average mutation rates inferred by Relate
read.avg_rate(filename)
read.avg_rate(filename)
filename |
string. Filename |
Returns a data frame.
read.avg_rate(system.file("extdata/example_avg.rate.gz", package = "relater"))
read.avg_rate(system.file("extdata/example_avg.rate.gz", package = "relater"))
This function parses a .coal file, which stores coalescence rates inferred by Relate
read.coal(filename)
read.coal(filename)
filename |
string. Filename |
Returns a data frame.
read.coal(system.file("extdata/example.coal.gz", package = "relater"))
read.coal(system.file("extdata/example.coal.gz", package = "relater"))
This function parses a .freq file, which stores frequencies in Relate-inferred genealogies
read.freq(filename, CHR = NA)
read.freq(filename, CHR = NA)
filename |
string. Filename |
CHR |
int. Chromosome index. |
Returns a data frame.
read.freq(system.file("extdata/example.freq.gz", package = "relater"))
read.freq(system.file("extdata/example.freq.gz", package = "relater"))
This function uses fread to parse a .haps file, which is part of the haps/sample output file format of SHAPEIT2.
read.haps(filename, ...)
read.haps(filename, ...)
filename |
string. Filename |
... |
Any other parameters for fread |
Returns a data table.
read.haps(system.file("extdata/example.haps.gz", package = "relater"))
read.haps(system.file("extdata/example.haps.gz", package = "relater"))
This function parses a .lin file, which stores number of lineages remaining in Relate-inferred genealogies
read.lin(filename, CHR = NA)
read.lin(filename, CHR = NA)
filename |
string. Filename |
CHR |
int. Chromosome index. |
Returns a data frame.
read.lin(system.file("extdata/example.lin.gz", package = "relater"))
read.lin(system.file("extdata/example.lin.gz", package = "relater"))
This function uses fread to parse a .mut file, which is part of the anc/mut output file format of SHAPEIT2.
read.mut(filename, CHR = NA, ...)
read.mut(filename, CHR = NA, ...)
filename |
string. Filename |
CHR |
int. Chromosome index. |
... |
Any other parameters for fread |
Returns a data table.
read.mut(system.file("extdata/example.mut.gz", package = "relater"))
read.mut(system.file("extdata/example.mut.gz", package = "relater"))
This function parses a .qual file, which stores summary statistics on the quality of Relate-inferred genealogies
read.qual(filename, CHR = NA)
read.qual(filename, CHR = NA)
filename |
string. Filename |
CHR |
int. Chromosome index. |
Returns a data frame.
read.qual(system.file("extdata/example.qual.gz", package = "relater"))
read.qual(system.file("extdata/example.qual.gz", package = "relater"))
This function uses fread to parse a .sample file, which is part of the haps/sample output file format of SHAPEIT2.
read.sample(filename, ...)
read.sample(filename, ...)
filename |
string. Filename |
... |
Any other parameters for fread |
Returns a data table.
read.sample(system.file("extdata/example.sample.gz", package = "relater"))
read.sample(system.file("extdata/example.sample.gz", package = "relater"))
This function parses a .sele file, which stores selection p-values inferred by Relate
read.sele(filename, CHR = NA)
read.sele(filename, CHR = NA)
filename |
string. Filename |
CHR |
int. Chromosome index. |
Returns a data frame.
read.sele(system.file("extdata/example.sele.gz", package = "relater"))
read.sele(system.file("extdata/example.sele.gz", package = "relater"))
Functions for parsing, writing, manipulating input and output files of Relate
Leo Speidel
Multiply a number by two
timesTwo(x)
timesTwo(x)
x |
A single integer. |
timesTwo(2)
timesTwo(2)