Skip to content

Commit

Permalink
fix: bug related to updateDatasetFolder() and dimension error (CRITICAL)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokwee committed Nov 8, 2023
1 parent f7f5fba commit 60d0534
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions R/pgx-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -821,18 +821,21 @@ pgxinfo.updateDatasetFolder <- function(pgx.dir,
fc.add <- any(!colnames(allFC) %in% cn)
fc.del <- any(!cn %in% colnames(allFC))
if (fc.add) {
dbg("[pgxinfo.updateDatasetFolder] adding sigDB (full create)")
pgx.createSignatureDatabaseH5.fromMatrix(sigdb.file, X = allFC)
}
cn <- rhdf5::h5read(sigdb.file, "data/colnames") ## new size
}

if (fc.del) {
del <- which(!cn %in% colnames(allFC))
## cn[del] <- paste("[DELETED]", sub(".*\\] ", "", cn[del]))
cn[del] <- paste("[DELETED]", cn[del])
rhdf5::h5delete(sigdb.file, "data/colnames")
rhdf5::h5write(cn, sigdb.file, "data/colnames")
Sys.sleep(0.1) ## time to write...
if (delete.old) {
dbg("[pgxinfo.updateDatasetFolder] deleting sigDB entry")
sigdb.removeDataset(sigdb.file, "DELETED")
Sys.sleep(0.1) ## allow write time
} else {
dbg("[pgxinfo.updateDatasetFolder] deletions tagged but not removed")
}
Expand All @@ -846,12 +849,17 @@ pgxinfo.updateDatasetFolder <- function(pgx.dir,
if (!file.exists(tsne.file) || pgxfc.changed) {
cn <- rhdf5::h5read(sigdb.file, "data/colnames")
tsne <- rhdf5::h5read(sigdb.file, "clustering/tsne2d")
length(cn)
dim(tsne)
if(length(cn) != nrow(tsne)) {
dbg("[pgxinfo.updateDatasetFolder] ***ERROR**** length mismatch!")
}
rownames(tsne) <- cn
colnames(tsne) <- paste0("tsne.", 1:2)
colnames(tsne) <- paste0("tsne.", 1:ncol(tsne))
utils::write.csv(tsne, file = tsne.file)
}
}

dbg("[pgxinfo.updateDatasetFolder] done!")
return()
}

Expand Down
4 changes: 4 additions & 0 deletions R/pgx-signature.R
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ pgx.createSignatureDatabaseH5.fromMatrix <- function(h5.file, X, update.only = F
rhdf5::h5write(pos[["pca2d"]], h5.file, "clustering/pca2d") ## can write list??
rhdf5::h5write(pos[["tsne2d"]], h5.file, "clustering/tsne2d") ## can write list??
rhdf5::h5write(pos[["umap2d"]], h5.file, "clustering/umap2d") ## can write list??

dbg("[pgx.createSignatureDatabaseH5.fromMatrix] dim.tsne2d = ", dim(pos[["tsne2d"]]))
dbg("[pgx.createSignatureDatabaseH5.fromMatrix] clustering done")
}

## --------------------------------------------------
Expand All @@ -380,6 +383,7 @@ pgx.createSignatureDatabaseH5.fromMatrix <- function(h5.file, X, update.only = F
pgx.addEnrichmentSignaturesH5(h5.file, X = X, mc.cores = 0, methods = "rankcor")

## done!
dbg("[pgx.createSignatureDatabaseH5.fromMatrix] done!")
rhdf5::h5closeAll()
}

Expand Down

0 comments on commit 60d0534

Please sign in to comment.