Skip to content

Commit

Permalink
improve random seed choosing
Browse files Browse the repository at this point in the history
  • Loading branch information
delomast committed Aug 12, 2020
1 parent b806959 commit a0e2c9e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions R/falseGrandma.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#' (a pair of either two maternal grandparents OR two paternal grandparents); "sP" - single parent inference
#' @param llrToTest a vector of llr thresholds to estimate error rates for
#' @param N the number of Monte Carlo samples to take to estimate the error rates (ignored for stratified methods)
#' @param seed a positive integer to use as a seed for random number generation. If \code{NULL}, a seed is
#' chosen based on the current system time
#' @param seed a positive integer to use as a seed for random number generation.
#' @param itersperMI the number of iterations per Mendelian incompatibility, in order of 0, 1, ...
#' (ignored for non-stratified methods)
#' @param errorType the type of error estimate to make
Expand All @@ -25,7 +24,7 @@
#'
#' @export
falseGrandma <- function(gmaData, relationship = c("ssGP", "sP"),
llrToTest, N = 10000, seed = NULL, itersPerMI = NULL,
llrToTest, N = 10000, seed = sample.int(.Machine$integer.max, 1), itersPerMI = NULL,
errorType = c("falseNegative", "pairwise", "Unrel", "Aunt", "HalfAunt", "ParCous",
"True_GAunt", "True_Unrel", "True_HGAunt", "True_GpCous",
"GAunt_Unrel", "HGAunt_Unrel", "GpCous_Unrel", "GAunt", "GAunt_HGAunt",
Expand All @@ -35,9 +34,6 @@ falseGrandma <- function(gmaData, relationship = c("ssGP", "sP"),
method <- match.arg(method)
rel <- match.arg(relationship)
tRel <- match.arg(errorType)
if(is.null(seed)) seed <- ceiling(as.numeric(format(Sys.time(), "%S")) *
as.numeric(format(Sys.time(), "%j")) *
as.numeric(format(Sys.time(), "%M")))
if(seed < 0) {
warning("seed must not be negative, setting seed to 1")
seed <- 1
Expand Down

0 comments on commit a0e2c9e

Please sign in to comment.