jianhong / ChIPpeakAnno

11 stars 4 forks source link

cvglists rtracklayer import error: Error in stop_if_wrong_length(what, ans_len) 'ranges' must have the length of the object to construct #30

Open c2b2pss opened 1 year ago

c2b2pss commented 1 year ago

Hi,

Greetings!

I am getting an error at the 'cvglists' create error: This was happening with my data, so I ran the demo data and I get the same error. The error withh traceback is below.

Error in stop_if_wrong_length(what, ans_len) :
'ranges' must have the length of the object to construct (79152) or length 1

12. | stop(wmsg(what, " must have the length of the object ", "to construct (", ans_len, ") or length 1"))

11. | stop_if_wrong_length(what, ans_len)

10. | new_GRanges("GRanges", seqnames = seqnames, ranges = ranges, strand = strand, mcols = mcols, seqinfo = seqinfo)

9. | GRanges(rep(seqnames(which), nhits), C_ans[[1L]], seqinfo = si)

8. | .local(con, format, text, ...)
-- | --

7. | import(FileForFormat(con, format), ...)
-- | --

6. | import(FileForFormat(con, format), ...)

5. | FUN(X[[i]], ...)

4. | FUN(X[[i]], ...)

3. |     lapply(X = X, FUN = FUN, ...)

2. | sapply(file.path(path, files), import, format = "BigWig", which = feature.recentered, as = "RleList")

1. | sapply(file.path(path, files), import, format = "BigWig", which = feature.recentered, as = "RleList")

The error happens with these steps: It occurs only when building "cvglists"

path <- system.file("extdata", package="ChIPpeakAnno")
files <- dir(path, "broadPeak")
data <- sapply(file.path(path, files), toGRanges, format="broadPeak")
(names(data) <- gsub(".broadPeak", "", files))

ol <- findOverlapsOfPeaks(data, connectedPeaks="keepAll")
features <- ol$peaklist[[length(ol$peaklist)]]
feature.recentered <- reCenterPeaks(features, width=4000)

library(rtracklayer)
files <- dir(path, "bigWig")
if(.Platform$OS.type != "windows"){
  cvglists <- sapply(file.path(path, files), import,
                     format="BigWig",
                     which=feature.recentered,
                     as="RleList")
}else{## rtracklayer can not import bigWig files on Windows
  load(file.path(path, "cvglist.rds"))
}

It looks like a print out rather than an error. But my heatmap is empty after the error!

Any help is appreciated !

hukai916 commented 1 year ago

Hi @c2b2pss , I seem not able to replicate this error. Which version of ChIPpeakAnno and rtracklayer are you using? I tested with ChIPpeakAnno v3.28.1 and rtracklayer 1.54.0 and it works fine.

c2b2pss commented 1 year ago

@hukai916

Thank you so much for the quick reply!

packageVersion("ChIPpeakAnno") 
[1] '3.32.0' 
packageVersion("rtracklayer") 
[1] '1.58.0'

Do I need to downgrade? I am using Bioconductor 3.16 and it gives me ver 3.32. I am using R 4.2 on Linux.

Edit: I cannot find source for ver 3.28.1 of ChIPpeakAnno

c2b2pss commented 1 year ago

Any ideas?

hukai916 commented 1 year ago

Hi @c2b2pss , I still can not replicate your error with 3.32.0. I built a Docker image to test your codes and it works well. Can you install Docker and use the following image to test so that we have exact the same environment? This image comes with the latest ChIPpeakAnno v3.32.0.

docker pull hukai916/r_4.2.2:0.2

Then,

docker run -it hukai916/r_4.2.2:0.2

Then, run your code from there and let me know if you still encounter the problem.