Learn R Programming

SeqVarTools (version 1.10.0)

applyMethod: Apply method to GDS object

Description

Apply a method to a subset of variants and/or samples in a GDS object

Usage

"applyMethod"(gdsobj, FUN, variant, sample=NULL, ...) "applyMethod"(gdsobj, FUN, variant, sample=NULL, ...) "applyMethod"(gdsobj, FUN, variant, sample=NULL, ...) "applyMethod"(gdsobj, FUN, variant, sample=NULL, ...)

Arguments

gdsobj
A SeqVarGDSClass object with VCF data.
FUN
A method or function to be applied to gdsobj.
variant
A vector of variant.id values or a GRanges object defining the variants to be included in the call to FUN.
sample
A vector of sample.id values defining the samples to be included in the call to FUN.
...
Additional arguments, passed to FUN.

Value

The result of the call to FUN.

Details

applyMethod applies a method or function FUN to the subset of variants defined by variant and samples defined by sample in a GDS object.

If a filter was previously set with seqSetFilter, it will be saved and reset after the call to applyMethod.

See Also

SeqVarGDSClass

Examples

Run this code
gds <- seqOpen(seqExampleFileName("gds"))
variant.id <- seqGetData(gds, "variant.id")
sample.id <- seqGetData(gds, "sample.id")
applyMethod(gds, getGenotype, variant.id[1:5], sample.id[1:10])

library(GenomicRanges)
chrom <- seqGetData(gds, "chromosome")
pos22 <- seqGetData(gds, "position")[chrom == 22]
ranges <- GRanges(seqnames="22", IRanges(min(pos22), max(pos22)))
applyMethod(gds, heterozygosity, ranges, margin="by.sample")
applyMethod(gds, heterozygosity, ranges, margin="by.variant")

seqClose(gds)

Run the code above in your browser using DataLab