Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inherits(pyr, "pyranges.pyranges.PyRanges") is not TRUE #1

Open
vinodsinghjnu opened this issue Jul 28, 2023 · 3 comments
Open

inherits(pyr, "pyranges.pyranges.PyRanges") is not TRUE #1

vinodsinghjnu opened this issue Jul 28, 2023 · 3 comments

Comments

@vinodsinghjnu
Copy link

vinodsinghjnu commented Jul 28, 2023

Can anybody tell what type of error this is, on a given test example?

> use_python("/home/xx/miniforge3/envs/R.4.2_cloned_mapdemo_env/bin/python3")
> gr <- GRanges("chr1", IRanges(1:3, 20))
> pyr <- makePyRangesFromGRanges(gr)
> pyr  # PyRanges objects follow the 0-based start convention!!

+--------------+-----------+-----------+
| Chromosome   |     Start |       End |
| (category)   |   (int64) |   (int64) |
|--------------+-----------+-----------|
| chr1         |         0 |        20 |
| chr1         |         1 |        20 |
| chr1         |         2 |        20 |
+--------------+-----------+-----------+

> makeGRangesFromPyRanges(pyr)

Unstranded PyRanges object has 3 rows and 3 columns from 1 chromosomes.
For printing, the PyRanges was sorted on Chromosome.
Error in makeGRangesFromPyRanges(pyr) : 
 inherits(pyr, "pyranges.pyranges.PyRanges") is not TRUE
@hpages
Copy link
Owner

hpages commented Aug 11, 2023

Can't reproduce this:

library(BiocPyRanges)

gr <- GRanges("chr1", IRanges(1:3, 20))
pyr <- makePyRangesFromGRanges(gr)

class(pyr)
# [1] "pyranges.pyranges.PyRanges" "python.builtin.object"     

inherits(pyr, "pyranges.pyranges.PyRanges")
# [1] TRUE

makeGRangesFromPyRanges(pyr)
# GRanges object with 3 ranges and 0 metadata columns:
#       seqnames    ranges strand
#          <Rle> <IRanges>  <Rle>
#   [1]     chr1      1-20      *
#   [2]     chr1      2-20      *
#   [3]     chr1      3-20      *
#   -------
#   seqinfo: 1 sequence from an unspecified genome; no seqlengths

What versions of pyranges + pandas are you using and what's your sessionInfo()? See mines below.

Best,
H.

> subset(py_list_packages(), package %in% c("pandas", "pyranges"))
    package version       requirement
77   pandas   1.5.3     pandas==1.5.3
92 pyranges 0.0.111 pyranges==0.0.111

sessionInfo():

R version 4.3.0 Patched (2023-05-31 r84481)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 23.04

Matrix products: default
BLAS:   /home/hpages/R/R-4.3.r84481/lib/libRblas.so 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.11.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Los_Angeles
tzcode source: system (glibc)

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] BiocPyRanges_0.0.1   GenomicRanges_1.52.0 GenomeInfoDb_1.36.1 
[4] IRanges_2.34.1       S4Vectors_0.38.1     BiocGenerics_0.46.0 
[7] reticulate_1.31     

loaded via a namespace (and not attached):
 [1] zlibbioc_1.46.0         Matrix_1.6-0            lattice_0.21-8         
 [4] GenomeInfoDbData_1.2.10 XVector_0.40.0          RCurl_1.98-1.12        
 [7] png_0.1-8               bitops_1.0-7            cli_3.6.1              
[10] grid_4.3.0              compiler_4.3.0          tools_4.3.0            
[13] Rcpp_1.0.11             rlang_1.1.1             jsonlite_1.8.7         

@vinodsinghjnu
Copy link
Author

vinodsinghjnu commented Aug 11, 2023

Thankyou Hervé Pagès, for your quick response and putting your efforts to a tool that have huge opportunities.

Here are my details of the code and R environment. Please note that I am running R under conda environment

> use_python("/home/xx/miniforge3/envs/R.4.2_cloned_mapdemo_env/bin/python3")
> gr <- GRanges("chr1", IRanges(1:3, 20))
> pyr <- makePyRangesFromGRanges(gr)
> makeGRangesFromPyRanges(pyr)
Error in makeGRangesFromPyRanges(pyr) : 
  inherits(pyr, "pyranges.pyranges.PyRanges") is not TRUE
> 
> class(pyr)
[1] "pyranges.pyranges_main.PyRanges" "python.builtin.object"          
> inherits(pyr, "pyranges.pyranges.PyRanges")
[1] FALSE
> 
> subset(py_list_packages(), package %in% c("pandas", "pyranges"))
     package version      requirement     channel
173   pandas   2.0.3     pandas=2.0.3 conda-forge
202 pyranges 0.0.129 pyranges=0.0.129        pypi
> sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /home/xx/miniforge3/envs/R.4.2_cloned_mapdemo_env/lib/libopenblasp-r0.3.23.so

locale:
 [1] LC_CTYPE=en_US.utf-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.utf-8        LC_COLLATE=en_US.utf-8    
 [5] LC_MONETARY=en_US.utf-8    LC_MESSAGES=en_US.utf-8   
 [7] LC_PAPER=en_US.utf-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.utf-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
[1] BiocPyRanges_0.0.1   GenomicRanges_1.50.2 GenomeInfoDb_1.34.9 
[4] IRanges_2.32.0       S4Vectors_0.36.2     BiocGenerics_0.44.0 
[7] reticulate_1.30     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.11            here_1.0.1             lattice_0.21-8        
 [4] png_0.1-8              rprojroot_2.0.3        withr_2.5.0           
 [7] rappdirs_0.3.3         bitops_1.0-7           grid_4.2.3            
[10] jsonlite_1.8.7         zlibbioc_1.44.0        rlang_1.1.1           
[13] cli_3.6.1              XVector_0.38.0         Matrix_1.6-0          
[16] tools_4.2.3            RCurl_1.98-1.12        compiler_4.2.3        
[19] GenomeInfoDbData_1.2.9

@hpages
Copy link
Owner

hpages commented Aug 11, 2023

Looks like you're using a more recent version of the pyranges module (0.0.129, the latest).

So it seems that, back in April, the pyranges folks renamed the pyranges.pyranges submodule -> pyranges.pyranges_main (see pyranges/pyranges@74901aa). The change happened in pyranges 0.0.120, but, surprisingly, such breaking change is not mentioned in the CHANGELOG.txt file (see https://github.com/pyranges/pyranges/blob/master/CHANGELOG.txt).

The consequence of this change is that the class of the object returned by makePyRangesFromGRanges() is now pyranges.pyranges_main.PyRanges (like in your case), whereas before that it was pyranges.pyranges.PyRanges (like in my case).

I commited a small tweak to BiocPyRanges to accomodate for this change (see commit 9c7fb50). The fix is in BiocPyRanges 0.0.2. Let me know if you still run into issues with this new version.

Best,
H.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants