# @hidden_cell
library(Seurat)
library(data.table)
library(dplyr)
library(SeuratDisk)
library(ggplot2)
library(patchwork)
options(repr.plot.width=16, repr.plot.height=8)
work.dir<-"~/cluster/projects/u19_multiomics"
immune.combined<-readRDS(paste0(work.dir, "/analyses/lungs_and_spleens_merged.rds"))
immune.combined
Loading required package: Signac
An object of class Seurat 187471 features across 53647 samples within 3 assays Active assay: RNA (36601 features, 0 variable features) 2 other assays present: ATAC, integrated 2 dimensional reductions calculated: pca, umap
ct.clusters<-read.csv(paste0(work.dir, "/analyses/merged_scRNA_Immune_low_labels.csv"))
immune.combined@meta.data[,"majority_voting"]<-ct.clusters$majority_voting
# Visualization
p1 <- DimPlot(immune.combined, reduction = "umap",
group.by = "full.ident", label=TRUE, repel = TRUE) +
ggtitle("Tissue of origin")
p2 <- DimPlot(immune.combined, reduction = "umap",
group.by = "majority_voting", label = TRUE, repel = TRUE) +
ggtitle("cell types from majority voting")
p1 + p2
DimPlot(immune.combined, split.by="tissue.ident")
Idents(immune.combined)<-"majority_voting"
levels(immune.combined@active.ident)
ggplot(immune.combined@meta.data,
aes(majority_voting, fill=tissue.ident)) +
geom_bar() + theme_light(base_size = 15) +
theme(axis.text.x=element_text(size=15, vjust=0.7, angle = 45))
for(c in levels(immune.combined@active.ident)){
DEG.test<-FindMarkers(immune.combined, ident.1="lungs", group.by="tissue.ident",
subset.ident=c, test.use = "wilcox")
#uniform the format of separator
c<-gsub("/", "_", c)
c<-gsub(" ", "_", c)
write.table(DEG.test, sprintf("../../output/DE_analysis_wilcox/%s_DE_results.csv", c), quote = F, sep=",")
}
Differential expression test was performed on normalized values stored in immune.combine[["RNA"]]@data
. Here are the normalization steps:
for(c in levels(immune.combined@active.ident)){
DEG.test<-FindMarkers(immune.combined, ident.1="lungs", group.by="tissue.ident",
subset.ident=c, test.use = "MAST")
#uniform the format of separator
c<-gsub("/", "_", c)
c<-gsub(" ", "_", c)
write.table(DEG.test, sprintf("../../output/DE_analysis_mast/%s_DE_results.csv", c), quote = F, sep=",")
}
Color scheme:
Red: negative log2FC
blue: positive log2FC
grey: data points not passing bonferroni corrected cutoff 0.05
input.tbl<-read.csv("../../output/DE_analysis_mast/Tem_Trm_cytotoxic_T_cells_DE_results.csv", header=T)
volcano_plots<-list()
for(c in levels(immune.combined@active.ident)){
#uniform the format of separator
c<-gsub("/", "_", c)
c<-gsub(" ", "_", c)
print(c)
input.tbl<-read.table(sprintf("../../output/DE_analysis_mast/%s_DE_results.csv", c), sep=",")
p<-ggplot(input.tbl, aes(x=avg_log2FC, y=-log10(p_val),
colour=avg_log2FC>0)) +
geom_point(size=2) +
geom_point(data=input.tbl%>%filter(p_val_adj>0.05),
aes(x=avg_log2FC, y=-log10(p_val)),
colour=alpha("grey",0.7), size=2) +
theme_light(base_size=15) + theme(legend.position = "none") +
ggtitle(c)
volcano_plots[[c]]<-p
}
[1] "Memory_B_cells" [1] "CD16+_NK_cells" [1] "Tcm_Naive_helper_T_cells" [1] "Tem_Trm_cytotoxic_T_cells" [1] "Type_17_helper_T_cells" [1] "ILC3" [1] "Plasma_cells" [1] "Naive_B_cells" [1] "Regulatory_T_cells" [1] "Classical_monocytes" [1] "CD16-_NK_cells" [1] "Epithelial_cells"
library(gridExtra)
ml <- marrangeGrob(volcano_plots, nrow=2, ncol=3)
ml
[[1]] NULL [[2]] NULL
Identify the known pathways that are enriched with the differentially expressed genes in lungs