Skip to content

Commit

Permalink
fix bug in VS() for SNC approach
Browse files Browse the repository at this point in the history
  • Loading branch information
zhizuio committed Oct 4, 2024
1 parent 24d40e9 commit 2f6a148
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/VS.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ VS <- function(x, method = "FDR", threshold = NA, subgroup = 1) {
}
}
} else {
# count the total number of parameters in the list
total_num <- 0
for (l in seq_len(length(x))) {
total_num <- total_num + prod(dim(x[[l]])[-1])
}
# # count the total number of parameters in the list
# total_num <- 0
# for (l in seq_len(length(x))) {
# total_num <- total_num + prod(dim(x[[l]])[-1])
# }

ret <- rep(list(NULL), length(x))
for (l in seq_len(length(x))) {
Expand All @@ -156,14 +156,14 @@ VS <- function(x, method = "FDR", threshold = NA, subgroup = 1) {

if (is.matrix(x[[l]])) { # for an matrix
for (j in seq_len(NCOL(x[[l]]))) {
if (sum(abs(x[[l]][, j]) > sd(x[[l]][, j])) / total_num > threshold) {
if (mean(abs(x[[l]][, j]) > sd(x[[l]][, j])) > threshold) {
ret[[l]][j] <- TRUE
}
}
} else { # for an array
for (j in seq_len(dim(x[[l]])[2])) {
for (k in seq_len(dim(x[[l]])[3])) {
if (sum(abs(x[[l]][, j, k]) > sd(x[[l]][, j, k])) / total_num > threshold) {
if (mean(abs(x[[l]][, j, k]) > sd(x[[l]][, j, k])) > threshold) {
ret[[l]][j, k] <- TRUE
}
}
Expand Down

0 comments on commit 2f6a148

Please sign in to comment.