datarail / gr_metrics

15 stars 12 forks source link

python: Invalid file path or buffer object type: <class 'gr50.linereader.LineReader'> #34

Closed levlitichev closed 7 years ago

levlitichev commented 7 years ago

Hello,

I'm trying to use the Python implementation of this code. It seems like pandas doesn't like reading this LineReader object that you're using. If you could provide any assistance, it would be much appreciated.

(gr50) ~ $ cd ~/code/gr50/SRC/python/
(gr50) ~/code/gr50/SRC/python $ conda list
# packages in environment at /Users/lev/miniconda2/envs/gr50:
#
ca-certificates           2017.4.17                     0    conda-forge
certifi                   2017.4.17                py27_0    conda-forge
gr50                      0.1                       <pip>
mkl                       2017.0.1                      0
ncurses                   5.9                          10    conda-forge
numpy                     1.12.1                   py27_0
openssl                   1.0.2k                        0    conda-forge
pandas                    0.20.2              np112py27_0    conda-forge
pip                       9.0.1                    py27_0    conda-forge
python                    2.7.13                        1    conda-forge
python-dateutil           2.6.0                    py27_0    conda-forge
pytz                      2017.2                   py27_0    conda-forge
readline                  6.2                           0    conda-forge
setuptools                33.1.1                   py27_0    conda-forge
six                       1.10.0                   py27_1    conda-forge
sqlite                    3.13.0                        1    conda-forge
tk                        8.5.19                        1    conda-forge
wheel                     0.29.0                   py27_0    conda-forge
zlib                      1.2.11                        0    conda-forge
(gr50) ~/code/gr50/SRC/python $ head examples/example_input1.tsv
cell_line   agent   perturbation    replicate   time    concentration   cell_count  cell_count__ctrl    cell_count__time0
MCF10A  drugA   0   1   48  0.001   1131    1212.5  299.5
MCF10A  drugA   0   1   48  0.003162    1205    1212.5  299.5
MCF10A  drugA   0   1   48  0.01    1021    1212.5  299.5
MCF10A  drugA   0   1   48  0.03162 743 1212.5  299.5
MCF10A  drugA   0   1   48  0.1 459 1212.5  299.5
MCF10A  drugA   0   1   48  0.3162  318 1212.5  299.5
MCF10A  drugA   0   1   48  1   284 1212.5  299.5
MCF10A  drugA   0   1   48  3.162   274 1212.5  299.5
MCF10A  drugA   0   1   48  10  249 1212.5  299.5
(gr50) ~/code/gr50/SRC/python $ python scripts/compute_gr_metrics.py examples/example_input1.tsv > examples/example_output.tsv
Traceback (most recent call last):
  File "scripts/compute_gr_metrics.py", line 42, in <module>
    main()
  File "scripts/compute_gr_metrics.py", line 37, in main
    data = pd.read_csv(reader, delimiter='\t')
  File "/Users/lev/miniconda2/envs/gr50/lib/python2.7/site-packages/pandas/io/parsers.py", line 655, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/Users/lev/miniconda2/envs/gr50/lib/python2.7/site-packages/pandas/io/parsers.py", line 392, in _read
    filepath_or_buffer, encoding, compression)
  File "/Users/lev/miniconda2/envs/gr50/lib/python2.7/site-packages/pandas/io/common.py", line 210, in get_filepath_or_buffer
    raise ValueError(msg.format(_type=type(filepath_or_buffer)))
ValueError: Invalid file path or buffer object type: <class 'gr50.linereader.LineReader'>
(gr50) ~/code/gr50/SRC/python $

Thank you, Lev

levlitichev commented 7 years ago

Ah, I realized that I should first be calling add_gr_column.py. That works fine, but calling compute_gr_metrics.py on the output of that script yields the same error.

(gr50) ~/code/gr50/SRC/python/scripts $ python add_gr_column.py ../../../INPUT/toy_example_input1.tsv > output.tsv
(gr50) ~/code/gr50/SRC/python/scripts $ python compute_gr_metrics.py output.tsv > output2.tsv
Traceback (most recent call last):
  File "compute_gr_metrics.py", line 42, in <module>
    main()
  File "compute_gr_metrics.py", line 37, in main
    data = pd.read_csv(reader, delimiter='\t')
  File "/Users/lev/miniconda2/envs/gr50/lib/python2.7/site-packages/pandas/io/parsers.py", line 655, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/Users/lev/miniconda2/envs/gr50/lib/python2.7/site-packages/pandas/io/parsers.py", line 392, in _read
    filepath_or_buffer, encoding, compression)
  File "/Users/lev/miniconda2/envs/gr50/lib/python2.7/site-packages/pandas/io/common.py", line 210, in get_filepath_or_buffer
    raise ValueError(msg.format(_type=type(filepath_or_buffer)))
ValueError: Invalid file path or buffer object type: <class 'gr50.linereader.LineReader'>
(gr50) ~/code/gr50/SRC/python/scripts $ head output2.tsv
(gr50) ~/code/gr50/SRC/python/scripts $ 
jmuhlich commented 7 years ago

Looks like Pandas recently changed how it validates file/buffer-like objects. (I swear LineReader used to work fine!) I've fixed it and will merge it in momentarily.

levlitichev commented 7 years ago

Thanks for the fix! I managed to do what I wanted to do using the online GR calculator. It's a nice tool. Thank you for creating and maintaining it.

On Tue, Jun 13, 2017 at 4:41 PM, Jeremy Muhlich notifications@github.com wrote:

Closed #34 https://github.com/datarail/gr_metrics/issues/34 via #35 https://github.com/datarail/gr_metrics/pull/35.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/datarail/gr_metrics/issues/34#event-1122154626, or mute the thread https://github.com/notifications/unsubscribe-auth/AJZrI2b46wUfFBWu8vj8z-ucWe_7UPEWks5sDvP6gaJpZM4N0gl4 .