Skip to content
Permalink
420cb1f07e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
23 lines (19 sloc) 1.05 KB
#!/home/jhamp/.conda/envs/tfbs/bin/Rscript
args=commandArgs(TRUE)
min=as.numeric(args[1])
max=as.numeric(args[2])
folder=args[3]
splitted = read.table(paste(folder, "/pass2Tr.bed", sep=''), header=FALSE)
colnames(splitted) = c("chromosome", "start", "stop", "id", "score", "maxpos", "length")
p1 = read.table(paste(folder, "/pass1Tr.bed", sep=''), header=FALSE)
colnames(p1) = c("chromosome", "start", "stop", "id", "score", "maxpos", "length")
p1$maxpos = p1$start + p1$maxpos
splitted=rbind(splitted, p1)
splitted=splitted[which(splitted$stop - splitted$start >= min),]
splitted=splitted[which(splitted$stop - splitted$start <= max),]
splitted$id=make.unique(as.character(splitted$id))
splitted$length=splitted$stop - splitted$start
splitted=cbind(splitted, containsMaxpos=0)
splitted$containsMaxpos[intersect(which(splitted$start <= splitted$maxpos), which(splitted$stop > splitted$maxpos))] = 1
splitted$maxpos = splitted$maxpos - splitted$start
write.table(splitted, paste(folder, "/merged.bed", sep=''), row.names=FALSE, col.names=FALSE, quote=FALSE, sep='\t')