library(Seurat) library(dplyr) Full_final <- readRDS("/DATA/31/molteni/vexas_mouse_3/results/Full/01-seurat/Full_final.rds") # computation on cluster numbers setwd("/DATA/31/molteni/vexas_mouse_3/results/DE_markers/") Idents(Full_final)<-"RNA_snn_h.orig.ident_res.0.6" clusters <- levels(Full_final@meta.data$RNA_snn_h.orig.ident_res.0.6) for(i in 0:length(clusters)) { markers <- FindMarkers(Full_final, ident.1 = "A", group.by = "orig.ident", subset.ident = i) markers['cluster'] <- i filename=paste("markers_cluster_",i,".csv", sep="") write.csv(markers, file=filename) } df <- list.files(path='/DATA/31/molteni/vexas_mouse_3/results/DE_markers/') %>% lapply(read.csv) %>% bind_rows df <- df[df$p_val_adj<0.05,] write.csv(df, file="AvsC_sigMarkers.csv") cells_by_sample <- table(Full_final@meta.data$RNA_snn_h.orig.ident_res.0.6, Full_final@meta.data$orig.ident) write.csv(cells_by_sample, file="cells_bysample.csv") # computation on custom annotation Full_final <- readRDS("/DATA/31/molteni/vexas_mouse_3/results/Full/01-seurat/Full_final_annot.rds") setwd("/DATA/31/molteni/vexas_mouse_3/results/DE_markers2/new/") clusters <- unique (Full_final$celltypes_annot) for(i in clusters) { markers <- FindMarkers(Full_final, ident.1 = "A", group.by = "orig.ident", subset.ident = i) markers['cluster'] <- i filename=paste("markers_cluster_",i,".csv", sep="") write.csv(markers, file=filename) } df <- list.files(path='/DATA/31/molteni/vexas_mouse_3/results/DE_markers2/new/') %>% lapply(read.csv) %>% bind_rows df <- df[df$p_val_adj<0.05,] setwd("/DATA/31/molteni/vexas_mouse_3/results/summary") write.csv(df, file="AvsC_sigMarkers_custom.csv") cc_distribution <-as.data.frame (table(Full_final$Phase, Full_final$orig.ident, Full_final$celltypes_annot)) colnames(cc_distribution) <- c("Phase","orig.ident","cluster","CellNumb") write.csv(cc_distribution, file="cell_cycle.csv") # computation on custom annotation after filtering cluster 19, res 1.2 Full_final <- readRDS("/DATA/31/molteni/vexas_mouse_3/results/Full/01-seurat/Full_final_annot_filt.rds") setwd("/DATA/31/molteni/vexas_mouse_3/results/DE_markers/AvsC/") clusters <- unique (Full_final$celltypes_annot) for(i in clusters) { markers <- FindMarkers(Full_final, ident.1 = "A", group.by = "orig.ident", subset.ident = i) markers['cluster'] <- i filename=paste("markers_cluster_",i,".csv", sep="") write.csv(markers, file=filename) } df <- list.files(path='/DATA/31/molteni/vexas_mouse_3/results/DE_markers/AvsC/') %>% lapply(read.csv) %>% bind_rows df <- df[df$p_val_adj<0.05,] setwd("/DATA/31/molteni/vexas_mouse_3/results/summary") write.csv(df, file="AvsC_sigMarkers_custom.csv") cells_by_sample <- table(Full_final@meta.data$celltypes_annot, Full_final@meta.data$orig.ident) write.csv(cells_by_sample, file="cells_bysample.csv") cc_distribution <-as.data.frame (table(Full_final$Phase, Full_final$orig.ident, Full_final$celltypes_annot)) colnames(cc_distribution) <- c("Phase","orig.ident","cluster","CellNumb") write.csv(cc_distribution, file="cell_cycle.csv") #markers tra cluster specifici ## GMP2 VS GMP2 setwd("/DATA/31/molteni/vexas_mouse_3/results/DE_GMP2_GMP1") Idents(Full_final) <- "celltypes_annot" markers <- FindMarkers(Full_final, ident.1 = "GMP_2", ident.2 = "GMP_1") write.csv(markers, file="GMP2vsGMP1_Full.csv") Idents(Full_final) <- "orig.ident" Full_final_A <- subset(Full_final, idents = "A") Idents(Full_final_A) <- "celltypes_annot" markers <- FindMarkers(Full_final_A, ident.1 = "GMP_2", ident.2 = "GMP_1") write.csv(markers, file="GMP2vsGMP1_A.csv") Idents(Full_final) <- "orig.ident" Full_final_C <- subset(Full_final, idents ="C") Idents(Full_final_C) <- "celltypes_annot" markers <- FindMarkers(Full_final_C, ident.1 = "GMP_2", ident.2 = "GMP_1") write.csv(markers, file="GMP2vsGMP1_C.csv") ## B Cell Prog 1 vs B Cell Prog 2 setwd("/DATA/31/molteni/vexas_mouse_3/results/DE_BP1_BP2") Idents(Full_final) <- "celltypes_annot" markers <- FindMarkers(Full_final, ident.1 = "B_cell_progenitors_1", ident.2 = "B_cell_progenitors_2") write.csv(markers, file="BP1vsBP2_Full.csv") Idents(Full_final_A) <- "celltypes_annot" markers <- FindMarkers(Full_final_A, ident.1 = "B_cell_progenitors_1", ident.2 = "B_cell_progenitors_2") write.csv(markers, file="BP1vsBP2_A.csv") Idents(Full_final_C) <- "celltypes_annot" markers <- FindMarkers(Full_final_C, ident.1 = "B_cell_progenitors_1", ident.2 = "B_cell_progenitors_2") write.csv(markers, file="BP1vsBP2_C.csv") setwd("/DATA/31/molteni/vexas_mouse_3/results/DE_markers/AvsC/") df <- list.files(path='/DATA/31/molteni/vexas_mouse_3/results/DE_markers/AvsC/') %>% lapply(read.csv) %>% bind_rows #df <- df[df$p_val_adj<0.05,] top50 <- df %>% group_by(cluster) %>% dplyr::filter(avg_log2FC > 0) %>% slice_head(n = 50) %>% ungroup() -> top50 write.csv(top50, file="top50_by_cluster.csv")