Skip to content

Commit

Permalink
Merge pull request #185 from bigomics/fix-phenoclustering-phenocorrel…
Browse files Browse the repository at this point in the history
…ation

Fix phenoclustering phenocorrelation
  • Loading branch information
ESCRI11 authored Nov 20, 2024
2 parents 5fcfbab + 9e3b74d commit d3f65fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ depend:
install: depend
R CMD INSTALL .


VERSION = "v3.4.4"

install.rcmd:
Rscript dev/install_playbase.R 'rcmd'

Expand Down
7 changes: 5 additions & 2 deletions R/pgx-correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ pgx.computePartialCorrelationMatrix <- function(tX, method = PCOR.METHODS, fast
#'
#' @export
pgx.testPhenoCorrelation <- function(df, plot = TRUE, cex = 1, compute.pv = TRUE) {

cl <- sapply(df, class)
nlev <- apply(df, 2, function(x) length(unique(x[!is.na(x)])))
cvar <- which(cl %in% c("numeric", "integer") & nlev >= 2)
Expand All @@ -413,6 +414,7 @@ pgx.testPhenoCorrelation <- function(df, plot = TRUE, cex = 1, compute.pv = TRUE
rvar <- sub("=.*", "", colnames(Rx))
Rx[is.nan(Rx)] <- 0
Rx[is.na(Rx)] <- 0

R <- tapply(1:nrow(Rx), rvar, function(i) apply(Rx[c(i, i), , drop = FALSE], 2, max, na.rm = TRUE))
R <- do.call(rbind, R)
R <- tapply(1:ncol(R), rvar, function(i) apply(R[, c(i, i), drop = FALSE], 1, max, na.rm = TRUE))
Expand All @@ -421,6 +423,7 @@ pgx.testPhenoCorrelation <- function(df, plot = TRUE, cex = 1, compute.pv = TRUE
} else {
R <- do.call(cbind, R)
}

R <- t(R / sqrt(diag(R))) / sqrt(diag(R))
R[is.nan(R)] <- NA

Expand Down Expand Up @@ -448,7 +451,7 @@ pgx.testPhenoCorrelation <- function(df, plot = TRUE, cex = 1, compute.pv = TRUE
rownames(fisher.P) <- colnames(dd)
colnames(fisher.P) <- colnames(dd)
}

## discrete vs continuous -> ANOVA or Kruskal-Wallace
kruskal.P <- NULL
if (ncol(dc) > 0) {
Expand All @@ -463,7 +466,7 @@ pgx.testPhenoCorrelation <- function(df, plot = TRUE, cex = 1, compute.pv = TRUE
rownames(kruskal.P) <- colnames(dd)
colnames(kruskal.P) <- colnames(dc)
}

## continuous vs continuous -> correlation test
cor.P <- NULL
if (ncol(dc) > 1) {
Expand Down

0 comments on commit d3f65fe

Please sign in to comment.