This function takes a feature × domain association matrix and applies different methods to control for global/shared correlation structure (e.g., some features are globally correlated with all domains). It then provides domain assignments based on the adjusted scores.

adjust_assoc_matrix(
  assoc_mat,
  method = c("none", "row_normalize", "col_normalize", "both_normalize", "pc1_regress",
    "glasso"),
  lambda = 0.1,
  return_scores = FALSE
)

Arguments

assoc_mat

A numeric matrix of size (features × domains).

method

A character string specifying adjustment method. Options: - "none" (raw associations) - "row_normalize" (z-score across rows) - "col_normalize" (z-score across columns) - "both_normalize" (z-score rows and columns) - "pc1_regress" (remove 1st principal component effect) - "glasso" (apply graphical lasso for partial correlations).

lambda

Numeric penalty parameter for glasso (only used if method="glasso").

return_scores

Logical; if TRUE, return the full adjusted score matrix. If FALSE, return only best assignments per feature.

Value

If return_scores=FALSE, a character vector of assigned domains (one per feature). If TRUE, a list with: - adjusted_matrix: the adjusted score matrix - assignments: best-matching domain per feature

Examples

set.seed(1)
mat <- matrix(rnorm(50), nrow=5, ncol=10)
rownames(mat) <- paste0("Feature", 1:5)
colnames(mat) <- paste0("Domain", 1:10)
adjust_assoc_matrix(mat, method="row_normalize")
#> [1] "Domain3" "Domain5" "Domain4" "Domain1" "Domain3"