Code Monkey home page Code Monkey logo

Comments (8)

fairliereese avatar fairliereese commented on September 27, 2024 1

I've been having issues like this as well. Rolling back to 0.0.127 seems to work for me to solve some issues.

from pyranges.

endrebak avatar endrebak commented on September 27, 2024

I'll look into it soon. Thanks!

from pyranges.

fairliereese avatar fairliereese commented on September 27, 2024

To give some more detail, I'm having issues when trying to use join on two stranded PyRanges objects. I suspect something under the hood is causing this issue.

Pdb) bed1.head()
+--------------+-----------+-----------+--------------+----------------------+----------------------------+------------+-------+
| Chromosome   |     Start |       End | Strand       | Name                 | source                     | novelty    | +3    |
| (category)   |   (int64) |   (int64) | (category)   | (object)             | (object)                   | (object)   | ...   |
|--------------+-----------+-----------+--------------+----------------------+----------------------------+------------+-------|
| chr1         |  75945539 |  75945646 | +            | ENCODEMG000099158_1  | lapa                       | Novel      | ...   |
| chr1         |  85973317 |  85973418 | +            | ENCODEMG000101206_1  | lapa,polya_atlas           | Novel      | ...   |
| chr1         | 166166458 | 166166560 | +            | ENSMUSG00000000544_1 | vM25,vM21,lapa,polya_atlas | Known      | ...   |
| chr1         | 166154085 | 166154186 | +            | ENSMUSG00000000544_2 | vM25,vM21,lapa,polya_atlas | Known      | ...   |
| chr1         | 166157478 | 166157579 | +            | ENSMUSG00000000544_3 | vM25,vM21                  | Known      | ...   |
| chr1         |  36528186 |  36528287 | +            | ENSMUSG00000001138_1 | vM25,vM21,lapa,polya_atlas | Known      | ...   |
| chr1         |  36519523 |  36519624 | +            | ENSMUSG00000001138_2 | vM25,vM21,lapa             | Known      | ...   |
| chr1         |  36520384 |  36520485 | +            | ENSMUSG00000001138_3 | vM25,vM21,lapa             | Known      | ...   |
+--------------+-----------+-----------+--------------+----------------------+----------------------------+------------+-------+
Stranded PyRanges object has 8 rows and 10 columns from 1 chromosomes.
For printing, the PyRanges was sorted on Chromosome and Strand.
3 hidden columns: gene_id, tes, id
Pdb) bed2.head()
+--------------+-----------+-----------+--------------+----------------------+------------+--------------------+-----------+-------+
| Chromosome   |     Start |       End | Strand       | Name                 | source     | gene_id            |       tes | +2    |
| (category)   |   (int64) |   (int64) | (category)   | (object)             | (object)   | (object)           |   (int64) | ...   |
|--------------+-----------+-----------+--------------+----------------------+------------+--------------------+-----------+-------|
| chr1         |  36527164 |  36527265 | +            | ENSMUSG00000001138_1 | s2         | ENSMUSG00000001138 |         1 | ...   |
| chr1         |  36528186 |  36528287 | +            | ENSMUSG00000001138_2 | s2         | ENSMUSG00000001138 |         2 | ...   |
| chr1         |  39545328 |  39545429 | +            | ENSMUSG00000003135_1 | s2         | ENSMUSG00000003135 |         1 | ...   |
| chr1         |  39546822 |  39546933 | +            | ENSMUSG00000003135_2 | s2         | ENSMUSG00000003135 |         2 | ...   |
| chr1         | 172130960 | 172131061 | +            | ENSMUSG00000003464_1 | s2         | ENSMUSG00000003464 |         1 | ...   |
| chr1         | 172135229 | 172135333 | +            | ENSMUSG00000003464_2 | s2         | ENSMUSG00000003464 |         2 | ...   |
| chr1         | 172135725 | 172135826 | +            | ENSMUSG00000003464_3 | s2         | ENSMUSG00000003464 |         3 | ...   |
| chr1         | 172136439 | 172136540 | +            | ENSMUSG00000003464_4 | s2         | ENSMUSG00000003464 |         4 | ...   |
+--------------+-----------+-----------+--------------+----------------------+------------+--------------------+-----------+-------+
Stranded PyRanges object has 8 rows and 10 columns from 1 chromosomes.
For printing, the PyRanges was sorted on Chromosome and Strand.
2 hidden columns: novelty, id

PyRanges join command:

temp_joined = bed1.join(bed2,
            strandedness='same',
            suffix='_new',
            slack=slack,
            how='left')

Error:

AssertionError: Can only do stranded operations when both PyRanges contain strand info

Hopefully this extra detail helps!

from pyranges.

fairliereese avatar fairliereese commented on September 27, 2024

Okay I've actually taken a look at what is actually going on here. Looks like when PyRanges objects are initialized, possibly from older PyRanges objects that were already read in, or from PyRanges objects that have been converted to pandas DataFrames and back, this condition is satisfied because the Strand PyRanges column is by default given a Categorical dtype with categories '.', '+', and '-':

(From check_strandedness() in methods/init.py

    if str(df.Strand.dtype) == "category" and (set(df.Strand.cat.categories) - set("+-")):
         contains_more_than_plus_minus_in_strand_col = True

I'm not going to try to submit a PR to change this because I want to make sure the bug can be addressed in a way that's consistent with how the rest of the package behaves, but I will probably just comment out the above code in my fork so that I can get on with my life. Hopefully this also helps!

from pyranges.

endrebak avatar endrebak commented on September 27, 2024

Thanks. I have Friday in two weeks off and will look at it then.

from pyranges.

endrebak avatar endrebak commented on September 27, 2024

Looking at it now :) Perhaps related to the fix for

#342

from pyranges.

endrebak avatar endrebak commented on September 27, 2024

I am unable to reproduce. Can you show me a reproducible example? Perhaps by sharing the data you use? :D

from pyranges.

endrebak avatar endrebak commented on September 27, 2024

The reported issue might also be different from yours @fairliereese Would you mind creating a new issue and I'll have a look?

Btw: I started a hypothesis run that generated 10,000 example triplets of PyRanges and tried joining them in a chain with how="left" and I did not get your reported error once.

from pyranges.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.