text: user16242: I would like to add n (e.g., 1k) bases to a PyRange object (i.e., shifting PyRanges coordinates).
  How can I do that?
  Input:
  import pyranges as pr
  gr = pr.random(3)
  
  # gr:
  # +--------------+-----------+-----------+--------------+
  # | Chromosome   |     Start |       End | Strand       |
  # | (category)   |   (int32) |   (int32) | (category)   |
  # |--------------+-----------+-----------+--------------|
  # | chr1         |  10000000 |  20000000 | -            |
  # | chr2         |  20000000 |  30000000 | +            |
  # | chr22        |  30000000 |  40000000 | -            |
  # +--------------+-----------+-----------+--------------+
  
  Desired output:
  # magical command[gr + 1000]:
  # +--------------+-----------+-----------+--------------+
  # | Chromosome   |     Start |       End | Strand       |
  # | (category)   |   (int32) |   (int32) | (category)   |
  # |--------------+-----------+-----------+--------------|
  # | chr1         |  10001000 |  20001000 | -            |
  # | chr2         |  20001000 |  30001000 | +            |
  # | chr22        |  30001000 |  40001000 | -            |
  # +--------------+-----------+-----------+--------------+
  
  
  user3541: You can use the .extend() method. Starting with your data above, gr.extend({"3": -10000, "5": 10000}) would generate the following:
  +--------------+-----------+-----------+--------------+
  | Chromosome   |     Start |       End | Strand       |
  | (category)   |   (int32) |   (int32) | (category)   |
  |--------------+-----------+-----------+--------------|
  | chr1         |  10010000 |  20010000 | -            |
  | chr2         |  19990000 |  29990000 | +            |
  | chr22        |  30010000 |  40010000 | -            |
  +--------------+-----------+-----------+--------------+
  
  I don't know a way of to apply this "range extension" in a strand specific way (to be able to generate the desired output exactly) but if this is really needed, you should be able to generate 2 gr objects, one for each strand, do the manipulation and bring these together.
  
original_text: 16242: <p>I would like to add <code>n</code> (e.g., 1k) bases to a PyRange object (i.e., shifting PyRanges coordinates).
  How can I do that?</p>
  <p><strong>Input:</strong></p>
  <pre class="lang-py prettyprint-override"><code>import pyranges as pr
  gr = pr.random(3)
  
  # gr:
  # +--------------+-----------+-----------+--------------+
  # | Chromosome   |     Start |       End | Strand       |
  # | (category)   |   (int32) |   (int32) | (category)   |
  # |--------------+-----------+-----------+--------------|
  # | chr1         |  10000000 |  20000000 | -            |
  # | chr2         |  20000000 |  30000000 | +            |
  # | chr22        |  30000000 |  40000000 | -            |
  # +--------------+-----------+-----------+--------------+
  </code></pre>
  <p><strong>Desired output:</strong></p>
  <pre class="lang-py prettyprint-override"><code># magical command[gr + 1000]:
  # +--------------+-----------+-----------+--------------+
  # | Chromosome   |     Start |       End | Strand       |
  # | (category)   |   (int32) |   (int32) | (category)   |
  # |--------------+-----------+-----------+--------------|
  # | chr1         |  10001000 |  20001000 | -            |
  # | chr2         |  20001000 |  30001000 | +            |
  # | chr22        |  30001000 |  40001000 | -            |
  # +--------------+-----------+-----------+--------------+
  </code></pre>
   3541: <p>You can use the <code>.extend()</code> method. Starting with your data above, <code>gr.extend({&quot;3&quot;: -10000, &quot;5&quot;: 10000})</code> would generate the following:</p>
  <pre><code>+--------------+-----------+-----------+--------------+
  | Chromosome   |     Start |       End | Strand       |
  | (category)   |   (int32) |   (int32) | (category)   |
  |--------------+-----------+-----------+--------------|
  | chr1         |  10010000 |  20010000 | -            |
  | chr2         |  19990000 |  29990000 | +            |
  | chr22        |  30010000 |  40010000 | -            |
  +--------------+-----------+-----------+--------------+
  </code></pre>
  <p>I don't know a way of to apply this &quot;range extension&quot; in a strand specific way (to be able to generate the desired output exactly) but if this is really needed, you should be able to generate 2 <code>gr</code> objects, one for each strand, do the manipulation and bring these together.</p>
  