snpgdsSlidingWindow | R Documentation |
Apply a user-defined function with a sliding window.
snpgdsSlidingWindow(gdsobj, sample.id=NULL, snp.id=NULL,
FUN=NULL, winsize=100000L, shift=10000L, unit=c("basepair", "locus"),
winstart=NULL, autosome.only=FALSE, remove.monosnp=TRUE, maf=NaN,
missing.rate=NaN, as.is=c("list", "numeric", "array"),
with.id=c("snp.id", "snp.id.in.window", "none"), num.thread=1,
verbose=TRUE, ...)
gdsobj |
an object of class |
sample.id |
a vector of sample id specifying selected samples; if NULL, all samples are used |
snp.id |
a vector of snp id specifying selected SNPs; if NULL, all SNPs are used |
FUN |
a character or a user-defined function, see details |
winsize |
the size of sliding window |
shift |
the amount of shifting the sliding window |
unit |
|
winstart |
|
autosome.only |
if |
remove.monosnp |
if TRUE, remove monomorphic SNPs |
maf |
to use the SNPs with ">= maf" only; if NaN, no MAF threshold |
missing.rate |
to use the SNPs with "<= missing.rate" only; if NaN, no missing threshold |
as.is |
save the value returned from |
with.id |
"snp.id", "snp.id.in.window" or "none" |
num.thread |
the number of (CPU) cores used; if |
verbose |
if TRUE, show information |
... |
optional arguments to |
If FUN="snpgdsFst"
, two additional arguments "population"
and
"method"
should be specified. "population"
and "method"
are defined in snpgdsFst
. "as.is"
could be "list" (returns
a list of the values from snpgdsFst
), "numeric" (
population-average Fst, returns a vector) or "array" (population-average and
-specific Fst, returns a ‘# of pop + 1’-by-‘# of windows’ matrix, and the first
row is population-average Fst).
Return a list
Xiuwen Zheng
# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())
# sliding windows
rv <- snpgdsSlidingWindow(genofile, winsize=500000, shift=100000,
FUN=function(...) NULL)
# plot
plot(rv$chr1.num, ylab="# of SNPs in the sliding window")
# close the genotype file
snpgdsClose(genofile)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.