DOI: 10.5281/zenodo.10015471
title: TSd5.RDS - CD40 inhibiton in AMI on d5, seq on d7 and d14

description: ##### CD40 inhibiton in AMI on d5, seq on d7 and d14
 
 
# Load necessary libraries for data manipulation, analysis, and visualization
library(dplyr)
library(Seurat)
library(patchwork)
library(plyr)
 
# Set the working directory to the folder containing the data
setwd("C:/Users/ALL/sciebo - Lang, Alexander (allan101@uni-duesseldorf.de)@uni-duesseldorf.sciebo.de/ALL_NGS/scRNAseq/scRNAseq/01_TS_d5_paper/03_CD40 inhibition on day 5, seq on day 7 and 14/938-2_cellranger_count/outs")
 
# Read the M0 dataset from the 10X Genomics format
pbmc.data <- Read10X(data.dir = "filtered_feature_bc_matrix/")
 
RNA <- pbmc.data$`Gene Expression`
 
ADT <- pbmc.data$`Antibody Capture`
 
HST <- pbmc.data$`Multiplexing Capture`
 
 
# Load the Matrix package
library(Matrix)
 
# Hashtag 1, 2 and 3 are marking the mouse replicates per condition
# Subset the rows based on row names
subsetted_rows <- c("TotalSeq-B0301", "TotalSeq-B0302", "TotalSeq-B0303")
animals_data <- HST[subsetted_rows, , drop = FALSE]
 
# Hashtag 4, 5, 6, 7 are representing DMSO d7, TS d7, DMSO d14 and TS d14
subsetted_rows <- c(""TotalSeq-B0304", "TotalSeq-B0305", "TotalSeq-B0306", "TotalSeq-B0307")
treatment_data <- HST[subsetted_rows, , drop = FALSE]
 
#Create a Seurat obeject and more assays to combine later
RNA <- CreateSeuratObject(counts = RNA)
ADT <- CreateAssayObject(counts = ADT)
Mice <- CreateAssayObject(counts = animals_data)
Treatment <- CreateAssayObject(counts = treatment_data)
 
 
seurat <- RNA
 
#Add the Assays
seurat[["ADT"]] <- ADT
 
seurat[["HST_Mice"]] <- Mice
 
seurat[["HST_Treatment"]] <- Treatment
 
#Check for AK Names
rownames(seurat[["ADT"]])
 
#Cluster cells on the basis of their scRNA-seq profiles
# perform visualization and clustering steps
DefaultAssay(seurat) <- "RNA"
seurat <- NormalizeData(seurat)
seurat <- FindVariableFeatures(seurat)
seurat <- ScaleData(seurat)
seurat <- RunPCA(seurat, verbose = FALSE)
seurat <- FindNeighbors(seurat, dims = 1:30)
seurat <- FindClusters(seurat, resolution = 0.8, verbose = FALSE)
seurat <- RunUMAP(seurat, dims = 1:30)
DimPlot(seurat, label = TRUE)
 
FeaturePlot(seurat, features = "Col1a1", order = T)
 
# Normalize ADT data,
DefaultAssay(seurat) <- "ADT"
seurat <- NormalizeData(seurat, normalization.method = "CLR", margin = 2)
 
#Demultiplex cells based on Mouse_Hashtag Enrichment
seurat <- NormalizeData(seurat, assay = "HST_Mice", normalization.method = "CLR")
seurat <- HTODemux(seurat, assay = "HST_Mice", positive.quantile = 0.60)
 
 
#Visualize demultiplexing results
# Global classification results
table(seurat$HST_Mice_classification.global)
 
DimPlot(seurat, group.by = "HST_Mice_classification")
 
 
#Demultiplex cells based on Treatment_Hashtag Enrichment
seurat <- NormalizeData(seurat, assay = "HST_Treatment", normalization.method = "CLR")
seurat <- HTODemux(seurat, assay = "HST_Treatment", positive.quantile = 0.60)
 
 
#Visualize demultiplexing results
# Global classification results
table(seurat$HST_Treatment_classification.global)
 
DimPlot(seurat, group.by = "HST_Treatment_classification")
 
Idents(seurat) <- seurat$HST_Treatment_classification
pbmc.singlet <- subset(seurat, idents = "Negative", invert = T)
Idents(pbmc.singlet) <- pbmc.singlet$HST_Mice_classification
pbmc.singlet <- subset(pbmc.singlet, idents = "Negative", invert = T)
 
DimPlot(pbmc.singlet, group.by = "HST_Treatment_maxID")
 
#Redo the clssification to remove the doublettes
pbmc.singlet <- HTODemux(pbmc.singlet, assay = "HST_Treatment", positive.quantile = 0.99)
table(pbmc.singlet$HST_Treatment_classification.global)
 
DimPlot(pbmc.singlet, group.by = "HST_Treatment_classification")
pbmc.singlet <- subset(pbmc.singlet, idents = "Doublet", invert = T)
 
 
pbmc.singlet <- HTODemux(pbmc.singlet, assay = "HST_Mice", positive.quantile = 0.99)
table(pbmc.singlet$HST_Mice_classification.global)
pbmc.singlet <- subset(pbmc.singlet, idents = "Doublet", invert = T)
 
pbmc.singlet <- HTODemux(pbmc.singlet, assay = "HST_Mice", positive.quantile = 0.60)
pbmc.singlet <- HTODemux(pbmc.singlet, assay = "HST_Treatment", positive.quantile = 0.60)
DimPlot(pbmc.singlet, group.by = "HST_Treatment_maxID")
DimPlot(pbmc.singlet, group.by = "HST_Mice_maxID")
 
 
seurat <- pbmc.singlet
 
seurat$mice <- seurat$HST_Mice_maxID
seurat$treatment <- seurat$HST_Treatment_maxID
 
 
library(plyr)
seurat$treatment <- revalue(seurat$treatment, c(
 "TotalSeq-B0304" = "DMSO_d7",
 "TotalSeq-B0305" = "TS_d7",
 "TotalSeq-B0306" = "DMSO_d14",
 "TotalSeq-B0307" = "TS_d14"
))
 
library(plyr)
seurat$mice <- revalue(seurat$mice, c(
 "TotalSeq-B0301" = "1",
 "TotalSeq-B0302" = "2",
 "TotalSeq-B0303" = "3"
))
 
 
#Cluster cells on the basis of their scRNA-seq profiles without doublettes
# perform visualization and clustering steps
DefaultAssay(seurat) <- "RNA"
seurat <- NormalizeData(seurat)
seurat <- FindVariableFeatures(seurat)
seurat <- ScaleData(seurat)
seurat <- RunPCA(seurat, verbose = FALSE)
seurat <- FindNeighbors(seurat, dims = 1:30)
seurat <- FindClusters(seurat, resolution = 0.8, verbose = FALSE)
seurat <- RunUMAP(seurat, dims = 1:30)
DimPlot(seurat, label = TRUE)
 
 
DefaultAssay(seurat) <- "ADT"
seurat <- NormalizeData(seurat, normalization.method = "CLR", margin = 2)
setwd("C:/Users/ALL/sciebo - Lang, Alexander (allan101@uni-duesseldorf.de)@uni-duesseldorf.sciebo.de/ALL_NGS/scRNAseq/scRNAseq/01_TS_d5_paper/03_CD40 inhibition on day 5, seq on day 7 and 14/Analyse")
 
saveRDS(seurat, file= "TSd5.v0.1.RDS")