Skip to content

Commit

Permalink
muxscan for mock and - maybe - performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebolo1993 committed Jan 9, 2023
1 parent c502421 commit d2c3cd4
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 30 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"
"path": "~/NanoR/R"
}
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": -1
"activeTab": 0
}
14 changes: 7 additions & 7 deletions .Rproj.user/F43DE67C/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"left": {
"splitterpos": 345,
"topwindowstate": "HIDE",
"panelheight": 835,
"windowheight": 873
"splitterpos": 302,
"topwindowstate": "NORMAL",
"panelheight": 732,
"windowheight": 770
},
"right": {
"splitterpos": 519,
"splitterpos": 454,
"topwindowstate": "NORMAL",
"panelheight": 835,
"windowheight": 873
"panelheight": 732,
"windowheight": 770
}
}
6 changes: 3 additions & 3 deletions .Rproj.user/F43DE67C/persistent-state
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
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\":2,\"output\":\"ℹ Updating NanoR documentation\\n\"},{\"type\":2,\"output\":\"ℹ Loading NanoR\\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\\n\"},{\"type\":2,\"output\":\"Warning: package ‘dplyr’ was built under R version 4.1.1\\nWarning: package ‘tidyr’ was built under R version 4.1.1\\n\"},{\"type\":1,\"output\":\"Writing '\\u001B]8;;ide:run:pkgload::dev_help('alfredstats')\\u0007alfredstats.Rd\\u001B]8;;\\u0007'\\n\"},{\"type\":2,\"output\":\"Warning: Skipping 'NAMESPACE'\\n✖ 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\":\"\"},{\"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\":\"** 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\":\"\"}]"
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\":\"\"}]"
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\":\"\"}"
imageDirtyState="0"
saveActionState="0"
imageDirtyState="1"
saveActionState="-1"
1 change: 1 addition & 0 deletions .Rproj.user/F43DE67C/sources/prop/INDEX
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
~%2FNanoR%2FDESCRIPTION="300FBE73"
~%2FNanoR%2FR%2Fmuxscan.R="68F33D03"
26 changes: 13 additions & 13 deletions R/heatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,23 @@ heatmap<-function(summary,time=1,platform="minion",out) {

channels_activity_overtime<-channels_activity_overtime_pass<-matrix(0,ncol=n_channels, nrow=length(bins)-1)
channels_activity<-channels_activity_pass<-rep(0,n_channels)

for (i in c(1:n_channels)) {

subtab<-subset(tab, (tab$channel == i))
subtab<-tab[channel==i]
channels_activity[i]<-sum(subtab$sequence_length_template)
channels_activity_pass[i]<-sum(subset(subtab, (subtab$passes_filtering == TRUE))$sequence_length_template)

channels_activity_pass[i]<-sum(subtab[passes_filtering == TRUE]$sequence_length_template)
for (l in c(1:(length(bins)-1))) {

from<-bins[l]
to<-bins[l+1]
subsubtab<-subset(subtab, (subtab$template_unix > from & subtab$template_unix <= to))
channels_activity_overtime[l,i]<-sum(subsubtab$sequence_length_template)
channels_activity_overtime_pass[l,i]<-sum(subset(subsubtab, (subsubtab$passes_filtering == TRUE))$sequence_length_template)
from<-bins[l]
to<-bins[l+1]
subsubtab<-subtab[template_unix > from & template_unix <= to]
channels_activity_overtime[l,i]<-sum(subsubtab$sequence_length_template)
channels_activity_overtime_pass[l,i]<-sum(subsubtab[passes_filtering == TRUE]$sequence_length_template)

}

}

channels_activity_labels<-matrix("0",nrow=max(layout$row),ncol=max(layout$col))
Expand Down
27 changes: 22 additions & 5 deletions R/muxscan.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @title muxscan
#' @description generate an interactive HTML report with muxes status over time
#' @description generate an interactive HTML report with muxes status over time
#' @param muxdata path to a mux scan data file from a single ONT run
#' @param out path to HTML report
#' @return HTML file
Expand All @@ -24,11 +24,22 @@ muxscan<-function(muxdata,out) {
csv<-as.data.frame(csv %>% group_by(B) %>% count(B, A))
csv<-as.data.frame(complete(csv,B,A))
csv[is.na(csv)] <- 0
csv<-unstack(form=n ~ A, x=csv)

if (length(unique(csv$B)) == 1) {

fakedt<-csv
fakedt$B<-2
csv<-rbind(csv,fakedt)
csv<-unstack(form=n ~ A, x=csv)[1,]

} else {

csv<-unstack(form=n ~ A, x=csv)
}

csv<-setDT(csv, keep.rownames = TRUE)[]
csv$rn<-factor(csv$rn, levels=as.character(csv$rn))


f <- list(
size = 10,
color = "#7f7f7f"
Expand All @@ -38,7 +49,13 @@ muxscan<-function(muxdata,out) {

fig <- plot_ly(csv, x = ~rn, y = ~single_pore, type = "bar", name = "single_pore")
fig <- fig %>% add_trace(y = ~saturated, name = "saturated")
fig <- fig %>% add_trace(y = ~multiple, name = "multiple")

if ("multiple" %in% colnames(csv)) {

fig <- fig %>% add_trace(y = ~multiple, name = "multiple")

}

fig <- fig %>% add_trace(y = ~other, name = "other")
fig <- fig %>% add_trace(y = ~zero, name = "zero")
fig <- fig %>% add_trace(y = ~unavailable, name = "unavailable")
Expand All @@ -54,4 +71,4 @@ muxscan<-function(muxdata,out) {
message("[",Sys.time(),"]"," done")


}
}

0 comments on commit d2c3cd4

Please sign in to comment.