Skip to content

Commit

Permalink
Feat: Add peak analysis script to pipe4C
Browse files Browse the repository at this point in the history
  • Loading branch information
marrip committed Apr 7, 2020
1 parent 7ee948a commit 958a8e4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pipe4C/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM r-base:3.6.2
RUN apt-get update && apt-get install -y git libcurl4-gnutls-dev libxml2-dev libssl-dev bowtie2 samtools
# Install R packages
RUN mkdir /RScripts
ADD install.R conf_generator.R /RScripts/
ADD install.R conf_generator.R peak_analysis.R /RScripts/
RUN Rscript /RScripts/install.R
# Clone pipe4C
ENV PIPE4C_REPO=https://github.com/deLaatLab/pipe4C.git \
Expand Down
35 changes: 35 additions & 0 deletions pipe4C/peak_analysis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Load peakC and pipe4C functions
library(peakC)
source("/RScripts/pipe4C/functions.R")

# Get rds file names
getRDSFileNames <- function() {
args <- commandArgs(TRUE)
return(list(path = args[1], fileNames = list.files(args[1])))
}

mkDir <- function(path) {
folders <- strsplit(path, "/")[[1]]
resFolder <- folders[length(folders)-1]
dir.create(resFolder)
return(resFolder)
}

doIndividualPeakAnalysis <- function(RDSpath, RDSFileNames, resFolder) {
for (f in RDSFileNames) {
print(paste("Run PeakC analysis for", f))
results <- doPeakC(rdsFiles = paste0(RDSpath, "/", f))
name <- sub(".rds", "", f)
ymax <- c(10, 100, 1000)
for (y in ymax) {
pdf(paste0(resFolder, "/", name, "_peak_plot_", y, ".pdf"))
plot_C(results, y.max=y)
dev.off()
}
exportPeakCPeaks(resPeakC=results,bedFile=paste0(resFolder, "/", name, "_peakC_peaks.bed"),name=name)
}
}

RDSInfo <- getRDSFileNames()
RDSInfo$resFolder <- mkDir(RDSInfo$path)
doIndividualPeakAnalysis(RDSInfo$path, RDSInfo$fileNames, RDSInfo$resFolder)

0 comments on commit 958a8e4

Please sign in to comment.