From 47e0107a5a3de13d5178a9d851174e8592a6b137 Mon Sep 17 00:00:00 2001 From: Ryan Corces Date: Fri, 9 Dec 2022 15:02:19 -0800 Subject: [PATCH 1/2] save PermPval and PermFDR in output addressing https://github.com/GreenleafLab/ArchR/issues/1768#issuecomment-1342932122 --- R/IntegrativeAnalysis.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/IntegrativeAnalysis.R b/R/IntegrativeAnalysis.R index ec4a2671..c5f24d00 100644 --- a/R/IntegrativeAnalysis.R +++ b/R/IntegrativeAnalysis.R @@ -1306,8 +1306,8 @@ addPeak2GeneLinks <- function( cdf <- ecdf(p$Pval) o$PermPval <- o$PermPval + p$Pval } - o$PermPval <- (o$PermPval / nperm) #Average - o$PermFDR <- pmin(ecdf(o$PermPval)(o$Pval) / ecdf(o$Pval)(o$Pval), 1) + out$PermPval <- (o$PermPval / nperm) #Average + out$PermFDR <- pmin(ecdf(o$PermPval)(o$Pval) / ecdf(o$Pval)(o$Pval), 1) } #Save Group Matrices From 25a854ffad5136f44fa7372eb5d35ce7b31d538c Mon Sep 17 00:00:00 2001 From: Ryan Corces Date: Mon, 19 Dec 2022 13:46:39 -0800 Subject: [PATCH 2/2] return permuted pvals, FDR, and null correlations addressing https://github.com/GreenleafLab/ArchR/issues/1768 --- R/IntegrativeAnalysis.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/R/IntegrativeAnalysis.R b/R/IntegrativeAnalysis.R index c5f24d00..2fd54a24 100644 --- a/R/IntegrativeAnalysis.R +++ b/R/IntegrativeAnalysis.R @@ -1294,9 +1294,11 @@ addPeak2GeneLinks <- function( #Permuted Pval if(addPermutedPval){ message("Performing Permuted P-values similar to Regner et al., 2021") + #set up variables to hold new data + permPval <- 0 + correlation <- 0 #Permute p <- o - o$PermPval <- 0 for(i in seq_len(nperm)){ message("Running Permutation ", i, " of ", nperm) idx <- sample(ncol(seATAC)) @@ -1304,10 +1306,12 @@ addPeak2GeneLinks <- function( p$TStat <- (p$Correlation / sqrt((1-p$Correlation^2)/(ncol(seATAC)-2))) #T-statistic P-value p$Pval <- 2*pt(-abs(p$TStat), ncol(seATAC) - 2) cdf <- ecdf(p$Pval) - o$PermPval <- o$PermPval + p$Pval + permPval <- permPval + p$Pval + correlation <- correlation + p$Correlation } - out$PermPval <- (o$PermPval / nperm) #Average - out$PermFDR <- pmin(ecdf(o$PermPval)(o$Pval) / ecdf(o$Pval)(o$Pval), 1) + out$PermCorrelation <- (correlation / nperm) #Average + out$PermPval <- (permPval / nperm) #Average + out$PermFDR <- pmin(ecdf(out$PermPval)(o$Pval) / ecdf(o$Pval)(o$Pval), 1) } #Save Group Matrices