|
| 1 | +library(dplyr) |
| 2 | +library(Seurat) |
| 3 | +library(patchwork) |
| 4 | +library(clustifyr) |
| 5 | +library(tidyverse) |
| 6 | +library(digest) |
| 7 | +library(here) |
| 8 | + |
| 9 | +proj_dir <- here() |
| 10 | +GSE131957 <- file.path(proj_dir, "Reference-Matrix-Generation", "data", "GSE131957_Raw 2", "GSM3832740_ccr7ko_naive_adt.csv.gz") |
| 11 | + |
| 12 | +mat_mouseLungLesions <- read.csv(GSE131957) |
| 13 | +mat_mouseLungLesions <- mat_mouseLungLesions %>% |
| 14 | + # as.data.frame() %>% |
| 15 | + column_to_rownames('X') |
| 16 | +# as.matrix() %>% |
| 17 | +# t() |
| 18 | +mat_mouseLungLesions[1:5, 1:5] |
| 19 | + |
| 20 | +meta_mouseLungLesions <- read_csv("ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE131nnn/GSE131957/suppl/GSE131957_single_cell_metadata.csv.gz") |
| 21 | +meta_mouseLungLesions <- meta_mouseLungLesions %>% column_to_rownames("X1") %>% t() %>% as.data.frame() |
| 22 | +meta2 <- meta_mouseLungLesions[colnames(mat_mouseLungLesions),] |
| 23 | +meta_mouseLungLesions |
| 24 | +sum(colnames(mat_mouseLungLesions) %in% meta_mouseLungLesions$cluster) |
| 25 | +ncol(mat_mouseLungLesions) |
| 26 | + |
| 27 | +source("~/Reference-Matrix-Generation/R/utils/utils.r") |
| 28 | +checkRawCounts(as.matrix(mat_mouseLungLesions)) |
| 29 | + |
| 30 | +GSE131957WTNaiveNormalized <- NormalizeData(mat_mouseLungLesions) |
| 31 | + |
| 32 | +new_ref_matrix <- average_clusters(mat = GSE131957WTNaiveNormalized, metadata = meta2, cluster_col = "cluster_annotation", if_log = FALSE) |
| 33 | +new_ref_matrix_hashed <- average_clusters(mat = mat_mouseLungLesions, metadata = meta_mouseLungLesions, if_log = FALSE) |
| 34 | +head(new_ref_matrix) |
| 35 | +tail(new_ref_matrix) |
| 36 | +newcols <- sapply(colnames(new_ref_matrix_hashed), digest, algo = "sha1") |
| 37 | +colnames(new_ref_matrix_hashed) <- newcols |
| 38 | +head(new_ref_matrix_hashed) |
| 39 | +tail(new_ref_matrix_hashed) |
| 40 | +saveRDS(new_ref_matrix_hashed, "GSE131957Hashed.rds") |
| 41 | +saveRDS(new_ref_matrix, "GSE131957ccr7koNaiveADT.rds") |
0 commit comments