1
$\begingroup$

I have a bunch of folders containing barcodes.tsv.gz, features.tsv.gz, and matrix.mtx.gz from the Cellranger Count output for a single-cell dataset that was sent to me from another lab. I need the .h5 version of these count matrices, but I do not have access to the original Cellranger Count output which contains the generated .h5 files.

Is there an R or Python function that can reliably convert these files into the proper hdf5 format? I haven't found anything online yet.

(x-post: https://www.reddit.com/r/bioinformatics/comments/veku5r/how_to_convert_10x_matrix_tsv_files_to_hdf5_format/)

$\endgroup$
1
  • $\begingroup$ Conversion into HDF5 from Python3 is straight forward. Could you please forward your CellRanger output example? The key is ... the key and I'd need to see the stuff you want to write and look at the keys in a CellRanger file (keys are everything in HDF5) $\endgroup$
    – M__
    Jun 17, 2022 at 22:35

2 Answers 2

0
$\begingroup$

Answered on biostars (https://www.biostars.org/p/9527636/#9527638) as well as on reddit: (https://www.reddit.com/r/bioinformatics/comments/veku5r/how_to_convert_10x_matrix_tsv_files_to_hdf5_format/icqsfwn/)

The biostars answer is better as it needs just one package (DropletUtils) as opposed to the 2-3 required by the Seurat-allied packages suggested on reddit. Plus, Seurat can take forever to load a dataset.

$\endgroup$
0
$\begingroup$

Conversion into HDF5 from Python3 is straight forward, if this is a simple key: value dictionary format then it should be easy to mimic the CellRanger format. If it is a more complex data structure that would be tricky. The key to HDF5 is 'the HDF5 key' which you need to find (you would call it the directory)

To find the 'key' one approach is do is download https://www.hdfgroup.org/downloads/hdfview/ and then forward a screenshot of the CellRanger HDF5 file here. The directories are what HDF5 call 'keys' and you need these to write to and call from HDF5. There is a CLI for this operation.

An example of the data you are writing to would be needed.If per chance the data is in a Python dataframe you're in business, because these easily IO to HDF5

All you do is put the data into a simple dictionary and assign the dictionary to a key which is written to HDF5. Parsing the data from e.g. an AlignIO/SeqIO object to the dictionary is more complicated. When the HDF5 is read, the key has to be supplied then the dictionary is extracted and assembled back into an object.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.