GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)
MIT License
388 stars 140 forks source link

Error in .requirePackage(genomeAnnotation$genome) : #1539

Closed Larrycpan closed 2 years ago

Larrycpan commented 2 years ago

I'm performing proj.PC <- addReproduciblePeakSet(ArchRProj = proj.PC, groupBy = "Clusters", peakMethod = "Tiles", method = "p"), and encounter an error: Error in .requirePackage(genomeAnnotation$genome) : Required package : BSgenome.Hsapiens.UCSC.hg38 is not installed/found!

I have succesfully load the package BSgenome.Hsapiens.UCSC.hg38 but it doesn't work. How to fix it? Thanks! ArchR-addReproduciblePeakSet-f7a07653743e-Date-2022-08-02_Time-11-23-37.log

rcorces commented 2 years ago

Hi @KeWXiong! Thanks for using ArchR! Please make sure that your post belongs in the Issues section. Only bugs and error reports belong in the Issues section. Usage questions and feature requests should be posted in the Discussions section, not in Issues.
Before we help you, you must respond to the following questions unless your original post already contained this information: 1. If you've encountered an error, have you already searched previous Issues to make sure that this hasn't already been solved? 2. Can you recapitulate your error using the tutorial code and dataset? If so, provide a reproducible example. 3. Did you post your log file? If not, add it now. 4. Remove any screenshots that contain text and instead copy and paste the text using markdown's codeblock syntax (three consecutive backticks). You can do this by editing your original post.

rcorces commented 2 years ago

you should not get this error and I'm unable to reproduce this behavior.

I would strongly discourage you from using the "Tiles" method for peak calling. We never should have introduced this as an option and the next documentation update will make this more explicitly clear.

That being said, the .requirePackage() function is very basic and you can easily step through the code to figure out why this is failing on your system (it should not be failing). I'm closing this issue but feel free to comment below if you figure out why it is failing and I will re-open the issue. It is likely something specific to your environment. I would start by resetting your R session.


.requirePackage <- function(x = NULL, load = TRUE, installInfo = NULL, source = NULL){
  if(x %in% rownames(installed.packages())){
    if(load){
      suppressPackageStartupMessages(require(x, character.only = TRUE))
    }else{
      return(0)
    }
  }else{
    if(!is.null(source) & is.null(installInfo)){
      if(tolower(source) == "cran"){
        installInfo <- paste0('install.packages("',x,'")')
      }else if(tolower(source) == "bioc"){
        installInfo <- paste0('BiocManager::install("',x,'")')
      }else{
        stop("Unrecognized package source, available are cran/bioc!")
      }
    }
    if(!is.null(installInfo)){
      stop(paste0("Required package : ", x, " is not installed/found!\n  Package Can Be Installed : ", installInfo))
    }else{
      stop(paste0("Required package : ", x, " is not installed/found!"))
    }
  }
}