Skip to content

Commit

Permalink
Merge pull request #37 from michaelgruenstaeudl/testing
Browse files Browse the repository at this point in the history
Testing
  • Loading branch information
michaelgruenstaeudl authored Feb 29, 2024
2 parents c3e8fce + ff19b9c commit 8026d25
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 46 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
#### Version 1.0.9 (2024.02.28)
* Improving variable and file names
* Correcting output plot specifications
* Increase logger use, improve logger format

#### Version 1.0.8 (2024.02.28)
* Handling of GenBank features with multiple qualifiers of the same name
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: PACVr
Version: 1.0.9
Date: 2024-02-28
Date: 2024-02-29
Title: Plastome Assembly Coverage Visualization
Authors@R: c(person("Gregory", "Smith", role=c("ctb")),
person("Nils", "Jenke", role=c("ctb")),
Expand Down
11 changes: 5 additions & 6 deletions R/PACVr.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ PACVr.vizWithRCircos <- function(gbkData,
#' value of the average coverage instead of an absolute value
#' @param textSize a numeric value that specifies the relative font size of the
#' text element in the visualization
#' @param verbose a boolean, that when TRUE, generates additional files with
#' @param tabularCovStats a boolean, that when TRUE, generates additional files with
#' detailed genomic region information
#' @param output a character string that specifies the name of, and path to,
#' the output file
Expand All @@ -98,15 +98,15 @@ PACVr.vizWithRCircos <- function(gbkData,
#' outFile <- paste(tempdir(), "/NC_045072__all_reads.pdf", sep="")
#' PACVr.complete(gbkFile=gbkFile, bamFile=bamFile, windowSize=250, logScale=FALSE,
#' threshold=0.5, IRCheck=1, relative=TRUE, textSize=0.5,
#' verbose=FALSE, output=outFile)
#' tabularCovStats=FALSE, output=outFile)
#' }
#' \dontrun{
#' gbkFile <- system.file("extdata", "MG936619/MG936619.gb", package="PACVr")
#' bamFile <- system.file("extdata", "MG936619/MG936619_subsampled.bam", package="PACVr")
#' outFile <- paste(tempdir(), "/MG936619_CoverageViz.pdf", sep="")
#' PACVr.complete(gbkFile=gbkFile, bamFile=bamFile, windowSize=50, logScale=FALSE,
#' threshold=0.5, IRCheck=NA, relative=TRUE, textSize=0.5,
#' verbose=FALSE, output=outFile)
#' tabularCovStats=FALSE, output=outFile)
#' }

PACVr.complete <- function(gbkFile,
Expand All @@ -117,7 +117,7 @@ PACVr.complete <- function(gbkFile,
IRCheck=NA,
relative=TRUE,
textSize=0.5,
verbose=FALSE,
tabularCovStats=FALSE,
output=NA) {
######################################################################
read.gbData <- PACVr.read.gb(gbkFile)
Expand All @@ -131,7 +131,6 @@ PACVr.complete <- function(gbkFile,
logger::log_fatal('Parsing of any sequence features unsuccessful.')
return(-1)
}

###################################
plotSpecs <- getPlotSpecs(logScale,
threshold,
Expand All @@ -145,7 +144,7 @@ PACVr.complete <- function(gbkFile,
plotSpecs$logScale)

###################################
if (verbose) {
if (tabularCovStats) {
PACVr.compileCovStats(gbkData,
coverage$raw,
analysisSpecs,
Expand Down
16 changes: 8 additions & 8 deletions R/RCircosOps.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ PACVr.Histogram.Plot <- function(hist.data = NULL,
genomic.columns = 3,
is.sorted = TRUE) {
if (is.null(hist.data)) {
warning("Genomic data missing in input.")
stop()
logger::log_error("Genomic data missing in input.")
stop() # Should 'stop()' be replaced with 'return(NULL)' ?
}
boundary <- RCircos::RCircos.Get.Plot.Boundary(track.num, side, inside.pos, outside.pos, FALSE)
outerPos <- boundary[1]
innerPos <- boundary[2]
if (is.null(genomic.columns) || genomic.columns < 2 || genomic.columns > 3) {
warning("Number of columns for genomic position incorrect.")
stop()
logger::log_error("Number of columns for genomic position incorrect.")
stop() # Should 'stop()' be replaced with 'return(NULL)' ?
}
if (is.null(data.col) || data.col <= genomic.columns) {
warning(paste("Number of input columns must be > ", genomic.columns, ".", sep=""))
stop()
logger::log_error(paste("Number of input columns must be > ", genomic.columns, ".", sep=""))
stop() # Should 'stop()' be replaced with 'return(NULL)' ?
}
RCircos.Pos <- RCircos::RCircos.Get.Plot.Positions()
RCircos.Par <- RCircos::RCircos.Get.Plot.Parameters()
Expand All @@ -72,8 +72,8 @@ PACVr.Histogram.Plot <- function(hist.data = NULL,
min.value <- min(histValues)
} else {
if (min.value > max.value) {
warning("min.value must be greater than max.value.")
stop()
logger::log_error("min.value must be greater than max.value.")
stop() # Should 'stop()' be replaced with 'return(NULL)' ?
}
}
histHeight <- RCircos::RCircos.Get.Data.Point.Height(histValues,
Expand Down
4 changes: 2 additions & 2 deletions R/coverageCalcOps.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ CovCalc <- function(coverageRaw,
# RETURNS:
# data.frame with region names, chromosome start, chromosome end and coverage calcucation
if (!is.numeric(windowSize) | windowSize < 0) {
warning("User-selected window size must be >= 1.")
stop()
logger::log_error("User-selected window size must be >= 1.")
stop() # Should 'stop()' be replaced with 'return(NULL)' ?
}
bins <- GenomicRanges::tileGenome(
sum(IRanges::runLength(coverageRaw)),
Expand Down
4 changes: 2 additions & 2 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ HistCol <- function(cov, threshold, relative, logScale) {
# color vector
# Error handling
if (!is.numeric(threshold) | threshold < 0) {
warning("User-defined coverage depth threshold must be >=1.")
stop()
logger::log_error("User-defined coverage depth threshold must be >=1.")
stop() # Should 'stop()' be replaced with 'return(NULL)' ?
}
if (relative == TRUE & logScale) {
threshold <- mean(cov[, 4]) + log(threshold)
Expand Down
8 changes: 3 additions & 5 deletions R/visualisationOps.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,13 @@ createVizFile <- function(plotSpecs) {
if (outputType == "pdf") {
pdf(output,
width=10,
height=10,
units="cm",
res=600)
height=10)
} else if (outputType == "png") {
png(output,
width=10,
height=10,
units="cm",
res=600)
units="in",
res=300)
}
}

Expand Down
8 changes: 4 additions & 4 deletions inst/extdata/PACVr_Rscript.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CmdLineArgs <- function() {
dest = "threshold",
help = "a numeric value that specifies the threshold for plotting coverage depth bars in red as opposed to the default black [default = %default]",
metavar = "integer"),
make_option(opt_str = c("-irc","--IRCheck"),
make_option(opt_str = c("-i","--IRCheck"),
type = "numeric",
default = 1,
dest = "IRCheck",
Expand All @@ -69,10 +69,10 @@ CmdLineArgs <- function() {
dest = "textSize",
help = "a numeric value that specifies the relative font size of the text element in the visualization [default = %default]",
metavar = "integer"),
make_option(opt_str = c("-v","--verbose"),
make_option(opt_str = c("-c","--tabularCovStats"),
type = "logical",
default = FALSE,
dest = "verbose",
dest = "tabularCovStats",
help = paste("a boolean, that when TRUE, generates additional files with",
"detailed genomic region information"),
metavar = "logical"),
Expand Down Expand Up @@ -111,7 +111,7 @@ PACVr.complete(gbkFile = opt$gbkFile,
IRCheck = opt$IRCheck,
relative = opt$relative,
textSize = opt$textSize,
verbose = opt$verbose,
tabularCovStats = opt$tabularCovStats,
output = opt$output)

########################################################################
Expand Down
26 changes: 13 additions & 13 deletions inst/extdata/PACVr_run_parallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ run_PACVr <- function(f) {
gbkFile <- paste0(inFileDir, basename(f))
bamFile <- paste0(inFileDir, accNum, "_mapping_OneMoreLocations.sorted.bam")

tmpName <- paste0(inFileDir, accNum, "_CoverageViz_IRCheckFALSE")
#sink(paste0(tmpName, ".log"))
outFile <- paste0(tmpName, ".png")
PACVr.complete(gbkFile, bamFile, windowSize=250, logScale=FALSE,
threshold=0.5, relative=TRUE, textSize=0.5,
output=outFile)
#sink()
# tmpName <- paste0(inFileDir, accNum, "_CoverageViz_IRCheckFALSE")
# outFile <- paste0(tmpName, ".png")
# PACVr.complete(gbkFile, bamFile, windowSize=250, logScale=FALSE,
# threshold=0.5, relative=TRUE, textSize=0.5,
# output=outFile)

# tmpName <- paste0(inFileDir, accNum, "_CoverageViz_IRCheck0")
# sink(paste0(tmpName, ".log"))
# outFile <- paste0(tmpName, ".png")
# PACVr.complete(gbkFile, bamFile, windowSize=250, logScale=FALSE,
# threshold=0.5, relative=TRUE, textSize=0.5,
# IRCheck=0, output=outFile)
# sink()

# tmpName <- paste0(inFileDir, accNum, "_CoverageViz_IRCheck1")
# sink(paste0(tmpName, ".log"))
tmpName <- paste0(inFileDir, accNum, "_CoverageViz_IRCheck1")
outFile <- paste0(tmpName, ".png")
PACVr.complete(gbkFile, bamFile, windowSize=250, logScale=FALSE,
threshold=0.5, relative=TRUE, textSize=0.5,
IRCheck=1, output=outFile)

# tmpName <- paste0(inFileDir, accNum, "_CoverageViz_IRCheck1_withStats")
# outFile <- paste0(tmpName, ".png")
# PACVr.complete(gbkFile, bamFile, windowSize=250, logScale=FALSE,
# threshold=0.5, relative=TRUE, textSize=0.5,
# IRCheck=1, output=outFile)
# sink()
# IRCheck=1, tabularCovStats=TRUE, output=outFile)
}

foreach(i=1:length(inFiles), .packages=c("PACVr")) %dopar% {
Expand Down
8 changes: 4 additions & 4 deletions man/PACVr.complete.Rd

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

2 changes: 1 addition & 1 deletion vignettes/PACVr_Vignette.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ outFile <- paste(tempdir(), "/NC_045072_CoverageViz.pdf", sep="")
PACVr.complete(gbkFile, bamFile, windowSize=250,
logScale=FALSE, threshold=0.5, syntenyLineType=1,
relative=TRUE, textSize=0.5, regionsCheck=FALSE,
verbose=FALSE, output=outFile)
tabularCovStats=FALSE, output=outFile)
\end{BGVerbatim}

\subsection{Via Unix shell}
Expand Down

0 comments on commit 8026d25

Please sign in to comment.