h5Read: Read data from an existing HDF5 link

View source: R/AllGenerics.R

h5ReadR Documentation

Read data from an existing HDF5 link

Description

Function to read data from an existing HDF5 group.

Usage

h5Read(x, name = NULL, ...)

## S3 method for class 'H5Group'
h5Read(x, name = NULL, transpose = FALSE, ...)

## S3 method for class 'H5File'
h5Read(x, name = NULL, transpose = FALSE, ...)

## S3 method for class 'character'
h5Read(x, name = NULL, transpose = FALSE, ...)

Arguments

x

An H5File, H5Group or a path name of HDF5 file.

name

Name of the HDF5 link to be read.

...

Arguments passed to h5ReadDataset.

transpose

Whether or not to transpose the read matrix. Only works for a 2-dimension array-like data.

Value

The load R object. Currently support vector, matrix, data.frame, list and sparse matrix (dgCMatrix and dgRMatrix).

Examples

file <- system.file("extdata", "pbmc_small.h5ad", package = "hdf5r.Extra")

# Read a matrix
x <- h5Read(file, name = "X")
x <- h5Read(file, name = "X", transpose = TRUE)
x <- h5Read(file, name = "X", idx_list = list(1:10, 1:20))
x <- h5Read(
  file, 
  name = "X", 
  idx_list = list(1:10, 1:20), 
  transpose = TRUE
)

# Read a dgCMatrix
x <- h5Read(file, name = "raw/X")
x <- h5Read(file, name = "raw/X", transpose = TRUE)

# Read a data.frame
x <- h5Read(file, name = "obs")
x <- h5Read(file, name = "raw/var") # Read a data.frame with empty column

# Read a list
x <- h5Read(file)
x <- h5Read(file, "raw")
x <- h5Read(file, "obsm")


hdf5r.Extra documentation built on Oct. 18, 2024, 9:06 a.m.