Skip to content

Commit

Permalink
mod compare
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebolo1993 committed Apr 17, 2023
1 parent d2c3cd4 commit 002357d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .Rproj.user/F43DE67C/pcs/files-pane.pper
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"ascending": true
}
],
"path": "~/NanoR/R"
"path": "~/NanoR"
}
2 changes: 1 addition & 1 deletion .Rproj.user/F43DE67C/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"activeTab": 0
"activeTab": 2
}
12 changes: 6 additions & 6 deletions .Rproj.user/F43DE67C/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"left": {
"splitterpos": 302,
"splitterpos": 425,
"topwindowstate": "NORMAL",
"panelheight": 732,
"windowheight": 770
"panelheight": 1089,
"windowheight": 1127
},
"right": {
"splitterpos": 454,
"splitterpos": 676,
"topwindowstate": "NORMAL",
"panelheight": 732,
"windowheight": 770
"panelheight": 1089,
"windowheight": 1127
}
}
2 changes: 1 addition & 1 deletion .Rproj.user/F43DE67C/persistent-state
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build-last-errors="[]"
build-last-errors-base-dir="~/NanoR/"
build-last-outputs="[{\"type\":0,\"output\":\"==> devtools::document(roclets = c('rd', 'collate', 'namespace'))\\n\\n\"},{\"type\":1,\"output\":\"\\u001B[36mℹ\\u001B[39m Updating \\u001B[34m\\u001B[34mNanoR\\u001B[34m\\u001B[39m documentation\\n\"},{\"type\":1,\"output\":\"\\u001B[36mℹ\\u001B[39m Loading \\u001B[34m\\u001B[34mNanoR\\u001B[34m\\u001B[39m\\n\"},{\"type\":2,\"output\":\"Warning: package ‘plotly’ was built under R version 4.1.1\\nWarning: package ‘ggplot2’ was built under R version 4.1.1\\nWarning: package ‘scales’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘data.table’ was built under R version 4.1.1\\nWarning: package ‘dplyr’ was built under R version 4.1.1\\nWarning: package ‘tidyr’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: \\u001B[1m\\u001B[22mSkipping \\u001B]8;;file:///Users/davide.bolognini/NanoR/NAMESPACE\\u0007\\u001B[34mNAMESPACE\\u001B[39m\\u001B]8;;\\u0007\\n\\u001B[31m✖\\u001B[39m It already exists and was not generated by roxygen2.\\n\"},{\"type\":1,\"output\":\"Documentation completed\\n\\n\"},{\"type\":0,\"output\":\"==> R CMD INSTALL --preclean --no-multiarch --with-keep.source NanoR\\n\\n\"},{\"type\":1,\"output\":\"* installing to library ‘/Users/davide.bolognini/Library/R/arm64/4.1/library’\\n\"},{\"type\":1,\"output\":\"* installing *source* package ‘NanoR’ ...\\n\"},{\"type\":1,\"output\":\"** using staged installation\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** R\\n\"},{\"type\":1,\"output\":\"** data\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** moving datasets to lazyload DB\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** inst\\n\"},{\"type\":1,\"output\":\"** byte-compile and prepare package for lazy loading\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"Warning messages:\\n\"},{\"type\":1,\"output\":\"1: package ‘plotly’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"2: package ‘ggplot2’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"3: package ‘scales’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"4: package ‘data.table’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"5: package ‘dplyr’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"6: package ‘tidyr’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** help\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** installing help indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** building package indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from temporary location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":2,\"output\":\"Warning: package ‘plotly’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘ggplot2’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘scales’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘data.table’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘dplyr’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘tidyr’ was built under R version 4.1.1\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from final location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":2,\"output\":\"Warning: package ‘plotly’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘ggplot2’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘scales’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘data.table’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘dplyr’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘tidyr’ was built under R version 4.1.1\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"* DONE (NanoR)\\n\"},{\"type\":1,\"output\":\"\"}]"
build-last-outputs="[{\"type\":0,\"output\":\"==> devtools::document(roclets = c('rd', 'collate', 'namespace'))\\n\\n\"},{\"type\":1,\"output\":\"\\u001B[36mℹ\\u001B[39m Updating \\u001B[34m\\u001B[34mNanoR\\u001B[34m\\u001B[39m documentation\\n\"},{\"type\":1,\"output\":\"\\u001B[36mℹ\\u001B[39m Loading \\u001B[34m\\u001B[34mNanoR\\u001B[34m\\u001B[39m\\n\"},{\"type\":2,\"output\":\"Warning: package ‘plotly’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘ggplot2’ was built under R version 4.1.1\\nWarning: package ‘scales’ was built under R version 4.1.1\\nWarning: package ‘data.table’ was built under R version 4.1.1\\nWarning: package ‘dplyr’ was built under R version 4.1.1\\nWarning: package ‘tidyr’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: \\u001B[1m\\u001B[22mSkipping \\u001B]8;;file:///Users/davide.bolognini/NanoR/NAMESPACE\\u0007\\u001B[34mNAMESPACE\\u001B[39m\\u001B]8;;\\u0007\\n\\u001B[31m✖\\u001B[39m It already exists and was not generated by roxygen2.\\n\"},{\"type\":1,\"output\":\"Documentation completed\\n\\n\"},{\"type\":0,\"output\":\"==> R CMD INSTALL --preclean --no-multiarch --with-keep.source NanoR\\n\\n\"},{\"type\":1,\"output\":\"* installing to library ‘/Users/davide.bolognini/Library/R/arm64/4.1/library’\\n\"},{\"type\":1,\"output\":\"* installing *source* package ‘NanoR’ ...\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** using staged installation\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** R\\n\"},{\"type\":1,\"output\":\"** data\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** moving datasets to lazyload DB\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** inst\\n\"},{\"type\":1,\"output\":\"** byte-compile and prepare package for lazy loading\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"Warning messages:\\n\"},{\"type\":1,\"output\":\"1: package ‘plotly’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"2: package ‘ggplot2’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"3: package ‘scales’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"4: package ‘data.table’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"5: package ‘dplyr’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"6: package ‘tidyr’ was built under R version 4.1.1 \\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** help\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** installing help indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** building package indices\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from temporary location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":2,\"output\":\"Warning: package ‘plotly’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘ggplot2’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘scales’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘data.table’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘dplyr’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘tidyr’ was built under R version 4.1.1\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from final location\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":2,\"output\":\"Warning: package ‘plotly’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘ggplot2’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘scales’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘data.table’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘dplyr’ was built under R version 4.1.1\\n\"},{\"type\":2,\"output\":\"Warning: package ‘tidyr’ was built under R version 4.1.1\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package keeps a record of temporary installation path\\n\"},{\"type\":1,\"output\":\"* DONE (NanoR)\\n\"},{\"type\":1,\"output\":\"\"}]"
compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}"
files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}"
Expand Down
3 changes: 3 additions & 0 deletions .Rproj.user/F43DE67C/sources/prop/INDEX
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
~%2FNanoR%2FDESCRIPTION="300FBE73"
~%2FNanoR%2FR%2Fcompare.R="DDB686B2"
~%2FNanoR%2FR%2Fmuxscan.R="68F33D03"
~%2FNanoR%2FREADME.md="668CEBF6"
~%2FNanoR%2Fman%2Fcompare.Rd="35EB6A46"
40 changes: 27 additions & 13 deletions R/compare.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' @title compare
#' @description generate an interactive HTML report comparing length and quality of reads from multiple sequencing summary files
#' @param summaries a character vector containing paths to multiple sequencing summaries (each from a different ONT sequencing run)
#' @param labels a character vector containing ordered names for the sequencing files. Override the default behaviour, which is to use the run_id
#' @param time compare run statistics using this time interval (hours). Default to 10
#' @param out path to HTML report
#' @return HTML file
Expand All @@ -9,10 +10,10 @@
#' exp1<-file.path("/path/to/exp1_sequencing_summary.txt")
#' exp2<-file.path("/path/to/exp2_sequencing_summary.txt")
#' outhtml<-file.path("/path/to/comparison.html")
#' NanoR::compare(summaries=c(exp1,exp2), fraction=.001, out=outhtml)
#' NanoR::compare(summaries=c(exp1,exp2), time=10, out=outhtml)


