Answers.Body: <p>You can access the data.frame just using <code>$</code>. All of them can be accessed using <code>values()</code> . Something like this:</p>
  <pre><code>library(GenomicRanges)
  gr = GRanges(seqnames=1,IRanges(start=1:10,width=1))
  values(gr) = data.frame(eigen=rnorm(10),ratio=runif(10))
  
  plot(start(gr),gr$eigen)
  </code></pre>
  <p>or</p>
  <pre><code>plot(start(gr),values(gr)$eigen)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-18T14:56:08.977Z
Answers.LastActivityDate: 2020-06-18T14:56:08.977Z
Answers.UserDisplayName: StupidWolf
Body: <p>I have a GRanges object with metadata that I want to plot. Many of the online tutorials which manipulate these GRanges for plotting show how to plot the main columns (chromosome,start/end,strand) but nothing to plot the metadata as a function of the position in each row.</p>
  
  <p>How precisely should I do this? Ideally, I would like to plot metadata from multiple GRanges objects on the same plot to compare them.</p>
  
  <p>EDIT (following comment):</p>
  
  <pre><code>GRanges object with 6 ranges and 140 metadata columns:
        seqnames        ranges strand |
           &lt;Rle&gt;     &lt;IRanges&gt;  &lt;Rle&gt; |
    [1]     chr1 100000-199999      * |
    [2]     chr1 400000-499999      * |
    [3]     chr1 600000-699999      * |
    [4]     chr1 700000-799999      * |
    [5]     chr1 800000-899999      * |
    [6]     chr1 900000-999999      * |
                    eigen   domain         arm
                &lt;numeric&gt; &lt;factor&gt; &lt;character&gt;
    [1] -1.62475825405065     open          1p
    [2] -1.62475825405065     open          1p
    [3] -1.62475825405065     open          1p
    [4] -1.62475825405065     open          1p
    [5] -1.63354915136132     open          1p
    [6]  -1.6322733358426     open          1p
        exon.fraction       gc     short      long
            &lt;numeric&gt; &lt;matrix&gt; &lt;numeric&gt; &lt;numeric&gt;
    [1]       0.02968  0.45815         0         0
    [2]       0.04305  0.40192         0         0
    [3]       0.00959  0.42091         0         0
    [4]       0.04593  0.43337         0         1
    [5]       0.02425  0.44822         2         1
    [6]       0.16977  0.62123        27        56
           nfrags             ratio   short.corrected
        &lt;numeric&gt;         &lt;numeric&gt;         &lt;numeric&gt;
    [1]         0               NaN              &lt;NA&gt;
    [2]         0               NaN              &lt;NA&gt;
    [3]         0               NaN              &lt;NA&gt;
    [4]         1                 0 -3.50822623240367
    [5]         3                 2  2.81796238367926
    [6]        83 0.482142857142857  39.8824095079959
  ...
  </code></pre>
  
  <p>My question regards plotting a column like <code>eigen</code> as a function of the position (given by <code>seqnames</code> and <code>ranges</code>)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-06-17T13:58:52.890Z
Comments.Text: Can you show us `head(., 10)` for a few of the datasets so we can understand what you're trying to plot?
Comments.UserDisplayName: Ram RS
Tags: <r><bioconductor>
Title: Plotting metadata from GenomicRanges object
ThreadText: # Plotting metadata from GenomicRanges object
  
  (Asked by: username_0 on 2020-06-17)
  
  I have a GRanges object with metadata that I want to plot. Many of the online tutorials which manipulate these GRanges for plotting show how to plot the main columns (chromosome,start/end,strand) but nothing to plot the metadata as a function of the position in each row.
  
  How precisely should I do this? Ideally, I would like to plot metadata from multiple GRanges objects on the same plot to compare them.
  
  EDIT (following comment):
  
  ```
  GRanges object with 6 ranges and 140 metadata columns:
        seqnames        ranges strand |
           <Rle>     <IRanges>  <Rle> |
    [1]     chr1 100000-199999      * |
    [2]     chr1 400000-499999      * |
    [3]     chr1 600000-699999      * |
    [4]     chr1 700000-799999      * |
    [5]     chr1 800000-899999      * |
    [6]     chr1 900000-999999      * |
                    eigen   domain         arm
                <numeric> <factor> <character>
    [1] -1.62475825405065     open          1p
    [2] -1.62475825405065     open          1p
    [3] -1.62475825405065     open          1p
    [4] -1.62475825405065     open          1p
    [5] -1.63354915136132     open          1p
    [6]  -1.6322733358426     open          1p
        exon.fraction       gc     short      long
            <numeric> <matrix> <numeric> <numeric>
    [1]       0.02968  0.45815         0         0
    [2]       0.04305  0.40192         0         0
    [3]       0.00959  0.42091         0         0
    [4]       0.04593  0.43337         0         1
    [5]       0.02425  0.44822         2         1
    [6]       0.16977  0.62123        27        56
           nfrags             ratio   short.corrected
        <numeric>         <numeric>         <numeric>
    [1]         0               NaN              <NA>
    [2]         0               NaN              <NA>
    [3]         0               NaN              <NA>
    [4]         1                 0 -3.50822623240367
    [5]         3                 2  2.81796238367926
    [6]        83 0.482142857142857  39.8824095079959
  ...
  
  ```
  
  My question regards plotting a column like `eigen` as a function of the position (given by `seqnames` and `ranges`)
  
  **Tags:** r, bioconductor
  
  > **Comments:**
  > **username_1**: Can you show us `head(., 10)` for a few of the datasets so we can understand what you're trying to plot?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-06-18. Score: 1
  
  You can access the data.frame just using `$`. All of them can be accessed using `values()` . Something like this:
  
  ```
  library(GenomicRanges)
  gr = GRanges(seqnames=1,IRanges(start=1:10,width=1))
  values(gr) = data.frame(eigen=rnorm(10),ratio=runif(10))
  
  plot(start(gr),gr$eigen)
  
  ```
  
  or
  
  ```
  plot(start(gr),values(gr)$eigen)
  
  ```
  
  
  ---
  
  