Learn R Programming

SeqArray (version 1.10.1)

seqSetFilter-methods: Set a Filter to Sample or Variant

Description

Sets a filter to sample and/or variant.

Usage

"seqSetFilter"(object, sample.id=NULL, variant.id=NULL, samp.sel=NULL, variant.sel=NULL, action=c("set", "intersect", "push", "push+set", "push+intersect", "pop"), verbose=TRUE)
seqResetFilter(object, sample=TRUE, variant=TRUE, verbose=TRUE)

Arguments

object
sample.id
IDs of selected samples
variant.id
IDs of selected variants
samp.sel
a logical/raw vector indicating the selected samples
variant.sel
a logical/raw vector indicating the selected variants
action
"set" -- set the current filter via sample.id, variant.id, samp.sel or variant.sel; "intersect" -- set the current filter to the intersection of selected samples and/or variants; "push" -- push the current filter to the stack, and it could be recovered by "pop" later, no change on the current filter; "push+set" -- push the current filter to the stack, and changes the current filter via sample.id, variant.id, samp.sel or variant.sel; "push+intersect" -- push the current filter to the stack, and set the current filter to the intersection of selected samples and/or variants; "pop" -- pop up the last filter
sample
logical, if TRUE, include all samples
variant
logical, if TRUE, include all variants
verbose
if TRUE, show information

Value

None.

Details

seqResetFilter(file) is equivalent to seqSetFilter(file), where the selection arguments in seqSetFilter are NULL.

See Also

seqGetFilter, seqSetFilterChrom, seqGetData, seqApply

Examples

Run this code
# the GDS file
(gds.fn <- seqExampleFileName("gds"))

# display
(f <- seqOpen(gds.fn))

# get 'sample.id
(samp.id <- seqGetData(f, "sample.id"))
# "NA06984" "NA06985" "NA06986" ...

# get 'variant.id'
head(variant.id <- seqGetData(f, "variant.id"))

# get 'chromosome'
table(seqGetData(f, "chromosome"))

# get 'allele'
head(seqGetData(f, "allele"))
# "T,C" "G,A" "G,A" ...


# set sample and variant filters
seqSetFilter(f, sample.id=samp.id[c(2,4,6,8,10)])
set.seed(100)
seqSetFilter(f, variant.id=sample(variant.id, 10))

# get genotypic data
seqGetData(f, "genotype")



## set the intersection

seqResetFilter(f)
seqSetFilterChrom(f, 10L)
seqSummary(f, "genotype", check="none")

AF <- seqAlleleFreq(f)
table(AF <= 0.9)

seqSetFilter(f, variant.sel=(AF<=0.9), action="intersect")
seqSummary(f, "genotype", check="none")


# close the GDS file
seqClose(f)

Run the code above in your browser using DataLab