calc.pi: sliding window pi and rho - across all snps

Description Usage Arguments Value Note Examples

View source: R/gwscaR_popgen.R

Description

sliding window pi and rho - across all snps

Usage

1
calc.pi(vcf.row)

Arguments

vcf.row

A row of a vcf file; use this in conjunction with apply

Value

The nucleotide diversity at that site

Note

pi = 1-sum((ni choose 2)/(n choose i)); ni is number of alleles i in sample, n = sum(ni)

Jones et al. (2012) used 2500bp sliding windows with a step size 500bp<-more than just SNPs, but I'll just focus on SNPs

Hohenlohe did a similar thing and weighted pi by all nt sites (not just SNPs) but rho by SNPs only

Examples

1
2
3
vcf.file<-system.file("extdata", "example.vcf.txt",package = "gwscaR")
vcf<-parse.vcf(vcf.file)
all.pi<-apply(vcf,1,calc.pi)

spflanagan/gwscaR documentation built on Nov. 14, 2019, 9:16 p.m.