Using Hdf5 To Store Bio-Data
10
25
Entering edit mode
14.8 years ago

Hi all,

Has anybody ever used the HDF5 API to store some biological data (genotypes...). I know about this kind of reference (BioHDF...) but I'm looking for some source code I could browse to understand how I can access data faster.

Pierre

PS: hum, I'm a new user. I'm not allowed to add the following tags: storage database hdf5 source code

hdf5 storage database • 11k views
ADD COMMENT
12
Entering edit mode
14.7 years ago

This might be useful for you. This code snippet read the Simulation data and manipulate in HDF5.

ADD COMMENT
0
Entering edit mode

Thank you Abhishek !

ADD REPLY
0
Entering edit mode

In the light of 3.7 years of more experience (hmm hmm) this should be marked as the correct answer instead of the one describing netCDF. As one can easily see the APIs are quite different.

ADD REPLY
6
Entering edit mode
14.8 years ago

In the GeneTrack software we have used HDF to store values for each genomic base. Its main advantage over other storage systems was that it was able to return consecutive values with minimal overhead.

For example it is extremely fast (ms) in retrieving say 100,000 consecutive values starting with a certain index.We used the Python bindings to HDF. An added advantage of these bindings is that they will return the data back as numpy arrays (very fast numerical operations).

Here is the relevant code that deals with HDF only: hdf.py

The HDF schema is set up in a different module, but in the end it simply something like:

class MySchema( IsDescription ):
    """
    Stores a triplet of float values for each index.
    """
    ix = IntCol  ( pos=1 )  # index
    wx = FloatCol( pos=2 )  # values on the W (forward) strand
    cx = FloatCol( pos=3 )  # value on the C (reverse) strand
    ax = FloatCol( pos=4 )  # weighted value on the combined W + C strands
ADD COMMENT
0
Entering edit mode

Still not the kind of source code I'm looking for but it is very interesting ! Your project reminds me Jan Aerts' Locus Tree : http://saaientist.blogspot.com/2009/04/locustree-searching-genomic-loci.html

ADD REPLY
0
Entering edit mode

Interesting link. You might want to also check out the PyTables documentation. That may have some use cases that you might be interested in. You can safely ignore the python related features: http://www.pytables.org/docs/manual/

ADD REPLY
5
Entering edit mode
14.8 years ago

What I do have is a netCDF-3 based Java application that I could show you. NetCDF-3 is basically the same idea as HDF, but quite more limited as it cannot do compound datatypes among other limitations.

But here's a small test code example to toy with:

Use the above in the following way:

ADD COMMENT
0
Entering edit mode

Very interesting. I'll flag this answer as "correct", but please, if anybody knows some source code that would highlight the power of HDF5. Please, feel free to post it here. Thanks

ADD REPLY
0
Entering edit mode

Unfortunately, this answer is incorrect with respect to the question.

ADD REPLY
0
Entering edit mode

you're right, but 3,7 years later, I don't think HDF5 will help me :-)

ADD REPLY
4
Entering edit mode
14.8 years ago

Hello Pierre!

I have been talking with the BioHDF guys and from what they tell me, their work will be centered around a number of command-line APIs, written in C, that will address some areas of usage which for now do not seem to overlap.

I have seen this example on their site: http://www.hdfgroup.org/projects/biohdf/biohdf_tools.html Don't know if that helps.

I have been talking with them to see if we can achieve an API for saving genotype data. Don't know yet where that will lead me.

If you are looking for something more versatile, you will probably have to delve in the official HDF5 C code ( http://www.hdfgroup.org/HDF5/Tutor/ ), which seems to be the only one that offers all the functionality and goodies of that impressive storage system.

ADD COMMENT
0
Entering edit mode

Many thanks Fernando. As I said , I'm especially looking for some source code: e.g. I'd like to see a short program that would store/retrieve data just to see/understand why I should use this HDF instead of a classic RDBM or another engine (berkeleydb, couchdb...)

ADD REPLY
0
Entering edit mode

There are Perl-based bindings to both HDF5 and BioHDF here, along with some docs:

ftp://ftp.hdfgroup.uiuc.edu/pub/outgoing/BioHDF/Perl/

ADD REPLY
0
Entering edit mode
ADD REPLY
4
Entering edit mode
14.8 years ago
Michael 55k

There is also a Perl binding to HDF5: PDL::IO::HDF5

http://search.cpan.org/~cerney/PDL-IO-HDF5-0.5/ This requires the Perl Data Language (PDL) package. The way, data-structures can be handled, sub-ranges of data can be defined an data can be manipulated is actually very elegant in PDL such that computational code can profit from PDLs vectorized style of writing expressions.

The same is true for R and the hdf5 package: http://cran.r-project.org/web/packages/hdf5/index.html

Code examples are in the package documentations of both, the R-hdf5 package documentation is quite little though.

Both of these language bindings might be a very efficient way to read and write HDF5 files.

There are also APIs in Fortran, Java, Python, Matlab, C, or C++. So it might make sense to select the language and define the type of data you wish to store first.

ADD COMMENT
4
Entering edit mode
14.8 years ago
Chris Fields ★ 2.2k

I've been talking a bit with one of the devs behind BioHDF (being at UIUC, up the road from The HDF Group doesn't hurt). I believe a publication is on the way describing it along with some implementation details.

ADD COMMENT
4
Entering edit mode
14.8 years ago
Darked89 4.7k

Not BioHDF5 but probably readable and maintained:

HDF5 for Python http://code.google.com/p/h5py/

ADD COMMENT
1
Entering edit mode
ADD REPLY
3
Entering edit mode
14.8 years ago

Unfortunately I don't have any example to shows you yet. I don't know how to program in C/C++ so I have been looking at two hdf5 wrappers in python, PyTables and H5PY.

PyTables has a database-like approach in which HDF5 is used as a sort of hierarchical database, in which a column can be a table itself, allowing to store nested data. For example, you have a table called 'SNPs' with two columns, 'id' and 'genotypes'; the column 'genotypes' contains a nested table, with the columns 'individual' and 'genotype'; and so on.

H5Py is basically a re-implementation of numpy's arrays, so you can store and access arrays/matrixes as you would do with numpy (it is similar to arrays and matrixes in matlab, R, and any other language with this data type) and they are stored in an HDF5 file so the access is faster.

ADD COMMENT
1
Entering edit mode

one point to clarify is that with the nesting in pytables, you only get the equivalent of 1 row in the nest. so you'd have:

row['genotypes/genotype'] = 'XXX'

so while it is nested, you dont actually get a many-to-one relationship. still, i find pytables to be excellent for many things.

ADD REPLY
3
Entering edit mode
14.7 years ago

Our Genomedata system stores multiple tracks of 1-bp resolution genomic data in a HDF5 array. Documentation and full source code is available on that page. It has a Python (PyTables) interface for reading the data. For originally loading it into HDF5, we wrote a C loader for added speed.

ADD COMMENT
0
Entering edit mode

thanks, that's very useful too

ADD REPLY
1
Entering edit mode
14.0 years ago

Another answer: I've been looking at the IGV ( Integrative Genomics Viewer ) sources, it use the JAVA bindings for HDF5 to store the data about the genomic tracks.

ADD COMMENT

Login before adding your answer.

Traffic: 1999 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6