Skip to contents

Make h5 object from Seurat assay data

Usage

makeH5fromSeurat(obj, sc1meta, filename, gex.assay, gex.slot, chunkSize)

Arguments

obj

input Seurat (v3+) object

sc1meta

data.table of cell metadata

filename

filename of output h5 file

gex.assay

assay in Seurat object to use

gex.slot

slot in single-cell assay to use

chunkSize

number of genes written to h5file at any one time

Value

h5 object

Author

John F. Ouyang

Examples

if (requireNamespace("Seurat", quietly = TRUE)) {
  set.seed(1)
  counts <- matrix(rpois(10 * 15, 5), nrow = 10, ncol = 15,
                    dimnames = list(paste0("Gene", 1:10), paste0("Cell", 1:15)))
  seu <- Seurat::CreateSeuratObject(counts = counts, min.cells = 0, min.features = 0)
  seu <- Seurat::NormalizeData(seu, verbose = FALSE)
  sc1meta <- data.table::data.table(cellID = colnames(seu))
  makeH5fromSeurat(seu, sc1meta, filename = tempfile(fileext = ".h5"),
                    gex.assay = "RNA", gex.slot = "data", chunkSize = 500)
}