library(sceptre)
#install.packages("devtools")
#devtools::install_github("katsevich-lab/sceptre")
#install.packages("tidyverse")
#install.packages("cowplot")
# SCEPTRE example
library(tidyverse)
library(cowplot)
library(Matrix)
library(sceptre)
data(gene_matrix)
data(gRNA_matrix)
data(covariate_matrix)
perturbation_matrix <- threshold_gRNA_matrix(gRNA_matrix)
data("gRNA_groups_table")
combined_perturbation_matrix <- combine_perturbations(perturbation_matrix = perturbation_matrix,
gRNA_groups_table = gRNA_groups_table)
data(gene_gRNA_group_pairs)
side <- "left"
result <- run_sceptre_high_moi(gene_matrix = gene_matrix,
combined_perturbation_matrix = combined_perturbation_matrix,
covariate_matrix = covariate_matrix,
gene_gRNA_group_pairs = gene_gRNA_group_pairs,
side = side)
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# generate covariate matrix
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
rownames(covariate_matrix2) <- colnames(gene_matrix2)
covariate_matrix2$lg_gRNA_lib_size <- 10
covariate_matrix2$lg_gene_lib_size <- 10
covariate_matrix2$p_mito <- 0.001
covariate_matrix2$batch <- "prep_batch_1"
covariate_matrix2 <- covariate_matrix2[c("lg_gRNA_lib_size","lg_gene_lib_size",
"p_mito","batch")]
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE)[,1:3])
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
# gene gRNA group pairs
gene_gRNA_group_pairs2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gene_gRNA_group_pairs2.csv", header = TRUE)[,1:3])
result2 <- run_sceptre_high_moi(gene_matrix = gene_matrix2,
combined_perturbation_matrix = combined_perturbation_matrix2,
covariate_matrix = covariate_matrix2,
gene_gRNA_group_pairs = gene_gRNA_group_pairs2,
side = side)
View(combined_perturbation_matrix2)
View(gRNA_matrix2)
gene_matrix2
combined_perturbation_matrix2
dim(gene_matrix2)
dim(combined_perturbation_matrix2)
combined_perturbation_matrix2
View(combined_perturbation_matrix)
View(gRNA_matrix)
View(gene_matrix2)
View(gene_matrix)
View(combined_perturbation_matrix2)
View(gene_gRNA_group_pairs2)
View(gene_gRNA_group_pairs)
dim(gene_gRNA_group_pairs2)
gene_gRNA_group_pairs2 <- gene_gRNA_group_pairs2[(gene_gRNA_group_pairs2$gene_id %in% rownames(gene_matrix2)), ]
dim(gene_gRNA_group_pairs2)
result2 <- run_sceptre_high_moi(gene_matrix = gene_matrix2,
combined_perturbation_matrix = combined_perturbation_matrix2,
covariate_matrix = covariate_matrix2,
gene_gRNA_group_pairs = gene_gRNA_group_pairs2,
side = side)
View(gene_gRNA_group_pairs2)
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# generate covariate matrix
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
rownames(covariate_matrix2) <- colnames(gene_matrix2)
covariate_matrix2$lg_gRNA_lib_size <- 10
covariate_matrix2$lg_gene_lib_size <- 10
covariate_matrix2$p_mito <- 0.001
covariate_matrix2$batch <- "prep_batch_1"
covariate_matrix2 <- covariate_matrix2[c("lg_gRNA_lib_size","lg_gene_lib_size",
"p_mito","batch")]
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE)[,1:3])
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
# gene gRNA group pairs
gene_gRNA_group_pairs2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gene_gRNA_group_pairs2.csv", header = TRUE)[,1:3])
gene_gRNA_group_pairs2 <- gene_gRNA_group_pairs2[(gene_gRNA_group_pairs2$gene_id %in% rownames(gene_matrix2)), ]
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# generate covariate matrix
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
rownames(covariate_matrix2) <- colnames(gene_matrix2)
covariate_matrix2$lg_gRNA_lib_size <- 10
covariate_matrix2$lg_gene_lib_size <- 10
covariate_matrix2$p_mito <- 0.001
covariate_matrix2$batch <- "prep_batch_1"
covariate_matrix2 <- covariate_matrix2[c("lg_gRNA_lib_size","lg_gene_lib_size",
"p_mito","batch")]
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE)[,1:3])
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
# gene gRNA group pairs
gene_gRNA_group_pairs2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gene_gRNA_group_pairs2.csv", header = TRUE)[,1:3])
dim(gene_matrix2)
rownames(gene_matrix2)
gene_gRNA_group_pairs2$gene_id
(gene_gRNA_group_pairs2$gene_id %in% rownames(gene_matrix2))
rownames(gene_gRNA_group_pairs2) <- gene_gRNA_group_pairs2$gene_id
is_tibble(gene_gRNA_group_pairs2)
gene_gRNA_group_pairs2 <- as.data.frame(gene_gRNA_group_pairs2)
gene_gRNA_group_pairs2 <- gene_gRNA_group_pairs2[(gene_gRNA_group_pairs2$gene_id %in% rownames(gene_matrix2)), ]
dim(gene_gRNA_group_pairs2)
rownames(gene_matrix2)
gene_gRNA_group_pairs2 <- as.data.frame(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gene_gRNA_group_pairs2.csv", header = TRUE)[,1:3])
genes <- rownames(gene_matrix2)
gene_gRNA_group_pairs2 <- as.data.frame(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gene_gRNA_group_pairs2.csv", header = TRUE)[,1:3])
gene_gRNA_group_pairs2 <- as.data.frame(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gene_gRNA_group_pairs2.csv", header = TRUE)[,1:3])
gene_gRNA_group_pairs2$check <- paste0(gene_gRNA_group_pairs2$gene_id, gene_gRNA_group_pairs2$gRNA_group, gene_gRNA_group_pairs2$pair_type)
dim(gene_gRNA_group_pairs2)
gene_gRNA_group_pairs2 <- gene_gRNA_group_pairs2[!duplicated(gene_gRNA_group_pairs2[,"check"]),]
dim(gene_gRNA_group_pairs2)
gene_gRNA_group_pairs2 <- as_tibble(gene_gRNA_group_pairs2)
result2 <- run_sceptre_high_moi(gene_matrix = gene_matrix2,
combined_perturbation_matrix = combined_perturbation_matrix2,
covariate_matrix = covariate_matrix2,
gene_gRNA_group_pairs = gene_gRNA_group_pairs2,
side = side)
result2 <- run_sceptre_high_moi(gene_matrix = gene_matrix2,
combined_perturbation_matrix = combined_perturbation_matrix2,
covariate_matrix = covariate_matrix2,
gene_gRNA_group_pairs = gene_gRNA_group_pairs2,
side = side)
View(gene_gRNA_group_pairs)
View(gene_gRNA_group_pairs2)
View(gene_gRNA_group_pairs)
gene_gRNA_group_pairs2 <- as_tibble(gene_gRNA_group_pairs2)[,1:3]
result2 <- run_sceptre_high_moi(gene_matrix = gene_matrix2,
combined_perturbation_matrix = combined_perturbation_matrix2,
covariate_matrix = covariate_matrix2,
gene_gRNA_group_pairs = gene_gRNA_group_pairs2,
side = side)
View(gRNA_groups_table2)
View(gRNA_groups_table)
View(gene_gRNA_group_pairs)
View(gene_gRNA_group_pairs2)
View(gRNA_groups_table2)
gene_gRNA_group_pairs2 <- as.data.frame(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gene_gRNA_group_pairs2.csv", header = TRUE)[,1:3])
gene_gRNA_group_pairs2 <- as_tibble(gene_gRNA_group_pairs2)[,1:3]
result2 <- run_sceptre_high_moi(gene_matrix = gene_matrix2,
combined_perturbation_matrix = combined_perturbation_matrix2,
covariate_matrix = covariate_matrix2,
gene_gRNA_group_pairs = gene_gRNA_group_pairs2,
side = side)
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE)[,1:3])
#install.packages("devtools")
#devtools::install_github("katsevich-lab/sceptre")
#install.packages("tidyverse")
#install.packages("cowplot")
# SCEPTRE example
library(tidyverse)
library(cowplot)
library(Matrix)
library(sceptre)
data(gene_matrix)
data(gRNA_matrix)
data(covariate_matrix)
perturbation_matrix <- threshold_gRNA_matrix(gRNA_matrix)
data("gRNA_groups_table")
combined_perturbation_matrix <- combine_perturbations(perturbation_matrix = perturbation_matrix,
gRNA_groups_table = gRNA_groups_table)
data(gene_gRNA_group_pairs)
side <- "left"
result <- run_sceptre_high_moi(gene_matrix = gene_matrix,
combined_perturbation_matrix = combined_perturbation_matrix,
covariate_matrix = covariate_matrix,
gene_gRNA_group_pairs = gene_gRNA_group_pairs,
side = side)
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# generate covariate matrix
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
rownames(covariate_matrix2) <- colnames(gene_matrix2)
covariate_matrix2$lg_gRNA_lib_size <- 10
covariate_matrix2$lg_gene_lib_size <- 10
covariate_matrix2$p_mito <- 0.001
covariate_matrix2$batch <- "prep_batch_1"
covariate_matrix2 <- covariate_matrix2[c("lg_gRNA_lib_size","lg_gene_lib_size",
"p_mito","batch")]
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE)[,1:3])
View(gRNA_groups_table2)
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
View(perturbation_matrix2)
#install.packages("devtools")
#devtools::install_github("katsevich-lab/sceptre")
#install.packages("tidyverse")
#install.packages("cowplot")
# SCEPTRE example
library(tidyverse)
library(cowplot)
library(Matrix)
library(sceptre)
data(gene_matrix)
data(gRNA_matrix)
data(covariate_matrix)
perturbation_matrix <- threshold_gRNA_matrix(gRNA_matrix)
data("gRNA_groups_table")
combined_perturbation_matrix <- combine_perturbations(perturbation_matrix = perturbation_matrix,
gRNA_groups_table = gRNA_groups_table)
data(gene_gRNA_group_pairs)
side <- "left"
result <- run_sceptre_high_moi(gene_matrix = gene_matrix,
combined_perturbation_matrix = combined_perturbation_matrix,
covariate_matrix = covariate_matrix,
gene_gRNA_group_pairs = gene_gRNA_group_pairs,
side = side)
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE)[,1:3])
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
View(perturbation_matrix2)
dim(perturbation_matrix2)
dim(gRNA_groups_table2)
colnames(gRNA_matrix2)
rownames(gRNA_matrix2)
rownames(gene_matrix2)
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE)[,1:3])
View(gRNA_groups_table2)
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
# load
setwd("./Developing/rotation2/")
setwd("~/Developing/rotation2")
#install.packages("devtools")
#devtools::install_github("katsevich-lab/sceptre")
#install.packages("tidyverse")
#install.packages("cowplot")
# SCEPTRE example
library(tidyverse)
library(cowplot)
library(Matrix)
library(sceptre)
data(gene_matrix)
data(gRNA_matrix)
data(covariate_matrix)
perturbation_matrix <- threshold_gRNA_matrix(gRNA_matrix)
data("gRNA_groups_table")
combined_perturbation_matrix <- combine_perturbations(perturbation_matrix = perturbation_matrix,
gRNA_groups_table = gRNA_groups_table)
data(gene_gRNA_group_pairs)
side <- "left"
result <- run_sceptre_high_moi(gene_matrix = gene_matrix,
combined_perturbation_matrix = combined_perturbation_matrix,
covariate_matrix = covariate_matrix,
gene_gRNA_group_pairs = gene_gRNA_group_pairs,
side = side)
```{r,eval=FAlSE}
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# generate covariate matrix
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
rownames(covariate_matrix2) <- colnames(gene_matrix2)
covariate_matrix2$lg_gRNA_lib_size <- 10
covariate_matrix2$lg_gene_lib_size <- 10
covariate_matrix2$p_mito <- 0.001
covariate_matrix2$batch <- "prep_batch_1"
covariate_matrix2 <- covariate_matrix2[c("lg_gRNA_lib_size","lg_gene_lib_size",
"p_mito","batch")]
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
View(gRNA_groups_table)
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
View(perturbation_matrix2)
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE))
View(gRNA_matrix)
View(gRNA_groups_table2)
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
remove.packages("sceptre", lib="~/R/x86_64-pc-linux-gnu-library/4.2")
library(tidyverse)
library(cowplot)
library(Matrix)
library(sceptre)
side <- "left"
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
setwd("~/Developing/rotation2")
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# generate covariate matrix
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
rownames(covariate_matrix2) <- colnames(gene_matrix2)
covariate_matrix2$lg_gRNA_lib_size <- 10
covariate_matrix2$lg_gene_lib_size <- 10
covariate_matrix2$p_mito <- 0.001
covariate_matrix2$batch <- "prep_batch_1"
covariate_matrix2 <- covariate_matrix2[c("lg_gRNA_lib_size","lg_gene_lib_size",
"p_mito","batch")]
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE))
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
View(perturbation_matrix2)
View(gRNA_groups_table2)
is_tibble(gRNA_groups_table2)
library(sceptre)
remove.packages("sceptre", lib="/usr/local/lib/R/site-library")
remove.packages("sceptre", lib="/usr/local/lib/R/site-library")
remove.packages("sceptre", lib="/usr/local/lib/R/site-library")
setwd("~/Developing/rotation2")
# load
setwd("./Developing/rotation2/")
library(workflowr)
library(sceptre)
library(tidyverse)
library(cowplot)
library(Matrix)
data(gene_matrix)
data(gRNA_matrix)
data(covariate_matrix)
perturbation_matrix <- threshold_gRNA_matrix(gRNA_matrix)
data("gRNA_groups_table")
combined_perturbation_matrix <- combine_perturbations(perturbation_matrix = perturbation_matrix,
gRNA_groups_table = gRNA_groups_table)
data(gene_gRNA_group_pairs)
side <- "left"
result <- run_sceptre_high_moi(gene_matrix = gene_matrix,
combined_perturbation_matrix = combined_perturbation_matrix,
covariate_matrix = covariate_matrix,
gene_gRNA_group_pairs = gene_gRNA_group_pairs,
side = side)
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE))
View(gRNA_groups_table2)
View(gRNA_groups_table)
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
remove.packages("sceptre", lib="~/R/x86_64-pc-linux-gnu-library/4.2")
library(sceptre)
setwd("~/Developing/rotation2")
library(tidyverse)
library(cowplot)
library(Matrix)
library(sceptre)
side <- "left"
# read gene and gRNA matrices
Expression <- readRDS("../Morris_2021/filter/Expression.rds", refhook = NULL)
gRNA <- readRDS("../Morris_2021/filter/gRNA.rds", refhook = NULL)
gene_matrix2 <- as(Expression@assays$RNA@counts, "dgTMatrix")
gRNA_matrix2 <- as(gRNA@assays$RNA@counts, "dgTMatrix")
rm("Expression","gRNA")
# generate covariate matrix
covariate_matrix2 <- as.data.frame(colnames(gene_matrix2))
rownames(covariate_matrix2) <- colnames(gene_matrix2)
covariate_matrix2$lg_gRNA_lib_size <- 10
covariate_matrix2$lg_gene_lib_size <- 10
covariate_matrix2$p_mito <- 0.001
covariate_matrix2$batch <- "prep_batch_1"
covariate_matrix2 <- covariate_matrix2[c("lg_gRNA_lib_size","lg_gene_lib_size",
"p_mito","batch")]
# subset the expression matrix by gene
genes <- lapply(paste0("./output/SCEPTRE/gene-gRNA_pairs/",
list.files(path = "./output/SCEPTRE/gene-gRNA_pairs/", pattern='*_pairs.csv')),
read.csv)
genes <- do.call(rbind.data.frame, genes)[,"Gene"]
Sys.sleep(3)
gene_matrix2 <- gene_matrix2[(rownames(gene_matrix2) %in% genes), ]
rm("genes")
# generate perturbation matrix
perturbation_matrix2 <- threshold_gRNA_matrix(gRNA_matrix2)
# gRNA group table
gRNA_groups_table2 <- as_tibble(read.csv("./output/SCEPTRE/gene-gRNA_pairs/gRNA_groups_table2.csv", header = TRUE))
View(gRNA_groups_table2)
# combine perturbation
combined_perturbation_matrix2 <- combine_perturbations(perturbation_matrix = perturbation_matrix2,
gRNA_groups_table = gRNA_groups_table2)
