Skip to content

Commit

Permalink
Merge branch 'master' into cinmf
Browse files Browse the repository at this point in the history
  • Loading branch information
mvfki committed Mar 31, 2024
2 parents 388b757 + 9c3dc07 commit 4d203a4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
3 changes: 3 additions & 0 deletions R/import.R
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ readLiger <- function(
if (!inherits(obj, "liger")) # nocov start
cli::cli_abort("Object is not of class {.cls liger}.") # nocov end
ver <- obj@version
if (ver == package_version("1.99.0")) {
obj <- rliger2_to_rliger_namespace(obj, dimredName = dimredName)
}
if (ver >= package_version("1.99.0")) {
if (isH5Liger(obj)) obj <- restoreH5Liger(obj)
return(obj)
Expand Down
49 changes: 29 additions & 20 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -686,27 +686,18 @@ searchH <- function(object, useRaw = NULL) {
# now we rename the package back to `rliger` and you'll need to have the objects
# compatible with "new" package name.
rliger2_to_rliger_namespace <- function(obj, dimredName) {
cm <- obj@cellMeta
# Slots that contain things of rliger2 namespace
datasetList <- list()
drList <- list()
commandList <- list()

cm <- obj@cellMeta
for (i in dimredName) {
drList[[i]] <- cm[[i]]
cm[[i]] <- NULL
}
new <- methods::new(
"liger",
datasets = obj@datasets,
cellMeta = cm,
varFeatures = obj@varFeatures,
W = obj@W,
H.norm = obj@H.norm,
uns = obj@uns,
commands = obj@commands,
version = obj@version
)
for (i in dimredName) {
dimRed(new, i) <- drList[[i]]
}
for (i in seq_along(obj)) {

for (i in names(obj@datasets)) {
ld <- obj@datasets[[i]]
basics <- list(
rawData = ld@rawData,
Expand Down Expand Up @@ -748,11 +739,12 @@ rliger2_to_rliger_namespace <- function(obj, dimredName) {
Class = "ligerDataset"
))
}
new@datasets[[i]] <- do.call("new", basics)
datasetList[[i]] <- do.call("new", basics)
}
for (i in seq_along(new@commands)) {
cmd <- new@commands[[i]]
new@commands[[i]] <- methods::new(

for (i in names(obj@commands)) {
cmd <- obj@commands[[i]]
commandList[[i]] <- methods::new(
"ligerCommand",
funcName = cmd@funcName,
time = cmd@time,
Expand All @@ -763,5 +755,22 @@ rliger2_to_rliger_namespace <- function(obj, dimredName) {
dependencyVersion = cmd@dependencyVersion
)
}

new <- methods::new(
"liger",
datasets = datasetList,
cellMeta = cm,
varFeatures = obj@varFeatures,
W = obj@W,
H.norm = obj@H.norm,
uns = obj@uns,
commands = commandList,
version = obj@version
)

for (i in dimredName) {
dimRed(new, i) <- drList[[i]]
}

new
}

0 comments on commit 4d203a4

Please sign in to comment.