R/agnesPearson.R

Defines functions agnesPearson

Documented in agnesPearson

#' agnesPearson
#'
#' @param x [[matrix]] A matrix containg the gene expression.
#' @param k [[numeric]] A integer number indicating the number of clusters.
#'
#' @keywords internal
#' @usage NULL
#' @import cluster
#' @importFrom stats cutree
#' @return [[list]]
agnesPearson <- function(x,k){
  distance <- 1 -  stats::cor(x = t(x) ,method = "spearman")
  agnesObj <- cluster::agnes(x = distance, diss = T, method="gaverage")
  assignments <- stats::cutree(agnesObj,k=k)
  names(assignments) <- rownames(distance)
  return(list("cluster" = assignments))
}
roderickslieker/CONQUER documentation built on Nov. 12, 2021, 10:19 p.m.