Created
February 26, 2025 05:08
-
-
Save abikoushi/58586d01689a42aea23ea7d2e706d14f to your computer and use it in GitHub Desktop.
first try rliger `runOnlineINMF`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install.packages('RcppPlanc', repos = c('https://welch-lab.r-universe.dev', 'https://cloud.r-project.org')) | |
library(rliger) | |
library(RcppPlanc) | |
library(bench) | |
pbmc <- normalize(pbmc) | |
pbmc <- selectGenes(pbmc) | |
pbmc <- scaleNotCenter(pbmc) | |
getOption("ligerVerbose", TRUE) | |
bm <- bench::mark({ | |
pbmc <- runOnlineINMF(pbmc, k=20, nCores = 1, | |
minibatchSize = 200, maxEpochs = 10, | |
verbose = FALSE) | |
}, iterations = 1) | |
print(bm$total_time) | |
#[1] 47.7ms | |
print(bm$mem_alloc) | |
#[1] 371KB | |
W = getMatrix(pbmc, slot = "W") | |
V = getMatrix(pbmc, slot = "V") | |
H = getMatrix(pbmc, slot = "H") | |
X = getMatrix(pbmc, slot = "scaleData") | |
dim(X$ctrl) | |
dim(X$stim) | |
#checking goodness-of-fit | |
plot((W + V$ctrl)%*%H$ctrl, X$ctrl, col=rgb(0, 0, 0, 0.1)) | |
abline(0,1, col="royalblue", lty=2) | |
plot((W + V$stim)%*%H$stim, X$stim, col=rgb(0, 0, 0, 0.1)) | |
abline(0,1, col="royalblue", lty=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment