forked from ParkerLab/bioinf545
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_centipede.R
executable file
·30 lines (17 loc) · 1.09 KB
/
run_centipede.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/Rscript
# ---------------------------------------------------------------------------
library(CENTIPEDE)
args<-commandArgs(TRUE)
# args1 = Tab-delimited gzipped cuts file (Required)
# args2 = Tab-delimited gzipped motif file with score in the 5th column (Required)
# args3 = name for tab-delimited gzipped output file that contains CENTIPEDE posterior probability appended to motifs file (Required)
# args4 = column that contain motif scores. Defaults to 5
# args5 = number of lines to read in. Defaults to -1
scores <- ifelse(!is.na(args[4]), as.numeric(args[4]), 5)
nlines <- ifelse(!is.na(args[5]), as.numeric(args[5]), -1)
###################### Read Data & Manipulate ################################
cuts<-read.table(file=args[1], colClasses = 'integer', nrows = nlines)
anno<-read.table(file=args[2], nrows = nlines)
centFit <-fitCentipede(Xlist = list(DNase=as.matrix(cuts)), Y=cbind(rep(1, dim(anno)[1]), anno[,scores]), DampLambda=0.01,DampNegBin=0.001)
output<-cbind(anno, centFit$PostPr)
write.table(output, gzfile(args[3]), quote=FALSE, sep="\t", col.names=FALSE, row.names=FALSE)