beads <- as.data.frame(beads[-c(1), ])
names(beads) <- c('V1', 'V2', 'V3', 'V4')
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
JtoB1kb <- function(x,y,z){
Path <-x
file1 <-y
OutputName <- z
#
Data <- paste(Path,'/', file1, sep='')
Sample <- fromJSON(file=Data)
#Loop throug each chromosome
Sample.1 <- lapply(Sample, function(I)
{
data.frame(matrix(unlist(I),ncol = 1, byrow = TRUE))
})
#Remove the data frame with metadata
Sample.1$metadata <- NULL
#Prepare files for each chromosome for the Sample
ChrI <- Sample.1$I
ChrI$chr <- 'chrI'
ChrI$start <-seq(from=1, to =15072423, by= 1000)
ChrI <- ChrI[-c(15073),]
ChrI$end <- seq(from =1000, to= 15072401, by=1000 )
names(ChrI)[1:4] <- c('value', 'chr','start', 'end')
ChrI <- ChrI[c('chr','start', 'end', 'value')]
ChrII <- Sample.1$II
ChrII$chr <- 'chrII'
ChrII$start <-seq(from=1, to =15279345, by= 1000)
ChrII <- ChrII[-c(15280),]
ChrII$end <- seq(from =1000, to= 15279301, by=1000 )
names(ChrII)[1:4] <- c('value', 'chr','start', 'end')
ChrII <- ChrII[c('chr','start', 'end', 'value')]
ChrIII <- Sample.1$III
ChrIII$chr <- 'chrIII'
ChrIII$start <-seq(from=1, to =13783700, by= 1000)
ChrIII <- ChrIII[-c(13784),]
ChrIII$end <- seq(from =1000, to= 13783601, by=1000)
names(ChrIII)[1:4] <- c('value', 'chr','start', 'end')
ChrIII <- ChrIII[c('chr','start', 'end', 'value')]
ChrIV<- Sample.1$IV
ChrIV$chr <- 'chrIV'
ChrIV$start <-seq(from=1, to =17493793, by= 1000)
ChrIV <- ChrIV[-c(17494),]
ChrIV$end <- seq(from =1000, to= 17493701, by=1000 )
names(ChrIV)[1:4] <- c('value', 'chr','start', 'end')
ChrIV <- ChrIV[c('chr','start', 'end', 'value')]
ChrV<- Sample.1$V
ChrV$chr <- 'chrV'
ChrV$start <-seq(from=1, to =20924149, by= 1000)
ChrV <- ChrV[-c(20925),]
ChrV$end <- seq(from =1000, to= 20924101, by=1000 )
names(ChrV)[1:4] <- c('value', 'chr','start', 'end')
ChrV <- ChrV[c('chr','start', 'end', 'value')]
ChrX<- Sample.1$X
ChrX$chr <- 'chrX'
ChrX$start <-seq(from=1, to =17718866, by= 1000)
ChrX <- ChrX[-c(17719),]
ChrX$end <- seq(from =1000, to= 17718801, by=1000 )
names(ChrX)[1:4] <- c('value', 'chr','start', 'end')
ChrX <- ChrX[c('chr','start', 'end', 'value')]
ChrMT<- Sample.1$MtDNA
ChrMT$chr <- 'chrM'
ChrMT$start <-seq(from=1, to =13794, by= 1000)
ChrMT <- ChrMT[-c(14),]
ChrMT$end <- seq(from =1000, to= 13701, by=1000 )
names(ChrMT)[1:4] <- c('value', 'chr','start', 'end')
ChrMT <- ChrMT[c('chr','start', 'end', 'value')]
#Connect all the data frame together in one data frame
Sample.2 <- rbind(ChrI,ChrII,ChrIII,ChrIV,ChrV,ChrX,ChrMT)
#Convert data.frame column from factor to numeric
indx <- sapply(Sample.2$value, is.character)
Sample.2[indx] <- lapply(Sample.2[indx], function(x) as.numeric(as.character(x)))
#Avoid scientific numbers (unread by UCSC)
Sample.2 <- format(Sample.2, scientific=FALSE)
#changes to have a format accepted by SIB
Sample.3 <- Sample.2
Sample.3$name <- 1:nrow(Sample.3)
names(Sample.3)[1:5] <- c('chrom','chromStart', 'chromEnd', 'score', 'name')
Sample.3 <- Sample.3[c('chrom','chromStart', 'chromEnd', 'name', 'score')]
#Add criteria for UCSC)
Sample.4<- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on   autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar   maxHeightPixels=128:75:11       windowingFunction=maximum       smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Sample.2)
#Save this file that can be load on UCSC
write.table(Sample.4,paste(Path,'/',OutputName, sep=''),sep="\t", col.name = FALSE, row.names = FALSE, quote = FALSE)
#write.table(Sample.3,'/data_disk1/Maude/ChEC_analysis_SIB/Merged/FAS_FREE_merged_convert.bed',sep="\t", col.name= FALSE,row.names = FALSE, quote = FALSE)
}
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads[,2])/beads_reads) * 50000000
print(beads)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads$V4)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
print(beads$V4)
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads$V4)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
print(beads[,4])
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads$V4)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
print(beads[,4])
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads$V4)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads$V1)
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads[1,])
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads[1,])
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.delim(beads, header = F)
input <- read.delim(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- as.data.frame(beads[-c(1), ])
input <- as.data.frame(input[-c(1), ])
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads[,1])
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
)
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.table(beads, header = F)
input <- read.table(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- beads[-c(1), ]
input <- input[-c(1), ]
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
print(beads[,4])
print(beads[,5])
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
#names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
#Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.table(beads, header = F)
input <- read.table(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- beads[-c(1), ]
input <- input[-c(1), ]
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
#                              autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
#                             maxHeightPixels=128:75:11       windowingFunction=maximum
#                            smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.table(beads, header = F)
input <- read.table(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- beads[-c(1), ]
input <- input[-c(1), ]
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on
autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar
maxHeightPixels=128:75:11       windowingFunction=maximum
smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
NormaDelta <- function(beads, Input,Breads, Ireads, output){
beads <- read.table(beads, header = F)
input <- read.table(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
##########
beads <- beads[-c(1), ]
input <- input[-c(1), ]
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
Normalized <- as.data.frame(beads)
Normalized$V5 <- as.numeric(Normalized$V5) - as.numeric(input$V5)
Normalized$V4 <- NULL
names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
#Add criteria for UCSC)
Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar maxHeightPixels=128:75:11       windowingFunction=maximum smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output, sep = '/') ,sep="\t", col.name = FALSE,
row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_Delta.bed')
devtools::document()
library("EasyBED", lib.loc="/Library/Frameworks/R.framework/Versions/3.4/Resources/library")
detach("package:EasyBED", unload=TRUE)
library("EasyBED", lib.loc="/Library/Frameworks/R.framework/Versions/3.4/Resources/library")
devtools::document()
devtools::document()
devtools::document()
#' Normalization by division
#' Normalization by dividing beads reads by input reads
#' NormaDelta(beads, Input,Breads, Ireads, output)
#' @param beads and @param Input are both file
#' @param Breads and @param Ireads are total of mapped reads for each files
#' @param output is output name, without extension
#' @return two bed files, one just divided and one with the ratio
#' @examples NormaDelta(beads.bed, input.bed, 1000,200,ChIP_delta.bed)
NormaRatio <- function(beads, Input,Breads, Ireads, output){
beads <- read.table(beads, header = F)
input <- read.table(Input, header = F)
beads_reads <-as.numeric(Breads)
input_reads <-as.numeric(Ireads)
beads <- beads[-c(1), ]
input <- input[-c(1), ]
beads['V5'] <- (as.numeric(beads$V4)/beads_reads) * 50000000
input['V5'] <- (as.numeric(input$V4)/input_reads) * 50000000
input['V6'] <- input$V5 + 1
beads['V6'] <- beads$V5 + 1
Normalized <- beads
Normalized['V7']<- Normalized$V6/input$V6
Normalized$V4 <- NULL
Normalized$V5 <- NULL
Normalized$V6 <- NULL
names(Normalized)[1:4] <- c('chr', 'start', 'end', 'value')
Norma_log <- Normalized
Norma_log$logValue <- log2(as.numeric(Norma_log$value))
Norma_log$value <- NULL
#Add criteria for UCSC)
Normalized <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on   autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar   maxHeightPixels=128:75:11       windowingFunction=maximum       smoothingWindow=off', start ='', end='',value='',stringsAsFactors=FALSE ),Normalized)
Norma_log <- rbind(data.frame(chr ='track type=bedGraph  visibility=full  yLineOnOff=on   autoScale=on    yLineMark="0.0"  alwaysZero=on  graphType=bar   maxHeightPixels=128:75:11       windowingFunction=maximum       smoothingWindow=off', start ='', end='',logValue='',stringsAsFactors=FALSE ),Norma_log)
#Save this file that can be load on UCSC
write.table(Normalized,paste(output,'ratio.bed', sep = '_') ,sep="\t", col.name = FALSE, row.names = FALSE, quote = FALSE)
write.table(Norma_log,paste(output,'Logratio.bed', sep = '_'),sep="\t", col.name = FALSE, row.names = FALSE, quote = FALSE)
}
NormaDelta('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed')
NormaRatio('/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_ex.bed','/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed_in.bed', 10,100, '/Users/maude/Desktop/PhD/PhD_course/Programmation/SIB_Rpackaging/Test/Bed')
devtools::document()
devtools::document()
devtools::document()
devtools::document()
devtools::document()
library(EasyBED)
devtools::document()
library(EasyBED)
devtools::document()
library(EasyBED)
devtools::document()
library(EasyBED)
devtools::document()
library(EasyBED)
## try http:// if https:// URLs are not supported
source("https://bioconductor.org/biocLite.R")
biocLite("karyoploteR")
library(karyoploteR)
