Skip to content

Commit

Permalink
tagging release 4.1 as stable for promethion flowcell and releaseing …
Browse files Browse the repository at this point in the history
…alfredstats
  • Loading branch information
davidebolo1993 committed Dec 5, 2022
1 parent 7c97f83 commit c502421
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 11 deletions.
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": 307,
"splitterpos": 345,
"topwindowstate": "HIDE",
"panelheight": 741,
"windowheight": 779
"panelheight": 835,
"windowheight": 873
},
"right": {
"splitterpos": 461,
"splitterpos": 519,
"topwindowstate": "NORMAL",
"panelheight": 741,
"windowheight": 779
"panelheight": 835,
"windowheight": 873
}
}
2 changes: 1 addition & 1 deletion .Rproj.user/F43DE67C/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TabSet1": 3,
"TabSet2": 2,
"TabSet2": 0,
"TabZoom": {}
}
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\\nWarning: 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\\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: 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\":\"* installing *source* package ‘NanoR’ ...\\n\"},{\"type\":1,\"output\":\"** using staged installation\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** R\\n\"},{\"type\":1,\"output\":\"\"},{\"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\":\"\"},{\"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\":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\":\"\"}]"
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="1"
saveActionState="-1"
imageDirtyState="0"
saveActionState="0"
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: NanoR
Type: Package
Title: Analyze MinION and GridION sequencing data
Version: 4.0
Version: 4.1
Author: Davide Bolognini, PhD [aut, cre]
Maintainer: Davide Bolognini <davidebolognini7@gmail.com>
Depends:
Expand Down
114 changes: 114 additions & 0 deletions R/alfredstats.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#' @title alfredstats
#' @description generate an interactive HTML report with statistics from alfred qc (zgrep "^ME <qc.tsv.gz> | cut -f 2- | datamash transpose)
#' @param qcdata path to alfred qc.tsv.gz
#' @param out path to HTML report
#' @return HTML file
#' @examples
#' #do not run
#' qcdata<-file.path("/path/to/qc.tsv.gz")
#' outhtml<-file.path("/path/to/qc.html")
#' NanoR::alfredstats(qcdata=qcdata, out=outhtml)

