Remove entries in a IRangesList
1
0
Entering edit mode
6.4 years ago

Hi! I have an IRangesList with several entries like:

[[1]]
IRanges object with 1 range and 8 metadata columns:
       start       end     width |           tx_id    cds_ok         exon_id exon_rank seq_start   seq_end
   <integer> <integer> <integer> |     <character> <logical>     <character> <integer> <integer> <integer>
          -1        -1         1 | ENST00000281043      <NA> ENSE00000804855         1  16080686  16080760
      seq_name  seq_strand
   <character> <character>
             2           *

[[2]]
IRanges object with 1 range and 8 metadata columns:
       start       end     width |           tx_id    cds_ok         exon_id exon_rank seq_start   seq_end
   <integer> <integer> <integer> |     <character> <logical>     <character> <integer> <integer> <integer>
          -1        -1         1 | ENST00000281043      <NA> ENSE00000804855         1  16080850  16080865
      seq_name  seq_strand
   <character> <character>
             2           *

[[3]]
IRanges object with 2 ranges and 8 metadata columns:
                      start       end     width |           tx_id    cds_ok         exon_id exon_rank
                  <integer> <integer> <integer> |     <character> <logical>     <character> <integer>
  ENSP00000373700      1230      1230         1 | ENST00000389048      TRUE ENSE00001154390        24
        LRG_488p1      1230      1230         1 |       LRG_488t1      TRUE    LRG_488t1e24        24
                  seq_start   seq_end    seq_name  seq_strand
                  <integer> <integer> <character> <character>
  ENSP00000373700  29436905  29436905           2           *
        LRG_488p1  29436905  29436905           2           *

[[4]]
IRanges object with 6 ranges and 8 metadata columns:
                      start       end     width |           tx_id    cds_ok         exon_id exon_rank
                  <integer> <integer> <integer> |     <character> <logical>     <character> <integer>
  ENSP00000260795        80       122        43 | ENST00000260795      TRUE ENSE00001164902         2
  ENSP00000339824        80       122        43 | ENST00000340107      TRUE ENSE00001164902         3
  ENSP00000231803        80       122        43 | ENST00000352904      TRUE ENSE00001164902         2
  ENSP00000412903        80       122        43 | ENST00000412135      TRUE ENSE00001164902         3
  ENSP00000414914        80       122        43 | ENST00000440486      TRUE ENSE00001164902         3
  ENSP00000420533        80       122        43 | ENST00000481110      TRUE ENSE00001164902         3
                  seq_start   seq_end    seq_name  seq_strand
                  <integer> <integer> <character> <character>
  ENSP00000260795   1801109   1801235           4           *
  ENSP00000339824   1801109   1801235           4           *
  ENSP00000231803   1801109   1801235           4           *
  ENSP00000412903   1801109   1801235           4           *
  ENSP00000414914   1801109   1801235           4           *
  ENSP00000420533   1801109   1801235           4           *

I would like to remove the entries that are not well mapped (in this case [[1]], and [[2]]) from the IRangesList without performing unlist.

Any ideas? Thanks!

R • 2.0k views
ADD COMMENT
1
Entering edit mode
6.4 years ago
ATpoint 85k
## Keep entries where the start coordinate is not (-1):
your.list[unlist(lapply(your.list, function(x) start(x) != -1))]

Is it intentional that you use IRanges instead of GenomicRanges, so no chromosome information? Because that forbids all kinds of intersection operations. Or is the <seq_name> the chromosome?

ADD COMMENT
0
Entering edit mode

Hi! Thanks! It worked for me without the unlist function. And yes, <seq_name> gives the chromosome information :).

ADD REPLY

Login before adding your answer.

Traffic: 1645 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