h5Read {hdf5r.Extra}R 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, toS4.func = NULL, ...)

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

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

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.

toS4.func

A function to convert the read R list into an S4 object.

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")


[Package hdf5r.Extra version 0.0.6 Index]