⭐ Loompy v2.0 was released Dec. 24, 2017! ([what's new](https://github.com/linnarsson-lab/loompy/releases/tag/v2.0)?)
⭐ Loompy v3.0 was released Sep. 24, 2019!
`.loom` is an efficient file format for very large omics datasets,
consisting of a main matrix, optional additional layers, a variable number of row and column
annotations. Loom also supports sparse graphs. We use loom files to store single-cell gene expression
data: the main matrix contains the actual expression values (one
column per cell, one row per gene); row and column annotations
contain metadata for genes and cells, such as `Name`, `Chromosome`,
`Position` (for genes), and `Strain`, `Sex`, `Age` (for cells).

Loom files (`.loom`) are created in the [HDF5](https://en.wikipedia.org/wiki/Hierarchical_Data_Format) file format, which
supports an internal collection of numerical multidimensional datasets.
HDF5 is supported by many computer languages, including Java, MATLAB,
Mathematica, Python, R, and Julia. `.loom` files are accessible from
any language that supports HDF5.
To get started, head over to [the documentation](http://linnarssonlab.org/loompy/)!
To get started, head over to [the documentation](http://loompy.org)!
Loom, loompy, and the [loom-viewer](https://github.com/linnarsson-lab/loom-viewer) are being developed by members of the [Linnarsson Lab](http://linnarssonlab.org).
@@ -74,6 +74,19 @@ any language that supports HDF5, including `Python <http://h5py.org>`__,
.. _specifications:
Standards
---------
The official MIME media type for a loom file is ``application/vnd.loom``, `approved by IANA <https://www.iana.org/assignments/media-types/application/vnd.loom>`_.
You should use this media type when requesting a file using HTTP, or if you create a server that offers Loom files for download.
See the `IANA record for application/vnd.loom <https://www.iana.org/assignments/media-types/application/vnd.loom>`_ for important security considerations.
The Loom file format is designated as a standard format for gene expression matrices by the `Global Alliance for Genomics and Health (GA4GH) <https://www.ga4gh.org>`_ standards body, as part of the `rnaget API <https://github.com/ga4gh-rnaseq/schema/blob/master/rnaget.md>`_.
The rnaget API documentation contains good examples of how to use the media type specification.
Specification
-------------
@@ -91,15 +104,20 @@ Main matrix and layers
Global attributes
^^^^^^^^^^^^^^^^^
- There can OPTIONALLY be at least one `HDF5
attribute <https://www.hdfgroup.org/HDF5/Tutor/crtatt.html>`__ on the
root ``/`` group, which can be any valid scalar or multidimensional datatype and should be
interpreted as attributes of the whole Loom file.
- There can OPTIONALLY be an `HDF5
attribute <https://www.hdfgroup.org/HDF5/Tutor/crtatt.html>`__ on the
root ``/`` group named ``LOOM_SPEC_VERSION``, a string value giving the
loom file spec version that was followed in creating the file. See top of this
document for the current version of the spec.
- There MUST be an HDF5 group ``/attrs`` containing global attributes.
- There MUST be a HDF5 dataset ``/attrs/LOOM_SPEC_VERSION`` with the value ``v3.0.0``.
Global attributes apply semantically to the whole file, not any specific part of it.
Such attributes are stored in the HDF5 group ``/attrs`` and can be any valid scalar
or multidimensional datatype.
As of Loom file format v3.0.0, only one global attribute is mandatory: the ``LOOM_SPEC_VERSION``
attribute, which is a string value giving the loom file spec version that was followed in creating
the file. See top of this document for the current version of the spec.
Note: previous versions of the loom file format stored global attributes as `HDF5 attributes <https://www.hdfgroup.org/HDF5/Tutor/crtatt.html>`__
on the root ``/`` group. However, such attributes are size-limited, which caused problems for some
applications.
Row and column attributes
@@ -144,6 +162,8 @@ Row and column sparse graphs
format. The lengths of the three datasets MUST be equal, which defines the number
of edges in the graph. Note that the number of rows in the dataset defines
the vertices, so an unconnected vertex is one that has no entry in ``a`` or ``b``.
- Vertex indexing is zero-based. When an entry in ``a`` or ``b`` is zero, this denotes the first column
in the matrix. If there are N columns, then vertices are numbered from 0 to N - 1.
Datatypes
---------
@@ -154,19 +174,12 @@ Row and column attributes are multidimensional arrays whose first dimension matc
Global attributes are scalars or multidimensional arrays of any shape, whose elements are any of the numeric datatypes ``int8``, ``int16``, ``int32``, ``int64``, ``uint8``, ``uint16``, ``uint32``, ``uint64``, ``float16``, ``float32`` and ``float64`` or fixed-length ASCII strings.
All strings in Loom files are stored as fixed-length null-padded 7-bit ASCII. ``h5dump`` should report something like this:
.. code::
DATATYPE H5T_STRING {
STRSIZE 24;
STRPAD H5T_STR_NULLPAD;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
Starting with v3.0.0 of the spec, all strings are stored as variable-length UTF-8 encoded.
Note: in previous version, strings were stored as fixed-length null-padded 7-bit ASCII. Unicode characters outside 7-bit ASCII were stored using
`XML entity encoding <https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references>`_, to ensure maximum compatibility. Strings
were decoded when read and encoded when written.
Unicode characters outside 7-bit ASCII are stored using `XML entity encoding <https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references>`_, to ensure maximum compatibility. Strings SHOULD be decoded when read and encoded when written. A compatible implementation may choose to encode/decode or not, but MUST decode on reading if it encodes on writing.
.. _loomexample:
@@ -178,6 +191,10 @@ Here's an example of the structure of a valid Loom file: