cmap / cmapPy

Assorted tools for interacting with .gct, .gctx files and other Connectivity Map (Broad Institute) data/tools
https://clue.io/cmapPy/index.html
BSD 3-Clause "New" or "Revised" License
126 stars 76 forks source link

write_gctx TypeError in Python 3.6 #37

Closed alex-wenzel closed 6 years ago

alex-wenzel commented 6 years ago

I noticed there are other known Python 3 compatibility issues and I'm not sure if this is related, but just in case,

import cmapPy.pandasGEXpress as GEX                                                                                                                                                                                                            
import cmapPy.pandasGEXpress.write_gctx as write_gctx

lincs_path = "path to the 'level 5' .gctx from GEO GSE70138"                                                                                                                           
gctoo_1 = GEX.parse(lincs_path)                                                                                                                                                                                                        
write_gctx.write(gctoo_1, "test.gctx") 

results in

Traceback (most recent call last):
  File "RGES/L1KGCT.py", line 173, in <module>
    write_gctx.write(gctoo_1, "test.gctx")
  File "/home/atwenzel/miniconda3/lib/python3.6/site-packages/cmapPy/pandasGEXpress/write_gctx.py", line 53, in write
    write_metadata(hdf5_out, "col", gctoo_object.col_metadata_df, convert_back_to_neg_666)
  File "/home/atwenzel/miniconda3/lib/python3.6/site-packages/cmapPy/pandasGEXpress/write_gctx.py", line 124, in write_metadata
    hdf5_out.create_dataset(metadata_node_name + "/id", data=[str(x) for x in metadata_df.index])
  File "/home/atwenzel/miniconda3/lib/python3.6/site-packages/h5py/_hl/group.py", line 106, in create_dataset
    dsid = dataset.make_new_dset(self, shape, dtype, data, **kwds)
  File "/home/atwenzel/miniconda3/lib/python3.6/site-packages/h5py/_hl/dataset.py", line 100, in make_new_dset
    tid = h5t.py_create(dtype, logical=1)
  File "h5py/h5t.pyx", line 1530, in h5py.h5t.py_create
  File "h5py/h5t.pyx", line 1552, in h5py.h5t.py_create
  File "h5py/h5t.pyx", line 1613, in h5py.h5t.py_create
TypeError: No conversion path for dtype: dtype('<U26')
oena commented 6 years ago

Hi @alex-wenzel, you're correct that there are some Python 3 compatibility issues; we don't currently support that version of Python. To avoid this and related issues, I'd recommend setting up a conda environment with the package versions we do support; instructions on how to do that are available in our installation instructions.

Or, if you'd like to fix this yourself, you're more than welcome to contribute to the package! Contribution guidelines are available here.