create (function)

Create a new Loom file.

loompy.create(filename: str, layers: Union[numpy.ndarray, Dict[str, numpy.ndarray], loompy.layer_manager.LayerManager], row_attrs: Union[loompy.attribute_manager.AttributeManager, Dict[str, numpy.ndarray]], col_attrs: Union[loompy.attribute_manager.AttributeManager, Dict[str, numpy.ndarray]], *, file_attrs: Dict[str, str] = None) → None[source]

Create a new Loom file from the given data.

Parameters
  • filename (str) – The filename (typically using a .loom file extension)

  • layers

    One of the following:

    • Two-dimensional (N-by-M) numpy ndarray of float values

    • Sparse matrix (e.g. scipy.sparse.csr_matrix)

    • Dictionary of named layers, each an N-by-M ndarray or sparse matrix

    • A LayerManager, with each layer an N-by-M ndarray

  • row_attrs (dict) – Row attributes, where keys are attribute names and values are numpy arrays (float or string) of length N

  • col_attrs (dict) – Column attributes, where keys are attribute names and values are numpy arrays (float or string) of length M

  • file_attrs (dict) – Global attributes, where keys are attribute names and values are strings

Returns

Nothing

Remarks:

If the file exists, it will be overwritten.

In order to work with a newly created file you have to connect to it:

loompy.create("filename.loom", m, row_attrs, col_attrs)
with loompy.connect("filename.loom") as ds:
    ....do something with ds
# File closes automatically

Note: if you simply want to create the file, and not access it, there is no need to use a with statement:

loompy.create("filename.loom", m, row_attrs, col_attrs)

This will leave the file closed.