siheming / mspypeline

Package to analyze Mass Spec Data
MIT License
11 stars 11 forks source link

Volcano plot issue #33

Closed fmriemers closed 2 years ago

fmriemers commented 2 years ago

Thank you for developing this. I recently found it and tried it with the provided public data. Was able to reproduce most of the analysis\plot as shown in the benchmark data analysis (https://mspypeline.readthedocs.io/en/latest/examplary_bio_analysis.html) that I tried. Unfortunately, the volcano plot did not work for me.

Running it from the GUI using the log2LFQ (lfq_log2) at level 0 results in the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\mspypeline\core\MSPypeline.py", line 242, in <lambda>
    command=lambda: self.start_button())
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\mspypeline\core\MSPypeline.py", line 381, in start_button
    mspplots.create_results()
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\mspypeline\core\MSPPlots\BasePlotter.py", line 259, in create_results
    getattr(self, plot_name)(**plot_settings)
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\mspypeline\core\MSPPlots\BasePlotter.py", line 51, in wrapper
    return f(self, dfs_to_use=dfs_to_use, levels=levels, **kwargs)
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\mspypeline\core\MSPPlots\BasePlotter.py", line 1404, in plot_r_volcano
    data = self.get_r_volcano_data(g1, g2, df_to_use)
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\mspypeline\core\MSPPlots\BasePlotter.py", line 1325, in get_r_volcano_data
    contrast_fit = limma.contrasts_fit(fit, c_matrix)
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\rpy2\robjects\functions.py", line 202, in __call__
    .__call__(*args, **kwargs))
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\rpy2\robjects\functions.py", line 124, in __call__
    res = super(Function, self).__call__(*new_args, **new_kwargs)
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 45, in _
    cdata = function(*args, **kwargs)
  File "F:\Users\frank\miniconda3\envs\mspypeline\lib\site-packages\rpy2\rinterface.py", line 810, in __call__
    raise embedded.RRuntimeError(_rinterface._geterrmessage())
