GreenleafLab / ArchR

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

Positions for peakAnnotation not found #188

Closed Brawni closed 4 years ago

Brawni commented 4 years ago

Hello,

saveArchRProject throws an error after adding following peak annotation to the ArchR object:

proj <- addArchRAnnotations(ArchRProj = proj, collection = "EncodeTFBS")

Saving the object:

 saveArchRProject(proj, load=T)
Saving ArchRProject...
Loading ArchRProject...
Error in loadArchRProject(path = outputDirectory) : 
  Positions for peakAnnotation do not exist in saved ArchRProject!

This is because there is no Position file saved for this collection:

proj@peakAnnotation@listData
$EncodeTFBS
$EncodeTFBS$Name
[1] "EncodeTFBS"

$EncodeTFBS$Positions
[1] "None"

$EncodeTFBS$Matches
[1] "HemeTutorial/Annotations/EncodeTFBS-Matches-In-Peaks.rds"

Reproduced this on the tutorial data too.

jgranja24 commented 4 years ago

I added the following check in loadArchRProject,

Thanks

Jeff

    for(i in seq_along(ArchRProj@peakAnnotation)){
      #Postions
      if(!is.null(ArchRProj@peakAnnotation[[i]]$Positions)){

        if(tolower(ArchRProj@peakAnnotation[[i]]$Positions) != "none"){

          PositionsNew <- gsub(outputDir, outputDirNew, ArchRProj@peakAnnotation[[i]]$Positions)
          if(!all(file.exists(PositionsNew))){
            if(force){
              keepAnno[i] <- FALSE
              message("Positions for peakAnnotation do not exist in saved ArchRProject!")
            }else{
              stop("Positions for peakAnnotation do not exist in saved ArchRProject!")
            }
          }
          ArchRProj@peakAnnotation[[i]]$Positions <- PositionsNew

        }

      }
schnappi-wkl commented 1 year ago

Hi, Jeff, relative path is more applicable to this module(loadArchRProject) than absolute path at the points of user. Best wishes! Schnappi

WS-FL commented 11 months ago

I second with Schnappi.

Boyuan