Skip to content

Commit

Permalink
streamline name
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueMakowski committed Dec 1, 2024
1 parent b8767d8 commit 4f13dd5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/cor_sort.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ cor_sort.easycormatrix <- function(x, distance = "correlation", hclust_method =
#' @export
cor_sort.matrix <- function(x, distance = "correlation", hclust_method = "complete", ...) {
if(isSquare(x)) {

Check warning on line 81 in R/cor_sort.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/cor_sort.R,line=81,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.

Check warning on line 81 in R/cor_sort.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/cor_sort.R,line=81,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
i <- .cor_sort_order_square(x, distance = distance, hclust_method = hclust_method, ...)
i <- .cor_sort_square(x, distance = distance, hclust_method = hclust_method, ...)
} else {
i <- .cor_sort_order_nonsquare(x, distance = "euclidean", ...)
i <- .cor_sort_nonsquare(x, distance = "euclidean", ...)
}

reordered <- x[i$row_order, i$col_order]
Expand All @@ -98,7 +98,7 @@ cor_sort.matrix <- function(x, distance = "correlation", hclust_method = "comple
# Utils -------------------------------------------------------------------


.cor_sort_order_square <- function(m, distance = "correlation", hclust_method = "complete", ...) {
.cor_sort_square <- function(m, distance = "correlation", hclust_method = "complete", ...) {
if (distance == "correlation") {
d <- stats::as.dist((1 - m) / 2) # r = -1 -> d = 1; r = 1 -> d = 0
} else if (distance == "raw") {
Expand All @@ -113,7 +113,7 @@ cor_sort.matrix <- function(x, distance = "correlation", hclust_method = "comple
}


.cor_sort_order_nonsquare <- function(m, distance = "euclidean", ...) {
.cor_sort_nonsquare <- function(m, distance = "euclidean", ...) {
# Step 1: Perform clustering on rows and columns independently
row_dist <- dist(m, method = distance) # Distance between rows
col_dist <- dist(t(m), method = distance) # Distance between columns
Expand Down

0 comments on commit 4f13dd5

Please sign in to comment.