rpy2.rinterface_lib.embedded.RRuntimeError: Error in (function (fit, contrasts = NULL, coefficients = NULL)  :
  contrasts must be a numeric matrix

It appears that, for some reason, the contrasts are not properly transferred between python and R. Could you please shed some light on this issue and possible ways to solve it? Below is some additional version information that might help in solving the issue. Thank you.

Regards, Frank

.libPaths() [1] "F:/Users/frank/miniconda3/envs/mspypeline/Lib/R/library" packageVersion("limma") [1] '3.50.3'

R version 4.1.3 (2022-03-10) -- "One Push-Up" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

(mspypeline) C:\Users\frank>conda info

     active environment : mspypeline
    active env location : F:\Users\frank\miniconda3\envs\mspypeline
            shell level : 2
       user config file : F:\Users\frank\.condarc
 populated config files :
          conda version : 4.10.3
    conda-build version : not installed
         python version : 3.9.5.final.0
       virtual packages : __win=0=0
                          __archspec=1=x86_64
       base environment : F:\Users\frank\miniconda3  (writable)
      conda av data dir : F:\Users\frank\miniconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : F:\Users\frank\miniconda3\pkgs
                          F:\Users\frank\.conda\pkgs
                          F:\Users\frank\AppData\Local\conda\conda\pkgs
       envs directories : F:\Users\frank\miniconda3\envs
                          F:\Users\frank\.conda\envs
                          F:\Users\frank\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.10.3 requests/2.25.1 CPython/3.9.5 Windows/10 Windows/10.0.19044
          administrator : False
             netrc file : None
           offline mode : False
siheming commented 2 years ago

Hi @fmriemers, does this error also occur for other levels or normalization (or no normalization)? As you can see from the message, the code tries to call R code using the rpy2 package. Unfortunately the package is often hard to set up correctly, so it might be that something is not installed correctly, or the data passed to it is actually incorrect. Could you provide information about the versions of your installed python packages (with e.g. conda list)

fmriemers commented 2 years ago

Hi @siheming , thank you for your swift reply. I have tried the analisis with all of the six normalisation options at levels 0 and 1, all resulting in the same error. Below is the output of the installed packages. Thanks for looking into this. Regards, FRank

(mspypeline) C:\Users\frank>conda list
# packages in environment at F:\Users\frank\miniconda3\envs\mspypeline:
#
# Name                    Version                   Build  Channel
_r-mutex                  1.0.1               anacondar_1    conda-forge
adjusttext                0.7.3.1                    py_1    conda-forge
backports                 1.0                        py_2    conda-forge
backports.zoneinfo        0.2.1            py37hcc03f2d_4    conda-forge
ca-certificates           2022.5.18.1          h5b45459_0    conda-forge
cffi                      1.15.0           py37hd8e9650_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
freetype                  2.10.4               h546665d_1    conda-forge
gettext                   0.19.8.1          ha2e2712_1008    conda-forge
gst-plugins-base          1.20.2               he07aa86_1    conda-forge
gstreamer                 1.20.2               hdff456e_1    conda-forge
icu                       70.1                 h0e60522_0    conda-forge
intel-openmp              2022.1.0          h57928b3_3787    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
joblib                    1.1.0              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h8ffe710_1    conda-forge
kiwisolver                1.4.3            py37h8c56517_0    conda-forge
krb5                      1.19.3               h1176d77_0    conda-forge
libblas                   3.9.0              15_win64_mkl    conda-forge
libcblas                  3.9.0              15_win64_mkl    conda-forge
libclang                  14.0.5          default_h77d9078_0    conda-forge
libclang13                14.0.5          default_h77d9078_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libglib                   2.70.2               h3be07f2_4    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
liblapack                 3.9.0              15_win64_mkl    conda-forge
libogg                    1.3.4                h8ffe710_1    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libvorbis                 1.3.7                h0e60522_0    conda-forge
libzlib                   1.2.12               h8ffe710_0    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
m2w64-bwidget             1.9.10                        2    conda-forge
m2w64-bzip2               1.0.6                         6    conda-forge
m2w64-expat               2.1.1                         2    conda-forge
m2w64-fftw                3.3.4                         6    conda-forge
m2w64-flac                1.3.1                         3    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gettext             0.19.7                        2    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-gsl                 2.1                           2    conda-forge
m2w64-libiconv            1.14                          6    conda-forge
m2w64-libjpeg-turbo       1.4.2                         3    conda-forge
m2w64-libogg              1.3.2                         3    conda-forge
m2w64-libpng              1.6.21                        2    conda-forge
m2w64-libsndfile          1.0.26                        2    conda-forge
m2w64-libtiff             4.0.6                         2    conda-forge
m2w64-libvorbis           1.3.5                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
m2w64-libxml2             2.9.3                         3    conda-forge
m2w64-mpfr                3.1.4                         4    conda-forge
m2w64-pcre2               10.34                         0    conda-forge
m2w64-speex               1.2rc2                        3    conda-forge
m2w64-speexdsp            1.2rc3                        3    conda-forge
m2w64-tcl                 8.6.5                         3    conda-forge
m2w64-tk                  8.6.5                         3    conda-forge
m2w64-tktable             2.10                          5    conda-forge
m2w64-wineditline         2.101                         5    conda-forge
m2w64-xz                  5.2.2                         2    conda-forge
m2w64-zlib                1.2.8                        10    conda-forge
markupsafe                2.1.1            py37hcc03f2d_1    conda-forge
matplotlib                3.2.2                         1    conda-forge
matplotlib-base           3.2.2            py37hab8957c_1    conda-forge
matplotlib-venn           0.11.7             pyhd8ed1ab_0    conda-forge
mkl                       2022.1.0           h6a75c08_874    conda-forge
mspypeline                0.11.0                   py37_0    siheming
msys2-conda-epoch         20160418                      1    conda-forge
numpy                     1.21.6           py37h2830a78_0    conda-forge
openssl                   1.1.1o               h8ffe710_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.3.4            py37h9386db6_1    conda-forge
pcre                      8.45                 h0e60522_0    conda-forge
pip                       22.1.2             pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyqt                      5.15.4           py37h35e25fb_1    conda-forge
pyqt5-sip                 12.9.0           py37hf2a7229_1    conda-forge
python                    3.7.12          h7840368_100_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-tzdata             2022.1             pyhd8ed1ab_0    conda-forge
python_abi                3.7                     2_cp37m    conda-forge
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pytz-deprecation-shim     0.1.0.post0      py37h03978a9_1    conda-forge
qt-main                   5.15.4               h467ea89_2    conda-forge
r-base                    4.1.3                hddad469_1    conda-forge
rpy2                      3.5.1           py37r41hb2b6c3e_0    conda-forge
ruamel_yaml               0.15.80         py37hcc03f2d_1007    conda-forge
scikit-learn              1.0.2            py37hcabfae0_0    conda-forge
scipy                     1.7.3            py37hb6553fb_0    conda-forge
setuptools                59.8.0           py37h03978a9_1    conda-forge
simplegeneric             0.8.1                      py_1    conda-forge
sip                       6.5.1            py37hf2a7229_2    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sqlite                    3.38.5               h8ffe710_0    conda-forge
tbb                       2021.5.0             h2d74725_1    conda-forge
threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tornado                   6.1              py37hcc03f2d_3    conda-forge
typing-extensions         4.2.0                hd8ed1ab_1    conda-forge
typing_extensions         4.2.0              pyha770c72_1    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
tzlocal                   4.2              py37h03978a9_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
vc                        14.2                 hb210afc_6    conda-forge
vs2015_runtime            14.29.30037          h902a5da_6    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
yaml                      0.2.5                h8ffe710_2    conda-forge
zlib                      1.2.12               h8ffe710_0    conda-forge
zstd                      1.5.2                h6255e5f_1    conda-forge
siheming commented 2 years ago

I would suggest to try a different version of rpy2. could you try to downgrade from version 3.5.1 to 3.4.2? conda install -c conda-forge rpy2=3.4.2 should hopefully do that.

fmriemers commented 2 years ago

Yes, downgrading the rpy2 version to the suggested version solved the issue. As this also downgrades the version of R to 4.0.5 I just made a new env with these 2 packages downgraded using:

conda create --name mspypeline python=3.7 r-base=4.0.5 rpy2=3.4.2 mspypeline -c conda-forge -c siheming

After this, I needed to fix the location of the R libraries in envs\mspypeline\Lib\R\etc\Rprofile.site to keep it separate from my local R, due to the way I have it set up. But after that it worked for me. So there is probably something different in the newer version of R and or rpy2 that created the issue and resulted in R not getting the data. This issue is still there but with these downgrades, it works. Thank you for the suggestion and assistance. Best, FRank