Commit 196c84d0 authored by Lena Hersemann's avatar Lena Hersemann

updated script according to recent Seurat updates

parent 401eda6f
......@@ -86,7 +86,7 @@ sop %>% kable()
## load count matrix and annotation data
count_data <- fread(count_matrix_file)
count_matrix <- as.data.frame(count_data) %>%
column_to_rownames(colnames(count_data)[str_detect(colnames(count_data), "gene_id")]) %>%
column_to_rownames(colnames(count_data)[str_detect(colnames(count_data), "gene_")]) %>%
as.matrix()
pheno_data <- fread(annot_data_file) %>% as.data.frame()
......@@ -133,14 +133,10 @@ gene_info %>% write_tsv("gene_infos.txt")
## create Surat object -------------------------------------------------------------------------------------------------
# we do not apply additional filter at this stage, i.e. min.cells, min.genes and is.expr are set to 0
seo <- CreateSeuratObject(raw.data = count_matrix, meta.data = pheno_data)
seo <- CreateSeuratObject(counts = count_matrix, meta.data = pheno_data)
rm(count_data)
rm(count_matrix)
## convert to sparse matrix
seo <- MakeSparse(seo)
## calculate and add proportion of mitochondrial genes
if (!"percent.mito" %in% colnames(as.data.frame(seo@meta.data))) {
mito.genes <- gene_info %>%
......@@ -159,7 +155,7 @@ if (!"percent.mito" %in% colnames(as.data.frame(seo@meta.data))) {
# check quality metrics ------------------------------------------------------------------------------------------------
#' ## Quality metrices of single cells
cells_before = ncol(seo@data)
cells_before = ncol(GetAssayData(seo))
cf <- sop %>% filter(str_detect(parameter, "cell_filter")) %>% #na.omit() %>%
transmute(feature = str_replace_all(parameter, "cell_filter_|_min|_max", ""), direction = str_match(parameter, "_([a-z]+$)")[,2], settings = ifelse(is.na(settings), Inf, as.numeric(settings))) %>% spread(direction, settings) %>% filter(max != min) %>% mutate(min = replace(min, is.infinite(min), 0))
......@@ -431,3 +427,5 @@ writeLines(capture.output(devtools::session_info()), ".sessionInfo.txt")
session::save.session(".seurat_analysis.R.dat");
# session::restore.session(".seurat_analysis.R.dat")
#accessing new Seurat object: https://github.com/satijalab/seurat/wiki/Seurat
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment