a$fork[a$pos<ori.center|a$pos>dif.center]<-abs(a$fork[a$pos<ori.center|a$pos>dif.center]-16)# left of the Ori and right of the dif (dif > ori) is switch 0 -> 16 and 16 -> 0 to have the leading and lagging
if(ter.center>ori.center){
a$fork[a$pos<ori.center|a$pos>ter.center]<-abs(a$fork[a$pos<ori.center|a$pos>ter.center]-16)# left of the Ori and right of the dif (dif > ori) is switch 0 -> 16 and 16 -> 0 to have the leading and lagging
}else{
a$fork[a$pos<=ori.center&a$pos>=dif.center]<-abs(a$fork[a$pos<=ori.center&a$pos>=dif.center]-16)# right of the Ori and left of the dif (dif < ori) is switch 0 -> 16 and 16 -> 0 to have the leading and lagging
a$fork[a$pos<=ori.center&a$pos>=ter.center]<-abs(a$fork[a$pos<=ori.center&a$pos>=ter.center]-16)# right of the Ori and left of the dif (dif < ori) is switch 0 -> 16 and 16 -> 0 to have the leading and lagging
fun_report(data="\n\n<br /><br />\n\nON THE RIGHT OF THE ORI AND LEFT OF THE DIFF\nFORWARD INSERSION = LEADING\nREVERSE INSERSION = LAGGING",output=report.rmd,path="./",overwrite=FALSE)
fun_report(data="\n\n<br /><br />\n\nON THE LEFT OF THE ORI OR RIGHT OF THE DIFF\nFORWARD INSERSION = LAGGING\nREVERSE INSERSION = LEADING",output=report.rmd,path="./",overwrite=FALSE)
options(scipen=1000)# to avoid writing of scientific numbers in tables, see https://stackoverflow.com/questions/3978266/number-format-writing-1e-5-instead-of-0-00001
fun_report(data=paste0("\n\n<br /><br />\n\nPROPORTION OF THE FORWARD LEADING PART OF THE GENOME [(dif.center - ori.center) / coli.size]\n",round(p.fw.lead,3),"\n\n"),output=report.rmd,path="./",overwrite=FALSE)
fun_report(data=paste0("\n\n<br /><br />\n\nPROPORTION OF THE FORWARD LEADING PART OF THE GENOME [(ter.center - ori.center) / genome_size]\n",round(p.fw.lead,3),"\n\n"),output=report.rmd,path="./",overwrite=FALSE)
fun_report(data=paste0("\n\n<br /><br />\n\nPROPORTION OF THE FORWARD LAGGING PART OF THE GENOME (1 - p.fw.lead)\n",round(p.fw.lag,3),"\n\n"),output=report.rmd,path="./",overwrite=FALSE)
fun_report(data=paste0("\n\n<br /><br />\n\nPROPORTION OF THE REVERSE LEADING PART OF THE GENOME (= p.fw.lag)\n",round(p.rv.lead,3),"\n\n"),output=report.rmd,path="./",overwrite=FALSE)
fun_report(data=paste0("\n\n<br /><br />\n\nPROPORTION OF THE REVERSE LAGGING PART OF THE GENOME (= p.fw.lead)\n",round(p.rv.lag,3),"\n\n"),output=report.rmd,path="./",overwrite=FALSE)
@@ -247,11 +266,13 @@ if(any(arg.check) == TRUE){ # normally no NA
# end management of NA arguments
# management of NULL arguments
tempo.arg<-c(
"pos",
"freq",
"ori_coord",
"ter_coord",
"xlab",
"genome_size",
"window_size",
"step",
"file_name",
"cute",
"log"
...
...
@@ -273,25 +294,38 @@ warn <- NULL
# other checkings
ori_coord<-strsplit(ori_coord,split=" ")[[1]]
if(length(ori_coord)!=2&any(grepl(ori_coord,pattern="\\D"))){# normally no NA with is.null()
if(length(ori_coord)!=2&any(grepl(ori_coord,pattern="\\D"))){# "\\D" means at least something other than 0123456789 to have TRUE
tempo.cat<-paste0("ERROR IN plot_insertion.R:\nTHE ori_coord PARAMETER MUST BE TWO INTEGERS SEPARATED BY A SINGLE SPACE\nHERE IT IS: \n",paste0(ori_coord,collapse=" "))
stop(paste0("\n\n================\n\n",tempo.cat,"\n\n================\n\n"),call.=FALSE)# == in stop() to be able to add several messages between ==
}else{
ori_coord<-as.integer(ori_coord)
}
ter_coord<-strsplit(ter_coord,split=" ")[[1]]
if(length(ter_coord)!=2&any(grepl(ter_coord,pattern="\\D"))){# normally no NA with is.null()
if(length(ter_coord)!=2&any(grepl(ter_coord,pattern="\\D"))){# "\\D" means at least something other than 0123456789 to have TRUE
tempo.cat<-paste0("ERROR IN plot_insertion.R:\nTHE ter_coord PARAMETER MUST BE TWO INTEGERS SEPARATED BY A SINGLE SPACE\nHERE IT IS: \n",paste0(ter_coord,collapse=" "))
stop(paste0("\n\n================\n\n",tempo.cat,"\n\n================\n\n"),call.=FALSE)# == in stop() to be able to add several messages between ==
}else{
ter_coord<-as.integer(ter_coord)
}
if(length(genome_size)!=1&any(grepl(genome_size,pattern="\\D"))){# normally no NA with is.null()
if(any(grepl(genome_size,pattern="\\D"))){# "\\D" means at least something other than 0123456789 to have TRUE, not need of length(step) != 1 because of the space between two numbers
tempo.cat<-paste0("ERROR IN plot_insertion.R:\nTHE genome_size PARAMETER MUST BE A SINGLE INTEGER\nHERE IT IS: \n",paste0(genome_size,collapse=" "))
stop(paste0("\n\n================\n\n",tempo.cat,"\n\n================\n\n"),call.=FALSE)# == in stop() to be able to add several messages between ==
}else{
genome_size<-as.integer(genome_size)
}
window_size<-strsplit(window_size,split=" ")[[1]]
if(any(grepl(window_size,pattern="\\D"))){# "\\D" means at least something other than 0123456789 to have TRUE
tempo.cat<-paste0("ERROR IN plot_insertion.R:\nTHE window_size PARAMETER MUST BE INTEGER\nHERE IT IS: \n",paste0(window_size,collapse=" "))
stop(paste0("\n\n================\n\n",tempo.cat,"\n\n================\n\n"),call.=FALSE)# == in stop() to be able to add several messages between ==
}else{
window_size<-as.integer(window_size)
}
if(any(grepl(step,pattern="\\D"))){# "\\D" means at least something other than 0123456789 to have TRUE, not need of length(step) != 1 because of the space between two numbers
tempo.cat<-paste0("ERROR IN plot_insertion.R:\nTHE step PARAMETER MUST BE A SINGLE INTEGER\nHERE IT IS: \n",paste0(step,collapse=" "))
stop(paste0("\n\n================\n\n",tempo.cat,"\n\n================\n\n"),call.=FALSE)# == in stop() to be able to add several messages between ==
}else{
step<-as.integer(step)
}
# end other checkings
...
...
@@ -344,7 +378,8 @@ if(erase.graphs == TRUE){
################ Data import
obs<-read.table(pos,stringsAsFactors=FALSE)# does not take the header
echo -e "\\n\\n<br /><br />\\n\\nIn each sequence of length \$((${insertion_dist} * 2)) <br />position \$((${insertion_dist} + 1)) corresponds to the first nucleotide of the reference genome part of the read" >> report.rmd
echo -e "\\n\\n<br /><br />\\n\\n### Random insertion sites\\n\\n" > report.rmd