Identification and validation of central amygdala FGFR1 as a therapeutic target for alcohol use disorder using single-nucleus sequencing in rats.
The 4 matches
- [1] § Methods › snRNA-seq data processing › Co-expression network analysis ↔ master.R, lines 783–862 · score 0.94 · soft power, ConstructNetwork, ModuleConnectivity, ModuleEigengenes, SampleID, WGCNA
- [2] § Methods › snRNA-seq data processing › Quality control and clustering ↔ master.R, lines 89–145 · score 0.88 · SCTransform, percent.mt, percent.ribo, sample layers, M22, M33
- [3] § Methods › snRNA-seq data processing › Differential expression analysis ↔ master.R, lines 1615–1684 · score 0.77 · distinct_test, min_non_zero_cells, name_cluster, name_sample, cpm, matrix
- [4] § Methods › snRNA-seq data processing › Subclustering of GABAergic cells ↔ master.R, lines 432–491 · score 0.69 · percent.mt, percent.ribo, sample layers, split, subset, Subclustering
Paper
Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC
The paper is loaded when this pane is shown.
The authors' code
R · 2,362 lines · 59 KB · MIT · 4 matches
- library(Seurat)
- library(SeuratDisk)
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- library(BPCells)
- adata.data = open_matrix_anndata_hdf5("D:/Leon/snRNAseq/high_depth_processing/Heilig_aggr_noF1_nonormalize_highdepth/outs/count/high_processing.h5ad")
- write_matrix_dir(
- mat = adata.data,
- dir = "D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth/counts"
- )
- adata.mat = open_matrix_dir(dir = "D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth/counts")
- #library(biomaRt)
- #ensembl = useMart("ensembl", dataset = "rnorvegicus_gene_ensembl")
- #bm = getBM(attributes = c("ensembl_gene_id", "external_gene_name"), values = rownames(adata.mat), mart = ensembl)
- #symbols = bm$external_gene_name[match(rownames(adata.mat), bm$ensembl_gene_id)]
- #rownames(adata.mat) = symbols
- adata = CreateSeuratObject(counts = adata.mat, min.cells = 3, min.features = 200)
- adata
- SampleID_barcode <- read.csv("D:/Leon/snRNAseq/high_depth_processing/Heilig_aggr_noF1_nonormalize_highdepth/outs/SampleID.csv")
- meta_file<-read.csv("D:/Leon/snRNAseq/high_depth_processing/Heilig_aggr_noF1_nonormalize_highdepth/outs/aggregation.csv")
- barcode_sampleid<-merge(SampleID_barcode,meta_file,by.x="SampleID",by.y="sample_id")
- rownames(barcode_sampleid)<-barcode_sampleid$Barcode
- adata<-AddMetaData(adata,barcode_sampleid)
- adata = subset(adata, subset = Sex == "Male")
- adata[["RNA"]]$counts <- as(object = adata[["RNA"]]$counts, Class = "dgCMatrix")
- Features(adata)
- saveRDS(adata, "males_unprocessed_high.Rds")
- #-----------------------------------------------QC---------------------------------------
- library(Seurat)
- library(BPCells)
- library(scuttle)
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- adata = readRDS("males_unprocessed_high.Rds")
- adata
- library(BiocParallel)
- library(scDblFinder)
- #adata[["RNA"]]$counts <- as(object = adata[["RNA"]]$counts, Class = "dgCMatrix")
- adata = as.SingleCellExperiment(adata)
- adata = scDblFinder(adata, samples="SampleID")
- table(adata$scDblFinder.class)
- adata = as.Seurat(adata, data = NULL)
- adata
- gc()
- Idents(adata) <- "scDblFinder.class"
- adata = subset(adata, idents = "singlet") #remove doublets
- adata
- adata[['percent.mt']] = PercentageFeatureSet(adata, pattern = "^Mt-")
- gc()
- adata[['percent.ribo']] = PercentageFeatureSet(adata, pattern = "(^Rpl|^Rps|^Mrp)")
- gc()
- #adata.sce = as.SingleCellExperiment(adata)
- #low.total = isOutlier(adata.sce$nCount_RNA, type="lower", log=TRUE, batch = adata.sce$SampleID)
- #summary(low.total)
- #discard.mito = isOutlier(adata.sce$percent.mt, type="higher", batch=adata.sce$SampleID)
- #discard.ribo = isOutlier(adata.sce$percent.ribo, type="higher", batch=adata.sce$SampleID)
- #discard.sum = isOutlier(adata.sce$nCount_RNA, type="lower", log=TRUE, batch=adata.sce$SampleID)
- #discard.feature = isOutlier(adata.sce$nFeature_RNA, type="lower", log=TRUE, batch=adata.sce$SampleID)
- #qc.stats = perCellQCMetrics(adata.sce)
- VlnPlot(adata, 'nFeature_RNA', group.by = 'SampleID', pt.size = 0)
- VlnPlot(adata, 'nCount_RNA', group.by = 'SampleID', pt.size = 0)
- VlnPlot(adata, 'percent.mt', group.by = 'SampleID', pt.size = 0)
- VlnPlot(adata, 'percent.ribo', group.by = 'SampleID', pt.size = 0)
- FeatureScatter(adata, 'nCount_RNA', 'percent.mt')
- FeatureScatter(adata, 'nCount_RNA', 'nFeature_RNA')
- adata = adata[, !adata$SampleID=='M22'] #removing bad samples
- adata = adata[, !adata$SampleID=='M33']
- adata = adata[, !adata$SampleID=='M8']
- gc()
- adata = subset(adata, subset = nFeature_RNA < 7000)
- adata = subset(adata, subset = percent.mt < 5)
- adata = subset(adata, subset = percent.ribo < 2.5)
- gc()
- VlnPlot(adata, 'nFeature_RNA', group.by = 'SampleID', pt.size = 0)
- VlnPlot(adata, 'percent.mt', group.by = 'SampleID', pt.size = 0)
- VlnPlot(adata, 'percent.ribo', group.by = 'SampleID', pt.size = 0)
- adata
- FeatureScatter(adata, 'nCount_RNA', 'percent.mt')
- FeatureScatter(adata, 'nCount_RNA', 'nFeature_RNA')
- saveRDS(adata, "males_filtered_high.rds")
- #---------------------------normalization----------------------------------
- adata = readRDS("males_filtered_high.rds")
- table(adata$Groups)
- counts = GetAssayData(adata, assay = "RNA")
- #remove mito and ribo genes
- discard = which(grepl("^Rpl|^Rps|^Mt-|^Mrp", rownames(counts)))
- counts = counts[-c(discard),]
- adata = subset(adata, features = rownames(counts))
- adata
- gc()
- adata[["RNA"]] <- split(adata[["RNA"]], f = adata$SampleID) #split the counts into sample-layers
- gc()
- adata <- SCTransform(adata, vars.to.regress = c("percent.mt", "percent.ribo"))
- gc()
- saveRDS(adata, "filtered_SCT_high.rds")
- #---------------------------------------------- dim reduction and clustering -----------------------------------
- library(Seurat)
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- adata = readRDS("filtered_SCT_high.rds")
- gc()
- adata
- adata = RunPCA(adata)
- gc()
- ElbowPlot(adata,ndims = 50)
- gc()
- adata = RunUMAP(adata, dims = 1:50, metric = 'euclidean', reduction.name = 'euclidean_umap')
- gc()
- #adata = RunUMAP(adata, dims = 1:50, metric = 'correlation', reduction.name = 'correlation_umap')
- adata
- gc()
- DimPlot(adata, reduction = "euclidean_umap", group.by = "SampleID")
- DimPlot(adata, reduction = "euclidean_umap", group.by = "Groups")
- gc()
- adata <- FindNeighbors(adata, dims = 1:50, reduction = "pca")
- gc()
- adata <- FindClusters(adata, resolution = 0.1, cluster.name = "SCT_clusters")
- gc()
- DimPlot(adata, reduction = "euclidean_umap", group.by = "SCT_clusters")
- gc()
- adata = PrepSCTFindMarkers(adata)
- gc()
- adata.markers = FindAllMarkers(adata, only.pos = TRUE)
- saveRDS(adata, "high_clustered.rds")
- write.csv(adata.markers, "high_markers.csv")
- #---------------------------anotation------------------------------------
- library(Seurat)
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- adata = readRDS("high_clustered.rds")
- markers = read.csv('high_markers.csv')
- gc()
- DimPlot(adata, reduction = "euclidean_umap", group.by = "SCT_clusters", label = TRUE)
- markers[markers$gene == "Slc17a7",]
- gc()
- VlnPlot(adata, features = c(""))
- FeaturePlot(adata, features = c("Ndst4"), reduction = "euclidean_umap")
- VlnPlot(adata, features = c("Slc17a7"))
- #adata = RenameIdents(adata,
- "0" = "Oligendrocytes", #Mog, Mobp, Mag
- "1"= "Gabaergic", #Rbfox3, Gad1, Gad2,
- "2" = "Gabaergic", #Rbfox3, Gad1, Gad2,
- "3" = "Hbb-b1_Hbb-a2_Blood?", #,
- "4" = "OPC", #Pdgfra, Epn2, Neu4, Pcdh15
- "5" = "Microglia", # Itgam, Cx3cr1, P2ry12, Tmem119
- "6" = "Gabaergic", #Rbfox3, Gad2, Foxp2,
- "7" = "Astrocytes", #Slc1a2, Gfap, Agt, Aqp4,
- "8" = "Gabaergic", #Rbfox3, Gad1, Foxp2,
- "9" = "Gabaergic", #Rbfox3, Gad1, Gad2,
- "10" = "Gabaergic", #Gad1, Gad2,
- "11" = "Glutaminergic_Slc17a6", #Rbfox3, Slc17a6,
- "12" = "Endothelial", #Cd93, Vwf, Emcn, Flt1
- "13" = "Cholinergic", #Slc5a7, Acly,
- "14" = "Glutaminergic_Slc17a7", #Slc17a7, Rbfox3,
- "15" = "Gabaergic", #Rbfox3, Gad1, Gad2,
- "16" = "Microglia", #Itgam, Cx3cr1, P2ry12, Tmem119
- "17" = "Microglia ", #Itgam, P2ry12,
- )
- current.cluster.ids = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
- new.cluster.ids = c("Oligendrocytes","Gabaergic","Gabaergic", "Hbb-b1_Hbb-a2_Blood?",
- "OPC","Microglia","Gabaergic","Astrocytes","Gabaergic",
- "Gabaergic","Gabaergic","Glutaminergic_Slc17a6","Endothelial",
- "Cholinergic","Glutaminergic_Slc17a7","Gabaergic","Microglia","Microglia")
- library(plyr)
- adata$cell_type = plyr::mapvalues(x = adata$SCT_clusters, from = current.cluster.ids, to = new.cluster.ids)
- DimPlot(adata, group.by='cell_type', reduction = "euclidean_umap")
- #---------------------- cluster exploration------------------------
- Idents(adata) = adata$cell_type
- RidgePlot(adata, features = "percent.ribo")
- RidgePlot(adata, features = "percent.mt")
- RidgePlot(adata, features = "nCount_RNA")
- RidgePlot(adata, features = "nFeature_RNA")
- table(adata$cell_type, adata$SampleID)
- DimPlot(adata, group.by='SampleID', reduction = "euclidean_umap")
- features = c("Mog", "Mobp", "Mag", "Gad1", "Gad2", "Hbb-b1", "Hba-a2",
- "Pdgfra", "Epn2", "Pcdh15", "Csf1r", "Cx3cr1", "P2ry12", "Tmem119",
- "Satb1", "Slc17a6","Slc17a7", "Cd93", "Vwf", "Emcn", "Flt1", "Slc5a7",
- "Acly", "Slc1a2", "Gfap", "Agt", "Aqp4", "Plp1"
- , "Rbfox3")
- DotPlot(adata, features = features, group.by = "cell_type") + RotatedAxis()
- VlnPlot(adata, "Mog", layer = "scale.data", pt.size = 0)
- RidgePlot(adata, features = c("Gad1", "Gad2"), layer = "scale.data", ncol = 2)
- RidgePlot(adata, features = c("Rbfox3"), layer = "scale.data", ncol = 1)
- RidgePlot(adata, features = c("Pdgfra", "Pcdh15"), layer = "scale.data", ncol = 1)
- RidgePlot(adata, features = c("Csf1r", "Cx3cr1", "P2ry12"), layer = "scale.data", ncol = 1)
- RidgePlot(adata, features = c("Slc17a7", "Slc17a6"), ncol = 1)
- RidgePlot(adata, features = c("Emcn"), layer = "scale.data", ncol = 1)
- RidgePlot(adata, features = c("Slc5a7"), layer = "scale.data", ncol = 1)
- RidgePlot(adata, features = c("Slc1a2"), layer = "scale.data", ncol = 1)
- saveRDS(adata, "high_annotated.rds")
- ############################ decontX ###############################
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- library(Seurat)
- library(celda)
- library(qs)
- adata = readRDS('high_annotated.rds')
- gc()
- DefaultAssay(adata) = 'RNA'
- adata
- gc()
- adata[['RNA']] = JoinLayers(adata[['RNA']])
- gc()
- counts = GetAssayData(adata, slot = 'counts')
- gc()
- sce = SingleCellExperiment(list(counts = counts))
- gc()
- sce = decontX(sce)
- metadata(sce)$decontX$estimates$all_cells$delta
- #öka delta här
- sce.delta = decontX(sce, delta = c(3.55, 20), estimateDelta = F)
- library(scater)
- plot(sce$decontX_contamination, sce.delta$decontX_contamination,
- xlab = "DecontX estimated priors",
- ylab = "Setting priors to estimate higher contamination")
- abline(0, 1, col = "red", lwd = 2)
- umap = reducedDim(sce.delta, "decontX_UMAP")
- plotDimReduceCluster(sce.delta$decontX_clusters,
- dim1 = umap[, 1], dim2 = umap[, 2])
- plotDecontXContamination(sce)
- plotDecontXContamination(sce.delta)
- differences_sce = rowMeans(counts) - rowMeans(decontXcounts(sce))
- gc()
- top_genes_sce = sort(abs(differences_sce), decreasing = T)[1:20]
- top_genes_sce
- differences_sce_delta = rowMeans(counts) - rowMeans(decontXcounts(sce.delta))
- gc()
- top_genes_sce_delta = sort(abs(differences_sce_delta), decreasing = T)[1:20]
- top_genes_sce_delta
- gc()
- sum(counts(sce) < decontXcounts(sce))
- celltypemappings = list(Oligodendrocytes = 2
- )
- plotDecontXMarkerExpression(sce,
- markers = 'Kcnip4',
- groupClusters = celltypemappings
- )
- adata[["decontXcounts"]] = CreateAssayObject(counts = decontXcounts(sce.delta))
- gc()
- VlnPlot(adata, 'Gad1', group.by = 'cell_type', pt.size = 0, assay = 'decontXcounts') + NoLegend()
- VlnPlot(adata, 'Gad1', group.by = 'cell_type', pt.size = 0, assay = 'RNA') + NoLegend()
- rm(counts)
- rna_matrix = GetAssayData(adata, assay = "RNA", layer = 'counts')
- gc()
- decontx_matrix = GetAssayData(adata, assay = "decontXcounts", layer = "counts")
- common_genes = intersect(rownames(rna_matrix), rownames(decontx_matrix))
- rna_matrix = rna_matrix[common_genes,]
- decontx_matrix = decontx_matrix[common_genes,]
- gc()
- differences = rowMeans(rna_matrix) - rowMeans(decontx_matrix)
- gc()
- top_genes = names(sort(abs(differences), decreasing = T))[1:20]
- top_genes
- VlnPlot(adata, group.by = 'cell_type', 'Nkain2', pt.size = 0, assay = 'decontXcounts') + NoLegend()
- VlnPlot(adata, group.by = 'cell_type', 'Nkain2', pt.size = 0, assay = 'RNA') + NoLegend()
- genes = c('Kcnip4', 'Nkain2')
- for (gene in top_genes) {
- DefaultAssay(adata) = 'RNA'
- FeaturePlot(adata, gene, reduction = 'euclidean_umap', max.cutoff = 1) + NoLegend()
- ggsave(paste0('males/decontx/gabaergic/genes/',gene,'_before_decont.jpg'))
- DefaultAssay(adata) = 'decontXcounts'
- FeaturePlot(adata, gene, reduction = 'euclidean_umap', max.cutoff = 1) + NoLegend()
- ggsave(paste0('males/decontx/gabaergic/genes/',gene,'_after_decont.jpg'))
- }
- qsave(adata, 'high_annotated_males_decontx.qs')
- #------------------------------------subclustering GABA------------------------------
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- library(Seurat)
- adata = readRDS("high_annotated_males_decontx.qs")
- gc()
- adata = subset(adata, subset = cell_type == "Gabaergic")
- gc()
- DefaultAssay(adata) = "decontXcounts"
- VlnPlot(adata, c('percent.mt',
- 'percent.ribo',
- 'nCount_decontXcounts',
- 'nFeature_decontXcounts'),
- group.by = 'SampleID',
- pt.size = 0,
- ncol = 2)
- adata = subset(adata, subset = nFeature_decontXcounts > 1500
- & nCount_decontXcounts < 20000
- & nCount_decontXcounts > 500
- & percent.ribo < 1
- & percent.mt < 3
- )
- VlnPlot(adata, c('percent.mt',
- 'percent.ribo',
- 'nCount_decontXcounts',
- 'nFeature_decontXcounts'),
- group.by = 'SampleID',
- pt.size = 0,
- ncol = 2)
- p1 = FeatureScatter(adata, 'nCount_decontXcounts', 'percent.mt')
- p2 = FeatureScatter(adata, 'nCount_decontXcounts', 'nFeature_decontXcounts')
- p3 = FeatureScatter(adata, 'nCount_decontXcounts', 'percent.ribo')
- p1+p2+p3
- gc()
- adata[["decontXcounts"]] <- split(adata[["decontXcounts"]], f = adata$SampleID) #split the counts into sample-layers
- DefaultAssay(adata) = 'decontXcounts'
- adata
- gc()
- adata <- SCTransform(adata, vars.to.regress = c("percent.mt", "percent.ribo"),
- assay = 'decontXcounts')
- gc()
- adata = RunPCA(adata)
- gc()
- ElbowPlot(adata,ndims = 50)
- adata <- FindNeighbors(adata, dims = 1:50, reduction = "pca")
- gc()
- adata <- FindClusters(adata, resolution = 0.1, cluster.name = "gaba_subclusters_0.1")
- gc()
- adata <- FindClusters(adata, resolution = 0.3, cluster.name = "gaba_subclusters_0.3")
- gc()
- adata <- FindClusters(adata, resolution = 0.5, cluster.name = "gaba_subclusters_0.5")
- gc()
- adata <- FindClusters(adata, resolution = 0.6, cluster.name = "gaba_subclusters_0.6")
- gc()
- adata <- FindClusters(adata, resolution = 0.7, cluster.name = "gaba_subclusters_0.7")
- gc()
- adata <- FindClusters(adata, resolution = 0.8, cluster.name = "gaba_subclusters_0.8")
- gc()
- adata = RunUMAP(adata, dims = 1:50, metric = 'euclidean', reduction.name = 'euclidean_umap_gaba')
- DimPlot(adata, reduction = "euclidean_umap_gaba", group.by = "gaba_subclusters_0.5", label = TRUE)
- adata
- gc()
- for (sample in 1:length(unique(adata$SampleID))) {
- print(sample)
- slot(adata@assays$[email hidden][[sample]], name="umi.assay") = "decontXcounts"
- }
- gc()
- adata = PrepSCTFindMarkers(adata)
- gc()
- Idents(adata) = adata$gaba_subclusters_0.5
- markers = FindAllMarkers(adata, only.pos = TRUE)
- write.csv(markers, 'gaba_males_subclustered_markers.csv')
- gc()
- DimPlot(adata, reduction = "euclidean_umap_gaba", group.by = "gaba_subclusters_0.5", label = TRUE)
- current.cluster_ids = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39)
- VlnPlot(adata, 'Sst', pt.size = 0, assay = 'decontXcounts', layer = 'data') + NoLegend()
- FeaturePlot(adata, c('Gad2', 'Slc17a6'), reduction = 'euclidean_umap_gaba', blend = T,
- max.cutoff = 1, pt.size = 2)
- FeaturePlot(adata, 'Sst', reduction = 'euclidean_umap_gaba')
- new.cluster_ids = c(
- 'CeL_Prkcd',#0
- 'CeM_Xylt1',#1
- 'Intercalated_Chst9',#2
- 'Drd2_Htr2c',#3
- 'Ebf1_1',#4
- 'Drd2_Calcrl',#5
- 'Satb1_Col5a2',#6
- 'Dlk1',#7
- 'Pallidum',#8
- 'Ndst3_Dach2',#9
- 'Nxph1_Tcf4',#10
- 'Npffr1_Dock11',#11
- 'Ebf1_2',#12
- 'Nos1_Plagl1_Sst',#13
- 'Egfr_Nxph1',#14
- 'Intercalated_Nos1',#15
- 'Prlr_tac3',#16
- 'Vipr2_Pdyn',#17
- 'Slc17a6',#18
- 'Nxph1_Nxph2',#19
- 'Ebf1_2',#20
- 'Intercalated_Glp1r',#21
- 'Tafa1_Slc17a8',#22
- 'Prlr_Esr1',#23
- 'Stac_Ndst4',#24
- 'Intercalated_Chrm2',#25
- 'Ebf1_3',#26
- 'Slc17a6',#27
- 'Drd2_Rai14',#28
- 'Mast4',#29
- 'Intercalated_Dach1',#30
- 'Lgr6',#31
- 'Vip',#32
- 'Zbtb7c',#33
- 'Sox6_Gpc5',#34
- 'Sox6_Ano4',#35
- 'Fign_Npsr1',#36
- 'Grm3',#37
- 'Mast4_Zfp536', #38
- 'Tf_Car2'#39
- )
- library(plyr)
- adata$cell_subtype = plyr::mapvalues(x = adata$gaba_subclusters_0.5, from = current.cluster_ids, to = new.cluster_ids)
- dir.create('males/subclustering')
- dir.create('males/subclustering/gabaergic/')
- p = DimPlot(adata, reduction = "euclidean_umap_gaba", group.by = "cell_subtype", label = TRUE,
- repel = T, raster = F, label.size = 6) + NoLegend()
- pdf('males/subclustering/gabaergic/umap_cellsubtypes.pdf',
- height = 15, width = 15)
- print(p)
- dev.off()
- qsave(adata, 'gabaergic_males_subclustered.qs')
- adata = qread('gabaergic_males_subclustered.qs')
- markers = FindAllMarkers(adata, only.pos = T)
- markers$cell_type = markers$cluster
- gc()
- DefaultAssay(adata) = 'SCT'
- #adata = NormalizeData(adata)
- #adata = ScaleData(adata)
- library(dplyr)
- markers %>%
- group_by(cell_type) %>%
- filter(avg_log2FC > 1) %>%
- slice_head(n = 20) %>%
- ungroup -> top10
- gc()
- Idents(adata) = 'cell_subtype'
- p = DoHeatmap(subset(adata, downsample = 500), features = top10$gene) + NoLegend()
- pdf('males/subclustering/gabaergic/heatmap_cellsubtypes.pdf',
- height = 10, width = 20)
- print(p)
- dev.off()
- DefaultAssay(adata) = 'decontXcounts'
- adata = NormalizeData(adata)
- adata = ScaleData(adata)
- gc()
- features = c('Prkcd', 'Nr2f2', 'Isl1', 'Crh',
- 'Calcrl', 'Sst','Oxtr', 'Nts', 'Tac3',
- 'Tacr1', 'Cck', 'Cartpt', 'Cxcl14',
- 'Htr2a', 'Htr2c', 'Drd1', 'Drd2',
- 'Drd3', 'Cnr1',
- 'Oprm1', 'Oprk1', 'Oprd1',
- 'Gria1', 'Gria2', 'Gria3', 'Gria4',
- 'Grik1', 'Grik2', 'Grik3', 'Grik4',
- 'Grik5', 'Grin1', 'Grin2a', 'Grin2b',
- 'Grin2c', 'Grin2d', 'Grin3a', 'Grin3b',
- 'Grm1', 'Grm5', 'Grm2', 'Grm3',
- 'Grm4', 'Grm6', 'Grm7', 'Grm8',
- 'Adra1a', 'Adra1b', 'Adra1c',
- 'Adra2a', 'Adra2b', 'Adra2c',
- 'Adrb1', 'Adrb2', 'Adrb3', 'Chrna1',
- 'Chrnb1', 'Chrnd', 'Chrne',
- 'Chrm1', 'Chrm2', 'Chrm3', 'Chrm4',
- 'Adora1','Adora1a', 'Adora2a', 'Adora3',
- 'Il13ra1', 'Il13ra2', 'Il1r1', 'Il6r',
- 'Tnfrsf1a', 'Tnfrsf1b'
- )
- celltype_counts = table(adata$cell_subtype)
- celltypes_to_keep = names(celltype_counts[celltype_counts >= 500])
- p = DoHeatmap(subset(subset(adata, cells = WhichCells(adata, expression = cell_subtype %in% celltypes_to_keep)), downsample = 500), features = features) + NoLegend()
- pdf('males/subclustering/gabaergic/heatmap_cellsubtypes_interesting_stuff.pdf',
- height = 15, width = 25)
- print(p)
- dev.off()
- FeaturePlot(adata, "Pde1c", reduction = "euclidean_umap_gaba")
- RidgePlot(adata, features = "percent.ribo")
- RidgePlot(adata, features = "percent.mt")
- RidgePlot(adata, features = "nCount_RNA")
- RidgePlot(adata, features = "nFeature_RNA")
- VlnPlot(adata, features = "percent.mt", group.by = "SampleID", pt.size = 0)
- # hdWGCNA
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- library(Seurat)
- library(tidyverse)
- library(cowplot)
- library(patchwork)
- library(WGCNA)
- library(hdWGCNA)
- library(writexl)
- library(readxl)
- library(qs)
- # using the cowplot theme for ggplot
- theme_set(theme_cowplot())
- # set random seed for reproducibility
- set.seed(12345)
- # optionally enable multithreading
- allowWGCNAThreads(nThreads = 7)
- #gabaergic cells only
- adata = qread('gabaergic_males_subclustered.qs')
- describe(adata$nCount_decontXcounts)
- describe(adata$nFeature_decontXcounts)
- adata
- describe(adata$cell_subtype)
- unique(adata$cell_subtype)
- gc()
- adata
- Idents(adata) = 'cell_subtype'
- markers = FindAllMarkers(adata, only.pos = T)
- write_xlsx(markers, 'Fgfr1_paper/gabaergic_markers.xlsx')
- markers$cell_type = markers$cluster
- Idents(adata) = 'cell_type'
- DefaultAssay(adata) = 'decontXcounts'
- gc()
- adata
- adata[['decontXcounts']] = JoinLayers(adata[['decontXcounts']])
- adata = NormalizeData(adata)
- adata = SetupForWGCNA(
- adata,
- gene_select = "fraction",
- fraction = 0.05,
- wgcna_name = 'gaba_males_consensus'
- )
- gc()
- adata
- adata = MetacellsByGroups(
- adata,
- group.by = c('cell_type', 'SampleID', 'Groups'),
- ident.group = 'cell_type',
- k = 25,
- max_shared = 12,
- min_cells = 50,
- reduction = 'pca'
- )
- gc()
- adata = NormalizeMetacells(adata)
- gc()
- adata = SetMultiExpr(
- adata,
- group_name = 'Gabaergic',
- group.by = 'cell_type',
- multi.group.by = "Groups"
- )
- adata = TestSoftPowersConsensus(adata)
- plot_list = PlotSoftPowers(adata)
- consensus_groups <- unique(adata$Groups)
- p_list <- lapply(1:length(consensus_groups), function(i){
- cur_group <- consensus_groups[[i]]
- plot_list[[i]][[1]] + ggtitle(paste0('Group: ', cur_group)) + theme(plot.title=element_text(hjust=0.5))
- })
- dir.create('males/wgcna/consensus')
- dir.create('males/wgcna/consensus/gabaergic')
- dir.create('males/wgcna/consensus/gabaergic/plots/')
- pdf('males/wgcna/consensus/gabaergic/plots/soft_powers.pdf')
- wrap_plots(p_list, ncol=2)
- dev.off()
- gc()
- adata = ConstructNetwork(
- adata,
- soft_power = c(9,8,8),
- consensus = TRUE,
- tom_name = 'gaba_male_consensus'
- )
- pdf('males/wgcna/consensus/gabaergic/plots/dendrogram.pdf')
- PlotDendrogram(adata, main = 'Groups consensus dendrogram')
- dev.off()
- adata = ScaleData(adata)
- gc()
- adata = ModuleEigengenes(
- adata,
- group.by.vars = "SampleID"
- )
- hMEs = GetMEs(adata)
- MEs = GetMEs(adata, harmonized=FALSE)
- adata = ModuleConnectivity(
- adata,
- group.by = 'cell_type', group_name = 'Gabaergic'
- )
- adata = ResetModuleNames(
- adata,
- new_name = "Gaba-M"
- )
- gc()
- p = PlotKMEs(adata, ncol = 6)
- pdf('males/wgcna/consensus/gabaergic/plots/kMEs.pdf',
- width = 10, height = 10)
- p
- dev.off()
- modules = GetModules(adata) %>% subset(module != 'grey')
- head(modules[,1:6])
- write_xlsx(modules, 'males/wgcna/consensus/gabaergic/consensus_modules.xlsx')
- qsave(adata, 'males/wgcna/consensus/gabaergic/wgcna_consensus_gaba_males.qs')
- ############################ network visualization
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- library(Seurat)
- library(tidyverse)
- library(cowplot)
- library(patchwork)
- library(WGCNA)
- library(hdWGCNA)
- library(igraph)
- library(qs)
- theme_set(theme_cowplot())
- set.seed(12345)
- gc()
- adata = qread('males/wgcna/consensus/gabaergic/wgcna_consensus_gaba_males.qs')
- hMEs <- GetMEs(adata)
- modules = GetModules(adata)
- mods = levels(modules$module); mods = mods[mods != 'grey']
- [email hidden] = cbind([email hidden], hMEs)
- ################### Make files fo rGEO ##################################
- metadata = [email hidden]
- write.csv(metadata, 'males/wgcna/consensus/gabaergic/metadata.csv')
- dir.create('Fgfr1_paper/for_geo')
- gc()
- library(Matrix)
- raw_counts = adata@assays$RNA@layers$counts
- write.table(colnames(raw_counts), "Fgfr1_paper/for_geo/barcodes.tsv")
- write.table(rownames(raw_counts), "Fgfr1_paper/for_geo/genes.tsv")
- gc()
- writeMM(raw_counts, file = 'Fgfr1_paper/for_geo/raw_counts.mtx')
- rm(raw_counts)
- gc()
- decont_counts = adata@assays$decontXcounts@layers$counts
- writeMM(decont_counts, file = 'Fgfr1_paper/for_geo/decontXcounts_counts.mtx')
- rm(decont_counts)
- gc()
- decont_SCT_data = adata@assays$SCT@data
- write.table(rownames(decont_SCT_data), "Fgfr1_paper/for_geo/genes_SCT.tsv")
- writeMM(decont_SCT_data, file = 'Fgfr1_paper/for_geo/decontXcounts_SCT_data.mtx')
- p = DotPlot(adata, features = mods ,group.by = 'cell_subtype')
- p = p +
- RotatedAxis() +
- scale_color_gradient2(high = 'red', mid = 'grey95', low = 'blue') +
- coord_flip() +
- theme(
- axis.text.x = element_text(size = 16, face = "bold"), # x-axis labels
- axis.text.y = element_text(size = 16, face = "bold"), # y-axis labels
- axis.title.x = element_text(size = 2, face = "bold"), # x-axis title
- axis.title.y = element_text(size = 2, face = "bold") # y-axis title
- )
- p
- pdf('males/wgcna/consensus/gabaergic/plots/modules_dotplot.pdf',
- height = 10, width = 20)
- print(p)
- dev.off()
- PlotKMEs_1 <- function(
- seurat_obj,
- n_hubs=10,
- text_size=2,
- ncol = 5,
- plot_widths = c(3,2),
- wgcna_name = NULL
- ){
- if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}
- modules <- GetModules(seurat_obj, wgcna_name) %>% subset(module != 'grey')
- mods <- levels(modules$module); mods <- mods[mods != 'grey']
- mod_colors <- modules %>% subset(module %in% mods) %>%
- dplyr::select(c(module, color)) %>%
- dplyr::distinct()
- # get hub genes:
- hub_df <- GetHubGenes(seurat_obj, n_hubs=n_hubs, wgcna_name=wgcna_name)
- plot_list <- lapply(mods, function(x){
- cur_color <- subset(mod_colors, module == x) %>% .$color
- cur_df <- subset(hub_df, module == x)
- top_genes <- cur_df %>% dplyr::top_n(n_hubs, wt=kME) %>% .$gene_name
- p <- cur_df %>% ggplot(aes(x = reorder(gene_name, kME), y = kME)) +
- geom_bar(stat='identity', width=1, color = cur_color, fill=cur_color) +
- ggtitle(x) +
- ylim(0, 1) +
- #xlab(paste0('kME_', x)) +
- theme(
- axis.ticks.x = element_blank(),
- axis.text.x = element_blank(),
- plot.title = element_text(hjust=0.5, size = 36, face = 'bold'),
- axis.title.x = element_blank(),
- axis.line.x = element_blank()
- )
- p_anno <- ggplot() + annotate(
- "label",
- x = 0,
- y = 0,
- label = paste0(top_genes, collapse="\n"),
- size=text_size,
- fontface = 'bold',
- label.size=0
- ) + theme_void()
- patch <- p + p_anno + plot_layout(widths=plot_widths)
- patch
- })
- wrap_plots(plot_list, ncol=ncol)
- }
- p = PlotKMEs_1(adata, ncol = 3, text_size = 4)
- p
- pdf('males/wgcna/consensus/gabaergic/plots/kMEs.pdf',
- width = 20, height = 15)
- p
- dev.off()
- plot_list = ModuleFeaturePlot(
- adata,
- features = 'hMEs',
- order=TRUE,
- reduction = 'euclidean_umap_gaba'
- )
- pdf('males/wgcna/consensus/gabaergic/plots/modules_umap.pdf',
- height = 10, width = 10)
- wrap_plots(plot_list, ncol = 6)
- dev.off()
- p = ModuleRadarPlot(
- adata,
- group.by = 'cell_subtype', axis.label.size = 3, grid.label.size = 3
- )
- pdf('males/wgcna/consensus/gabaergic/plots/radar_plot_cell_subtype.pdf',
- height = 10, width = 15)
- p
- dev.off()
- ModuleNetworkPlot(
- adata,
- outdir = 'males/wgcna/consensus/gabaergic/plots/mandala_plots'
- )
- library(readxl)
- ################## DME analysis ##################
- # celltypes
- dir.create('males/wgcna/consensus/gabaergic/DMEs')
- #res vs sen
- DMEs <- data.frame()
- for (cell_type in unique(adata$cell_subtype)) {
- print(cell_type)
- # group1 = [email hidden] %>% subset(cell_subtype == cell_type & Groups == 'Resistant') %>% rownames
- # group2 = [email hidden] %>% subset(cell_subtype == cell_type & Groups == 'Sensitive') %>% rownames
- group1 <- rownames(
- [email hidden][
- as.character([email hidden]$cell_subtype) == cell_type &
- [email hidden]$Groups == "Resistant", ]
- )
- group2 <- rownames(
- [email hidden][
- as.character([email hidden]$cell_subtype) == cell_type &
- [email hidden]$Groups == "Sensitive", ]
- )
- dir.create('males/wgcna/consensus/gabaergic/DMEs/res_vs_sen')
- dir.create(paste0('males/wgcna/consensus/gabaergic/DMEs/res_vs_sen/',cell_type))
- cur_DMEs <- FindDMEs(
- adata,
- barcodes1 = group1,
- barcodes2 = group2,
- test.use='wilcox',
- wgcna_name='gaba_males_consensus'
- )
- cur_DMEs$celltype = cell_type
- DMEs = rbind(DMEs, cur_DMEs)
- p = PlotDMEsLollipop(
- adata,
- cur_DMEs,
- wgcna_name='gaba_males_consensus',
- pvalue = "p_val_adj"
- )
- pdf(paste0('males/wgcna/consensus/gabaergic/DMEs/res_vs_sen/',cell_type,'/lollipop.pdf'))
- print(p)
- dev.off()
- }
- modules <- GetModules(adata)
- mods <- levels(modules$module); mods <- mods[mods != 'grey']
- plot_df <- DMEs
- plot_df$module <- factor(as.character(plot_df$module), levels=mods)
- maxval <- 0.5; minval <- -0.5
- plot_df$avg_log2FC <- ifelse(plot_df$avg_log2FC > maxval, maxval, plot_df$avg_log2FC)
- plot_df$avg_log2FC <- ifelse(plot_df$avg_log2FC < minval, minval, plot_df$avg_log2FC)
- plot_df$Significance <- gtools::stars.pval(plot_df$p_val_adj)
- plot_df$textcolor <- ifelse(plot_df$avg_log2FC > 0.2, 'black', 'white')
- p <- plot_df %>%
- ggplot(aes(y=celltype, x=module, fill=avg_log2FC)) +
- geom_tile()
- p <- p +
- geom_text(label=plot_df$Significance, color=plot_df$textcolor)
- p <- p +
- scale_fill_gradient2(low='purple', mid='black', high='yellow') +
- RotatedAxis() +
- theme(
- panel.border = element_rect(fill=NA, color='black', size=1),
- axis.line.x = element_blank(),
- axis.line.y = element_blank(),
- plot.margin=margin(0,0,0,0)
- ) + xlab('') + ylab('') +
- coord_equal() +
- ggtitle("Resistant vs Sensitive")
- pdf('males/wgcna/consensus/gabaergic/DMEs/res_vs_sen/dmes_heatmap_celltype.pdf',
- height = 10, width = 10)
- p
- dev.off()
- library(writexl)
- write_xlsx(DMEs, 'males/wgcna/consensus/gabaergic/DMEs/res_vs_sen/dmes_celltype.xlsx')
- #res vs yok
- DMEs <- data.frame()
- for (cell_type in unique(adata$cell_subtype)) {
- print(cell_type)
- # group1 = [email hidden] %>% subset(cell_subtype == cell_type & Groups == 'Resistant') %>% rownames
- # group2 = [email hidden] %>% subset(cell_subtype == cell_type & Groups == 'Sensitive') %>% rownames
- group1 <- rownames(
- [email hidden][
- as.character([email hidden]$cell_subtype) == cell_type &
- [email hidden]$Groups == "Resistant", ]
- )
- group2 <- rownames(
- [email hidden][
- as.character([email hidden]$cell_subtype) == cell_type &
- [email hidden]$Groups == "Yoked", ]
- )
- dir.create('males/wgcna/consensus/gabaergic/DMEs/res_vs_yok')
- dir.create(paste0('males/wgcna/consensus/gabaergic/DMEs/res_vs_yok/',cell_type))
- cur_DMEs <- FindDMEs(
- adata,
- barcodes1 = group1,
- barcodes2 = group2,
- test.use='wilcox',
- wgcna_name='gaba_males_consensus'
- )
- cur_DMEs$celltype = cell_type
- DMEs = rbind(DMEs, cur_DMEs)
- p = PlotDMEsLollipop(
- adata,
- cur_DMEs,
- wgcna_name='gaba_males_consensus',
- pvalue = "p_val_adj"
- )
- pdf(paste0('males/wgcna/consensus/gabaergic/DMEs/res_vs_yok/',cell_type,'/lollipop.pdf'))
- print(p)
- dev.off()
- }
- modules <- GetModules(adata)
- mods <- levels(modules$module); mods <- mods[mods != 'grey']
- plot_df <- DMEs
- plot_df$module <- factor(as.character(plot_df$module), levels=mods)
- maxval <- 0.5; minval <- -0.5
- plot_df$avg_log2FC <- ifelse(plot_df$avg_log2FC > maxval, maxval, plot_df$avg_log2FC)
- plot_df$avg_log2FC <- ifelse(plot_df$avg_log2FC < minval, minval, plot_df$avg_log2FC)
- plot_df$Significance <- gtools::stars.pval(plot_df$p_val_adj)
- plot_df$textcolor <- ifelse(plot_df$avg_log2FC > 0.2, 'black', 'white')
- p <- plot_df %>%
- ggplot(aes(y=celltype, x=module, fill=avg_log2FC)) +
- geom_tile()
- p <- p +
- geom_text(label=plot_df$Significance, color=plot_df$textcolor)
- p <- p +
- scale_fill_gradient2(low='purple', mid='black', high='yellow') +
- RotatedAxis() +
- theme(
- panel.border = element_rect(fill=NA, color='black', size=1),
- axis.line.x = element_blank(),
- axis.line.y = element_blank(),
- plot.margin=margin(0,0,0,0)
- ) + xlab('') + ylab('') +
- coord_equal() +
- ggtitle("Resistant vs Yoked")
- pdf('males/wgcna/consensus/gabaergic/DMEs/res_vs_yok/dmes_heatmap_celltype.pdf',
- height = 10, width = 10)
- p
- dev.off()
- library(writexl)
- write_xlsx(DMEs, 'males/wgcna/consensus/gabaergic/DMEs/res_vs_yok/dmes_celltype.xlsx')
- #Enrichment
- setwd("D:/Leon/snRNAseq/heilig_data_transfer/R/high_depth")
- library(Seurat)
- library(tidyverse)
- library(cowplot)
- library(patchwork)
- library(WGCNA)
- library(hdWGCNA)
- library(igraph)
- library(qs)
- theme_set(theme_cowplot())
- set.seed(12345)
- gc()
- adata = qread('males/wgcna/consensus/gabaergic/wgcna_consensus_gaba_males.qs')
- library(enrichR)
- library(GeneOverlap)
- dbs = c('GO_Biological_Process_2025',
- 'GO_Cellular_Component_2025',
- 'GO_Molecular_Function_2025')
- adata = RunEnrichr(
- adata,
- dbs=dbs,
- max_genes = 100
- )
- enrich_df = GetEnrichrTable(adata)
- dir.create('males/wgcna/consensus/gabaergic/enrichment')
- write_xlsx(enrich_df, 'males/wgcna/consensus/gabaergic/enrichment/modules_enrichment.xlsx')
- EnrichrBarPlot_1 <- function(
- seurat_obj,
- outdir = "enrichr_plots",
- n_terms = 25,
- p_cutoff = 0.05,
- p_adj = TRUE,
- plot_size = c(6,15),
- logscale=FALSE,
- plot_bar_color=NULL,
- plot_text_color=NULL,
- wgcna_name=NULL
- ){
- # get data from active assay if wgcna_name is not given
- if(is.null(wgcna_name)){wgcna_name <- seurat_obj@misc$active_wgcna}
- # get modules:
- modules <- GetModules(seurat_obj, wgcna_name)
- mods <- levels(modules$module)
- mods <- mods[mods != 'grey']
- # get Enrichr table
- enrichr_df <- GetEnrichrTable(seurat_obj, wgcna_name)
- dbs <- as.character(unique(enrichr_df$db))
- # subset based on significance level:
- if(p_adj){
- enrichr_df <- subset(enrichr_df, Adjusted.P.value <= p_cutoff)
- } else{
- enrichr_df <- subset(enrichr_df, P.value <= p_cutoff)
- }
- # helper function to wrap text
- wrapText <- function(x, len) {
- sapply(x, function(y) paste(strwrap(y, len), collapse = "\n"), USE.NAMES = FALSE)
- }
- # make output dir if it doesn't exist:
- if(!dir.exists(outdir)){dir.create(outdir)}
- # loop through modules:
- for(i in 1:length(mods)){
- cur_mod <- mods[i]
- cur_terms <- subset(enrichr_df, module == cur_mod)
- print(cur_mod)
- # get color for this module:
- cur_color <- modules %>% subset(module == cur_mod) %>% .$color %>% unique %>% as.character
- if(!is.null(plot_bar_color)){
- cur_color <- plot_bar_color
- }
- cur_color <- grDevices::adjustcolor(cur_color, alpha.f = 0.6)
- # skip if there are not any terms for this module:
- if(nrow(cur_terms) == 0){next}
- cur_terms$wrap <- wrapText(cur_terms$Term, 45)
- # plot top n_terms as barplot
- plot_list <- list()
- for(cur_db in dbs){
- plot_df <- subset(cur_terms, db==cur_db) %>%
- slice_max(order_by=Combined.Score, n=n_terms)
- # text color:
- if(is.null(plot_text_color)){
- if(cur_color == 'black'){
- text_color = 'grey'
- } else {
- text_color = 'black'
- }
- } else{
- text_color <- plot_text_color
- }
- # logscale?
- if(logscale){
- plot_df$Combined.Score <- log(plot_df$Combined.Score)
- lab <- 'Enrichment log(combined score)'
- x <- 0.2
- } else{lab <- 'Enrichment (combined score)'; x <- 5}
- # make bar plot:
- plot_list[[cur_db]] <- ggplot(plot_df, aes(x=Combined.Score, y=reorder(wrap, Combined.Score)))+
- geom_bar(stat='identity', position='identity', color='white', fill=cur_color) +
- geom_text(aes(label=wrap), x=x, color=text_color, size=8, hjust='left') +
- scale_x_continuous(expand = c(0, 0), limits = c(0, NA)) +
- xlab(lab) + ylab('') + ggtitle(cur_db) +
- theme(
- panel.grid.major=element_blank(),
- panel.grid.minor=element_blank(),
- legend.title = element_blank(),
- axis.ticks.y=element_blank(),
- axis.text.y=element_blank(),
- plot.title = element_text(hjust = 0.5),
- axis.line.y=element_blank()
- )
- }
- # make pdfs in output dir
- pdf(paste0(outdir, '/', cur_mod, '.pdf'), width=plot_size[1], height=plot_size[2])
- for(plot in plot_list){
- print(plot)
- }
- dev.off()
- }
- }
- EnrichrBarPlot_1(
- adata,
- outdir = 'males/wgcna/consensus/gabaergic/enrichment',
- n_terms = 5,
- plot_size = c(10,10),
- logscale = TRUE, p_cutoff = 0.1
- )
- p = EnrichrDotPlot(
- adata,
- mods = "all", # use all modules (default)
- database = "GO_Biological_Process_2025", # this must match one of the dbs used previously
- n_terms=2, # number of terms per module
- term_size=10, # font size for the terms
- p_adj = FALSE # show the p-val or adjusted p-val?
- ) + scale_color_stepsn(colors=rev(viridis::magma(256)))
- pdf('males/wgcna/consensus/gabaergic/enrichment/enrichment_dotplot_bio_process.pdf',
- height = 15, width = 15)
- print(p)
- dev.off()
- p = EnrichrDotPlot(
- adata,
- mods = "all", # use all modules (default)
- database = "GO_Cellular_Component_2025", # this must match one of the dbs used previously
- n_terms=2, # number of terms per module
- term_size=10, # font size for the terms
- p_adj = FALSE # show the p-val or adjusted p-val?
- ) + scale_color_stepsn(colors=rev(viridis::magma(256)))
- pdf('males/wgcna/consensus/gabaergic/enrichment/enrichment_dotplot_cell_process.pdf',
- height = 15, width = 15)
- print(p)
- dev.off()
- p = EnrichrDotPlot(
- adata,
- mods = "all", # use all modules (default)
- database = "GO_Molecular_Function_2025", # this must match one of the dbs used previously
- n_terms=2, # number of terms per module
- term_size=10, # font size for the terms
- p_adj = FALSE # show the p-val or adjusted p-val?
- ) + scale_color_stepsn(colors=rev(viridis::magma(256)))
- pdf('males/wgcna/consensus/gabaergic/enrichment/enrichment_dotplot_mol_function.pdf',
- height = 15, width = 15)
- print(p)
- dev.off()
- ################### modules in the same direction ##################
- library(readxl)
- res_vs_sen = read_excel('males/wgcna/consensus/gabaergic/DMEs/res_vs_sen/dmes_celltype.xlsx')
- res_vs_yok = read_excel('males/wgcna/consensus/gabaergic/DMEs/res_vs_yok/dmes_celltype.xlsx')
- res_vs_sen$comparison = 'res_vs_sen'
- res_vs_yok$comparison = 'res_vs_yok'
- df1_sig = subset(res_vs_sen, p_val_adj < 0.05)
- df2_sig = subset(res_vs_yok, p_val_adj < 0.05)
- library(dplyr)
- combined_data = merge(df1_sig, df2_sig, c('celltype', 'module'))
- combined_data$avg_log2FC.x <- as.numeric(combined_data$avg_log2FC.x)
- combined_data$avg_log2FC.y <- as.numeric(combined_data$avg_log2FC.y)
- df_filtered <- combined_data %>%
- filter(
- (avg_log2FC.x > 0 & avg_log2FC.y > 0 | avg_log2FC.x < 0 & avg_log2FC.y < 0) &
- abs(avg_log2FC.x) > 0.2 &
- abs(avg_log2FC.y) > 0.2 &
- pct.1.x > 0.5 &
- pct.1.y > 0.5 &
- pct.2.x > 0.5 &
- pct.2.y > 0.5
- )
- write_xlsx(df_filtered, 'Fgfr1_paper/DMEs_for_paper.xlsx')
- long_data <- df_filtered %>%
- pivot_longer(
- cols = c(avg_log2FC.x, avg_log2FC.y),
- names_to = "comparison",
- names_pattern = "avg_log2FC\\.(.)",
- values_to = "logFC"
- ) %>%
- mutate(
- comparison_label = ifelse(comparison == "x", "Res vs Sen", "Res vs Yok"),
- module_label = paste0(module, " (", comparison_label, ")")
- )
- write_xlsx(long_data, 'Fgfr1_paper/DMEs_for_paper.xlsx')
- #################### Distinct #####################
- setwd('outputs/distinct/males/')
- library(Seurat)
- library(SingleCellExperiment)
- library(distinct)
- library(qs)
- library(writexl)
- library(readxl)
- adata = qread('../../../objects/gabaergic_males_subclustered.qs')
- DefaultAssay(adata) = 'decontXcounts'
- adata[['decontXcounts']] = JoinLayers(adata[['decontXcounts']])
- adata
- sce = as.SingleCellExperiment(adata)
- rm(adata)
- sce
- gc()
- sce
- cpm_mat = scater::calculateCPM(counts(sce))
- assay(sce, "cpm") = cpm_mat
- sce = scater::logNormCounts(sce)
- sce
- gc()
- colData(sce)
- gc()
- sce$SampleID = as.factor(sce$SampleID)
- sce$Groups = as.factor(sce$Groups)
- sample_md <- unique(as.data.frame(colData(sce)[, c("SampleID", "Groups")]))
- design <- model.matrix(~Groups, data = sample_md)
- rownames(design) <- sample_md$SampleID
- design
- rownames(design)
- set.seed(1234)
- ###################################
- sce_sub <- sce[, sce$Groups %in% c("Resistant", "Sensitive")]
- unique(sce_sub$Groups)
- sce_sub$Groups = droplevels(sce_sub$Groups)
- unique(sce_sub$Groups)
- set.seed(123)
- sample_md <- unique(as.data.frame(colData(sce_sub)[, c("SampleID", "Groups")]))
- design_sub <- model.matrix(~ Groups, data = sample_md)
- rownames(design_sub) <- sample_md$SampleID
- design_sub
- gc()
- sce_sub
- sum(logcounts(sce_sub)["Sik2", ] > 0)
- res_sen <- distinct_test(
- x = sce_sub,
- name_assays_expression = "cpm",
- name_cluster = "cell_subtype",
- name_sample = "SampleID",
- design = design_sub,
- column_to_test = 2,
- min_non_zero_cells = 2000,
- n_cores = 10,
- P_4 = 20000
- )
- res_sen = log2_FC(res = res_sen,
- x = sce_sub,
- name_assays_expression = 'cpm',
- name_group = "Groups",
- name_cluster = "cell_subtype")
- top = top_results(res_sen,
- significance = 0.05, global = T)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = F)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = T)
- write_xlsx(x = top, 'res_sen.xlsx')
- #########################################
- sce_sub <- sce[, sce$Groups %in% c("Resistant", "Yoked")]
- unique(sce_sub$Groups)
- sce_sub$Groups = droplevels(sce_sub$Groups)
- unique(sce_sub$Groups)
- set.seed(123)
- sample_md <- unique(as.data.frame(colData(sce_sub)[, c("SampleID", "Groups")]))
- design_sub <- model.matrix(~ Groups, data = sample_md)
- rownames(design_sub) <- sample_md$SampleID
- design_sub
- gc()
- sce_sub
- sum(logcounts(sce_sub)["Slc17a7", ] > 0)
- res_yok <- distinct_test(
- x = sce_sub,
- name_assays_expression = "cpm",
- name_cluster = "cell_subtype",
- name_sample = "SampleID",
- design = design_sub,
- column_to_test = 2,
- min_non_zero_cells = 2000,
- n_cores = 10,
- P_4 = 20000
- )
- res_yok = log2_FC(res = res_yok,
- x = sce_sub,
- name_assays_expression = 'cpm',
- name_group = "Groups",
- name_cluster = "cell_subtype")
- top = top_results(res_yok,
- significance = 0.05, global = T)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = F)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = T)
- write_xlsx(x = top, 'res_yok.xlsx')
- gc()
- ######################### Analysis of results #################################
- res_sen = read_excel('res_sen.xlsx')
- res_yok = read_excel('res_yok.xlsx')
- head(res_sen)
- head(res_yok)
- library(dplyr)
- overlap <- inner_join(
- res_sen %>% select(gene, cluster_id, everything()),
- res_yok %>% select(gene, cluster_id, everything()),
- by = c("gene", "cluster_id"),
- suffix = c("_sen", "_yok")
- )
- overlap_same_direction <- overlap %>%
- filter(
- (`log2FC_Resistant/Sensitive` > 0 & `log2FC_Resistant/Yoked` > 0) |
- (`log2FC_Resistant/Sensitive` < 0 & `log2FC_Resistant/Yoked` < 0)
- )
- overlap_same_direction$average_log2FC = (overlap_same_direction$`log2FC_Resistant/Sensitive`+overlap_same_direction$`log2FC_Resistant/Yoked`)/2
- overlap_same_direction$average_p_adj = (overlap_same_direction$p_adj.glb_sen + overlap_same_direction$p_adj.glb_yok)/2
- write_xlsx(overlap_same_direction, 'DEG_list_males_gabaergic.xlsx')
- for_ipa = overlap_same_direction %>% select(gene, average_log2FC, average_p_adj, cluster_id)
- dir.create('for_ipa')
- celltypes <- unique(df$cluster_id)
- for (ct in celltypes) {
- sub <- for_ipa %>% filter(cluster_id == ct)
- write.csv(sub, paste0("for_ipa/IPA_", ct, ".csv"), row.names = FALSE)
- }
- ################################# Volcanoplots ############################3
- overlap_same_direction = read_xlsx('DEG_list_males_gabaergic.xlsx')
- library(dplyr)
- library(ggpubr)
- library(viridis)
- library(dplyr)
- library(ggplot2)
- library(patchwork)
- library(ggrepel)
- df = overlap_same_direction
- df <- df %>%
- mutate(
- reg_sen = case_when(
- p_adj.glb_sen < 0.05 & `log2FC_Resistant/Sensitive` > 0.1 ~ "Up",
- p_adj.glb_sen < 0.05 & `log2FC_Resistant/Sensitive` < -0.1 ~ "Down",
- TRUE ~ "NS"
- ),
- reg_yok = case_when(
- p_adj.glb_yok < 0.05 & `log2FC_Resistant/Yoked` > 0.1 ~ "Up",
- p_adj.glb_yok < 0.05 & `log2FC_Resistant/Yoked` < -0.1 ~ "Down",
- TRUE ~ "NS"
- )
- )
- make_volcano_pair <- function(df, cluster) {
- df_clust <- df %>% filter(cluster_id == cluster)
- p_sen <- ggplot(df_clust, aes(
- x = `log2FC_Resistant/Sensitive`,
- y = -log10(p_adj.glb_sen)
- )) +
- geom_point(aes(color = reg_sen), size = 1.2, alpha = 0.7) +
- geom_vline(xintercept = c(-0.1, 0.1), linetype = "dashed") +
- geom_hline(yintercept = -log10(0.05), linetype = "dashed") +
- geom_text_repel(
- data = df_clust %>% filter(reg_sen != "NS"),
- aes(label = gene),
- size = 3,
- max.overlaps = 20
- ) +
- scale_color_manual(
- values = c(Up = "red", Down = "blue", NS = "grey70")
- ) +
- labs(
- title = "Resistant vs Sensitive",
- x = "log2FC",
- y = "-log10(adj p-value)"
- ) +
- theme_classic() +
- theme(legend.position = "none")
- p_yok <- ggplot(df_clust, aes(
- x = `log2FC_Resistant/Yoked`,
- y = -log10(p_adj.glb_yok)
- )) +
- geom_point(aes(color = reg_yok), size = 1.2, alpha = 0.7) +
- geom_vline(xintercept = c(-0.1, 0.1), linetype = "dashed") +
- geom_hline(yintercept = -log10(0.05), linetype = "dashed") +
- geom_text_repel(
- data = df_clust %>% filter(reg_yok != "NS"),
- aes(label = gene),
- size = 3,
- max.overlaps = 20
- ) +
- scale_color_manual(
- values = c(Up = "red", Down = "blue", NS = "grey70")
- ) +
- labs(
- title = "Resistant vs Yoked",
- x = "log2FC",
- y = "-log10(adj p-value)"
- ) +
- theme_classic() +
- theme(legend.position = "none")
- (p_sen | p_yok) + plot_annotation(title = cluster)
- }
- clusters <- unique(df$cluster_id)
- volcano_plots <- lapply(clusters, function(cl) {
- make_volcano_pair(df, cl)
- })
- volcano_plots[[1]]
- dir.create('volcano_plots')
- clusters <- unique(df$cluster_id)
- for (cl in clusters) {
- p <- make_volcano_pair(df, cl)
- ggsave(
- filename = paste0("volcano_plots/volcano_", cl, ".pdf"),
- plot = p,
- width = 15,
- height = 10,
- units = "in"
- )
- }
- ################################################################################
- df_plot <- overlap_same_direction %>% count(cluster_id)
- p = ggbarplot(
- df_plot,
- x = "cluster_id",
- y = "n",
- fill = "cluster_id",
- palette = viridis(nrow(df_plot)),
- label = TRUE,
- lab.vjust = -0.5,
- sort.val = "desc", # sort bars by height (largest at top)
- sort.by.groups = FALSE,
- x.text.angle = 45,
- legend = "none" # remove legend
- ) +
- labs(
- title = "Number of DEGs per cluster",
- x = "Cluster ID",
- y = "Gene Count"
- )
- p
- pdf('number_of_degs_per_cluster.pdf')
- print(p)
- dev.off()
- m8 = read_excel('modules/M8_consensus.xlsx', col_names = 'gene')
- m5 = read_excel('modules/M5_consensus.xlsx', col_names = 'gene')
- m4 = read_excel('modules/M4_consensus.xlsx', col_names = 'gene')
- m2 = read_excel('modules/M2_consensus.xlsx', col_names = 'gene')
- degs_in_m8 = overlap_same_direction %>%
- filter(gene %in% m8$gene)
- degs_in_m5 = overlap_same_direction %>%
- filter(gene %in% m5$gene)
- degs_in_m4 = overlap_same_direction %>%
- filter(gene %in% m4$gene)
- degs_in_m2 = overlap_same_direction %>%
- filter(gene %in% m2$gene)
- adata = qread('../../../objects/gabaergic_males_subclustered.qs')
- FeaturePlot(adata, reduction = 'euclidean_umap_gaba', 'Tmcc3')
- p = DotPlot(
- adata,
- c('Pdzrn3', 'Sox5', 'Tmcc3', 'Arhgap6', 'Hdac9', 'Ankfn1', 'Dock10',
- 'Palmd', 'Pde7b', 'Maml2', 'Fgfr1', 'Slc35f3', 'Spata13', 'Epb41l4b',
- 'Kalrn', 'Shank2', 'Sec14l1', 'Camk4', 'Rap1gap', 'Mbnl1', 'Ptpro',
- 'Cnih3', 'Glis3', 'Vat1l', 'Dgkg'),
- group.by = 'cell_subtype'
- )
- p = p + theme(axis.text.x = element_text(angle = 45, hjust = 1))
- dir.create('../../males')
- dir.create('../../males/misc_plots')
- pdf('../../males/misc_plots/dotplot_hubgenes_celltypes.pdf',
- width = 20, height = 20)
- print(p)
- dev.off()
- ################################ Main celltypes ##################################################
- setwd("~/Documents/Projects/Compulsivity/snRNAseq_males_and_females/compulsive_snrnaseq_females_males")
- dir.create('outputs/distinct/males/main_celltypes')
- setwd('outputs/distinct/males/main_celltypes')
- library(Seurat)
- library(SingleCellExperiment)
- library(distinct)
- library(qs)
- library(writexl)
- library(readxl)
- library(dplyr)
- adata = readRDS('../../../../objects/high_annotated_males_decontx.rds')
- DefaultAssay(adata) = 'decontXcounts'
- adata
- adata$cell_type = recode(
- adata$cell_type,
- "Oligendrocytes" = "Oligodendrocytes",
- "Hbb-b1_Hbb-a2_Blood?" = "Blood",
- "Glutaminergic_Slc17a6" = "Glutamatergic_Vglut2",
- "Glutaminergic_Slc17a7" = "Glutamatergic_Vglut1"
- )
- unique(adata$cell_type)
- sce = as.SingleCellExperiment(adata)
- rm(adata)
- sce
- gc()
- cpm_mat = scater::calculateCPM(counts(sce))
- assay(sce, "cpm") = cpm_mat
- gc()
- sce = scater::logNormCounts(sce)
- sce
- gc()
- colData(sce)
- gc()
- sce$SampleID = as.factor(sce$SampleID)
- sce$Groups = as.factor(sce$Groups)
- rm(cpm_mat)
- gc()
- ###################################
- sce_sub <- sce[, sce$Groups %in% c("Resistant", "Sensitive")]
- res_list = list()
- clusters = unique(sce_sub$cell_type)
- #clusters = 'Microglia'
- set.seed(123)
- gc()
- for (cl in clusters) {
- #cl = 'Microglia'
- cat("Processing cluster:", cl, "\n")
- sce_cl <- sce_sub[, sce_sub$cell_type == cl]
- sce_cl$Groups = droplevels(sce_cl$Groups)
- sce_cl$cell_type = droplevels(sce_cl$cell_type)
- sample_md <- unique(as.data.frame(colData(sce_cl)[, c("SampleID", "Groups")]))
- design_sub <- model.matrix(~ Groups, data = sample_md)
- rownames(design_sub) <- sample_md$SampleID
- design_sub
- gc()
- res_cl <- distinct_test(
- x = sce_cl,
- name_assays_expression = "cpm",
- name_cluster = "cell_type", # single cluster, doesn't matter
- name_sample = "SampleID",
- design = design_sub,
- column_to_test = 2,
- min_non_zero_cells = 2000,
- n_cores = 10,
- P_4 = 5000
- )
- # Compute log2 FC
- res_cl <- log2_FC(
- res = res_cl,
- x = sce_cl,
- name_assays_expression = "cpm",
- name_group = "Groups",
- name_cluster = "cell_type"
- )
- # Store results with cluster name
- res_list[[cl]] <- res_cl
- gc()
- }
- res_sen <- bind_rows(res_list, .id = "cell_type")
- top <- top_results(res_sen, significance = 0.05, global = TRUE)
- write_xlsx(top, "res_sen_by_cluster.xlsx")
- gc()
- unique(sce_sub$Groups)
- sce_sub$Groups = droplevels(sce_sub$Groups)
- unique(sce_sub$Groups)
- design_sub
- gc()
- sce_sub
- sum(logcounts(sce_sub)["Sik2", ] > 0)
- table(sce$cell_type)
- res_sen <- distinct_test(
- x = sce_sub,
- name_assays_expression = "cpm",
- name_cluster = "cell_type",
- name_sample = "SampleID",
- design = design_sub,
- column_to_test = 2,
- min_non_zero_cells = 200,
- n_cores = 1,
- P_4 = 20000
- )
- res_sen = log2_FC(res = res_sen,
- x = sce_sub,
- name_assays_expression = 'cpm',
- name_group = "Groups",
- name_cluster = "cell_subtype")
- top = top_results(res_sen,
- significance = 0.05, global = T)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = F)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = T)
- write_xlsx(x = top, 'res_sen.xlsx')
- #########################################
- sce_sub <- sce[, sce$Groups %in% c("Resistant", "Yoked")]
- unique(sce_sub$Groups)
- sce_sub$Groups = droplevels(sce_sub$Groups)
- unique(sce_sub$Groups)
- set.seed(123)
- sample_md <- unique(as.data.frame(colData(sce_sub)[, c("SampleID", "Groups")]))
- design_sub <- model.matrix(~ Groups, data = sample_md)
- rownames(design_sub) <- sample_md$SampleID
- design_sub
- gc()
- sce_sub
- sum(logcounts(sce_sub)["Slc17a7", ] > 0)
- res_yok <- distinct_test(
- x = sce_sub,
- name_assays_expression = "cpm",
- name_cluster = "cell_subtype",
- name_sample = "SampleID",
- design = design_sub,
- column_to_test = 2,
- min_non_zero_cells = 2000,
- n_cores = 10,
- P_4 = 20000
- )
- res_yok = log2_FC(res = res_yok,
- x = sce_sub,
- name_assays_expression = 'cpm',
- name_group = "Groups",
- name_cluster = "cell_subtype")
- top = top_results(res_yok,
- significance = 0.05, global = T)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = F)
- plot_densities(x = sce_sub,
- gene = 'Cdk10',
- cluster = 'Drd2_Calcrl',
- name_assays_expression = 'cpm',
- name_cluster = 'cell_subtype',
- name_sample = 'SampleID',
- name_group = 'Groups', group_level = T)
- write_xlsx(x = top, 'res_yok.xlsx')
- gc()
- ######################### Analysis of results #################################
- res_sen = read_excel('res_sen.xlsx')
- res_yok = read_excel('res_yok.xlsx')
- head(res_sen)
- head(res_yok)
- library(dplyr)
- overlap <- inner_join(
- res_sen %>% select(gene, cluster_id, everything()),
- res_yok %>% select(gene, cluster_id, everything()),
- by = c("gene", "cluster_id"),
- suffix = c("_sen", "_yok")
- )
- overlap_same_direction <- overlap %>%
- filter(
- (`log2FC_Resistant/Sensitive` > 0 & `log2FC_Resistant/Yoked` > 0) |
- (`log2FC_Resistant/Sensitive` < 0 & `log2FC_Resistant/Yoked` < 0)
- )
- overlap_same_direction$average_log2FC = (overlap_same_direction$`log2FC_Resistant/Sensitive`+overlap_same_direction$`log2FC_Resistant/Yoked`)/2
- overlap_same_direction$average_p_adj = (overlap_same_direction$p_adj.glb_sen + overlap_same_direction$p_adj.glb_yok)/2
- write_xlsx(overlap_same_direction, 'DEG_list_males_main_celltypes.xlsx')
- for_ipa = overlap_same_direction %>% select(gene, average_log2FC, average_p_adj, cluster_id)
- dir.create('for_ipa')
- celltypes <- unique(df$cluster_id)
- for (ct in celltypes) {
- sub <- for_ipa %>% filter(cluster_id == ct)
- write.csv(sub, paste0("for_ipa/IPA_", ct, ".csv"), row.names = FALSE)
- }
- library(dplyr)
- library(ggpubr)
- library(viridis)
- ##########################################################################
- overlap_same_direction = read_xlsx('DEG_list_males_main_celltypes.xlsx')
- library(dplyr)
- library(ggpubr)
- library(viridis)
- library(dplyr)
- library(ggplot2)
- library(patchwork)
- library(ggrepel)
- df = overlap_same_direction
- df <- df %>%
- mutate(
- reg_sen = case_when(
- p_adj.glb_sen < 0.05 & `log2FC_Resistant/Sensitive` > 0.1 ~ "Up",
- p_adj.glb_sen < 0.05 & `log2FC_Resistant/Sensitive` < -0.1 ~ "Down",
- TRUE ~ "NS"
- ),
- reg_yok = case_when(
- p_adj.glb_yok < 0.05 & `log2FC_Resistant/Yoked` > 0.1 ~ "Up",
- p_adj.glb_yok < 0.05 & `log2FC_Resistant/Yoked` < -0.1 ~ "Down",
- TRUE ~ "NS"
- )
- )
- make_volcano_pair <- function(df, cluster) {
- df_clust <- df %>% filter(cluster_id == cluster)
- p_sen <- ggplot(df_clust, aes(
- x = `log2FC_Resistant/Sensitive`,
- y = -log10(p_adj.glb_sen)
- )) +
- geom_point(aes(color = reg_sen), size = 1.2, alpha = 0.7) +
- geom_vline(xintercept = c(-0.1, 0.1), linetype = "dashed") +
- geom_hline(yintercept = -log10(0.05), linetype = "dashed") +
- geom_text_repel(
- data = df_clust %>% filter(reg_sen != "NS"),
- aes(label = gene),
- size = 3,
- max.overlaps = 20
- ) +
- scale_color_manual(
- values = c(Up = "red", Down = "blue", NS = "grey70")
- ) +
- labs(
- title = "Resistant vs Sensitive",
- x = "log2FC",
- y = "-log10(adj p-value)"
- ) +
- theme_classic() +
- theme(legend.position = "none")
- p_yok <- ggplot(df_clust, aes(
- x = `log2FC_Resistant/Yoked`,
- y = -log10(p_adj.glb_yok)
- )) +
- geom_point(aes(color = reg_yok), size = 1.2, alpha = 0.7) +
- geom_vline(xintercept = c(-0.1, 0.1), linetype = "dashed") +
- geom_hline(yintercept = -log10(0.05), linetype = "dashed") +
- geom_text_repel(
- data = df_clust %>% filter(reg_yok != "NS"),
- aes(label = gene),
- size = 3,
- max.overlaps = 20
- ) +
- scale_color_manual(
- values = c(Up = "red", Down = "blue", NS = "grey70")
- ) +
- labs(
- title = "Resistant vs Yoked",
- x = "log2FC",
- y = "-log10(adj p-value)"
- ) +
- theme_classic() +
- theme(legend.position = "none")
- (p_sen | p_yok) + plot_annotation(title = cluster)
- }
- clusters <- unique(df$cluster_id)
- volcano_plots <- lapply(clusters, function(cl) {
- make_volcano_pair(df, cl)
- })
- volcano_plots[[1]]
- dir.create('volcano_plots')
- clusters <- unique(df$cluster_id)
- for (cl in clusters) {
- p <- make_volcano_pair(df, cl)
- ggsave(
- filename = paste0("volcano_plots/volcano_", cl, ".pdf"),
- plot = p,
- width = 15,
- height = 10,
- units = "in"
- )
- }
- ################################################################################
- df_plot <- overlap_same_direction %>% count(cluster_id)
- p = ggbarplot(
- df_plot,
- x = "cluster_id",
- y = "n",
- fill = "cluster_id",
- palette = viridis(nrow(df_plot)),
- label = TRUE,
- lab.vjust = -0.5,
- sort.val = "desc", # sort bars by height (largest at top)
- sort.by.groups = FALSE,
- x.text.angle = 45,
- legend = "none" # remove legend
- ) +
- labs(
- title = "Number of DEGs per cluster",
- x = "Cluster ID",
- y = "Gene Count"
- )
- p
- pdf('number_of_degs_per_cluster.pdf')
- print(p)
- dev.off()
master.R at commit 115c830, under MIT · at the source
Overview
- Center for Social and Affective Neuroscience, BKV, Linköping University, Linköping, Sweden
- Waggoner Center for Alcohol and Addiction Research and Departments of Neuroscience and Neurology, University of Texas at Austin, Austin, TX USA
- Department of Pharmacy and Biotechnology, Alma Mater Studiorum – University of Bologna, Bologna, Italy
- Center for Neuroscience, University of Camerino, Camerino, Italy
Abstract
A significant minority of alcohol users develop alcohol addiction, characterized by continued use despite negative consequences, referred to as compulsive-like. We previously showed that vulnerability to compulsive-like alcohol use can be modeled in rats using punished alcohol self-administration and in male rats is mediated by PKCδ+ neurons in the central nucleus of the amygdala (CeA). Here, we used cell-type-specific transcriptomics to identify molecular mechanisms underlying individual differences in this behavior. Transcriptional changes were restricted to a limited number of CeA neuronal populations, including PKCδ+ neurons, where weighted Gene Co-expression Network Analysis identified an upregulated co-expression module in punishment-resistant rats with FGFR1 as a druggable upstream regulator. Selective silencing of FgfR1 in PKCδ+ neurons normalized elevated PKCδ+ expression, and reduced punishment-resistant alcohol self-administration. This effect was recapitulated by systemic administration of the FgfR1-antagonist PD173074. These findings identify distinct CeA circuits that promote addiction vulnerability, and position FGFR1 as potential therapeutic targets.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 4 matches between paragraphs and lines of code.
leohog/Fgfr1_analysis
115c830f9e669f8eae77446eaca0d9d75e1e7ab0, 20 April 2026Availability: 1 check, the latest on 26 September 2026: the link answers
- 26 September 2026: the link answers
Code availability
The code used to perform these analyses is publicly available on GitHub at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Tracing map
Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.
What the map holds:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 1 script, each with its path and the digest of its content;
- 4 matches between paragraphs of the paper and lines of the code (method lexical-v1);
- neither the text of the paper nor the code itself.
Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.
Data
Datasets cited
- geo:GSE310229, at NCBI GEO; found in “Data availability”
Data Availability Statement
The RNA sequencing data generated in this study have been deposited in the GEO database under accession code GSE310229 (https://
The code used to perform these analyses is publicly available on GitHub at https://
Reproduced under the paper's license (CC BY), from the paper cited above.
Versions
The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.
Version 1, 27 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 11 authors, 2 keywords, 12 MeSH terms, 4 funders, 36 references, 1 RRID.
Cite
This paper
Barbier, E., Höglund, L., Xu, L., Salem, N. A., Osterndorff-Kahanek, E. A., Barchiesi, R., Lacorte, A., Fenno, L. E., Messing, R. O., Mayfield, R. D., & Heilig, M. (2026). Identification and validation of central amygdala FGFR1 as a therapeutic target for alcohol use disorder using single-nucleus sequencing in rats. Nature communications, 17(1), 9407. https://
BibTeX
@article{barbier2026iden
author = {Barbier, Estelle and Höglund, Leon and Xu, Li and Salem, Nihal A and Osterndorff-Kahanek, Elizabeth A and Barchiesi, Riccardo and Lacorte, Antonio and Fenno, Lief E and Messing, Robert O and Mayfield, R Dayne and Heilig, Markus},
title = {{Identification and validation of central amygdala FGFR1 as a therapeutic target for alcohol use disorder using single-nucleus sequencing in rats}},
journal = {Nature communications},
year = {2026},
month = sep,
volume = {17},
number = {1},
pages = {9407},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/
url = {https://
pmid = {42686758},
pmcid = {PMC13538410}
}
RIS
TY - JOUR
AU - Barbier, Estelle
AU - Höglund, Leon
AU - Xu, Li
AU - Salem, Nihal A
AU - Osterndorff-Kahanek, Elizabeth A
AU - Barchiesi, Riccardo
AU - Lacorte, Antonio
AU - Fenno, Lief E
AU - Messing, Robert O
AU - Mayfield, R Dayne
AU - Heilig, Markus
TI - Identification and validation of central amygdala FGFR1 as a therapeutic target for alcohol use disorder using single-nucleus sequencing in rats
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/
VL - 17
IS - 1
SP - 9407
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1038/
"type": "article-journal",
"title": "Identification and validation of central amygdala FGFR1 as a therapeutic target for alcohol use disorder using single-nucleus sequencing in rats",
"container-title": "Nature communications",
"author": [
{
"family": "Barbier",
"given": "Estelle"
},
{
"family": "Höglund",
"given": "Leon"
},
{
"family": "Xu",
"given": "Li"
},
{
"family": "Salem",
"given": "Nihal A"
},
{
"family": "Osterndorff-Kahanek",
"given": "Elizabeth A"
},
{
"family": "Barchiesi",
"given": "Riccardo"
},
{
"family": "Lacorte",
"given": "Antonio"
},
{
"family": "Fenno",
"given": "Lief E"
},
{
"family": "Messing",
"given": "Robert O"
},
{
"family": "Mayfield",
"given": "R Dayne"
},
{
"family": "Heilig",
"given": "Markus"
}
],
"container-title-short":
"volume": "17",
"issue": "1",
"page": "9407",
"DOI": "10.1038/
"PMID": "42686758",
"PMCID": "PMC13538410",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
9,
2
]
]
}
}
The tracing map gets a citation of its own once an author has validated it and it has a DOI.
Similar papers
The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.
- [1] doi:10.1038/s41398-026-04200-5 [code]
- Postmortem brain single-nucleus and bulk gene expression analyses identify shared and distinct abnormalities in bipolar disorder and major depressive disorder.Journal: Translational psychiatryIn common: WGCNA, SingleCellExperiment, igraph, 6 other tools, genetics / omics, cellular / molecular, 2 references
- [2] doi:10.1016/j.xcrm.2026.102766 [code]
- A longitudinal single-cell and spatial multiomic atlas of pediatric high-grade glioma.Journal: Cell reports. MedicineIn common: WGCNA, SingleCellExperiment, igraph, 6 other tools, genetics / omics, other condition, cellular / molecular, 1 reference
- [3] doi:10.1038/s44318-026-00806-z [code]
- Interspecific diversity in the neuronal composition of the mammalian cortex arises from heterochrony in neurogenesis.Journal: The EMBO journalIn common: WGCNA, SingleCellExperiment, igraph, 6 other tools, rat, 1 reference
- [4] doi:10.1038/s41593-026-02367-0 [code]
- A reproducible three-dimensional model of human brain tissue to investigate physiological and disease-associated microglia phenotypes.Journal: Nature neuroscienceIn common: WGCNA, SingleCellExperiment, igraph, 6 other tools, cellular / molecular, 1 reference
- [5] doi:10.1016/j.isci.2026.115573 [code]
- Female cortical cellular mosaicism underlies shared MeCP2 and PCB impacted gene pathways.Journal: iScienceIn common: WGCNA, SingleCellExperiment, igraph, 6 other tools, cellular / molecular, 1 reference
- [6] doi:10.1038/s41467-026-71542-5 [code]
- Astrocyte fatty acid metabolism as a driver of risk for major depressive disorder.Journal: Nature communicationsIn common: WGCNA, SingleCellExperiment, igraph, 5 other tools, genetics / omics, cellular / molecular, 1 reference
- [7] doi:10.1038/s41593-026-02384-z [code]
- cGAS-mediated type I IFN signaling contributes to disease progression in drug-refractory epilepsy.Journal: Nature neuroscienceIn common: WGCNA, SingleCellExperiment, igraph, 5 other tools, cellular / molecular, 1 reference
- [8] doi:10.1038/s41467-026-73305-8 [code]
- Comparative analysis of the cellular landscape in mammalian striatum.Journal: Nature communicationsIn common: WGCNA, SingleCellExperiment, Seurat, 5 other tools, genetics / omics, cellular / molecular, 1 reference
- [9] doi:10.1016/j.isci.2026.115196 [code]
- Transcriptional and cellular maturation of the chick spinal cord in the context of distinct neuromuscular circuits.Journal: iScienceIn common: WGCNA, SingleCellExperiment, igraph, 6 other tools
- [10] doi:10.1038/s41380-026-03629-w [code]
- Maternal fasting during early gestation induces epigenetic alterations and schizophrenia-related phenotypes.Journal: Molecular psychiatryIn common: WGCNA, igraph, Seurat, 4 other tools, genetics / omics, cellular / molecular, 2 references
Contribute
The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.
Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 1 script, and 4 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:35c64ca887cd6bd3…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
Request its removal
To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).
Discussion, reproductions, activity
Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.
Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.
Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.
