Skip to content

Commit

Permalink
Remove un-used codes and use && instead of & in condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene233 committed Mar 26, 2024
1 parent 34bf266 commit 892a8f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions R/tf_idf_iae_wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ idf <- function(expr, features = NULL, thres = 0) {
#' smartid:::idf_m(data)
idf_m <- function(expr, features = NULL, thres = 0) {
if (is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of total obs

# thres <- 0
# thres <- sparseMatrixStats::rowQuantiles(expr, probs = 0.25, na.rm = TRUE)
Expand Down Expand Up @@ -359,7 +358,6 @@ iae <- function(expr, features = NULL, thres = 0) {
#' smartid:::iae_m(data)
iae_m <- function(expr, features = NULL, thres = 0) {
if (is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of total obs

# thres <- 0
# thres <- sparseMatrixStats::rowQuantiles(expr, probs = 0.25, na.rm = TRUE)
Expand Down
8 changes: 4 additions & 4 deletions R/top_markers.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ top_markers_abs <- function(data, label, n = 10,
scale = TRUE, use.mgm = TRUE,
softmax = TRUE) {
method <- match.arg(method)
if (scale & use.mgm) {
if (scale && use.mgm) {
data <- scale_mgm(expr = data, label = label)
} else if (scale & !use.mgm) {
} else if (scale && !use.mgm) {
## scale scores on rows
# mu_s <- sparseMatrixStats::rowMeans2(data, na.rm = TRUE)
# sd_s <- sparseMatrixStats::rowSds(data, na.rm = TRUE)
Expand Down Expand Up @@ -126,15 +126,15 @@ top_markers_glm <- function(data, label, n = 10,
label <- factor(label) # factorize label

## scale
if (scale & !use.mgm) {
if (scale && !use.mgm) {
## scale scores on rows
# mu_s <- sparseMatrixStats::rowMeans2(data, na.rm = TRUE)
# sd_s <- sparseMatrixStats::rowSds(data, na.rm = TRUE)
# data <- (data - mu_s) / sd_s

data <- t(scale(t(data)))
data[is.na(data)] <- 0 # assign 0 to NA when sd = 0
} else if (scale & use.mgm) {
} else if (scale && use.mgm) {
data <- scale_mgm(expr = data, label = label)
}

Expand Down

0 comments on commit 892a8f3

Please sign in to comment.