2020# ' @export
2121# '
2222# ' @examples
23- # ' # library(ggcoverage)
24- # ' # peak.file <- system.file("extdata", "ChIP-seq", "consensus.peak", package = "ggcoverage")
25- # ' # peak.df <- GetConsensusPeak(peak.file = peak.file)
26- GetConsensusPeak <- function (peak.file , peak.folder = NULL , mspc.path = NULL , rep.type = c(" bio" , " tec" ), stringency.threshold = 1e-8 ,
27- weak.threshold = 1e-4 , gamma = 1e-8 , alpha = 0.05 , min.overlap.num = 1 ,
28- multiple.intersections = c(" Lowest" , " Highest" ), parallelism.degree = 1 ) {
23+ # ' peak_file <- system.file("extdata", "ChIP-seq", "consensus.peak", package = "ggcoverage")
24+ # ' peak_df <- GetConsensusPeak(peak.file = peak_file)
25+ # ' head(peak_df)
26+ # '
27+ GetConsensusPeak <- function (peak.file ,
28+ peak.folder = NULL ,
29+ mspc.path = NULL ,
30+ rep.type = c(" bio" , " tec" ),
31+ stringency.threshold = 1e-8 ,
32+ weak.threshold = 1e-4 ,
33+ gamma = 1e-8 ,
34+ alpha = 0.05 ,
35+ min.overlap.num = 1 ,
36+ multiple.intersections = c(" Lowest" , " Highest" ),
37+ parallelism.degree = 1 ) {
2938 # check parameters
3039 rep.type <- match.arg(arg = rep.type )
3140 multiple.intersections <- match.arg(arg = multiple.intersections )
@@ -39,7 +48,9 @@ GetConsensusPeak <- function(peak.file, peak.folder = NULL, mspc.path = NULL, re
3948 stop(" Peak file number is less than or equal to one!" )
4049 } else if (length(peak.file ) == 1 ) {
4150 # read file directly, do not get consensus peaks
42- consensus.peak.df <- read.table(file = peak.file , sep = " \t " , header = FALSE )
51+ consensus.peak.df <- read.table(file = peak.file ,
52+ sep = " \t " ,
53+ header = FALSE )
4354 consensus.peak.df <- consensus.peak.df [, 1 : 5 ]
4455 colnames(consensus.peak.df ) <- c(" chr" , " start" , " stop" , " name" , " score" )
4556 } else {
@@ -62,9 +73,26 @@ GetConsensusPeak <- function(peak.file, peak.folder = NULL, mspc.path = NULL, re
6273
6374 # full command
6475 mspc.cmd <- paste(
65- mspc.path , input.para , " -r" , rep.type , " -s" , stringency.threshold ,
66- " -w" , weak.threshold , " -g" , gamma , " -a" , alpha , " -c" , min.overlap.num , " -m" , multiple.intersections ,
67- " -d" , parallelism.degree , " -o" , out.folder
76+ mspc.path ,
77+ input.para ,
78+ " -r" ,
79+ rep.type ,
80+ " -s" ,
81+ stringency.threshold ,
82+ " -w" ,
83+ weak.threshold ,
84+ " -g" ,
85+ gamma ,
86+ " -a" ,
87+ alpha ,
88+ " -c" ,
89+ min.overlap.num ,
90+ " -m" ,
91+ multiple.intersections ,
92+ " -d" ,
93+ parallelism.degree ,
94+ " -o" ,
95+ out.folder
6896 )
6997 # change language information
7098 full.mspc.cmd <- paste0(" export LC_ALL=en_US.UTF-8;" , mspc.cmd )
@@ -78,11 +106,17 @@ GetConsensusPeak <- function(peak.file, peak.folder = NULL, mspc.path = NULL, re
78106 # obtain results
79107 if (! file.exists(file.path(out.folder , " ConsensusPeaks.bed" ))) {
80108 out.base <- basename(out.folder )
81- all.tmp.dirs <- sort(dir(path = dirname(out.folder ), pattern = out.base , full.names = TRUE ))
109+ all.tmp.dirs <- sort(dir(
110+ path = dirname(out.folder ),
111+ pattern = out.base ,
112+ full.names = TRUE
113+ ))
82114 out.folder <- all.tmp.dirs [length(all.tmp.dirs )]
83115 }
84116 consensus.peak.file <- file.path(out.folder , " ConsensusPeaks.bed" )
85- consensus.peak.df <- read.table(file = consensus.peak.file , sep = " \t " , header = TRUE )
117+ consensus.peak.df <- read.table(file = consensus.peak.file ,
118+ sep = " \t " ,
119+ header = TRUE )
86120 }
87121 return (consensus.peak.df )
88122}
0 commit comments