DistanceToNearest Not giving nearest Range
2
0
Entering edit mode
@chitsazanalex-11765
Last seen 6.6 years ago

I'm having trouble why the order of my subject is calling two different nearest cordinates. One is obviously closer, but for some reason it's chosing the first one rather than the actual nearest one. How can I fix this? 

Thanks!

 

Here is my code and a session_info() printout.


> ALL_merged_summits.gr["All_merged_peak_37393"]
GRanges object with 1 range and 4 metadata columns:
                        seqnames             ranges strand |                  Peak    Pileup              Gene
                           <Rle>          <IRanges>  <Rle> |              <factor> <numeric>       <character>
  All_merged_peak_37393    Chr04 [9853878, 9854277]      * | All_merged_peak_37393    3.1272 Xetrov90010392m.g
                        DistanceToTSS
                            <numeric>
  All_merged_peak_37393        -59404
  -------
  seqinfo: 3748 sequences from an unspecified genome; no seqlengths



> TSS[c("Xetrov90010392m.g", "pax6")]
GRanges object with 2 ranges and 0 metadata columns:
                    seqnames             ranges strand
                       <Rle>          <IRanges>  <Rle>
  Xetrov90010392m.g    Chr04 [9794473, 9794473]      -
               pax6    Chr04 [9859219, 9859219]      +
  -------
  seqinfo: 1515 sequences from an unspecified genome; no seqlengths




> distanceToNearest(ALL_merged_summits.gr["All_merged_peak_37393"], TSS[c("Xetrov90010392m.g", "pax6")])
Hits object with 1 hit and 1 metadata column:
      queryHits subjectHits |  distance
      <integer>   <integer> | <integer>
  [1]         1           1 |     59404
  -------
  queryLength: 1 / subjectLength: 2




> distanceToNearest(ALL_merged_summits.gr["All_merged_peak_37393"], TSS[c("pax6", "Xetrov90010392m.g")])
Hits object with 1 hit and 1 metadata column:
      queryHits subjectHits |  distance
      <integer>   <integer> | <integer>
  [1]         1           1 |      4941
  -------
  queryLength: 1 / subjectLength: 2
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] topGO_2.28.0         SparseM_1.77         GO.db_3.4.1          graph_1.54.0         AnnotationDbi_1.38.2
 [6] Biobase_2.36.2       biomaRt_2.32.1       VennDiagram_1.6.17   futile.logger_1.4.3  RColorBrewer_1.1-2  
[11] knitr_1.17           ggplot2_2.2.1        GenomicRanges_1.28.6 GenomeInfoDb_1.12.3  IRanges_2.10.5      
[16] S4Vectors_0.14.7     BiocGenerics_0.22.1  kableExtra_0.6.1     edgeR_3.18.1         limma_3.32.10       

loaded via a namespace (and not attached):
 [1] httr_1.3.1              tidyr_0.7.2             splines_3.4.2           bit64_0.9-7            
 [5] jsonlite_1.5            viridisLite_0.2.0       modelr_0.1.1            assertthat_0.2.0       
 [9] highr_0.6               blob_1.1.0              GenomeInfoDbData_0.99.0 cellranger_1.1.0       
[13] RSQLite_2.0             backports_1.1.1         lattice_0.20-35         glue_1.2.0             
[17] digest_0.6.12           XVector_0.16.0          rvest_0.3.2             colorspace_1.3-2       
[21] htmltools_0.3.6         plyr_1.8.4              psych_1.7.8             XML_3.98-1.9           
[25] pkgconfig_2.0.1         broom_0.4.2             haven_1.1.0             zlibbioc_1.22.0        
[29] purrr_0.2.4             scales_0.5.0            tibble_1.3.4            lazyeval_0.2.1         
[33] mnormt_1.5-5            magrittr_1.5            crayon_1.3.4            readxl_1.0.0           
[37] memoise_1.1.0           evaluate_0.10.1         nlme_3.1-131            forcats_0.2.0          
[41] xml2_1.1.1              foreign_0.8-69          tools_3.4.2             hms_0.3                
[45] matrixStats_0.52.2      stringr_1.2.0           munsell_0.4.3           locfit_1.5-9.1         
[49] lambda.r_1.2            bindrcpp_0.2            compiler_3.4.2          rlang_0.1.4            
[53] RCurl_1.95-4.8          rstudioapi_0.7          bitops_1.0-6            rmarkdown_1.6          
[57] gtable_0.2.0            DBI_0.7                 reshape2_1.4.2          R6_2.2.2               
[61] lubridate_1.7.1         dplyr_0.7.4             bit_1.1-12              bindr_0.1              
[65] rprojroot_1.2           futile.options_1.0.0    readr_1.1.1             stringi_1.1.5          
[69] Rcpp_0.12.13           
> 

 

GRanges distancetonearest • 1.4k views
ADD COMMENT
2
Entering edit mode
Julie Zhu ★ 4.3k
@julie-zhu-3596
Last seen 13 months ago
United States

Ok. If you set ignore.strand = TRUE, you will get the one with shortest distance.

distanceToNearest(x, TSS, ignore.strand= TRUE)
Hits object with 1 hit and 1 metadata column:
      queryHits subjectHits |  distance
      <integer>   <integer> | <integer>
  [1]         1           2 |      4941

 

Best regards,

Julie

ADD COMMENT
0
Entering edit mode

Thank you very much!

