First, I’m loading the required libraries & functions
suppressPackageStartupMessages(library(Seurat, lib.loc = "/software/Seuratv4/lib/")) # Seurat v4.4.0, library for single-cell analysis
suppressPackageStartupMessages(library(SeuratObject, lib.loc = "/software/Seuratv4/lib/")) # For compatibility purpose
suppressPackageStartupMessages(library(data.table)) # For writing DE gene file
suppressPackageStartupMessages(library(loomR)) # For building a file for ASAP
suppressPackageStartupMessages(library(Matrix)) # For building a file for ASAP
suppressPackageStartupMessages(library(ggplot2)) # For plotting
suppressPackageStartupMessages(library(ggpubr)) # For grid plotting
suppressPackageStartupMessages(library(plotly)) # For interactive plots
suppressPackageStartupMessages(library(crayon)) # Just for bolding the console output :D
cat(bold("Seurat"), "version", as.character(packageVersion("Seurat")), "\n")
## Seurat version 4.4.0
cat(bold("SeuratObject"), "version", as.character(packageVersion("SeuratObject")), "\n")
## SeuratObject version 4.1.4
cat(bold("data.table"), "version", as.character(packageVersion("data.table")), "\n")
## data.table version 1.16.4
cat(bold("loomR"), "version", as.character(packageVersion("loomR")), "\n")
## loomR version 0.2.0
cat(bold("Matrix"), "version", as.character(packageVersion("Matrix")), "\n")
## Matrix version 1.6.5
cat(bold("ggplot2"), "version", as.character(packageVersion("ggplot2")), "\n")
## ggplot2 version 3.5.1
cat(bold("ggpubr"), "version", as.character(packageVersion("ggpubr")), "\n")
## ggpubr version 0.6.0
cat(bold("plotly"), "version", as.character(packageVersion("plotly")), "\n")
## plotly version 4.10.4
# Random seed
set.seed(42)
Paper: Molecular Architecture of the Mouse Nervous System Zeisel, Amit et al. Cell, Volume 174, Issue 4, 999 - 1014.e22
Data repo: http://mousebrain.org/adolescent/downloads.html
Loom file: https://storage.googleapis.com/linnarsson-lab-loom/l5_all_rev1.loom
## Parameters
input_loom <- "./data/l5_all_rev1.loom"
input_Oxphos_133_AUCell_values_path <- "./data/Linnarsson_133_Oxphos_AUCell_auc.tsv"
output_figure_prefix <- "./figures/Figure_5A/"
First step is to read the Loom file
# Connect to the file
ds <- connect(filename = input_loom, mode = "r") # r for read-only and r+ for read/write
# Basic things
cell_id = ds[["col_attrs/CellID"]][]
ensembl = ds[["row_attrs/Accession"]][]
genes = ds[["row_attrs/Gene"]][]
# Retrieve metadata
data.metadata <- data.frame(cellID = cell_id)
for(col_attr in names(ds[["col_attrs"]])){
data.metadata[col_attr] <- ds[[paste0("col_attrs/", col_attr)]][]
}
# Close the file handle
ds$close_all()
data.metadata