From 248fb57df36dba192fb42cc37dd4d89ec8328594 Mon Sep 17 00:00:00 2001 From: 5Aki1 Date: Sun, 9 Feb 2025 19:28:25 -0500 Subject: [PATCH 1/2] Fixed issue with restriction fragment aware background correction --- hichipper/lambdaProcess.R | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hichipper/lambdaProcess.R b/hichipper/lambdaProcess.R index b67f661..fb4f3d4 100644 --- a/hichipper/lambdaProcess.R +++ b/hichipper/lambdaProcess.R @@ -8,10 +8,14 @@ suppressMessages(suppressWarnings(library(data.table))) suppressMessages(suppressWarnings(library(reshape2))) args <- commandArgs(trailingOnly = TRUE) -resfile <- args[1] -treatmentfile <- args[2] -backgroundfile <- args[3] -outdir <- args[4] +# resfile <- args[1] +# treatmentfile <- args[2] +# backgroundfile <- args[3] +# outdir <- args[4] +resfile <- "hichipper/MboI_resfrag_hg38.bed" +treatmentfile <- "hichipper/22RV1_REP1_temporary_treat_pileup.bdg" +backgroundfile <- "hichipper/22RV1_REP1_temporary_control_lambda.bdg" +outdir <- "hichipper" K <- 1000000 # Number of loci to sample from # Import Restriction Fragments / Convert to GRanges @@ -65,8 +69,12 @@ computeRatioEtc <- function(treatmentfile, backgroundfile){ # Compute nearest neighbor for background mid <- (start(cont) + end(cont))/2 backmid <- as(data.frame(chrom=seqnames(cont), start=mid, end=mid), "GRanges") - mcols(cont)$dist <- mcols(distanceToNearest(backmid, resSites))[,1] - + nearestHits <- distanceToNearest(backmid, resSites) + nearestDist <- rep(NA, length(cont)) + nearestDist[queryHits(nearestHits)] <- mcols(nearestHits)$distance + nearestDist[is.na(nearestDist)] <- 0 + mcols(cont)$dist <- nearestDist + vals <- tapply(txtVals/contVals, nndist, mean) # Write adjusted treatment (only filters out regions where no restriction enzyme information is contained) From ce7863b78ae6b9042beb66c27ecef7b22fdee479 Mon Sep 17 00:00:00 2001 From: 5Aki1 Date: Sun, 9 Feb 2025 19:31:39 -0500 Subject: [PATCH 2/2] Update lambdaProcess.R --- hichipper/lambdaProcess.R | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/hichipper/lambdaProcess.R b/hichipper/lambdaProcess.R index fb4f3d4..2154787 100644 --- a/hichipper/lambdaProcess.R +++ b/hichipper/lambdaProcess.R @@ -8,14 +8,10 @@ suppressMessages(suppressWarnings(library(data.table))) suppressMessages(suppressWarnings(library(reshape2))) args <- commandArgs(trailingOnly = TRUE) -# resfile <- args[1] -# treatmentfile <- args[2] -# backgroundfile <- args[3] -# outdir <- args[4] -resfile <- "hichipper/MboI_resfrag_hg38.bed" -treatmentfile <- "hichipper/22RV1_REP1_temporary_treat_pileup.bdg" -backgroundfile <- "hichipper/22RV1_REP1_temporary_control_lambda.bdg" -outdir <- "hichipper" +resfile <- args[1] +treatmentfile <- args[2] +backgroundfile <- args[3] +outdir <- args[4] K <- 1000000 # Number of loci to sample from # Import Restriction Fragments / Convert to GRanges