Export Loom Expression Matrix
For export in Loom format, a number of options can be specified (figure 3.3):
Figure 3.3: Options for export of expression matrix in Loom format.
- Cell format. Can be specified to include both the sample and barcode. Hover the mouse over this setting to see the possible options. Often the barcode in itself is sufficient as a unique identifier of cells. However, when an expression matrix contains multiple samples, the cell format must also include the sample, otherwise the export will fail.
- Clusters. A Cell Clusters () element to be exported with the matrix.
- Cell annotation. A Cell Annotations () element to be exported with the matrix.
- Export normalized. If selected and the matrix has been normalized with Normalize Single Cell Data (see Normalize Single Cell Data), the normalized expressions will be exported instead of the raw counts. If the matrix has not been normalized, the export will fail.
- Use compression. Select among gzip, zip or no compression which is default.
- Output file name. Shows the name of the file. This can be customized by changing the default pattern in Custom file name.
The Loom exporter creates a Loom file in format version 3.0.0, see https://linnarssonlab.org/loompy/format/index.html for details. In particular:
- The version number is written as an HDF5 dataset at
/attrs/LOOM_SPEC_VERSION
. - The expression data, either raw counts or normalized, is written as an HDF5 dataset at
/matrix
. - When exporting an Expression Matrix with spliced and unspliced counts (), the spliced and unspliced counts are written as HDF5 datasets at
/layers/spliced
and/layers/unspliced
, respectively. - The cell ID, composed of sample and barcode, is written as an HDF5 group at
col_attrs/CellID
. - The feature IDs and names are written as HDF5 groups at
col_attrs/Accession
andcol_attrs/Gene
, respectively. - Any exported clusters and annotations are written as additional HDF5 groups at
col_attrs
. - An empty
layers
HDF5 group is created.
To load a Loom file "myFile.loom" in Seurat, the following code may be useful:
library(Seurat) library(loomR) lfile <- connect(filename="myFile.loom", mode="r", skip.validate=TRUE) mySeurat <- as.Seurat(lfile) lfile$close()
To load a Loom file "myFile.loom" in Scanpy, the following code may be useful:
import scanpy as sc adata = sc.read_loom('myFile.loom',validate=False)