# run BMF without denoising and evaluate
result <- MEBF(data, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("without denoising: ", recon_error[[1]], "   ", recon_error[[2]]))
myplot(data,patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
# denoise with BIND
mat_after_bind <- denoise_with_bind(data)
write.csv(mat_after_bind, file = "bind.csv")
result <- MEBF(mat_after_bind, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after BIND: ", recon_error[[1]], "   ",recon_error[[2]]))
myplot(mat_after_bind,patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
# run BMF without denoising and evaluate
result <- MEBF(data, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("without denoising: ", recon_error[[1]], "   ", recon_error[[2]]))
result <- ASSO(data, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("without denoising: ", recon_error[[1]], "   ", recon_error[[2]]))
result <- PANDA(data, DIM = pat_num)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("without denoising: ", recon_error[[1]], "   ", recon_error[[2]]))
result <- MEBF(mat_after_bind, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after BIND: ", recon_error[[1]], "   ",recon_error[[2]]))
result <- ASSO(mat_after_bind, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after BIND: ", recon_error[[1]], "   ",recon_error[[2]]))
result <- PANDA(mat_after_bind, DIM = pat_num)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after BIND: ", recon_error[[1]], "   ",recon_error[[2]]))
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
result <- ASSO(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
result <- PANDA(mat_after_nn, DIM = pat_num)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
myplot(data,patterns)
myplot(mat_after_bind,patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
# simulate data
simulated <- simulate2(pat_num=2, pat_size=120, mat_size=500, min_bg_prob=0.1,
max_bg_prob=1, eobs_choice=2,  flip_error=0.01)
data <- simulated[[1]]
patterns <- simulated[[2]]
background <- simulated[[3]]
pat_num <- 2
myplot(data,patterns)
# run BMF without denoising and evaluate
result <- MEBF(data, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("without denoising: ", recon_error[[1]], "   ", recon_error[[2]]))
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
# simulate data
simulated <- simulate2(pat_num=2, pat_size=80, mat_size=500, min_bg_prob=0.1,
max_bg_prob=1, eobs_choice=2,  flip_error=0.01)
data <- simulated[[1]]
patterns <- simulated[[2]]
background <- simulated[[3]]
pat_num <- 2
# run BMF without denoising and evaluate
result <- MEBF(data, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("without denoising: ", recon_error[[1]], "   ", recon_error[[2]]))
myplot(data,patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
result <- MEBF(mat_after_nn, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("after nn: ", recon_error[[1]], "   ",recon_error[[2]]))
# simulate data
simulated <- simulate2(pat_num=4, pat_size=80, mat_size=500, min_bg_prob=0.3,
max_bg_prob=1, eobs_choice=2,  flip_error=0.01)
data <- simulated[[1]]
patterns <- simulated[[2]]
background <- simulated[[3]]
pat_num <- 4
# run BMF without denoising and evaluate
result <- MEBF(data, DIM = pat_num, Thres = 0.6)
recon_error <- pat_recon_err(result[[1]], result[[2]], patterns)
print(paste0("without denoising: ", recon_error[[1]], "   ", recon_error[[2]]))
myplot(data,patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
mat_after_nn <- as.matrix(read.csv("denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
setwd("~/Projects/BiasAware/Struggle")
source("~/Projects/BiasAware/Struggle/evaluate.R")
# evaluate the neural network result
data <- as.matrix(read.csv("simu1/data.csv")[, -1])
colnames(data) <- NULL
patterns <- as.matrix(read.csv("simu1/patterns.csv")[, -1])
colnames(patterns) <- NULL
background <- as.matrix(read.csv("simu1/bg.csv")[, -1])
colnames(background) <- NULL
mat_after_nn <- as.matrix(read.csv("simu1/denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
myplot(data,patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data,patterns)
library(RColorBrewer)
colors1=brewer.pal(n = 13, name = "Set1")
library(RColorBrewer)
colors1=brewer.pal(n = 13, name = "Set3")
library(RColorBrewer)
colors1=brewer.pal(n = 12, name = "Set3")
colors1
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data,patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data,patterns)
myplot(mat_after_nn,patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(mat_after_nn,patterns)
myplot(data,patterns)
colors1=brewer.pal(n = 9, name = "Set1")
colors1
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(mat_after_nn,patterns)
myplot(data,patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data,patterns)
setwd("~/Projects/BiasAware/Struggle")
source("~/Projects/BiasAware/Struggle/evaluate.R")
# evaluate the neural network result
data <- as.matrix(read.csv("simu3/data.csv")[, -1])
colnames(data) <- NULL
patterns <- as.matrix(read.csv("simu3/patterns.csv")[, -1])
colnames(patterns) <- NULL
background <- as.matrix(read.csv("simu3/bg.csv")[, -1])
colnames(background) <- NULL
mat_after_nn <- as.matrix(read.csv("simu3/denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
myplot(mat_after_nn, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(mat_after_nn, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(mat_after_nn, patterns)
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
myplot(mat_after_nn, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(mat_after_nn, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(mat_after_nn, patterns)
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
myplot(mat_after_nn, patterns)
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
source("~/Projects/BiasAware/Struggle/evaluate.R")
myplot(data, patterns)
# denoise with BIND
mat_after_bind <- denoise_with_bind(data)
source("~/Projects/BiasAware/Struggle/BIND_functions_only.r")
source("~/Projects/BiasAware/Struggle/example_Xiao3.R")
# denoise with BIND
mat_after_bind <- denoise_with_bind(data)
myplot(mat_after_bind, patterns)
myplot(mat_after_nn, patterns)
# evaluate the neural network result
data <- as.matrix(read.csv("simu4/data.csv")[, -1])
colnames(data) <- NULL
patterns <- as.matrix(read.csv("simu4/patterns.csv")[, -1])
colnames(patterns) <- NULL
background <- as.matrix(read.csv("simu4/bg.csv")[, -1])
colnames(background) <- NULL
mat_after_nn <- as.matrix(read.csv("simu4/denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
myplot(data, patterns)
# denoise with BIND
mat_after_bind <- denoise_with_bind(data)
myplot(mat_after_bind, patterns)
myplot(mat_after_nn, patterns)
myplot(data, patterns)
# evaluate the neural network result
data <- as.matrix(read.csv("simu3/data.csv")[, -1])
colnames(data) <- NULL
patterns <- as.matrix(read.csv("simu3/patterns.csv")[, -1])
colnames(patterns) <- NULL
background <- as.matrix(read.csv("simu3/bg.csv")[, -1])
colnames(background) <- NULL
mat_after_nn <- as.matrix(read.csv("simu3/denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
myplot(data, patterns)
# denoise with BIND
mat_after_bind <- denoise_with_bind(data)
write.csv(mat_after_bind, file = "bind.csv")
myplot(mat_after_bind, patterns)
# evaluate the neural network result
data <- as.matrix(read.csv("simu3/data.csv")[, -1])
colnames(data) <- NULL
patterns <- as.matrix(read.csv("simu3/patterns.csv")[, -1])
colnames(patterns) <- NULL
background <- as.matrix(read.csv("simu3/bg.csv")[, -1])
colnames(background) <- NULL
mat_after_nn <- as.matrix(read.csv("simu3/denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(mat_after_nn, patterns)
# denoise with BIND
mat_after_bind <- denoise_with_bind(data)
myplot(mat_after_bind, patterns)
myplot(mat_after_nn, patterns)
# evaluate the neural network result
data <- as.matrix(read.csv("simu4/data.csv")[, -1])
colnames(data) <- NULL
patterns <- as.matrix(read.csv("simu4/patterns.csv")[, -1])
colnames(patterns) <- NULL
background <- as.matrix(read.csv("simu4/bg.csv")[, -1])
colnames(background) <- NULL
mat_after_nn <- as.matrix(read.csv("simu4/denoised.csv")[, -1])
colnames(mat_after_nn) <- NULL
myplot(data,patterns)
# run on scRNA-seq data with CG
data <- as.matrix(read.csv("scRNA-seq/GSE125449/top2k.csv")[, -1])
patterns <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns.csv")[, -1])
myplot(data, patterns)
data_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/denoised.csv")[, -1])
patterns_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns_denoised.csv")[, -1])
myplot(data_denoised, patterns_denoised)
myplot(data, patterns)
data_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/denoised.csv")[, -1])
patterns_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns_denoised.csv")[, -1])
myplot(data, patterns)
myplot(data_denoised, patterns_denoised)
patterns <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns_original.csv")[, -1])
myplot(data, patterns)
data_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/denoised.csv")[, -1])
patterns_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns_denoised.csv")[, -1])
myplot(data_denoised, patterns_denoised)
data_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/denoised.csv")[, -1])
patterns_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns_denoised.csv")[, -1])
myplot(data_denoised, patterns_denoised)
myplot(data, patterns)
data_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/denoised.csv")[, -1])
patterns_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns_denoised.csv")[, -1])
myplot(data_denoised, patterns_denoised)
data_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/denoised.csv")[, -1])
patterns_denoised <- as.matrix(read.csv("scRNA-seq/GSE125449/patterns_denoised.csv")[, -1])
myplot(data_denoised, patterns_denoised)
# run on scRNA-seq data with CG
data <- as.matrix(read.csv("scRNA-seq/GSE143423/top2k.csv")[, -1])
patterns <- as.matrix(read.csv("scRNA-seq/GSE143423/patterns_original.csv")[, -1])
myplot(data, patterns)
data_denoised <- as.matrix(read.csv("scRNA-seq/GSE143423/denoised.csv")[, -1])
patterns_denoised <- as.matrix(read.csv("scRNA-seq/GSE143423/patterns_denoised.csv")[, -1])
myplot(data_denoised, patterns_denoised)
setwd("~/Projects/BiasAware/Struggle/scRNA-seq/GSE140228")
source("~/Projects/BiasAware/Struggle/MEBF.R")
library(readr)
top2k <- read_csv("top2k.csv")
View(top2k)
clustering_analysis <- function(assign_matrix, all_labels) {
pos <- apply(assign_matrix, 2, sum)==1
sub_matrix <- assign_matrix[, pos]
cluster_labels <- rep(0, dim(sub_matrix)[[2]])
for (j in 1:dim(sub_matrix)[[2]]) {
cluster_labels[[j]] <- which(sub_matrix[, j]==1)
}
true_labels <- all_labels[pos]
return(adj.rand.index(cluster_labels, true_labels))
}
# extract ground truth cell type labels
data <- top2k[, -1]
load("~/Projects/BiasAware/Struggle/scRNA-seq/GSE140228/GSE140228.RData")
selected_names <- colnames(data)
all_names <- cell.type$Cell
hits <- match(selected_names, all_names)
selected_types <- cell.type$`Celltype (major-lineage)`[hits]
result <- MEBF(data, DIM = 11, Thres = 0.6)
B_original <- result[[2]]
clustering_analysis(B_original, selected_types)
library(pdfCluster)
clustering_analysis(B_original, selected_types)
setwd("~/Projects/BiasAware/Struggle/scRNA-seq/GSE140228")
mat_after_nn <- as.matrix(read.csv('denoised.csv')[, -1])
result <- MEBF(mat_after_nn, DIM = 11, Thres = 0.6)
B_denoised <- result[[2]]
clustering_analysis(B_denoised, selected_types)
mat_after_nn <- as.matrix(read.csv('denoised.csv')[, -1])
result <- MEBF(mat_after_nn, DIM = 11, Thres = 0.6)
B_denoised <- result[[2]]
clustering_analysis(B_denoised, selected_types)
mat_after_nn <- as.matrix(read.csv('denoised2.csv')[, -1])
result <- MEBF(mat_after_nn, DIM = 11, Thres = 0.6)
B_denoised <- result[[2]]
clustering_analysis(B_denoised, selected_types)
mat_after_nn <- as.matrix(read.csv('denoised2.csv')[, -1])
result <- MEBF(mat_after_nn, DIM = 11, Thres = 0.6)
B_denoised <- result[[2]]
clustering_analysis(B_denoised, selected_types)
rm(list=ls())
gc()
load("~/Projects/BiasAware/Struggle/scRNA-seq/GSE125449/GSE125449.RData")
library(readr)
top2k_new <- read_csv("~/Projects/BiasAware/Struggle/scRNA-seq/GSE125449/top2k_new.csv")
View(top2k_new)
data <- top2k_new2[, -1]
selected_names <- colnames(data)
all_names <- cell.type$Cell
hits <- match(selected_names, all_names)
selected_types <- cell.type$`Celltype (minor-lineage)`[hits]
result <- MEBF(data, DIM = 8, Thres = 0.6)
source("~/Projects/BiasAware/Struggle/MEBF.R")
result <- MEBF(data, DIM = 8, Thres = 0.6)
result <- MEBF(data, DIM = 8, Thres = 0.6)
result <- MEBF(data, DIM = 11, Thres = 0.6)
result <- MEBF(as.matrix(data), DIM = 8, Thres = 0.6)
data <- top2k_new2[, -1]
data <- top2k_new[, -1]
selected_names <- colnames(data)
all_names <- cell.type$Cell
hits <- match(selected_names, all_names)
selected_types <- cell.type$`Celltype (minor-lineage)`[hits]
result <- MEBF(data, DIM = 8, Thres = 0.6)
B_original <- result[[2]]
clustering_analysis(B_original, selected_types)
clustering_analysis <- function(assign_matrix, all_labels) {
pos <- apply(assign_matrix, 2, sum)==1
sub_matrix <- assign_matrix[, pos]
cluster_labels <- rep(0, dim(sub_matrix)[[2]])
for (j in 1:dim(sub_matrix)[[2]]) {
cluster_labels[[j]] <- which(sub_matrix[, j]==1)
}
true_labels <- all_labels[pos]
return(adj.rand.index(cluster_labels, true_labels))
}
clustering_analysis(B_original, selected_types)
setwd("~/Projects/BiasAware/Struggle/scRNA-seq/GSE125449")
mat_after_nn <- as.matrix(read.csv('denoised.csv')[, -1])
result <- MEBF(mat_after_nn, DIM = 8, Thres = 0.6)
B_denoised <- result[[2]]
clustering_analysis(B_denoised, selected_types)
selected_types <- cell.type$`Celltype (major-lineage)`[hits]
result <- MEBF(data, DIM = 8, Thres = 0.6)
B_original <- result[[2]]
clustering_analysis(B_original, selected_types)
rm(list=ls())
gc()
setwd("~/Projects/BiasAware/Struggle/scRNA-seq/GSE140228")
load("~/Projects/BiasAware/Struggle/scRNA-seq/GSE140228/GSE140228.RData")
library(pdfCluster)
clustering_analysis <- function(assign_matrix, all_labels) {
pos <- apply(assign_matrix, 2, sum)==1
sub_matrix <- assign_matrix[, pos]
cluster_labels <- rep(0, dim(sub_matrix)[[2]])
for (j in 1:dim(sub_matrix)[[2]]) {
cluster_labels[[j]] <- which(sub_matrix[, j]==1)
}
true_labels <- all_labels[pos]
return(adj.rand.index(cluster_labels, true_labels))
}
library(readr)
top2k <- read_csv("top2k.csv")
View(top2k)
# extract ground truth cell type labels
data <- top2k[, -1]
selected_names <- colnames(data)
all_names <- cell.type$Cell
hits <- match(selected_names, all_names)
selected_types <- cell.type$`Celltype (major-lineage)`[hits]
# clustering analysis of original data
B_original <- read.csv('B2.csv')[, -1]
# clustering analysis of original data
B_original <- read.csv('B.csv')[, -1]
clustering_analysis(B_original, selected_types)
# clustering analysis of denoised data
B_denoised <- read.csv('B_d.csv')[, -1]
clustering_analysis(B_denoised, selected_types)
