Can't write cool file
Hey!
I wanted to filter out some of the chromosomes for my cool file, but got the error h5py/_objects.pyx in h5py._objects.with_phil.wrapper() h5py/_objects.pyx in h5py._objects.with_phil.wrapper() h5py/h5d.pyx in h5py.h5d.DatasetID.write() h5py/_proxy.pyx in h5py._proxy.dset_rw() h5py/_proxy.pyx in h5py._proxy.H5PY_H5Dwrite() OSError: Can't write data (no appropriate function for conversion path)
At the same time, it actually write the file but with no metadata at all. Here is how I did it
load initial cool file
clr = cooler.Cooler(cooler_file)
# create array with chromosomes needed to be extracted
c_sub = clr.chromnames[0:6]
# create bin df
c_bin_df = pd.DataFrame(columns=clr.bins().columns)
# create pixels df
c_pix_df = pd.DataFrame(columns=clr.pixels().columns)
# iterate through chromosomes to extract
for chrom in c_sub:
c_bin = clr.bins().fetch(chrom)
c_pix = clr.pixels().fetch(chrom)
c_bin_df = c_bin_df.append(c_bin)
c_pix_df = c_pix_df.append(c_pix)
r = clr.offset('chrM')
c_pix_df_fixed = \
c_pix_df[c_pix_list.bin2_id < r]
c_pix_df_fixed.sort_values(by=['bin1_id', 'bin2_id'])
new_clr_path = '/home/fox/projects/dicty/atacseq_study/dicty_hic_distiller/subsampled/0A_test.cool'
# write new cool file
cooler.create_cooler(
new_clr_path,
c_bin_df,
c_pix_df_fixed,
metadata={'bin-size': 2000,
'bin-type': 'fixed',
'format': 'HDF5::Cooler',
'format-url': 'https://github.com/mirnylab/cooler',
'bins': r}
)
my cooler version is 0.8.9
Can you check the dtypes of your c_bin_df and c_pix_df?
We haven't heard back. I'm closing this now, but we can re-open if you encounter this issue again.