20
20
# ' @export
21
21
# '
22
22
# ' @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 ) {
29
38
# check parameters
30
39
rep.type <- match.arg(arg = rep.type )
31
40
multiple.intersections <- match.arg(arg = multiple.intersections )
@@ -39,7 +48,9 @@ GetConsensusPeak <- function(peak.file, peak.folder = NULL, mspc.path = NULL, re
39
48
stop(" Peak file number is less than or equal to one!" )
40
49
} else if (length(peak.file ) == 1 ) {
41
50
# 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 )
43
54
consensus.peak.df <- consensus.peak.df [, 1 : 5 ]
44
55
colnames(consensus.peak.df ) <- c(" chr" , " start" , " stop" , " name" , " score" )
45
56
} else {
@@ -62,9 +73,26 @@ GetConsensusPeak <- function(peak.file, peak.folder = NULL, mspc.path = NULL, re
62
73
63
74
# full command
64
75
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
68
96
)
69
97
# change language information
70
98
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
78
106
# obtain results
79
107
if (! file.exists(file.path(out.folder , " ConsensusPeaks.bed" ))) {
80
108
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
+ ))
82
114
out.folder <- all.tmp.dirs [length(all.tmp.dirs )]
83
115
}
84
116
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 )
86
120
}
87
121
return (consensus.peak.df )
88
122
}
0 commit comments