alfredstats<-function(qcdata,out) {

qcdata<-normalizePath(file.path(qcdata))
out<-file.path(out)

message("[",Sys.time(),"]"," reading qc data")

#read, re-organize
df<-fread(qcdata)

#error-rate
keep<-c("#MatchedBases", "MatchRate",
"#MismatchedBases", "MismatchRate",
"#DeletionsCigarD", "DeletionRate",
"#InsertionsCigarI", "InsertionRate",
"ErrorRate")

error_df<- df[which(df$Sample %in% keep),]
error_df[match(keep, error_df$Sample),]

error_df<-transpose(error_df)
names(error_df) <- as.character(unlist(error_df[1,]))
error_df<-error_df[-1,]
TotalErrors<-as.integer(error_df[["#MismatchedBases"]]) + as.integer(error_df[["#DeletionsCigarD"]]) + as.integer(error_df[["#InsertionsCigarI"]])
error_df<-cbind(error_df,TotalErrors)
colnames(error_df)<-c(colnames(error_df)[c(1:length(colnames(error_df))-1)], c("#TotalErrors"))
cols<-colnames(error_df)
error_df<-transpose(error_df)
error_df$V2<-error_df$V1
error_df$V1<-cols

#counts
error_counts_df<-error_df[grepl("#", error_df$V1),]
error_counts_df$V1<-factor(error_counts_df$V1, levels=as.character(error_counts_df$V1))
#rates
error_rates_df<-error_df[!grepl("#", error_df$V1),]
error_rates_df$V1<-factor(error_rates_df$V1, levels=as.character(error_rates_df$V1))


#aligned reads

keep<-c("#Unmapped", "UnmappedFraction",
"#Mapped", "MappedFraction",
"#MappedForward", "MappedForwardFraction",
"#MappedReverse", "MappedReverseFraction",
"#SecondaryAlignments", "SecondaryAlignmentFraction",
"#SupplementaryAlignments", "SupplementaryAlignmentFraction",
"#SplicedAlignments", "SplicedAlignmentFraction"
)

alignment_df<-df[which(df$Sample %in% keep),]
colnames(alignment_df)<-c("V1", "V2")

#counts
alignment_counts_df<-alignment_df[grepl("#", alignment_df$V1),]
alignment_counts_df$V1<-factor(alignment_counts_df$V1, levels=as.character(alignment_counts_df$V1))
#rates
alignment_rates_df<-alignment_df[!grepl("#", alignment_df$V1),]
alignment_rates_df$V1<-factor(alignment_rates_df$V1, levels=as.character(alignment_rates_df$V1))

f <- list(
size = 10,
color = "#7f7f7f"
)


chart_type <- list(
type = "dropdown",
xanchor = 'center',
yanchor = "bottom",
buttons = list(
list(label = "counts",
method = "restyle",
args = list("visible", list(TRUE,FALSE))),
list(label = "rates",
method = "restyle",
args = list("visible", list(FALSE,TRUE)))
)
)

message("[",Sys.time(),"]"," plotting")

p1<-plot_ly() %>% add_trace(x=error_counts_df$V1,y=as.numeric(error_counts_df$V2),type="bar", color = I("darkblue"), name = "#bp", visible=TRUE) %>%
add_trace(x=error_rates_df$V1,y=as.numeric(error_rates_df$V2),type="bar", color = I("darkred"), name = ":bp", visible=FALSE) %>%
layout(showlegend=FALSE,updatemenus = list(chart_type))

p2<-plot_ly() %>% add_trace(x=alignment_counts_df$V1,y=as.numeric(alignment_counts_df$V2),type="bar", color = I("darkblue"), name = "#reads", visible=TRUE) %>%
add_trace(x=alignment_rates_df$V1,y=as.numeric(alignment_rates_df$V2),type="bar", color = I("darkred"), name = ":reads", visible=FALSE) %>%
layout(showlegend=FALSE,updatemenus = list(chart_type), title="Alfred statistics")


fig<- subplot(p1,p2,nrows = 2,titleX=TRUE, titleY=TRUE,margin=.05)

message("[",Sys.time(),"]"," storing plot to file")

htmlwidgets::saveWidget(fig, out)

rm(list=ls())
invisible(gc())

message("[",Sys.time(),"]"," done")

}
58 changes: 58 additions & 0 deletions data/sample_alfred_qc.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Sample Sample
Library DefaultLib
#QCFail 0
QCFailFraction 0
#DuplicateMarked 0
DuplicateFraction 0
#Unmapped 1145
UnmappedFraction 0.00420869
#Mapped 270911
MappedFraction 0.995791
#MappedRead1 270911
#MappedRead2 0
RatioMapped2vsMapped1 0
#MappedForward 136796
MappedForwardFraction 0.504948
#MappedReverse 134115
MappedReverseFraction 0.495052
#SecondaryAlignments 26
SecondaryAlignmentFraction 9.59725e-05
#SupplementaryAlignments 27071
SupplementaryAlignmentFraction 0.0999258
#SplicedAlignments 0
SplicedAlignmentFraction 0
#Pairs 0
#MappedPairs 0
MappedPairsFraction 0
#MappedSameChr 0
MappedSameChrFraction 0
#MappedProperPair 0
MappedProperFraction 0
#ReferenceBp 48502
#ReferenceNs 0
#AlignedBases 3461850049
#MatchedBases 3386511047
MatchRate 0.978237
#MismatchedBases 36853506
MismatchRate 0.0106456
#DeletionsCigarD 23582373
DeletionRate 0.00681207
HomopolymerContextDel 0.27756
#InsertionsCigarI 14903123
InsertionRate 0.00430496
HomopolymerContextIns 0.348669
#SoftClipped 266961
SoftClipRate 0.98542
#HardClipped 0
HardClipRate 0
ErrorRate 0.0217626
MedianReadLength 8020
DefaultLibraryLayout 0
MedianInsertSize 0
MedianCoverage 65344
SDCoverage 7560.2
CoveredBp 48502
FractionCovered 1
BpCov1ToCovNRatio 0
BpCov1ToCov2Ratio -nan
MedianMAPQ 60
25 changes: 25 additions & 0 deletions man/alfredstats.Rd

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

0 comments on commit c502421

Please sign in to comment.