vcfapply2: Apply a function to each SNP in a vcf file

Description Usage Arguments Value See Also Examples

View source: R/apply.R

Description

A routine that reads in the SNP data serially from a vcf file and applies a user specified function to the data for the selected SNPs.

Usage

1
vcfapply2(vcfinfo, func, snps, blksz, ...)

Arguments

vcfinfo

List with information about the vcf file returned from getvcfinfo

func

A user supplied function to apply to the data for each snp. The function must be provide with the following parameters, dosage, p0, p1, and p2, where dosage is the dosage values for each subject and p0, p1, and p2 are the probabilities that a subject has zero, one, and two copies of the alternate allele, respectively.

snps

List of SNPs to perform the function on. Null value indicates to perform function all all SNPs. Default NULL.

blksz

Number of lines to read in on each iteration. A larger number uses more memory but can reduce run time. Maximum value 1000. Default 100.

...

Additional parameters needed by the user supplied function

Value

A list with length equal to the number of SNPs in the vcf file. Each element of the list is the value returned by the user supplied function

See Also

Other Iterating functions: bdapply2()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Get information about a vcf file

vcf1afile <- system.file("extdata", "set1a.vcf", package = "BinaryDosage")
vcfinfo <- getvcfinfo(vcffiles = vcf1afile)

# Apply the getaaf, get alternate allele frequency, function
# to all the SNPs in the vcf file

aaf <- vcfapply2(vcfinfo = vcfinfo,
                 func = BinaryDosage:::getaaf)

USCbiostats/LinGxEScanR documentation built on Feb. 24, 2022, 12:43 p.m.