compare<-function(summaries,time=10,out){
compare<-function(summaries,labels=NULL,time=10,out){


out<-file.path(out)
Expand All @@ -24,23 +25,36 @@ compare<-function(summaries,time=10,out){
for (i in c(1:(length(compare_)-1))) {

h<-seq(from=compare_[i], to=compare_[i+1], by=1)

for (n in h) {

clist[[as.character(n)]]<-paste(h[1], h[length(h)],sep="-")

}
}


if (!is.null(labels)) {

if (length(labels) != length(summaries)) {

stop("[",Sys.time(),"]"," length of summaries and labels vector must be the same")

}

}

l<-1

for (summary in summaries) {

summary<-normalizePath(file.path(summary))

message("[",Sys.time(),"]"," reading sequencing summary file ", summary)

tab<-fread(summary,sep="\t",header=TRUE,showProgress=FALSE)
run<-unique(tab$run_id)
run<-ifelse(is.null(labels), unique(tab$run_id),labels[l])
l<-l+1

if (length(run) != 1) {

Expand All @@ -67,7 +81,7 @@ compare<-function(summaries,time=10,out){
range_<-clist[[as.character(from)]]

summ[i,]$x<-summ_pass[i,]$x<-range_

summ[i,]$y<-nrow(subtab)
summ_pass[i,]$y<-nrow(subset(subtab, (subtab$passes_filtering == TRUE)))

Expand All @@ -91,7 +105,7 @@ compare<-function(summaries,time=10,out){
taball_pass[[run]]<-summ_pass

}

taball<-do.call(rbind, taball)
taball_pass<-do.call(rbind,taball_pass)

Expand Down Expand Up @@ -124,22 +138,22 @@ compare<-function(summaries,time=10,out){


p1 <- plot_ly() %>% add_trace(x = taball$x, y = taball$y, color = taball$z, type = "box", visible=TRUE,legendgroup = taball$z,showlegend=F) %>%
add_trace(x=taball_pass$x,y=taball_pass$y,color = taball_pass$z, type = "box", visible=FALSE,legendgroup = taball_pass$z,showlegend=F) %>%
layout(boxmode = "group",legend = list(orientation = 'h'),updatemenus = list(chart_type), xaxis=list(title="Sequencing run-time (h)",titlefont=f,tickangle=45),
add_trace(x=taball_pass$x,y=taball_pass$y,color = taball_pass$z, type = "box", visible=FALSE,legendgroup = taball_pass$z,showlegend=F) %>%
layout(boxmode = "group",legend = list(orientation = 'h'),updatemenus = list(chart_type), xaxis=list(title="Sequencing run-time (h)",titlefont=f,tickangle=45),
yaxis=list(side="left",title="#reads",titlefont=f))

p2 <- plot_ly() %>% add_trace(x = taball$x, y = taball$y2, color = taball$z, type = "box", visible=TRUE,legendgroup = taball$z,showlegend=F) %>%
add_trace(x=taball_pass$x,y=taball_pass$y2,color = taball_pass$z, type = "box", visible=FALSE,legendgroup=taball_pass$z,showlegend=F) %>%
add_trace(x=taball_pass$x,y=taball_pass$y2,color = taball_pass$z, type = "box", visible=FALSE,legendgroup=taball_pass$z,showlegend=F) %>%
layout(boxmode = "group",legend = list(orientation = 'h'),updatemenus = list(chart_type), xaxis=list(title="Sequencing run-time (h)",titlefont=f,tickangle=45),
yaxis=list(side="left",title="#bases",titlefont=f))

p3 <- plot_ly() %>% add_trace(x = taball$x, y = taball$y3, color = taball$z, type = "box", visible=TRUE,legendgroup = taball$z,showlegend=F) %>%
add_trace(x=taball_pass$x,y=taball_pass$y3,color = taball_pass$z, type = "box", visible=FALSE,legendgroup=taball_pass$z,showlegend=F) %>%
add_trace(x=taball_pass$x,y=taball_pass$y3,color = taball_pass$z, type = "box", visible=FALSE,legendgroup=taball_pass$z,showlegend=F) %>%
layout(boxmode = "group",legend = list(orientation = 'h'),updatemenus = list(chart_type), xaxis=list(title="Sequencing run-time (h)",titlefont=f,tickangle=45),
yaxis=list(side="left",title="Length",titlefont=f))

p4<- plot_ly() %>% add_trace(x = taball$x, y = taball$y4, color = taball$z, type = "box", visible=TRUE,legendgroup = taball$z) %>%
add_trace(x=taball_pass$x,y=taball_pass$y4,color = taball_pass$z, type = "box", visible=FALSE, legendgroup=taball_pass$z) %>%
add_trace(x=taball_pass$x,y=taball_pass$y4,color = taball_pass$z, type = "box", visible=FALSE, legendgroup=taball_pass$z) %>%
layout(boxmode = "group",legend = list(orientation = 'h'),updatemenus = list(chart_type), xaxis=list(title="Sequencing run-time (h)",titlefont=f,tickangle=45),
yaxis=list(side="left",title="Qscore",titlefont=f))

Expand All @@ -157,4 +171,4 @@ compare<-function(summaries,time=10,out){
message("[",Sys.time(),"]"," done")


}
}
6 changes: 4 additions & 2 deletions man/compare.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 002357d

Please sign in to comment.