I apologize if this is very easy question but here I go. When I try to convert a bed file to granges using togranges I am getting this error. My bed file looks like this, it is a bedfile from MACS2 in Galaxy:
chr1 858727 858893 split_on_avi_rep1_peak_1 54 . 5.63956 8.06901 5.42788 64
> library(ChIPpeakAnno)
> bed <- system.file("extdata", "overlap_flag_coordinates_with_r_duplicates_removed.bed", package="ChIPpeakAnno")
> gr1 <- toGRanges(bed, format="BED", header=FALSE)
Error in .new_IRanges_from_start_end(start, end) :
'start' or 'end' cannot contain NAs
In addition: Warning message:
In toGRanges(bed, format = "BED", header = FALSE) :
NAs introduced by coercion
> sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252 LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C LC_TIME=English_Canada.1252
attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] rtracklayer_1.52.1 regioneR_1.24.0 ChIPpeakAnno_3.26.4 GenomicRanges_1.44.0 GenomeInfoDb_1.28.4
[6] IRanges_2.26.0 S4Vectors_0.30.2 BiocGenerics_0.38.0 BiocManager_1.30.16
loaded via a namespace (and not attached):
[1] ProtGenerics_1.24.0 bitops_1.0-7 matrixStats_0.61.0 bit64_4.0.5
[5] filelock_1.0.2 progress_1.2.2 httr_1.4.2 InteractionSet_1.20.0
[9] tools_4.1.1 utf8_1.2.2 R6_2.5.1 colorspace_2.0-2
[13] DBI_1.1.2 lazyeval_0.2.2 tidyselect_1.1.1 prettyunits_1.1.1
[17] bit_4.0.4 curl_4.3.2 compiler_4.1.1 VennDiagram_1.7.1
[21] graph_1.70.0 cli_3.1.1 Biobase_2.52.0 formatR_1.11
[25] xml2_1.3.3 DelayedArray_0.18.0 scales_1.1.1 RBGL_1.68.0
[29] rappdirs_0.3.3 stringr_1.4.0 digest_0.6.29 Rsamtools_2.8.0
[33] XVector_0.32.0 pkgconfig_2.0.3 MatrixGenerics_1.4.3 BSgenome_1.60.0
[37] dbplyr_2.1.1 fastmap_1.1.0 ensembldb_2.16.4 rlang_1.0.0
[41] rstudioapi_0.13 RSQLite_2.2.9 BiocIO_1.2.0 generics_0.1.2
[45] BiocParallel_1.26.2 dplyr_1.0.7 RCurl_1.98-1.5 magrittr_2.0.2
[49] GenomeInfoDbData_1.2.6 futile.logger_1.4.3 Matrix_1.3-4 munsell_0.5.0
[53] Rcpp_1.0.8 fansi_1.0.2 lifecycle_1.0.1 stringi_1.7.6
[57] yaml_2.2.2 MASS_7.3-54 SummarizedExperiment_1.22.0 zlibbioc_1.38.0
[61] BiocFileCache_2.0.0 grid_4.1.1 blob_1.2.2 crayon_1.4.2
[65] lattice_0.20-44 splines_4.1.1 Biostrings_2.60.2 multtest_2.48.0
[69] GenomicFeatures_1.44.2 hms_1.1.1 KEGGREST_1.32.0 pillar_1.7.0
[73] rjson_0.2.21 biomaRt_2.48.3 futile.options_1.0.1 XML_3.99-0.8
[77] glue_1.6.1 lambda.r_1.2.4 png_0.1-7 vctrs_0.3.8
[81] gtable_0.3.0 purrr_0.3.4 assertthat_0.2.1 cachem_1.0.6
[85] ggplot2_3.3.5 restfulr_0.0.13 AnnotationFilter_1.16.0 survival_3.2-11
[89] tibble_3.1.6 GenomicAlignments_1.28.0 AnnotationDbi_1.54.1 memoise_2.0.1
I think I solved the issue by using a different way to read the bed file then torganges has no problem.
Please let me know if this looks fine.
Thanks!
According to the documentation, toGRanges() is able to read in filename directly, so you should NOT need to manually convert bed into df. I informed the function developer on GitHub (https://github.com/jianhong/ChIPpeakAnno/issues/17#issue-1124441134).
BTW, the following is misleading, it basically tries to read the bed file from the extdata folder that comes with ChIPpeakAnno package and you are not supposed to put your custom data into that folder.
Please add one more line before gr1 <- toGRanges(bed, format="BED", header=FALSE)