asntech / intervene

Intervene: a tool for intersection and visualization of multiple genomic region and gene sets
http://intervene.rtfd.io/
Other
132 stars 28 forks source link

Error in pairwise module #58

Closed unique379r closed 9 months ago

unique379r commented 10 months ago

Hi i am trying to compute pairwise between gff files but getting error while executing it:

    is_first_col = lambda x: x.get_subplotspec().is_first_col()
AttributeError: 'SubplotSpec' object has no attribute 'is_first_col'

Command: intervene pairwise -i *.sort.gff --type genomic --compute frac --htype tribar --output PairedResults Any solution ?

asntech commented 10 months ago

This seems to be a version issue. What is the version of matplotlib and pandas?

cnluzon commented 9 months ago

Hi, I have also run into this issue when trying to create a conda environment fresh with:

conda create --name intervene intervene

When I run:

intervene pairwise -i *.narrowPeak

I get:

Traceback (most recent call last):
  File "/home/user/miniconda3/envs/intervene/bin/intervene", line 604, in <module>
    main()
  File "/home/user/miniconda3/envs/intervene/bin/intervene", line 424, in main
    pairwise.pairwise_intersection(label_names, options)
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/intervene/modules/pairwise/pairwise.py", line 486, in pairwise_intersection
    barplot(series, matrix, outfile, options, max_size=max(bed_sizes))
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/intervene/modules/pairwise/pairwise.py", line 158, in barplot
    ax = series.plot(ax=ax, kind='barh', title=options.title, linewidth=0,
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/pandas/plotting/_core.py", line 1031, in __call__
    return plot_backend.plot(data, kind=kind, **kwargs)
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/pandas/plotting/_matplotlib/__init__.py", line 71, in plot
    plot_obj.generate()
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/pandas/plotting/_matplotlib/core.py", line 456, in generate
    self._adorn_subplots()
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/pandas/plotting/_matplotlib/core.py", line 680, in _adorn_subplots
    handle_shared_axes(
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/pandas/plotting/_matplotlib/tools.py", line 431, in handle_shared_axes
    if is_first_col(ax):
  File "/home/user/miniconda3/envs/intervene/lib/python3.9/site-packages/pandas/plotting/_matplotlib/tools.py", line 397, in <lambda>
    is_first_col = lambda x: x.get_subplotspec().is_first_col()
AttributeError: 'SubplotSpec' object has no attribute 'is_first_col'

Some relevant versions:

intervene                 0.6.5              pyh3252c3a_1    bioconda   
pandas                    2.1.0            py39hddac248_0    conda-forge
numpy                     1.25.2           py39h6183b62_0    conda-forge
matplotlib-base           3.3.4            py39h2fa2bec_0    conda-forge
python                    3.9.18          h0755675_0_cpython    conda-forge

I am running this on Ubuntu 22.04 LTS.

I have tried two things to work around in the environment, one is to force more recent versions of python (3.10) but then I get some Iterable that cannot be imported from collections error, and the other one was to just upgrade slightly matplotlib-base to 3.4.3 but that gave me a different error.

Thanks in advance!

cnluzon commented 9 months ago

Hi, in case this helps to find the issue or to work around it, I went a bit trial an error with the environment and was able to run intervene on an environment.yml like this:

name: intervene
channels:
  - pytorch
  - conda-forge
  - bioconda
  - defaults
dependencies:
  - _libgcc_mutex=0.1
  - _openmp_mutex=4.5
  - bedtools=2.31.0
  - bzip2=1.0.8
  - ca-certificates=2023.7.22
  - ld_impl_linux-64=2.40
  - libffi=3.4.2
  - libgcc-ng=13.2.0
  - libgomp=13.2.0
  - libnsl=2.0.0
  - libsqlite=3.43.0
  - libstdcxx-ng=13.2.0
  - libzlib=1.2.13
  - ncurses=6.4
  - openssl=1.1.1w
  - pip=21.3.1
  - python=3.6.15
  - python_abi=3.6
  - readline=8.2
  - setuptools=58.0.4
  - sqlite=3.43.0
  - tk=8.6.12
  - wheel=0.37.1
  - xz=5.2.6
  - pip:
      - cycler==0.11.0
      - intervene==0.6.5
      - kiwisolver==1.3.1
      - matplotlib==3.3.4
      - numpy==1.19.5
      - pandas==1.1.5
      - pillow==8.4.0
      - pybedtools==0.9.1
      - pyparsing==3.1.1
      - pysam==0.21.0
      - python-dateutil==2.8.2
      - pytz==2023.3.post1
      - scipy==1.5.4
      - seaborn==0.11.2
      - six==1.16.0
unique379r commented 9 months ago

@asntech Python 3.9.18

Name: intervene Version: 0.6.5 Name: matplotlib Version: 3.3.4 Name: numpy Version: 1.26.0 Name: pandas Version: 2.1.0

Still getting error:

command i used:

intervene pairwise -i cDNA*.bed --type genomic --bedtools-options f=1.0,r,s --compute jaccard --htype tribar --output "$output" --corr --corrtype spearman --sort

Errors:

  File "/lib/python3.9/site-packages/intervene/modules/pairwise/pairwise.py", line 33, in jaccard_of_a
    return a.jaccard(b,u=True, **kwoptions)['jaccard']
  File "/lib/python3.9/site-packages/pybedtools/bedtool.py", line 397, in wrapped
    return does_not_return_bedtool(stream, **kwargs)
TypeError: _jaccard_output_to_dict() got multiple values for argument 's'

Also using fract or count, getting the same error as before:

    is_first_col = lambda x: x.get_subplotspec().is_first_col()
AttributeError: 'SubplotSpec' object has no attribute 'is_first_col'
asntech commented 9 months ago

Hi @cnluzon @unique379r, Please try to downgrade the pandas version to 1.5.3: conda install -c conda-forge pandas=1.5.3

cnluzon commented 9 months ago

That did work, thanks! Perhaps it would be interesting to pin that version in the bioconda recipe?

unique379r commented 9 months ago

Hi Thanks, downgrading pandas works :) but with a warning bug:

intervene/modules/pairwise/pairwise.py:165: UserWarning: First parameter to grid() is false, but line properties are supplied. The grid will be enabled.
ax.grid(b=False, which='major', axis='both', alpha=0.1)
unique379r commented 9 months ago

Hi, Other than running intervene, i have question about values obtain from bedtools and intervene.

My command in bash script

bedtools jaccard -a "$file1" -b "$file2" -f 1.0 -r -e | grep -v "intersection" | awk '{print $3}'
Sample  A   B   C   D   E   
A   1   0.307771    0.326171    0.257917    0.261808    
B   0.307771    1   0.32018 0.242112    0.248604    
C   0.326171    0.32018 1   0.260097    0.270409    
D   0.257917    0.242112    0.260097    1   0.363778    
E   0.261808    0.248604    0.270409    0.363778    1   

From pairwise

intervene pairwise -i *.bed --compute jaccard --bedtools-options f=1.0,r,e --htype tribar --output pairwise-results
    A   B   C   D   E
A   1.0 0.34152 0.355896    0.277933    0.282856
B   0.34152 1.0 0.354377    0.268735    0.269864
C   0.355896    0.354377    1.0 0.285222    0.290961
D   0.277933    0.268735    0.285222    1.0 0.386835
E   0.282856    0.269864    0.290961    0.386835    1.0

I am wondering, why the both results slightly differ in the values(jaccard) of the sample. Any clue ? Any insight would be helpful for my analysis.

Thanks

asntech commented 9 months ago

@cnluzon yes, the bioconda recipe needs to be updated. I've been working on an updated version, and thought I would update it when that is ready. @unique379r I'll inspect the jaccard difference in #59