Search
Question: an error on GRanges
0
gravatar for Bogdan
11 weeks ago by
Bogdan470
Palo Alto, CA, USA
Bogdan470 wrote:

Dear all, I would appreciate your help on learning how to fix the following error ; thank you !

"Error: subscript is a NSBS object that is incompatible with the current subsetting operation"

I am working with 2 Granges, let's call them "query" and "subject" (as shown below), and the purpose of the R code is to "transfer" the meta-information from "mcols" of "subject" to the "query"'s GRanges that are overlapping the "subject".

> query
GRanges object with 990 ranges and 0 metadata columns:
                           seqnames                 ranges strand
                              <Rle>              <IRanges>  <Rle>
         chr1:10001-140000     chr1      [ 10001,  140000]      *
        chr1:140002-180000     chr1      [140002,  180000]      *
        chr1:340002-530000     chr1      [340002,  530000]      *
        chr1:580002-770000     chr1      [580002,  770000]      *
       chr1:900002-1800000     chr1      [900002, 1800000]      *
                       ...      ...                    ...    ...
  chrX:154150002-154260000     chrX [154150002, 154260000]      *
  chrX:154260002-154560000     chrX [154260002, 154560000]      *
  chrX:154560002-154650000     chrX [154560002, 154650000]      *
  chrX:155340002-155380000     chrX [155340002, 155380000]      *
  chrX:155460002-155500000     chrX [155460002, 155500000]      *

and

> subject
GRanges object with 1081 ranges and 1 metadata column:
                           seqnames                 ranges strand |        name
                              <Rle>              <IRanges>  <Rle> | <character>
             chr1:2-140000     chr1      [     2,  140000]      * |         CN4
        chr1:140002-180000     chr1      [140002,  180000]      * |       CN128
        chr1:340002-530000     chr1      [340002,  530000]      * |        CN32
        chr1:580002-770000     chr1      [580002,  770000]      * |         CN6
       chr1:900002-1800000     chr1      [900002, 1800000]      * |         CN3
                       ...      ...                    ...    ... .         ...
  chrX:154150002-154260000     chrX [154150002, 154260000]      * |        CN32
  chrX:154260002-154560000     chrX [154260002, 154560000]      * |         CN3
  chrX:154560002-154650000     chrX [154560002, 154650000]      * |         CN7
  chrX:155340002-155380000     chrX [155340002, 155380000]      * |       CN128
  chrX:155460002-155500000     chrX [155460002, 155500000]      * |        CN64

The R code is :

ranges <- subsetByOverlaps(query, subject)
hits <- GenomicRanges::findOverlaps(query, subject, ignore.strand=TRUE)
idx <- unique(subjectHits(hits))
values <- DataFrame(cnv_id=names(subject)[idx], cnv_type=subject$name[idx])
mcols(ranges) <- c(mcols(ranges), values)

When we type "ranges", it says :

> ranges
GRanges object with 990 ranges and 4 metadata columns:
Error: subscript is a NSBS object that is incompatible with the current
  subsetting operation

As  for the sessioninfo(), it is :

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

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  stats4    stats     graphics  grDevices utils     datasets
[8] methods   base     

other attached packages:
 [1] dplyr_0.7.1                tidyr_0.6.3               
 [3] plyr_1.8.4                 ggthemes_3.4.0            
 [5] ggplot2_2.2.1              reshape2_1.4.2            
 [7] HelloRanges_1.0.1          GenomicAlignments_1.10.1  
 [9] VariantAnnotation_1.20.3   Rsamtools_1.26.2          
[11] SummarizedExperiment_1.4.0 GenomicFeatures_1.26.4    
[13] AnnotationDbi_1.36.2       Biobase_2.34.0            
[15] BSgenome_1.42.0            Biostrings_2.42.1         
[17] XVector_0.14.1             rtracklayer_1.34.2        
[19] GenomicRanges_1.26.4       GenomeInfoDb_1.10.3       
[21] IRanges_2.8.2              S4Vectors_0.12.2          
[23] BiocGenerics_0.20.0       

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11       bindr_0.1          bitops_1.0-6       tools_3.3.3       
 [5] zlibbioc_1.20.0    biomaRt_2.30.0     digest_0.6.12      bit_1.1-12        
 [9] docopt_0.4.5       gtable_0.2.0       RSQLite_2.0        memoise_1.1.0     
[13] tibble_1.3.3       lattice_0.20-35    pkgconfig_2.0.1    rlang_0.1.1       
[17] Matrix_1.2-10      DBI_0.7            bindrcpp_0.2       stringr_1.2.0     
[21] bit64_0.9-7        grid_3.3.3         glue_1.1.1         R6_2.2.2          
[25] XML_3.98-1.8       BiocParallel_1.8.2 blob_1.1.0         magrittr_1.5.0    
[29] scales_0.4.1       assertthat_0.2.0   colorspace_1.3-2   stringi_1.1.5     
[33] lazyeval_0.2.0     munsell_0.4.3      RCurl_1.95-4.8

 

 

 

 

 

ADD COMMENTlink written 11 weeks ago by Bogdan470

Hi Bogdan,

There are 2 problems with your question. The first is that you are using BioC 3.4 which is old and unsupported (the current Biocconductor release is BioC 3.5). The second is that you're not providing self-contained code (how can we make query and subject?) that we could just copy-and-paste to reproduce the error.

Thanks,

H.

ADD REPLYlink written 11 weeks ago by Hervé Pagès ♦♦ 13k

Dear Herve, 'm happy to hear from you, and many thanks for time, help and suggestions. Will get back on this question, after a few more tests ;)

ADD REPLYlink written 11 weeks ago by Bogdan470

Dear Herve, as an solution for my question above, I am going to use the R code that you've suggested at : 

A: about setdiff() and meta-information in GRanges ; Many thanks again for your kind help !

 

 

ADD REPLYlink written 10 weeks ago by Bogdan470

No problem. Glad the code I suggested works well for you!

Cheers,

H.

ADD REPLYlink written 10 weeks ago by Hervé Pagès ♦♦ 13k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 184 users visited in the last hour