Export Loom expression matrix
For export in Loom format a number of parameters can be specified, see figure 3.3.
Figure 3.3: Exposed parameters for export of expression matrix in Loom format
Matrix export parameters include the following options:
- 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. NOTE: when a matrix contains more than one sample the exporter will fail if sample handling has not been defined properly.
- Clusters Cell clusters as defined in an accompanying Cell Clusters () element
- Cell annotation Cell annotations as defined in an accompanying Cell Annotations () element
Use compression select among gzip, zip or no compression which is default.
Output file name is the name of the file and can be customised 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
. - 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)