readLiger {rliger}R Documentation

Read liger object from RDS file

Description

This file reads a liger object stored in RDS files under all kinds of types. 1. A liger object with in-memory data created from package version since 1.99. 2. A liger object with on-disk H5 data associated, where the link to H5 files will be automatically restored. 3. A liger object created with older package version, and can be updated to the latest data structure by default.

Usage

readLiger(
  filename,
  dimredName = "tsne_coords",
  clusterName = "clusters",
  h5FilePath = NULL,
  update = TRUE
)

Arguments

filename

Path to an RDS file of a liger object of old versions.

dimredName

The name of variable in cellMeta slot to store the dimensionality reduction matrix, which originally located in tsne.coords slot. Default "tsne.coords".

clusterName

The name of variable in cellMeta slot to store the clustering assignment, which originally located in clusters slot. Default "clusters".

h5FilePath

Named list, to specify the path to the H5 file of each dataset if location has been changed. Default NULL looks at the file paths stored in object.

update

Logical, whether to update an old (<=1.0.0) liger object to the currect version of structure. Default TRUE.

Value

New version of liger object

Examples

# Save and read regular current-version liger object
tempPath <- tempfile(fileext = ".rds")
saveRDS(pbmc, tempPath)
pbmc <- readLiger(tempPath, dimredName = NULL)

# Save and read H5-based liger object
h5Path <- system.file("extdata/ctrl.h5", package = "rliger")
h5tempPath <- tempfile(fileext = ".h5")
file.copy(from = h5Path, to = h5tempPath)
lig <- createLiger(list(ctrl = h5tempPath))
tempPath <- tempfile(fileext = ".rds")
saveRDS(lig, tempPath)
lig <- readLiger(tempPath)

## Not run: 
# Read a old liger object <= 1.0.1
# Assume the dimensionality reduction method applied was UMAP
# Assume the clustering was derived with Louvain method
lig <- readLiger(
    filename = "path/to/oldLiger.rds",
    dimredName = "UMAP",
    clusterName = "louvain",
    update = TRUE
)

## End(Not run)

[Package rliger version 2.0.1 Index]