DOI: 10.5281/zenodo.10018138
title: CD40 activation and the effect on Neutrophils

description: ##### CD40 activation and the effect on Neutrophils
 
 
# 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/05_FGK45 Wirkung auf Neutros - scRNAseq/938-1_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 organs (heart, blood, spleen)
# 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 IgG_1, IgG_1, FGK45_1 and FGK45_1
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)
Organ <- CreateAssayObject(counts = animals_data)
Treatment <- CreateAssayObject(counts = treatment_data)
 
 
seurat <- RNA
 
#Add the Assays
seurat[["ADT"]] <- ADT
 
seurat[["HST_Mice"]] <- Organ
 
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 = "S100a9", 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.99)
 
 
#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.99)
 
 
#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$organ <- seurat$HST_Mice_maxID
seurat$mouse <- seurat$HST_Treatment_maxID
seurat$treatment <- seurat$HST_Treatment_maxID
 
 
library(plyr)
seurat$treatment <- revalue(seurat$treatment, c(
 "TotalSeq-B0304" = "IgG",
 "TotalSeq-B0305" = "IgG",
 "TotalSeq-B0306" = "FGK45",
 "TotalSeq-B0307" = "FGK45"
))
 
library(plyr)
seurat$organ <- revalue(seurat$organ, c(
 "TotalSeq-B0301" = "heart",
 "TotalSeq-B0302" = "blood",
 "TotalSeq-B0303" = "spleen"
))
 
seurat$mouse <- revalue(seurat$mouse, c(
 "TotalSeq-B0304" = "1",
 "TotalSeq-B0305" = "2",
 "TotalSeq-B0306" = "3",
 "TotalSeq-B0307" = "4"
))
 
 
#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/05_FGK45 Wirkung auf Neutros - scRNAseq/Analyse")
 
 
saveRDS(seurat, file = "FGK45_heart_blood_spleen.v0.1.RDS")