The following code works fine in R but returns error in Rmarkdown code chunk.
for (i in seq(1, length(gr_list), by = 4)) {
peakHeatmap(gr_list[i:(i + 3)], color = rainbow(n = 4), TxDb = txdb, upstream = 3000, downstream = 3000) +
facet_grid(chr ~ .id)
}
Quitting from lines 54-58 (05_annotation.Rmd)
Error: external pointer is not valid
In addition: There were 50 or more warnings (use warnings() to see the first 50)
Solved. The txdb object should be explicitly exported into foreach, using the argument .export=txdb. Or export the whole global environment with .export = ls(globalenv()).
The following code works fine in R but returns error in Rmarkdown code chunk.