ADD REPLY
0
Entering edit mode
You are very welcome! Best regards, Julie Activity on a post you are following on support.bioconductor.org<https: support.bioconductor.org=""> User chitsazanalex<https: support.bioconductor.org="" u="" 11765=""/> wrote Comment: DistanceToNearest Not giving nearest Range<https: support.bioconductor.org="" p="" 104015="" #104079="">: Thank you very much! ________________________________ Post tags: GRanges, distancetonearest You may reply via email or visit C: DistanceToNearest Not giving nearest Range
ADD REPLY
0
Entering edit mode
Julie Zhu ★ 4.3k
@julie-zhu-3596
Last seen 13 months ago
United States
Looks like that you are trying to annotate peaks. If that is the case, you might want to try the function annotatePeakInBatch in the ChIPpeakAnno package http://bioconductor.org/packages/release/bioc/html/ChIPpeakAnno.html. Best regards, Julie Activity on a post you are following on support.bioconductor.org<https: support.bioconductor.org=""> User chitsazanalex<https: support.bioconductor.org="" u="" 11765=""/> wrote Question: DistanceToNearest Not giving nearest Range<https: support.bioconductor.org="" p="" 104015=""/>: I'm having trouble why the order of my subject is calling two different nearest cordinates. One is obviously closer, but for some reason it's chosing the first one rather than the actual nearest one. How can I fix this? Thanks! Here is my code and a session_info() printout. > ALL_merged_summits.gr["All_merged_peak_37393"] GRanges object with 1 range and 4 metadata columns: seqnames ranges strand | Peak Pileup Gene <rle> <iranges> <rle> | <factor> <numeric> <character> All_merged_peak_37393 Chr04 [9853878, 9854277] * | All_merged_peak_37393 3.1272 Xetrov90010392m.g DistanceToTSS <numeric> All_merged_peak_37393 -59404 ------- seqinfo: 3748 sequences from an unspecified genome; no seqlengths > TSS[c("Xetrov90010392m.g", "pax6")] GRanges object with 2 ranges and 0 metadata columns: seqnames ranges strand <rle> <iranges> <rle> Xetrov90010392m.g Chr04 [9794473, 9794473] - pax6 Chr04 [9859219, 9859219] + ------- seqinfo: 1515 sequences from an unspecified genome; no seqlengths > distanceToNearestALL_merged_summits.gr["All_merged_peak_37393"], TSS[c("Xetrov90010392m.g", "pax6")]) Hits object with 1 hit and 1 metadata column: queryHits subjectHits | distance <integer> <integer> | <integer> [1] 1 1 | 59404 ------- queryLength: 1 / subjectLength: 2 > distanceToNearestALL_merged_summits.gr["All_merged_peak_37393"], TSS[c("pax6", "Xetrov90010392m.g")]) Hits object with 1 hit and 1 metadata column: queryHits subjectHits | distance <integer> <integer> | <integer> [1] 1 1 | 4941 ------- queryLength: 1 / subjectLength: 2 > sessionInfo() R version 3.4.2 (2017-09-28) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.1 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid parallel stats4 stats graphics grDevices utils datasets methods base other attached packages: [1] topGO_2.28.0 SparseM_1.77 GO.db_3.4.1 graph_1.54.0 AnnotationDbi_1.38.2 [6] Biobase_2.36.2 biomaRt_2.32.1 VennDiagram_1.6.17 futile.logger_1.4.3 RColorBrewer_1.1-2 [11] knitr_1.17 ggplot2_2.2.1 GenomicRanges_1.28.6 GenomeInfoDb_1.12.3 IRanges_2.10.5 [16] S4Vectors_0.14.7 BiocGenerics_0.22.1 kableExtra_0.6.1 edgeR_3.18.1 limma_3.32.10 loaded via a namespace (and not attached): [1] httr_1.3.1 tidyr_0.7.2 splines_3.4.2 bit64_0.9-7 [5] jsonlite_1.5 viridisLite_0.2.0 modelr_0.1.1 assertthat_0.2.0 [9] highr_0.6 blob_1.1.0 GenomeInfoDbData_0.99.0 cellranger_1.1.0 [13] RSQLite_2.0 backports_1.1.1 lattice_0.20-35 glue_1.2.0 [17] digest_0.6.12 XVector_0.16.0 rvest_0.3.2 colorspace_1.3-2 [21] htmltools_0.3.6 plyr_1.8.4 psych_1.7.8 XML_3.98-1.9 [25] pkgconfig_2.0.1 broom_0.4.2 haven_1.1.0 zlibbioc_1.22.0 [29] purrr_0.2.4 scales_0.5.0 tibble_1.3.4 lazyeval_0.2.1 [33] mnormt_1.5-5 magrittr_1.5 crayon_1.3.4 readxl_1.0.0 [37] memoise_1.1.0 evaluate_0.10.1 nlme_3.1-131 forcats_0.2.0 [41] xml2_1.1.1 foreign_0.8-69 tools_3.4.2 hms_0.3 [45] matrixStats_0.52.2 stringr_1.2.0 munsell_0.4.3 locfit_1.5-9.1 [49] lambda.r_1.2 bindrcpp_0.2 compiler_3.4.2 rlang_0.1.4 [53] RCurl_1.95-4.8 rstudioapi_0.7 bitops_1.0-6 rmarkdown_1.6 [57] gtable_0.2.0 DBI_0.7 reshape2_1.4.2 R6_2.2.2 [61] lubridate_1.7.1 dplyr_0.7.4 bit_1.1-12 bindr_0.1 [65] rprojroot_1.2 futile.options_1.0.0 readr_1.1.1 stringi_1.1.5 [69] Rcpp_0.12.13 > ________________________________ Post tags: GRanges, distancetonearest You may reply via email or visit DistanceToNearest Not giving nearest Range
ADD COMMENT
0
Entering edit mode

I'm doing more than that. It's a function I have that can map any set of ranges to another, not just annotate peaks as it is in this function. Sometimes it's peaks. Sometimes it's an ENCODE dataset, a bed file, etc. I'd more would like to figure out why DistanceToNearest doesn't chose the nearest range, rather than a completely different package/function 

ADD REPLY

Login before adding your answer.

Traffic: 645 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6