Hello ! We are analyzing CAGE data and are trying to apply the cagefightR package. Unfortunately we got the following error message: "Error in asMethod(object) : all the ranges in the object to coerce to GPos must have a width of 1"
Can someone help us understanding where is our error, and how to correct it ?
Here is the code: library(CAGEfightR) library(stringr)
bwpath <- "../elaborateddata/directionalbw" bwplus <- list.files(bwpath, pattern = "pos", full.names = T) bwminus <- list.files(bwpath, pattern = "neg", full.names = T) sampnames <- strextract(bwplus, "[0-9]{3}[(W)(H)]") ix <- !is.na(sampnames) bwplus <- bwplus[ix] bwminus <- bwminus[ix] sampnames <- sampnames[ix] rownames <- str_extract(sampnames, "W|H")
design <- data.frame(row.names = sampnames, Name = sampnames, BigWigPlus = bwplus, BigWigMinus = bwminus)
bwplus <- BigWigFileList(bwplus) bwminus <- BigWigFileList(bwminus) names(bwplus) <- sampnames names(bwminus) <- sampnames
genomeinfo <- SeqinfoForUCSCGenome("mm10")
ctss <- quantifyCTSSs(plusStrand = bwplus, minusStrand = bwminus, genome = genomeinfo, design = design)
(Returns this error message after the last line:
Error in asMethod(object) : all the ranges in the object to coerce to GPos must have a width of 1)
Many thanks in advance.
This could be an issue with the BigWig-input files. CAGEfightR assumes all ranges in the BigWig is exactly 1, i.e. a single count for each single basepair (traditional CTSS format). This could be checked using something like this:
gr <- import(bw_file)
table(width(gr))