-
Notifications
You must be signed in to change notification settings - Fork 3
/
vsBulk_Impute.R
39 lines (36 loc) · 1.28 KB
/
vsBulk_Impute.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
source("~/MAGIC/R_Imputation_Functions.R")
require("scater")
require("methods")
# wd : /lustre/scratch117/cellgen/team218/TA/Simulations_Temporary_Files/Imputation/vsBulk/
# Create SCE - Kolo
dat <- read.table("counttable_es.csv", header=T)
dat <- dat[,-grep("_2i_", colnames(dat))]
dat <- dat[-grep("^ERCC-", rownames(dat)), ]
dat <- dat[-grep("__", rownames(dat)), ]
dat <- dat[rowSums(dat > 0) > 5,]
ann <- strsplit(colnames(dat), "_")
batch <- unlist(lapply(ann, function(a){a[4]}))
Group <- unlist(lapply(ann, function(a){a[3]}))
ann <- data.frame(batch=batch, Group=Group)
rownames(ann) <- colnames(dat)
sce_kolo <- SingleCellExperiment(assays=list(counts=as.matrix(dat)), colData=ann)
sce_kolo <- normalize(sce_kolo);
# Impute
sce_kolo <- Impute_default_all(sce_kolo)
# Save
saveRDS(sce_kolo, "Kolo_imputed.rds");
# Create SCE - Tung
dat <- read.table("GSE77288_molecules-raw-single-per-sample.txt.gz", header=T)
ann <- dat[,1:3]
dat <- dat[,-c(1:3)]
dat <- t(dat)
colnames(dat) <- paste("Cell", 1:ncol(dat));
dat <- dat[rowSums(dat > 0) > 5,]
rownames(ann) <- colnames(dat);
ann$Group <- ann$individual
sce_tung <- SingleCellExperiment(assays=list(counts=dat), colData=ann)
sce_tung <- normalize(sce_tung);
# Impute
sce_tung <- Impute_default_all(sce_tung)
# Save
saveRDS(sce_tung, "Tung_imputed.rds");