knitr::opts_chunk$set(echo = TRUE) options(width = 100)
The count table was downloaded from https://s3.amazonaws.com/czbiohub-tabula-muris/TM_facs_mat.rds, following instructions on https://github.com/czbiohub/tabula-muris-vignettes/tree/master/data (accessed August 26, 2018).
The metadata was obtained from https://github.com/czbiohub/tabula-muris-vignettes/tree/master/data (accessed August 26, 2018).
suppressPackageStartupMessages({ library(Matrix) library(SingleCellExperiment) library(readr) library(dplyr) }) counts <- readRDS("TM_facs_mat.rds") metadata <- readr::read_csv("TM_facs_metadata.csv")
SingleCellExperiment
objectstopifnot(all(colnames(counts) == metadata$cell)) smartseq2 <- SingleCellExperiment( assay = list(counts = counts), colData = DataFrame(metadata %>% dplyr::rename(mouse_id = mouse.id, mouse_sex = mouse.sex, plate_barcode = plate.barcode, FACS_selection = FACS.selection)), rowData = DataFrame(ID = rownames(counts), Symbol = rownames(counts)) )
SingleCellExperiment::isSpike(smartseq2, "ERCC") <- grep("^ERCC-", rownames(smartseq2)) dim(smartseq2) table(isSpike(smartseq2, "ERCC"))
smartseq2$mouse_id <- vapply(smartseq2$mouse_id, function(i) { tmp <- lapply(strsplit(i, "/")[[1]], function(w) { strsplit(w, "_")[[1]] }) paste(unlist(vapply(c(1, 3, 2), function(j) { paste(unique(unlist(lapply(tmp, function(x) x[j]))), collapse = "/") }, "")), collapse = "-") }, "")
SingleCellExperiment
objectsmartseq2 head(colData(smartseq2)) saveRDS(smartseq2, file = "TabulaMurisSmartSeq2.rds")
sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.