Skip to content

Commit

Permalink
start.pos="random.f500"
Browse files Browse the repository at this point in the history
snpgdsLDpruning()
  • Loading branch information
zhengxwen committed Mar 26, 2024
1 parent 738f27e commit fbf14aa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Package
Title: Parallel Computing Toolset for Relatedness and Principal Component
Analysis of SNP Data
Version: 1.37.2
Date: 2024-03-08
Date: 2024-03-26
Depends: R (>= 2.15), gdsfmt (>= 1.8.3)
LinkingTo: gdsfmt
Imports: methods
Expand Down
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ UTILITIES

o new option 'autosave' in `snpgdsLDpruning()`

o new option `start.pos="random.f500"` in `snpgdsLDpruning()`, allowing
faster genotype scanning (it is used by default now). To be compatible
with the previous versions, please specify `start.pos="random"` manually

o Fix the welcome message when running in a non x86 system


Expand Down
7 changes: 4 additions & 3 deletions R/LD.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ snpgdsLDMat <- function(gdsobj, sample.id=NULL, snp.id=NULL, slide=250L,
snpgdsLDpruning <- function(gdsobj, sample.id=NULL, snp.id=NULL,
autosome.only=TRUE, remove.monosnp=TRUE, maf=0.005, missing.rate=0.05,
method=c("composite", "r", "dprime", "corr"), slide.max.bp=500000L,
slide.max.n=NA, ld.threshold=0.2, start.pos=c("random", "first", "last"),
slide.max.n=NA, ld.threshold=0.2,
start.pos=c("random.f500", "random", "first", "last"),
num.thread=1L, autosave=NULL, verbose=TRUE)
{
# check
Expand All @@ -123,9 +124,8 @@ snpgdsLDpruning <- function(gdsobj, sample.id=NULL, snp.id=NULL,
if (length(autosave)!=1L || anyNA(autosave) || autosave=="")
stop("'autosave' should be NULL or a file name.")
}
stopifnot(is.logical(verbose), length(verbose)==1L)

start.pos <- match.arg(start.pos)
stopifnot(is.logical(verbose), length(verbose)==1L)

if (verbose)
{
Expand Down Expand Up @@ -196,6 +196,7 @@ snpgdsLDpruning <- function(gdsobj, sample.id=NULL, snp.id=NULL,

# call LD prune for this chromosome
startidx <- switch(start.pos,
random.f500 = sample.int(min(n.tmp, 500L), 1L),
random = sample.int(n.tmp, 1L),
first = 1L,
last = n.tmp)
Expand Down
9 changes: 6 additions & 3 deletions man/snpgdsLDpruning.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
snpgdsLDpruning(gdsobj, sample.id=NULL, snp.id=NULL, autosome.only=TRUE,
remove.monosnp=TRUE, maf=0.005, missing.rate=0.05,
method=c("composite", "r", "dprime", "corr"), slide.max.bp=500000L,
slide.max.n=NA, ld.threshold=0.2, start.pos=c("random", "first", "last"),
slide.max.n=NA, ld.threshold=0.2,
start.pos=c("random.f500", "random", "first", "last"),
num.thread=1L, autosave=NULL, verbose=TRUE)
}
\arguments{
Expand All @@ -31,8 +32,10 @@ snpgdsLDpruning(gdsobj, sample.id=NULL, snp.id=NULL, autosome.only=TRUE,
\item{slide.max.bp}{the maximum basepairs in the sliding window}
\item{slide.max.n}{the maximum number of SNPs in the sliding window}
\item{ld.threshold}{the LD threshold}
\item{start.pos}{"random": a random starting position; "first": start from
the first position; "last": start from the last position}
\item{start.pos}{"random.f500", a starting postion randomly selected from
the first 500 markers (by default); "random": a random starting
position; "first": start from the first position; "last": start from
the last position. "random.f500" is applicable for >= v1.37.2}
\item{num.thread}{the number of (CPU) cores used; if \code{NA}, detect
the number of cores automatically}
\item{autosave}{NULL or a file name for autosaving a single R object
Expand Down

0 comments on commit fbf14aa

Please sign in to comment.