Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regionstat.R should be more verbose if it cannot find the BSGenome package used for calculating and plotting GC content #37

Open
donaldcampbelljr opened this issue Feb 15, 2024 · 1 comment
Milestone

Comments

@donaldcampbelljr
Copy link
Member

Currently, the pipeline may skip calculating GC content if it cannot find the associated BSGenoma package in the namespace. Unfortunately, it does not log this and silently skips attempting to calculate the GC content:

doItAall <- function(query, fileId, genome, cellMatrix) {
plots = data.frame(stringsAsFactors=F)
bsGenomeAvail = ifelse((requireNamespace(BSg, quietly=TRUE) | requireNamespace(BSgm, quietly=TRUE)), TRUE, FALSE)

if (run_plot){
if (bsGenomeAvail) {
tryCatch(
expr = {
if (requireNamespace(BSgm, quietly=TRUE)){
library (BSgm, character.only = TRUE)
bsg = eval(as.name(BSgm))
gcvec = calcGCContent(query, bsg)
} else {
library (BSg, character.only = TRUE)
bsg = eval(as.name(BSg))
gcvec = calcGCContent(query, bsg)
}
plotBoth("gccontent", plotGCContent(gcvec))
if (exists("bedmeta")){
gc_content <- list(gc_content = signif(mean(gcvec), digits = 4))
bedmeta = append(bedmeta, gc_content)
}
plots = rbind(plots, getPlotReportDF("gccontent", "GC content"))
message("Successfully calculated and plot GC content.")
},
error = function(e){
message('Caught an error in creating: GC content plot!')
print(e, gcvec)
}
)
}
}

Simple solution would be to remove the quietly=TRUE from line 97, so that we capture this info:

Loading required namespace: BSgenome.Hsapiens.UCSC.hg38.masked
Failed with error:  'there is no package called 'BSgenome.Hsapiens.UCSC.hg38.masked''
@donaldcampbelljr
Copy link
Member Author

Should we also add the common ones to our R dependency installation script?

# build BSgenome package ID to check whether it's installed
if ( startsWith(genome, "T2T")){
  BSg = "BSgenome.Hsapiens.NCBI.T2T.CHM13v2.0"
} else {
  if (startsWith(genome, "hg") | startsWith(genome, "grch")) {
    orgName = "Hsapiens"
  } else if (startsWith(genome, "mm") | startsWith(genome, "grcm")){
    orgName = "Mmusculus"
  } else if (startsWith(genome, "dm")){
    orgName = "Dmelanogaster"
  } else if (startsWith(genome, "ce")){
    orgName = "Celegans"
  } else if (startsWith(genome, "danRer")){
    orgName = "Drerio"
  }  else if (startsWith(genome, "TAIR")){
    orgName = "Athaliana"
  } else {
    orgName = "Undefined"
  }
  BSg = paste0("BSgenome.", orgName , ".UCSC.", genome)
}

BSgm = paste0(BSg, ".masked")

In installRdeps.R ?

@nsheff nsheff added this to the v0.2.0 milestone Feb 16, 2024
@khoroshevskyi khoroshevskyi modified the milestones: v0.2.0, v0.3.0 Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants