Entering edit mode
Ludo Pagie
▴
40
@ludo-pagie-6130
Last seen 8.9 years ago
Hi all,
I'm getting an error when trying to coerce a GenomeData object to a
RangedData object. Here's the code I have used together with some
output (in particular the error msg when coercing):
######################################################################
# import human genome sequence
library(BSgenome.Hsapiens.UCSC.hg19)
# Virtual digest of the entire genome in GATC fragments:
# matchPattern to find GATC motifs, using bsapply
ExtractGATCFragments <- function(chr) {
# function for finding GATC sites in a chromosome and returning the
fragments
# starting and ending with GATC
GATC.match <- matchPattern(chr, pattern='GATC')
start <- c(1, start(GATC.match)) # not sure what happens if
chromosome starts with GATC
end <- c(end(GATC.match), length(chr))
Views(subject=unmasked(chr),start=start, end=end)
}
pm <- new('BSParams', X=Hsapiens, FUN=function(chr)
ExtractGATCFragments(chr) )
# create the GenomeData object:
GATC.fragments <- bsapply(pm)
# is it a genomeData??
class(GATC.fragments)
# [1] "GenomeData"
# attr(,"package")
# [1] "BSgenome"
# coerce it to a RangedData:
as(GATC.fragments, "RangedData")
# Error in FUN(X[[1L]], ...) :
# no method or default for coercing ?XStringViews? to ?RangedData?
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=nl_NL.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=nl_NL.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] parallel stats graphics grDevices utils datasets
methods
[8] base
other attached packages:
[1] BSgenome.Hsapiens.UCSC.hg19_1.3.19 BSgenome_1.30.0
[3] Biostrings_2.30.1 GenomicRanges_1.14.4
[5] XVector_0.2.0 IRanges_1.20.6
[7] BiocGenerics_0.8.0
loaded via a namespace (and not attached):
[1] stats4_3.0.2 tools_3.0.2
######################################################################
Can anybody point out to me why the object can not be coerced.
Thanks, Ludo