Skip to content

Commit

Permalink
Merge pull request #1045 from jiajic/suite_dev
Browse files Browse the repository at this point in the history
fix: seed setting
  • Loading branch information
jiajic authored Oct 8, 2024
2 parents 681a0d8 + 98f4c53 commit d481d44
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions R/dimension_reduction.R
Original file line number Diff line number Diff line change
Expand Up @@ -1756,12 +1756,20 @@ jackstrawPlot <- function(gobject,

# create a random subset if random_subset is not NULL
if (!is.null(random_subset)) {
withSeed(seed = seed_number, {
if (set_seed) {
withSeed(seed = seed_number, {
random_selection <- sort(sample(
seq_len(ncol(expr_values)), random_subset
))
expr_values <- expr_values[, random_selection]
})
} else {
random_selection <- sort(sample(
seq_len(ncol(expr_values)), random_subset
))
expr_values <- expr_values[, random_selection]
})
}

}


Expand All @@ -1786,13 +1794,26 @@ jackstrawPlot <- function(gobject,
))
}

jtest <- .perm_pa(
dat = expr_values,
iter = iter,
threshold = threshold,
ncp = ncp,
verbose = verbose
)
if (set_seed) {
withSeed(seed = seed_number, {
jtest <- .perm_pa(
dat = expr_values,
iter = iter,
threshold = threshold,
ncp = ncp,
verbose = verbose
)
})
} else {
jtest <- .perm_pa(
dat = expr_values,
iter = iter,
threshold = threshold,
ncp = ncp,
verbose = verbose
)
}


## results ##
nr_sign_components <- jtest$r
Expand Down

0 comments on commit d481d44

Please sign in to comment.