[BioC] Granges: range (gr) does not function

Hervé Pagès hpages at fhcrc.org
Tue Apr 9 17:55:24 CEST 2013


Hi Hermann,

On 04/09/2013 06:37 AM, Hermann Norpois wrote:
> Hello,
>
> I recognised a strange behaviour of range (gr). Shouldnt it treat the whole
> grange object? Like ranges(gr)? But it doesnt.
>
> What's wrong?
> Thanks
> Hermann
>
>> gr
> GRanges with 4 ranges and 1 metadata column:
>               seqnames         ranges strand |       score
>                  <Rle>      <IRanges>  <Rle> | <character>
>    rs55998931     chr1 [10492, 10492]      * |    0.115787
>    rs58108140     chr1 [10583, 10583]      * |    0.394721
>    rs75454623     chr1 [14930, 14930]      * |        0.48
>    rs12401368     chr1 [66507, 66507]      * |    0.499191
>    ---
>    seqlengths:
>                chr1           chr10 ...            chrX            chrY
>                  NA              NA ...              NA              NA
>> ranges (gr)
> IRanges of length 4
>      start   end width      names
> [1] 10492 10492     1 rs55998931
> [2] 10583 10583     1 rs58108140
> [3] 14930 14930     1 rs75454623
> [4] 66507 66507     1 rs12401368
>> range (gr)                # Only gives back gr[1]
> GRanges with 1 range and 0 metadata columns:
>        seqnames         ranges strand
>           <Rle>      <IRanges>  <Rle>
>    [1]     chr1 [10492, 66507]      *
>    ---
>    seqlengths:
>                chr1           chr10 ...            chrX            chrY
>                  NA              NA ...              NA              NA

This is the expected behavior: 1 range per distinct seqname / strand
combination. So in your case, only 1 range, because everything is on
chr1 / *. The fact that it happens to be the same as the 1st input
range is because that range contains all the other ranges. But it's not
always the case:

   > gr
   GRanges with 4 ranges and 0 metadata columns:
         seqnames    ranges strand
            <Rle> <IRanges>  <Rle>
     [1]     chr1  [ 7, 11]      *
     [2]     chr1  [ 6, 10]      *
     [3]     chr1  [ 5,  9]      *
     [4]     chr1  [20, 24]      *
     ---
     seqlengths:
      chr1
        NA
   > range(gr)
   GRanges with 1 range and 0 metadata columns:
         seqnames    ranges strand
            <Rle> <IRanges>  <Rle>
     [1]     chr1   [5, 24]      *
     ---
     seqlengths:
      chr1
        NA

See ?`range,GenomicRanges-method` for the details and more examples.

Cheers,
H.


>> dput (gr)
> new("GRanges"
>      , seqnames = new("Rle"
>      , values = structure(1L, .Label = c("chr1", "chr10", "chr11", "chr12",
> "chr13",
> "chr14", "chr15", "chr16", "chr17", "chr17_ctg5_hap1", "chr18",
> "chr19", "chr2", "chr20", "chr21", "chr22", "chr3", "chr4",
> "chr4_ctg9_hap1",
> "chr5", "chr6", "chr6_apd_hap1", "chr6_cox_hap2", "chr6_dbb_hap3",
> "chr6_mann_hap4", "chr6_mcf_hap5", "chr6_qbl_hap6", "chr6_ssto_hap7",
> "chr7", "chr8", "chr9", "chrM", "chrX", "chrY"), class = "factor")
>      , lengths = 4L
>      , elementMetadata = NULL
>      , metadata = list()
> )
>      , ranges = new("IRanges"
>      , start = c(10492L, 10583L, 14930L, 66507L)
>      , width = c(1L, 1L, 1L, 1L)
>      , NAMES = c("rs55998931", "rs58108140", "rs75454623", "rs12401368")
>      , elementType = "integer"
>      , elementMetadata = NULL
>      , metadata = list()
> )
>      , strand = new("Rle"
>      , values = structure(3L, .Label = c("+", "-", "*"), class = "factor")
>      , lengths = 4L
>      , elementMetadata = NULL
>      , metadata = list()
> )
>      , elementMetadata = new("DataFrame"
>      , rownames = NULL
>      , nrows = 4L
>      , listData = structure(list(score = c("0.115787", "0.394721", "0.48",
> "0.499191"
> )), .Names = "score")
>      , elementType = "ANY"
>      , elementMetadata = NULL
>      , metadata = list()
> )
>      , seqinfo = new("Seqinfo"
>      , seqnames = c("chr1", "chr10", "chr11", "chr12", "chr13", "chr14",
> "chr15",
> "chr16", "chr17", "chr17_ctg5_hap1", "chr18", "chr19", "chr2",
> "chr20", "chr21", "chr22", "chr3", "chr4", "chr4_ctg9_hap1",
> "chr5", "chr6", "chr6_apd_hap1", "chr6_cox_hap2", "chr6_dbb_hap3",
> "chr6_mann_hap4", "chr6_mcf_hap5", "chr6_qbl_hap6", "chr6_ssto_hap7",
> "chr7", "chr8", "chr9", "chrM", "chrX", "chrY")
>      , seqlengths = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> NA_integer_,
> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> NA_integer_, NA_integer_, NA_integer_, NA_integer_, NA_integer_,
> NA_integer_, NA_integer_, NA_integer_, NA_integer_)
>      , is_circular = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
> NA, NA,
> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
> NA, NA, NA)
>      , genome = c("hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
> "hg19",
> "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
> "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
> "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19", "hg19",
> "hg19", "hg19")
> )
>      , metadata = list(<S4 object of class structure("DataFrame", package =
> "IRanges")>)
> )
>> SessionInfo()
> Fehler: konnte Funktion "SessionInfo" nicht finden
>> sessionInfo()
> R version 2.15.3 (2013-03-01)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
>   [1] LC_CTYPE=de_DE.UTF-8       LC_NUMERIC=C
>   [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=de_DE.UTF-8
>   [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=de_DE.UTF-8
>   [7] LC_PAPER=C                 LC_NAME=C
>   [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] GenABEL_1.7-4        MASS_7.3-23          GenomicRanges_1.10.7
> [4] IRanges_1.16.6       BiocGenerics_0.4.0
>
> loaded via a namespace (and not attached):
> [1] compiler_2.15.3 parallel_2.15.3 stats4_2.15.3   tools_2.15.3
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
>

-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioconductor mailing list