Hi all,

I was trying to ChIPseeker for the first time to annotate some peaks 
with the genomic features, but got the following error:


peakAnno <- annotatePeak(peaks_gr,
    tssRegion=c(-300, 0),
    as="GRanges",
    TranscriptDb=txdb_hg19,
    annoDb="org.Hs.eg.db")

Error in IRanges:::normalizeSingleBracketSubscript(i, x) :
   subscript contains NAs or out of bounds indices


The peaks originated from Sicer which I converted to GRanges and then 
add the seqlengths independently. A tad convoluted but got the job done 
(or so I thought). Bellow the full code. I searched for the error but 
could not find out what is going wrong. Help is appreciated.

Alternatively, would any one point me to another way to annotate a list 
of peaks with genomic features (utr's, exons, introns, extragenic, ..)?

Cheers,
António


######################
## Peaks
######################
sicer2RangedData <-function(path.to.file) {
    # load the file
    bed = read.table(path.to.file, header=F, sep="\t", 
stringsAsFactors=FALSE)[,c(1:3)]
    # generate GRanges object
    myrange <- BED2RangedData(bed)
  return(myrange)
}

peaks_file="Tox-W50-G250-islands-summary-FDR0.01_50tags_2fold.bed"
peaks <- sicer2RangedData(peaks_file)

#########################
## ChIPseeker likes a proper GRanges obj
#########################
## chr size:
hg19_exons <- exons(txdb_ens)
peaks_gr <- as(peaks, "GRanges")
idx <- c( # where are the proper chromosomes?
    grep("^\\d", names(seqlengths(hg19_exons))),
    grep("^X", names(seqlengths(hg19_exons))),
    grep("^Y", names(seqlengths(hg19_exons)))
)

chrlen <- seqlengths(hg19_exons)[idx] # here they are
chrlen_sorted <- chrlen[sort(names(seqlengths(hg19_exons)[idx]))]
seqlengths(peaks_gr) <- chrlen_sorted

######################
## Annotate
######################
peakAnno <- annotatePeak(peaks_gr,
    tssRegion=c(-300, 0),
    as="GRanges",
    TranscriptDb=txdb_hg19,
    annoDb="org.Hs.eg.db")

###########
sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] parallel  grid      stats     graphics  grDevices utils datasets
[8] methods   base

other attached packages:
  [1] TxDb.Hsapiens.UCSC.hg19.knownGene_2.14.0
  [2] ChIPseeker_1.0.2
  [3] org.Hs.eg.db_2.14.0
  [4] GenomicFeatures_1.16.0
  [5] GenomicRanges_1.16.2
  [6] ChIPpeakAnno_2.12.1
  [7] AnnotationDbi_1.26.0
  [8] GenomeInfoDb_1.0.2
  [9] Biobase_2.24.0
[10] RSQLite_0.11.4
[11] DBI_0.2-7
[12] Biostrings_2.32.0
[13] XVector_0.4.0
[14] IRanges_1.21.43
[15] BiocGenerics_0.10.0
[16] VennDiagram_1.6.5
[17] biomaRt_2.20.0
[18] RColorBrewer_1.0-5
[19] plyr_1.8.1
[20] ggplot2_0.9.3.1

loaded via a namespace (and not attached):
  [1] BatchJobs_1.2           BBmisc_1.6 BiocParallel_0.6.0
  [4] bitops_1.0-6            brew_1.0-6 BSgenome_1.32.0
  [7] caTools_1.17            codetools_0.2-8 colorspace_1.2-4
[10] digest_0.6.4            fail_1.2 foreach_1.4.2
[13] gdata_2.13.3            GenomicAlignments_1.0.0 GO.db_2.14.0
[16] gplots_2.13.0           gtable_0.1.2 gtools_3.4.0
[19] iterators_1.0.7         KernSmooth_2.23-12 lattice_0.20-29
[22] limma_3.20.1            MASS_7.3-33 Matrix_1.1-3
[25] multtest_2.20.0         munsell_0.4.2 proto_0.3-10
[28] Rcpp_0.11.1             RCurl_1.95-4.1 reshape2_1.4
[31] Rsamtools_1.16.0        rtracklayer_1.23.22 scales_0.2.4
[34] sendmailR_1.1-2         splines_3.1.0 stats4_3.1.0
[37] stringr_0.6.2           survival_2.37-7 tools_3.1.0
[40] XML_3.98-1.1            zlibbioc_1.10.0

-- 
António Miguel de Jesus Domingues, PhD
Postdoctoral researcher
Deep Sequencing Group - SFB655
Biotechnology Center (Biotec)
Technische Universität Dresden
Fetscherstraße 105
01307 Dresden

Phone: +49 (351) 458 82362
Email: antonio.domingues(at)biotec.tu-dresden.de
--
The Unbearable Lightness of Molecular Biology


	[[alternative HTML version deleted]]

