Show all lines in GenomicRange package output
Asked Answered
M

3

6

I am working with GenomicRange R package. I have an input file like this:

dvex108056 + 87 206
dvex108056 + 87 226
dvex108056 - 101 240
dvex108056 - 104 240 
dvex108056 - 59 188
dvex108056 - 68 197
dvex108056 - 70 208
dvex108056 - 75 211
dvex108056 - 78 217
dvex108056 - 79 218
dvex108056 - 84 223
dvex108056 - 85 220
dvex108056 - 87 226
dvex108056 - 88 226
dvex108056 - 88 227
dvex108056 - 91 210
dvex108056 - 91 230
dvex114041 - 6255 6383
dvex144086 + 2557 2678
dvex144086 + 2561 2678
dvex144086 + 2562 2678
dvex144086 + 2564 2678
dvex144086 - 2549 2678
dvex186339 + 971 1108
dvex186339 + 971 1112
dvex186339 + 972 1112
dvex186339 + 979 1115
dvex209845 - 428 553
dvex209845 - 436 553
dvex209845 - 445 553
dvex238049 + 435 572
dvex238049 + 435 575
dvex238049 + 435 576
dvex238049 - 400 541
dvex490175 - 5 144
dvex564118 - 476 604
dvex567944 + 1 121
dvex567944 + 1 124 
dvex567944 + 1 125
dvex567944 + 1 129
dvex567944 + 6 125
dvex567944 - 1 130
dvex567944 - 6 125
dvex600495 - 706 844
dvex619713 - 26 165
dvex619713 - 28 167
dvex619713 - 34 173
dvex619713 - 49 185
dvex667132 + 1 119
dvex667132 + 1 99
dvex667132 - 1 120
dvex667132 - 1 121
dvex685093 - 113 242
dvex685093 - 127 243
dvex685093 - 144 243
dvex700401 - 1 120
dvex700401 - 1 130
dvex700401 - 1 132
dvex758265 - 1 139
dvex758265 - 15 154
dvex758265 - 16 155
dvex758265 - 21 160
dvex758265 - 36 172
dvex758265 - 4 140
dvex758265 - 7 146
dvex777870 + 100 200
dvex777870 + 104 200
dvex777870 + 80 200
dvex777870 + 84 200
dvex777870 + 85 200
dvex777870 + 87 200
dvex777870 + 90 200
dvex777870 + 94 200
dvex777870 - 72 200
dvex792767 - 2083 2211
dvex833399 - 434 545
dvex833399 - 435 545
dvex833399 - 437 545

When I use GRanges to reduce all of these lines into overlaping coordinates with these code:

> tabla <- read.table(file="~/Desktop/ncRNA/Data/Inputs/rRNAs/60/Infernal/test3.txt")
> colnames(tabla) <- c('scal', 'strand', 'start', 'end')
> all <- with(tabla, GRanges(scal, IRanges(start, end), strand))
> reduce(all)

R generates an output:

GRanges with 24 ranges and 0 metadata columns:
     seqnames       ranges strand
        <Rle>    <IRanges>  <Rle>
   [1] dvex108056 [  87,  226]      +
   [2] dvex108056 [  59,  240]      -
   [3] dvex114041 [6255, 6383]      -
   [4] dvex144086 [2557, 2678]      +
   [5] dvex144086 [2549, 2678]      -
   ...        ...          ...    ...
  [20] dvex758265 [   1,  172]      -
  [21] dvex777870 [  80,  200]      +
  [22] dvex777870 [  72,  200]      -
  [23] dvex792767 [2083, 2211]      -
  [24] dvex833399 [ 434,  545]      -
  ---
  seqlengths:
   dvex108056 dvex114041 dvex144086 ... dvex777870 dvex792767 dvex833399
           NA         NA         NA ...         NA         NA         NA

I want to print all the output generated by GenomicRanges. Avoiding the ... ... ... line. Is it possible? I believe that is a data.frame structure, but I can not access to all record.

Thanks in advance.

Millihenry answered 5/6, 2013 at 20:45 Comment(0)
M
6

In the current release (v. 1.12.4) on ?GenomicRanges there is this instruction

 ## The number of lines displayed in the 'show' method
 ## are controlled with two global options.
 longGR <- c(gr[,"score"], gr2[,"score"], gr3)
 longGR
 options("showHeadLines"=7)
 options("showTailLines"=2)
 longGR

 ## Revert to default values
 options("showHeadLines"=NULL)
 options("showTailLines"=NULL)

so for instance

options(showTailLines=Inf)

gives you screens full of everything.

Multiform answered 5/6, 2013 at 23:25 Comment(1)
Thanks a lot! that is the solution. Greetings from Bogotá, Colombia.Millihenry
C
2

Convert it to a data.frame and write it out "in the usual way":

red.all <- reduce(all)
write.table(as.data.frame(red.all), ...)
Chary answered 5/6, 2013 at 22:20 Comment(0)
S
0

Try to print it like that

write.table(YourData ,"Howyouwannanameit.tsv", quote=F, coln.names=T, row.names=F)

I'm quite sure it won't have the line ....I think that is just what R does when trying to show you the first and last rows.

Solidstate answered 5/6, 2013 at 21:13 Comment(5)
>write.table(bed ,"Test.tsv", quote=F, col.names=T, row.names=F) Its generated this error: Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class "structure("GRanges", package = "GenomicRanges")" to a data.frameMillihenry
Genera, el mismo error: Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class "structure("GRanges", package = "GenomicRanges")" to a data.frameMillihenry
y si usas solo: >all para ver si sale toda la información (las 24 lineas)Solidstate
Lastimosamente imprime lo mismo.Millihenry
>seqlevels(all) bioconductor.org/packages/2.13/bioc/manuals/GenomicRanges/man/… Te dejo este link igual y te funcione algo de ahiSolidstate

© 2022 - 2024 — McMap. All rights reserved.