Skip to content

Seed used in GSEA_fgsea is (almost always) the same #76

@vgilbart

Description

@vgilbart

Coming back to commit aeea30e as an answer to issue #45 that added the following in GSEA_fgsea function:

   if (seed)
       set.seed(.Random.seed)

I am not sure this is a good solution to set seed?
It seems that set.seed() will use the first value its given, but the first value of .Random.seed doesn't change unless one changes the generator method (RNGkind): https://stackoverflow.com/questions/70585494/first-two-values-in-random-seed-are-always-the-same-with-different-set-seeds

I see two problems with this commit at the moment:

  • using different seeds you'll always get the same results
  • users cannot actually set their own seed

See below for the use of set.seed():

set.seed(1234, kind = "Mersenne-Twister")
.Random.seed[1]
#[1] 10403
set.seed(.Random.seed, kind = "Mersenne-Twister")
y <- .Random.seed
set.seed(10403, kind = "Mersenne-Twister")
z <- .Random.seed

all(y == z)
#[1] TRUE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions