Skip to content

Commit 6eb4f93

Browse files
authored
0.0.57 (10.10.19): add overlap-flag to tile + bugfixes (#34)
* 0.0.57 (10.10.19): add overlap-flag to tile + bugfixes - add overlap-flag to tile - add chain to print-method - bugfix: printing stranded pyranges sorted output even though sort was false - bugfix: wrong number hidden cols on very small terminal widths - bugfix: unstrand did not change underlying dict to chromosomes only - show number of hidden columns in header - tests: mismatches in strand between dict and dataframes * Fix bug in tile overlap * Fix tests * Fix tile overlap * df/as_df returns non-duplicated index
1 parent 59e6e8e commit 6eb4f93

31 files changed

Lines changed: 576 additions & 422 deletions

CHANGELOG.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
# 0.0.57 (unreleased)
1+
# 0.0.57 (10.10.19)
22
- add overlap-flag to tile
33
- add chain to print-method
44
- bugfix: printing stranded pyranges sorted output even though sort was false
5+
- bugfix: wrong number hidden cols on very small terminal widths
6+
- bugfix: unstrand did not change underlying dict to chromosomes only
7+
- show number of hidden columns in header
8+
- tests: mismatches in strand between dict and dataframes
9+
- .df/.as_df() now returns with non-duplicated index
510

6-
# 0.0.56 (25.09.19)
11+
# 0).0.56 (25.09.19)
712
- add possibility of 5-end and 3-end in slack being different/none
813
- add slack to join-method
914
- add new_position method to take union or intersection of two pairs of Start/End-columns in pyranges

docs/applying-custom-methods-to-pairs-of-pyranges.html

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,18 @@ <h1><span class="header-section-number">13</span> Applying custom methods to pai
235235
## | Chromosome | Start | End | Name | Score | Strand |
236236
## | (category) | (int32) | (int32) | (object) | (int64) | (category) |
237237
## |--------------+-----------+-----------+------------+-----------+--------------|
238-
## | chr1 | 100079649 | 100079674 | U0 | 0 | - |
239-
## | chr1 | 144227079 | 144227104 | U0 | 0 | + |
240-
## | chr1 | 156338310 | 156338335 | U0 | 0 | - |
238+
## | chr1 | 212609534 | 212609559 | U0 | 0 | + |
241239
## | chr1 | 169887529 | 169887554 | U0 | 0 | + |
240+
## | chr1 | 216711011 | 216711036 | U0 | 0 | + |
241+
## | chr1 | 144227079 | 144227104 | U0 | 0 | + |
242242
## | ... | ... | ... | ... | ... | ... |
243-
## | chrY | 21559181 | 21559206 | U0 | 0 | + |
244243
## | chrY | 21751211 | 21751236 | U0 | 0 | - |
244+
## | chrY | 7701983 | 7702008 | U0 | 0 | - |
245245
## | chrY | 21910706 | 21910731 | U0 | 0 | - |
246246
## | chrY | 22054002 | 22054027 | U0 | 0 | - |
247247
## +--------------+-----------+-----------+------------+-----------+--------------+
248-
## Stranded PyRanges object has 240 rows and 6 columns from 24 chromosomes.</code></pre>
248+
## Stranded PyRanges object has 240 rows and 6 columns from 24 chromosomes.
249+
## The PyRanges is sorted on Chromosome and Strand.</code></pre>
249250
<div class="sourceCode" id="cb160"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb160-1" data-line-number="1"><span class="kw">def</span> set_start_to_zero(df):</a>
250251
<a class="sourceLine" id="cb160-2" data-line-number="2"> df.Start <span class="op">=</span> <span class="dv">0</span></a>
251252
<a class="sourceLine" id="cb160-3" data-line-number="3"> <span class="cf">return</span> df</a>
@@ -255,17 +256,18 @@ <h1><span class="header-section-number">13</span> Applying custom methods to pai
255256
## | Chromosome | Start | End | Name | Score | Strand |
256257
## | (category) | (int64) | (int32) | (object) | (int64) | (category) |
257258
## |--------------+-----------+-----------+------------+-----------+--------------|
258-
## | chr1 | 0 | 100079674 | U0 | 0 | - |
259-
## | chr1 | 0 | 144227104 | U0 | 0 | + |
260-
## | chr1 | 0 | 156338335 | U0 | 0 | - |
259+
## | chr1 | 0 | 212609559 | U0 | 0 | + |
261260
## | chr1 | 0 | 169887554 | U0 | 0 | + |
261+
## | chr1 | 0 | 216711036 | U0 | 0 | + |
262+
## | chr1 | 0 | 144227104 | U0 | 0 | + |
262263
## | ... | ... | ... | ... | ... | ... |
263-
## | chrY | 0 | 11942795 | U0 | 0 | + |
264-
## | chrY | 0 | 13517917 | U0 | 0 | - |
265264
## | chrY | 0 | 15224260 | U0 | 0 | - |
266-
## | chrY | 0 | 21559206 | U0 | 0 | + |
265+
## | chrY | 0 | 13517917 | U0 | 0 | - |
266+
## | chrY | 0 | 8010976 | U0 | 0 | - |
267+
## | chrY | 0 | 7405401 | U0 | 0 | - |
267268
## +--------------+-----------+-----------+------------+-----------+--------------+
268-
## Stranded PyRanges object has 10,000 rows and 6 columns from 24 chromosomes.</code></pre>
269+
## Stranded PyRanges object has 10,000 rows and 6 columns from 24 chromosomes.
270+
## The PyRanges is sorted on Chromosome and Strand.</code></pre>
269271
<p>Keyword arguments can be sent to the function:</p>
270272
<div class="sourceCode" id="cb162"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb162-1" data-line-number="1"><span class="kw">def</span> _print(df, kwargs):</a>
271273
<a class="sourceLine" id="cb162-2" data-line-number="2"> <span class="bu">print</span>(<span class="st">&quot;My keyword arguments were:&quot;</span>, kwargs.get(<span class="st">&quot;value&quot;</span>), <span class="st">&quot;and&quot;</span>, kwargs.get(<span class="st">&quot;whatever&quot;</span>))</a>
@@ -324,17 +326,18 @@ <h1><span class="header-section-number">13</span> Applying custom methods to pai
324326
## | Chromosome | Start | End | Name | Score | Strand |
325327
## | (category) | (int64) | (int32) | (object) | (int64) | (category) |
326328
## |--------------+-----------+-----------+------------+-----------+--------------|
327-
## | chr1 | 0 | 100079674 | U0 | 0 | - |
328-
## | chr1 | 0 | 144227104 | U0 | 0 | + |
329-
## | chr1 | 0 | 156338335 | U0 | 0 | - |
329+
## | chr1 | 0 | 212609559 | U0 | 0 | + |
330330
## | chr1 | 0 | 169887554 | U0 | 0 | + |
331+
## | chr1 | 0 | 216711036 | U0 | 0 | + |
332+
## | chr1 | 0 | 144227104 | U0 | 0 | + |
331333
## | ... | ... | ... | ... | ... | ... |
332-
## | chrY | 0 | 11942795 | U0 | 0 | + |
333-
## | chrY | 0 | 13517917 | U0 | 0 | - |
334334
## | chrY | 0 | 15224260 | U0 | 0 | - |
335-
## | chrY | 0 | 21559206 | U0 | 0 | + |
335+
## | chrY | 0 | 13517917 | U0 | 0 | - |
336+
## | chrY | 0 | 8010976 | U0 | 0 | - |
337+
## | chrY | 0 | 7405401 | U0 | 0 | - |
336338
## +--------------+-----------+-----------+------------+-----------+--------------+
337-
## Stranded PyRanges object has 10,000 rows and 6 columns from 24 chromosomes.</code></pre>
339+
## Stranded PyRanges object has 10,000 rows and 6 columns from 24 chromosomes.
340+
## The PyRanges is sorted on Chromosome and Strand.</code></pre>
338341
<p>They were printed 24 times since the function was applied once per chromosome.</p>
339342
<p>apply_chunks splits each chromosome into <code>nb_cpu</code> chunks and runs each chunk in
340343
parallel, which is useful for slow row-based operations (like fisher exact, for

docs/concatenating-pyranges.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ <h1><span class="header-section-number">6</span> Concatenating PyRanges</h1>
187187
## | chr1 | 8 | 9 | interval3 | 0 | + |
188188
## | chr1 | 5 | 7 | interval2 | 0 | - |
189189
## +--------------+-----------+-----------+------------+-----------+--------------+
190-
## Stranded PyRanges object has 3 rows and 6 columns from 1 chromosomes.</code></pre>
190+
## Stranded PyRanges object has 3 rows and 6 columns from 1 chromosomes.
191+
## The PyRanges is sorted on Chromosome and Strand.</code></pre>
191192
<div class="sourceCode" id="cb88"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb88-1" data-line-number="1"><span class="bu">print</span>(gr2)</a></code></pre></div>
192193
<pre><code>## +--------------+-----------+-----------+------------+-----------+--------------+
193194
## | Chromosome | Start | End | Name | Score | Strand |
@@ -196,7 +197,8 @@ <h1><span class="header-section-number">6</span> Concatenating PyRanges</h1>
196197
## | chr1 | 1 | 2 | a | 0 | + |
197198
## | chr1 | 6 | 7 | b | 0 | - |
198199
## +--------------+-----------+-----------+------------+-----------+--------------+
199-
## Stranded PyRanges object has 2 rows and 6 columns from 1 chromosomes.</code></pre>
200+
## Stranded PyRanges object has 2 rows and 6 columns from 1 chromosomes.
201+
## The PyRanges is sorted on Chromosome and Strand.</code></pre>
200202
<div class="sourceCode" id="cb90"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb90-1" data-line-number="1">concatted <span class="op">=</span> pr.concat([gr1, gr2, gr1])</a>
201203
<a class="sourceLine" id="cb90-2" data-line-number="2"></a>
202204
<a class="sourceLine" id="cb90-3" data-line-number="3"><span class="bu">print</span>(concatted)</a></code></pre></div>
@@ -213,7 +215,8 @@ <h1><span class="header-section-number">6</span> Concatenating PyRanges</h1>
213215
## | chr1 | 6 | 7 | b | 0 | - |
214216
## | chr1 | 5 | 7 | interval2 | 0 | - |
215217
## +--------------+-----------+-----------+------------+-----------+--------------+
216-
## Stranded PyRanges object has 8 rows and 6 columns from 1 chromosomes.</code></pre>
218+
## Stranded PyRanges object has 8 rows and 6 columns from 1 chromosomes.
219+
## The PyRanges is sorted on Chromosome and Strand.</code></pre>
217220

218221
</div>
219222
</section>

docs/fetching-gene-tracks-as-pyranges.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,27 @@ <h1><span class="header-section-number">27</span> Fetching gene tracks as PyRang
203203
## | chr1_GL383519v1_alt | 0 | 110268 |
204204
## | chr1_GL383520v2_alt | 0 | 366580 |
205205
## +---------------------+-----------+-----------+
206-
## Unstranded PyRanges object has 595 rows and 3 columns from 595 chromosomes.</code></pre>
206+
## Unstranded PyRanges object has 595 rows and 3 columns from 595 chromosomes.
207+
## The PyRanges is sorted on Chromosome.</code></pre>
207208
<div class="sourceCode" id="cb295"><pre class="sourceCode python"><code class="sourceCode python"><a class="sourceLine" id="cb295-1" data-line-number="1">genes <span class="op">=</span> pr_db.ucsc.genes(<span class="st">&quot;hg38&quot;</span>, head<span class="op">=</span><span class="va">True</span>)</a>
208209
<a class="sourceLine" id="cb295-2" data-line-number="2"></a>
209210
<a class="sourceLine" id="cb295-3" data-line-number="3"><span class="bu">print</span>(genes)</a></code></pre></div>
210211
<pre><code>## +--------------+-----------+-----------+--------------+--------------+-----------------+--------------+--------------+-------------------+
211212
## | Chromosome | Start | End | Feature | gene_id | transcript_id | Strand | ExonNumber | transcript_name |
212213
## | (category) | (int32) | (int32) | (category) | (category) | (float64) | (category) | (float64) | (category) |
213214
## |--------------+-----------+-----------+--------------+--------------+-----------------+--------------+--------------+-------------------|
214-
## | chr1 | 1385710 | 1398342 | gene | CCNL2 | nan | - | nan | nan |
215-
## | chr1 | 6783891 | 6784980 | gene | CAMTA1-DT | nan | - | nan | nan |
215+
## | chr1 | 12716114 | 12728759 | gene | AADACL3 | nan | + | nan | nan |
216216
## | chr1 | 6785323 | 7769706 | gene | CAMTA1 | nan | + | nan | nan |
217217
## | chr1 | 10430746 | 10442815 | gene | CENPS | nan | + | nan | nan |
218+
## | chr1 | 10430746 | 10452003 | gene | CENPS-CORT | nan | + | nan | nan |
218219
## | ... | ... | ... | ... | ... | ... | ... | ... | ... |
219220
## | chrY | 18547778 | 18548592 | exon | HSFY1 | 244.0 | + | 1.0 | NM_033108 |
220221
## | chrY | 18771813 | 18772627 | exon | HSFY1 | 245.0 | - | 0.0 | NM_033108 |
221222
## | chrY | 18771813 | 18773718 | transcript | HSFY1 | 245.0 | - | nan | NM_033108 |
222223
## | chrY | 18773105 | 18773718 | exon | HSFY1 | 245.0 | - | 1.0 | NM_033108 |
223224
## +--------------+-----------+-----------+--------------+--------------+-----------------+--------------+--------------+-------------------+
224-
## Stranded PyRanges object has 5,858 rows and 9 columns from 54 chromosomes.</code></pre>
225+
## Stranded PyRanges object has 5,858 rows and 9 columns from 54 chromosomes.
226+
## The PyRanges is sorted on Chromosome and Strand.</code></pre>
225227

226228
</div>
227229

0 commit comments

Comments
 (0)