Skip to content

Commit

Permalink
Made a few improvements to the examine_droplet_logliks.R analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarbo committed Mar 1, 2024
1 parent e4d7537 commit a1dd1d4
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inst/analysis/check_loglik_calcs.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A script to check our log-likelihood calculations for different
# packages (glmpca, scGBM, fastglmpca).
library(Matrix)
library(fastTopics)
library(fastglmpca)
source("../code/loglik.R")
load("~/git/fastTopics-experiments/data/droplet.RData")
counts <- t(counts)
Expand Down
54 changes: 54 additions & 0 deletions inst/analysis/examine_droplet_logliks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
library(Matrix)
library(fastglmpca)
library(ggplot2)
library(cowplot)
source("../code/loglik.R")
load("~/git/fastTopics-experiments/data/droplet.RData")
counts <- t(counts)
fit1 <- readRDS(paste("droplets_fastglmpca_fit_10_factors_5105_iter_28",
"cores_dec_23.rds",sep = "_"))
fit2 <- readRDS(paste("droplets_glmpca_fit_10_factors_10_hrs_avagrad",
"optimizer_minibatch_stochastic_dec_23.rds",sep = "_"))
fit3 <- readRDS("droplets_scGBM_fit_10_factors_no_beta_infer_10_hrs.rds")
glmpca_pois_loglik <- function (Y, H)
Y*H - exp(H) - lfactorial(as.matrix(Y))
H1 <- glmpca_pois_loglik(counts,logrates_fastglmpca(fit1))
H2 <- glmpca_pois_loglik(counts,logrates_glmpca(fit2))
H3 <- glmpca_pois_loglik(counts,logrates_scgbm(fit3))

tissue_colors <- c("royalblue", # basal
"firebrick", # ciliated
"forestgreen", # club
"gold", # goblet
"darkmagenta", # ionocyte
"darkorange", # neuroendocrine
"skyblue") # tuft

# Compare cell-wise logliks.
pdat <- cbind(samples,
data.frame(fastglmpca = colSums(H1),
glmpca = colSums(H2),
scgbm = colSums(H3)))
p1 <- ggplot(pdat,aes(x = glmpca,y = fastglmpca,color = tissue)) +
geom_point() +
geom_abline(intercept = 0,slope = 1,color = "black",linetype = "dotted") +
scale_color_manual(values = tissue_colors) +
theme_cowplot(font_size = 12)
p2 <- ggplot(pdat,aes(x = scgbm,y = fastglmpca,color = tissue)) +
geom_point() +
geom_abline(intercept = 0,slope = 1,color = "black",linetype = "dotted") +
scale_color_manual(values = tissue_colors) +
theme_cowplot(font_size = 12)

# Compare gene-wise logliks.
pdat <- data.frame(fastglmpca = rowSums(H1),
glmpca = rowSums(H2),
scgbm = rowSums(H3))
p3 <- ggplot(pdat,aes(x = glmpca,y = fastglmpca)) +
geom_point() +
geom_abline(intercept = 0,slope = 1,color = "magenta",linetype = "dotted") +
theme_cowplot(font_size = 12)
p4 <- ggplot(pdat,aes(x = scgbm,y = fastglmpca)) +
geom_point() +
geom_abline(intercept = 0,slope = 1,color = "magenta",linetype = "dotted") +
theme_cowplot(font_size = 12)

0 comments on commit a1dd1d4

Please sign in to comment.