OSCR

Comparative analysis of the cellular landscape in mammalian striatum.

Code ↔ Paper

23 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 23 matches · 1 of them tie a paragraph to a whole file, not to given lines: a weak match, whose lines are not tinted
  1. [1] § Methods › Single-nucleus RNA sequencing, cell type annotation, and cellular compositional abundance analysis ↔ 05_DGE_analysis/00_prep_pseudobulk_counts.R, lines 484–535 · score 0.98 · k.weight, LogNormalize, FindVariableFeatures, IntegrateData, FindIntegrationAnchors, SelectIntegrationFeatures
  2. [2] § Methods › Single-nucleus RNA sequencing dataset alignment and quality control ↔ 03_SPNs/00_get_orthologs.sh, the whole file · a weak match · score 0.97 · Mustela putorius furo, Callithrix jacchus, Homo Sapiens, Macaca mulatta, Mus musculus, Pan troglodytes
  3. [3] § Methods › Bat interneuron subtype analyses ↔ 02_Bat/04_WGCNA.R, lines 128–166 · score 0.97 · soft threshold power, blockwiseModules, deepSplit, maxBlockSize, minCoreKME, minKMEtoStay
  4. [4] § Methods › Bat interneuron subtype analyses ↔ 02_Human/06_WGCNA.R, lines 133–172 · score 0.96 · soft threshold power, blockwiseModules, deepSplit, maxBlockSize, minCoreKME, minKMEtoStay
  5. [5] § Results › Identification of striatal cell populations of each species ↔ QC_plots.R, lines 353–401 · score 0.85 · Il1rapl2, Ppp1r1b, Csf1r, Apbb1ip, CHRM2, GFAP
  6. [6] § Results › Non-primates have lower eSPN to SPN proportions ↔ 03_SPNs/03_eSPN_D1D2_hybrid_correlation.R, lines 43–82 · score 0.78 · SEMA5B, SV2B, eSPNs, CRYM, KREMEN1, SGK1
  7. [7] § Results › Non-primates have lower eSPN to SPN proportions ↔ 03_SPNs/03_eSPN_D1D2_hybrid_correlation.R, lines 43–82 · score 0.78 · SEMA5B, SV2B, eSPNs, CRYM, KREMEN1, SGK1
  8. [8] § Methods › Human-specific differentially expressed gene (HS DEG) analysis ↔ 02_Human/06_WGCNA.R, lines 235–277 · score 0.70 · HS DEGs, gene enrichment, GO term, cutoffs, WGCNA, modules
  9. [9] § Results › Differential gene expression analysis reveals stronger human specific change in SPNs than glia ↔ 02_Human/06_WGCNA.R, lines 235–277 · score 0.69 · red module genes, blue module genes, GO term, WGCNA, upregulated, enrichment
  10. [10] § Methods › Human-specific differentially expressed gene (HS DEG) analysis ↔ 05_DGE_analysis/01_primates_pseudobulk_DESeq2.R, lines 134–176 · score 0.67 · humanized age, DESeq2, covariates, pseudobulk, sex, log10
  11. [11] § Methods › Single-nucleus RNA sequencing, cell type annotation, and cellular compositional abundance analysis ↔ 05_DGE_analysis/00_prep_pseudobulk_counts.R, lines 94–137 · score 0.65 · FindIntegrationAnchors, SelectIntegrationFeatures, orthologous genes, Seurat, tool, NCBI
  12. [12] § Methods › Single-nucleus RNA sequencing dataset alignment and quality control ↔ 01_Generate_NHP_gtfs/MKREF_LIFTOFF_CHIMP.sh, lines 1–39 · score 0.63 · panTro5, mkref, GTF, liftoff, hg38, genomes
  13. [13] § Methods › Differentially expressed gene (DEG) and correlation analysis ↔ 03_SPNs/03_eSPN_D1D2_hybrid_correlation.R, lines 124–186 · score 0.63 · D1 D2 hybrid, gene expression, heatmap, correlation, SPN, macaque
  14. [14] § Methods › Differentially expressed gene (DEG) and correlation analysis ↔ 03_SPNs/03_eSPN_D1D2_hybrid_correlation.R, lines 124–180 · score 0.63 · D1 D2 hybrid, gene expression, heatmap, correlation, SPN, macaque
  15. [15] § Methods › Single-nucleus RNA sequencing, cell type annotation, and cellular compositional abundance analysis ↔ 03_SPNs/01_INTEGRATION_AND_CLUSTERING.R, lines 210–253 · score 0.61 · FindIntegrationAnchors, SelectIntegrationFeatures, SRR13808461, SRR13808459, NCBI, orthologous
  16. [16] § Results › Identification of interneurons found primarily in the bat ↔ 04_Interneurons/01_Integration&Clustering.R, lines 1076–1143 · score 0.61 · PDGFD PTHLH PVALB, FOXP2 EYA2, CCK VIP, FOXP2 TSHZ2, cluster, SST
  17. [17] § Results › Identification of striatal cell populations of each species ↔ 05_DGE_analysis/00_prep_pseudobulk_counts.R, lines 436–482 · score 0.59 · PPP1R1B, CSF1R, ARHGAP15, PDGFRA, AQP4, PENK
  18. [18] § Results › Identification of interneurons found primarily in the bat ↔ 04_Interneurons/04_Correlation_withinBatPutamen.R, lines 42–104 · score 0.57 · correlation matrix, FOXP2 EYA2, FOXP2 TSHZ2, gene expression, LMO3, interneurons
  19. [19] § Methods › Differentially expressed gene (DEG) and correlation analysis ↔ 04_Interneurons/01_Integration&Clustering.R, lines 1800–1842 · score 0.57 · BuildClusterTree, PlotClusterTree, distances, matrix, clustering
  20. [20] § Results › Identification of interneurons found primarily in the bat ↔ 04_Interneurons/03_DEG_Analysis.R, lines 311–350 · score 0.55 · GO term enrichment, upregulated genes, FOXP2 TSHZ2, enriched, interneurons, bat
  21. [21] § Results › Non-primates have lower eSPN to SPN proportions ↔ 03_SPNs/02_eSPN_markers.R, lines 395–444 · score 0.55 · RUNX1T1, DCLK1, eSPN, TSHZ1, CASZ1, FOXP2
  22. [22] § Methods › Differentially expressed gene (DEG) and correlation analysis ↔ 05_DGE_analysis/02_DEG_figures.R, lines 317–360 · score 0.54 · log2 fold change, downregulated, upregulated, DEGs, putamen, genes
  23. [23] § Methods › Differentially expressed gene (DEG) and correlation analysis ↔ 05_DGE_analysis/01_primates_pseudobulk_DESeq2.R, lines 134–176 · score 0.52 · log2 fold change, volcano, DEGs, sum, genes

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 · 1,667 lines · 69 KB · MIT · 3 matches

  1. # load packages
  2. library(patchwork)
  3. library(Seurat)
  4. library(rhdf5)
  5. library(DropletUtils)
  6. library(DropletQC)
  7. library(dplyr)
  8. library(Matrix)
  9. library(ggplot2)
  10. library(plyr)
  11. library(tidyverse)
  12. library(tidyr)
  13. library(ggpubr)
  14. library(reshape2)
  15. library(rio)
  16. library(data.table)
  17. library(harmony)
  18. library(ggrepel)
  19. library(edgeR)
  20. library(variancePartition)
  21. library(Matrix.utils)
  22. library(SingleCellExperiment)
  23. library(RColorBrewer)
  24. set.seed(1234)
  25. source("/project/Neuroinformatics_Core/Konopka_lab/s422071/SCRIPTS_pr/SCRIPTS/utility_functions.R")
  26. library(curl)
  27. #conda install bioconda::r-wgcna
  28. #BiocManager::install('WGCNA')
  29. library(WGCNA)
  30. library(flashClust)
  31. #remotes::install_url("https://cran.r-project.org/src/contrib/Archive/matrixStats/matrixStats_1.1.0.tar.gz")
  32. library(matrixStats)
  33. library(RColorBrewer)
  34. ####
  35. ## PREPARE DATASETS
  36. ####
  37. # read the data
  38. human_str <- readRDS(paste0(file_dir,"human_integrated_caudate_putamen_ANNOTATED.RDS"))
  39. chimp_str = readRDS(paste0(file_dir,"chimp_integrated_caudate_putamen_ANNOTATED.RDS"))
  40. macaque_str = readRDS(paste0(file_dir,"macaque_integrated_caudate_putamen_ANNOTATED.RDS"))
  41. marmoset_str = readRDS(paste0(file_dir,"marmoset_integrated_caudate_putamen_ANNOTATED.RDS"))
  42. mouse_str = readRDS(paste0(file_dir,"Mouse_Caudate_Annotated_FINAL.RDS"))
  43. mouse_str$Tissue = rep("Caudoputamen", nrow(mouse_str[[]]))
  44. mouse_str$Species = rep("Mouse", nrow(mouse_str[[]]))
  45. mouse_str$id = paste0(mouse_str$orig.ident, mouse_str$Tissue)
  46. bat_str = readRDS(paste0(file_dir,"bat_integrated_caudate_putamen_ANNOTATED.RDS"))
  47. ferret_str = readRDS(paste0(file_dir,"Ferret_Caudate_Krienen_ANNOTATED.RDS"))
  48. ferret_str$newannot_2 = ferret_str$newannot
  49. ferret_str$newannot = ferret_str$broad_annot
  50. # Reshape and combine metadata
  51. human_meta = [email hidden]
  52. human_meta$Species = 'Human'
  53. chimp_meta = [email hidden]
  54. chimp_meta$Species = 'Chimp'
  55. macaque_meta = [email hidden]
  56. macaque_meta$Species = 'Macaque'
  57. marmoset_meta = [email hidden]
  58. marmoset_meta$Species = 'Marmoset'
  59. bat_meta = [email hidden]
  60. bat_meta$Species = 'Bat'
  61. sub_obj_new_list <- list(
  62. Human = human_str,
  63. Chimp = chimp_str,
  64. Macaque = macaque_str,
  65. Marmoset = marmoset_str,
  66. Mouse = mouse_str,
  67. Bat = bat_str,
  68. Ferret = ferret_str
  69. )
  70. saveRDS(sub_obj_new_list, file = "/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/sub_obj_new_list_11_12_2025.RDS")
  71. # make RNA as active assay
  72. a <- lapply(sub_obj_new_list, function(x) {
  73. DefaultAssay(x) <- "RNA"
  74. x@assays$SCT = NULL
  75. x[["RNA"]] <- as(object = x[["RNA"]], Class = "Assay")
  76. x
  77. })
  78. b_new = Reduce(merge, a)
  79. ### microglia cleanup
  80. seurM = subset(b_new, subset = newannot_2 == "Microglia")
  81. # Found ortholog genes from human pr coding genes and extracted the genes which are ortholog in all 7 species using ncbi datasets tool
  82. ortho_genes <- read.table("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/metadata/orthologs_in_7_species_human_pr_codingOnly_2.csv", header = TRUE)$symbol #15055 pr coding ortho genes
  83. ### subset the genes and the Microglia from each Species
  84. # subset cells and metadata
  85. # Extract the count matrix from the Seurat object (default is "RNA" assay)
  86. mat = seurM@assays$RNA$counts
  87. new_mat <- mat[rownames(mat) %in% ortho_genes,]
  88. # generate new Seurat object
  89. glia_merged <- CreateSeuratObject(count = new_mat, meta.data = seurM[[]])
  90. ####
  91. ## SET VARIABLES
  92. ####
  93. marksToPlot <- c('NRGN', 'SYT1', 'SNAP25', 'GAD1', 'GAD2', 'DRD1', 'DRD2', 'FOXP2', 'TAC1', 'PENK', 'SST', 'NPY', 'MOG', 'PLP1', 'MBP', 'MOBP', 'SLC1A2', 'SLC1A3', 'APOE', 'GPC5', 'GLI3', 'AQP4', 'CSF1R', 'ARHGAP15', 'PLDL1', 'CASZ1', 'PTPRZ1', 'PCDH15', 'SOX6', 'FYN', 'BCAS1', 'ENPP6', 'GPR17', 'FLT1', 'DUSP1', 'COBLL1', 'CFTR', 'CHAT', 'ADARB2', 'LHX6', 'MEIS2', 'TAC3', 'VIP', 'TH', 'CCK', 'TTC34', 'CROCC', 'FHAD1', 'SOX4', 'PDGFRB', 'PDGFRA', 'SATB2', 'SLC17A7', 'EYA2', 'PDGFD', 'PTHLH', 'PVALB', 'SPARCL1', 'RSPO2', 'RMST', 'LMO3', 'TSHZ2', "CALB1", "CALB2", "NOS1", "TSHZ1", "OPRM1", "CHST9","GRM8", "PPP1R1B", 'GRIK3', 'CXCL14')
  94. pref = 'Microglia_AllSpecies_AllTissues_human_pr_coding_orthologs'
  95. ####
  96. ## INTEGRATE ACROSS SPECIES
  97. ####
  98. # Split data
  99. seurM = glia_merged
  100. seurM[["RNA"]] = as(object = seurM[["RNA"]], Class = "Assay")
  101. seurM$id = paste0(seurM$orig.ident, '_', seurM$Tissue)
  102. seurML = SplitObject(seurM, split.by = "id")
  103. # normalize and identify variable features for each dataset independently
  104. seurML = lapply(X = seurML, FUN = function(x) {
  105. x = NormalizeData(x)
  106. x = FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
  107. })
  108. # select features that are repeatedly variable across datasets for integration run PCA on each
  109. # dataset using these features
  110. features = SelectIntegrationFeatures(object.list = seurML)
  111. print(paste0('Number of genes to use for integration: ', length(features)))
  112. seurML = lapply(X = seurML, FUN = function(x) {
  113. x = ScaleData(x, features = features, verbose = FALSE)
  114. x = RunPCA(x, features = features, verbose = FALSE, npcs = 30)
  115. })
  116. anchors = FindIntegrationAnchors(object.list = seurML, anchor.features = features, normalization.method = "LogNormalize", reduction = "rpca")
  117. # save memory prior integration
  118. gc()
  119. # this command creates an 'integrated' data assay
  120. options(future.globals.maxSize = 16000 * 1024^2)
  121. allseur_integrated = IntegrateData(anchorset = anchors, k.weight = 30, normalization.method = 'LogNormalize')
  122. saveRDS(allseur_integrated, '/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/Integrated_rpca_Microglia_AllSpecies_ALLTissues_human_pr_coding_orthologs.RDS')
  123. # Clustering
  124. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  125. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  126. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  127. # Basic Plots
  128. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MICROGLIA/CLUSTERING_1")
  129. pdf(paste0(pref, "_INTEGRATED_UMAP.pdf"))
  130. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  131. dev.off()
  132. DefaultAssay(allseur_integrated) <- "integrated"
  133. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  134. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  135. pdf(paste0(pref, "_INTEGRATED_CLUSTERS.pdf"))
  136. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  137. dev.off()
  138. pdf(paste0(pref, "_INTEGRATED_PRIMATE_ANNOT.pdf"))
  139. DimPlot(allseur_integrated, label = T, raster = T, group.by = 'newannot') + NoLegend()
  140. dev.off()
  141. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_INTEGRATED_STACK_SAMPLES'), wd = 20)
  142. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_INTEGRATED_STACK_SPECIES'))
  143. # Plot previously identified markers
  144. DefaultAssay(allseur_integrated) = 'RNA'
  145. allseur_integrated = NormalizeData(allseur_integrated)
  146. pdf(paste0(pref, "_INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  147. DotPlot(allseur_integrated, features = marksToPlot) +
  148. xlab('') +
  149. ylab('') +
  150. theme(axis.text.x=element_text(size=20, face = 'bold'),
  151. axis.text.y=element_text(size=20, face = 'bold'),
  152. legend.text = element_text(size=20, face = 'bold'),
  153. legend.title = element_text(size=20, face = 'bold')) +
  154. rotate_x_text(45)
  155. dev.off()
  156. pdf(paste0(pref, "_INTEGRATED_DEPTH.pdf"))
  157. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  158. rotate_x_text(90)
  159. dev.off()
  160. pdf(paste0(pref, "_INTEGRATED_NUCLEAR_FRACTION.pdf"))
  161. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  162. rotate_x_text(90) +
  163. theme(text=element_text(size=20, face = 'bold'))
  164. dev.off()
  165. saveRDS(allseur_integrated, paste0('/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MICROGLIA/CLUSTERING_1/', pref, '_integrated_CLUSTERING1.RDS'))
  166. allseur_integrated = readRDS( paste0('/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MICROGLIA/CLUSTERING_1/', pref, '_integrated_CLUSTERING1.RDS'))
  167. ################# CLUSTERING_2 ##########################
  168. ##Cluster#,CellType
  169. #12*,MOL+micro
  170. #19*,Neu+Micro
  171. #21*,Endo+micro
  172. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MICROGLIA/CLUSTERING_2/")
  173. toremove = c(12,19,21)
  174. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  175. # Clustering
  176. DefaultAssay(allseur_integrated) = 'integrated'
  177. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  178. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  179. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  180. # Basic Plots
  181. pdf(paste0(pref, "_UMAP.pdf"))
  182. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  183. dev.off()
  184. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  185. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  186. pdf(paste0(pref, "_CLUSTERS.pdf"))
  187. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  188. dev.off()
  189. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  190. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  191. # Plot previously identified markers
  192. DefaultAssay(allseur_integrated) = 'RNA'
  193. allseur_integrated = NormalizeData(allseur_integrated)
  194. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  195. DotPlot(allseur_integrated, features = marksToPlot) +
  196. xlab('') +
  197. ylab('') +
  198. theme(axis.text.x=element_text(size=20, face = 'bold'),
  199. axis.text.y=element_text(size=20, face = 'bold'),
  200. legend.text = element_text(size=20, face = 'bold'),
  201. legend.title = element_text(size=20, face = 'bold')) +
  202. rotate_x_text(45)
  203. dev.off()
  204. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  205. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  206. rotate_x_text(90)
  207. dev.off()
  208. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  209. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  210. rotate_x_text(90) +
  211. theme(text=element_text(size=20, face = 'bold'))
  212. dev.off()
  213. # save
  214. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_2.RDS"))
  215. allseur_integrated = readRDS(paste0(pref,"_integrated_CLUSTERING_2.RDS"))
  216. ##################### CLUSTERING_3 #################
  217. #14*, MOL+micro
  218. #19*, MOL+micro
  219. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MICROGLIA/CLUSTERING_3/")
  220. toremove = c(14,19)
  221. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  222. # Clustering
  223. DefaultAssay(allseur_integrated) = 'integrated'
  224. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  225. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  226. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  227. # Basic Plots
  228. pdf(paste0(pref, "_UMAP.pdf"))
  229. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  230. dev.off()
  231. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  232. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  233. pdf(paste0(pref, "_CLUSTERS.pdf"))
  234. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  235. dev.off()
  236. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  237. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  238. # Plot previously identified markers
  239. DefaultAssay(allseur_integrated) = 'RNA'
  240. allseur_integrated = NormalizeData(allseur_integrated)
  241. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  242. DotPlot(allseur_integrated, features = marksToPlot) +
  243. xlab('') +
  244. ylab('') +
  245. theme(axis.text.x=element_text(size=20, face = 'bold'),
  246. axis.text.y=element_text(size=20, face = 'bold'),
  247. legend.text = element_text(size=20, face = 'bold'),
  248. legend.title = element_text(size=20, face = 'bold')) +
  249. rotate_x_text(45)
  250. dev.off()
  251. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  252. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  253. rotate_x_text(90)
  254. dev.off()
  255. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  256. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  257. rotate_x_text(90) +
  258. theme(text=element_text(size=20, face = 'bold'))
  259. dev.off()
  260. # save
  261. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_3.RDS"))
  262. allseur_integrated = readRDS(paste0(pref,"_integrated_CLUSTERING_3.RDS"))
  263. ################### CLUSTERING_4 ###################
  264. #15*,Endo
  265. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MICROGLIA/CLUSTERING_4/")
  266. toremove = c(15)
  267. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  268. # Clustering
  269. DefaultAssay(allseur_integrated) = 'integrated'
  270. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  271. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  272. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  273. # Basic Plots
  274. pdf(paste0(pref, "_UMAP.pdf"))
  275. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  276. dev.off()
  277. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  278. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  279. pdf(paste0(pref, "_CLUSTERS.pdf"))
  280. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  281. dev.off()
  282. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  283. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  284. # Plot previously identified markers
  285. DefaultAssay(allseur_integrated) = 'RNA'
  286. allseur_integrated = NormalizeData(allseur_integrated)
  287. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  288. DotPlot(allseur_integrated, features = marksToPlot) +
  289. xlab('') +
  290. ylab('') +
  291. theme(axis.text.x=element_text(size=20, face = 'bold'),
  292. axis.text.y=element_text(size=20, face = 'bold'),
  293. legend.text = element_text(size=20, face = 'bold'),
  294. legend.title = element_text(size=20, face = 'bold')) +
  295. rotate_x_text(45)
  296. dev.off()
  297. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  298. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  299. rotate_x_text(90)
  300. dev.off()
  301. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  302. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  303. rotate_x_text(90) +
  304. theme(text=element_text(size=20, face = 'bold'))
  305. dev.off()
  306. # save
  307. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_4.RDS"))
  308. ## annotate
  309. (mapnames <-setNames(rep("Microglia", 27),c(0:26)))
  310. # Create the broadannot
  311. allseur_integrated$Micro_annot = unname(mapnames[allseur_integrated[["seurat_clusters"]][,1]]) # to extract the annotations and not the cluster #s
  312. table(allseur_integrated$Micro_annot)
  313. #Microglia
  314. # 32961
  315. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MICROGLIA/ANNOTATED")
  316. # QC PLOTS
  317. pdf(paste0(pref, "_Clusters.pdf"))
  318. DimPlot(allseur_integrated, group.by = 'Micro_annot', label = T, raster = T, label.size = 7) +
  319. NoLegend() +
  320. ggtitle('')
  321. dev.off()
  322. pdf(paste0(pref, "_Depth_Gene.pdf"))
  323. ggboxplot(allseur_integrated[[]], x = 'Micro_annot', y = 'nFeature_RNA') +
  324. rotate_x_text(90)
  325. dev.off()
  326. pdf(paste0(pref, "_Depth_UMI.pdf"))
  327. ggboxplot(allseur_integrated[[]], x = 'Micro_annot', y = 'nCount_RNA', ylim = c(0,20000)) +
  328. rotate_x_text(90) +
  329. theme(text=element_text(size=20, face = 'bold'))
  330. dev.off()
  331. pdf(paste0(pref, "_NuclearFraction.pdf"))
  332. ggboxplot(allseur_integrated[[]], x = 'Micro_annot', y = 'intronRat') +
  333. rotate_x_text(90) +
  334. theme(text=element_text(size=20, face = 'bold'))
  335. dev.off()
  336. # MARKER GENE PLOTS
  337. DefaultAssay(allseur_integrated) = 'RNA'
  338. seurM_corr = NormalizeData(allseur_integrated)
  339. pdf(paste0(pref, "_MarkersDotPlot.pdf"), width = 20, height = 10)
  340. DotPlot(allseur_integrated, group.by = "Micro_annot", features = marksToPlot) +
  341. xlab('') +
  342. ylab('') +
  343. theme(axis.text.x=element_text(size=20, face = 'bold'),
  344. axis.text.y=element_text(size=20, face = 'bold'),
  345. legend.text = element_text(size=20, face = 'bold'),
  346. legend.title = element_text(size=20, face = 'bold')) +
  347. rotate_x_text(45)
  348. dev.off()
  349. stackedbarplot(allseur_integrated[[]], groupx = 'Micro_annot', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  350. stackedbarplot(allseur_integrated[[]], groupx = 'Micro_annot', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  351. # save
  352. saveRDS(allseur_integrated, paste0(pref,"_integrated_ANNOTATED.RDS"))
  353. ## add these annotations to the original seu obj
  354. # extract the newest annotations
  355. b$detailed_annot <- as.character(b$newannot_2)
  356. # Match cell names between objects
  357. common_cells <- intersect(rownames([email hidden]), rownames([email hidden]))
  358. # Update annotations for those cells
  359. b$detailed_annot[common_cells] <- allseur_integrated$Micro_annot[common_cells]
  360. b$is_micro = ifelse(rownames([email hidden]) %in% rownames([email hidden]), "yes", "no")
  361. # Identify microglia cells in b that are not in the integrated object
  362. b_keep = subset(b, subset = newannot_2 != "Microglia" | is_micro == "yes")
  363. ############################################
  364. ####### MOL + OPC
  365. ################################################
  366. ### subset the genes and the MOL+OPC from each Species
  367. # subset cells and metadata
  368. subset_b = subset(b_keep, subset = newannot_2 %in% c("MOL", "OPC")) # already orthologs only
  369. # Extract the count matrix from the Seurat object (default is "RNA" assay)
  370. mat = subset_b@assays$RNA$counts
  371. new_mat <- mat[rownames(mat) %in% ortho_genes,]
  372. # generate new Seurat object
  373. glia_merged <- CreateSeuratObject(count = new_mat, meta.data = subset_b[[]])
  374. ####
  375. ## SET VARIABLES
  376. ####
  377. # PPP1R1B IS AN SPN MARKER!
  378. # TSHZ1 IS A PATCH MARKER
  379. marksToPlot <- c('NRGN', 'SYT1', 'SNAP25', 'GAD1', 'GAD2', 'DRD1', 'DRD2', 'FOXP2', 'TAC1', 'PENK', 'SST', 'NPY', 'MOG', 'PLP1', 'MBP', 'MOBP', 'SLC1A2', 'SLC1A3', 'AQP4', 'CSF1R', 'ARHGAP15', 'PLD1','CASZ1', 'PTPRZ1', 'PCDH15', 'SOX6', 'FYN', 'BCAS1', 'ENPP6', 'GPR17', 'FLT1', 'DUSP1', 'COBLL1', 'CFTR', 'CHAT', 'ADARB2', 'LHX6', 'MEIS2', 'TAC3', 'VIP', 'TH', 'CCK', 'TTC34', 'CROCC', 'FHAD1', 'SOX4', 'PDGFRB', 'PDGFRA', 'SATB2', 'SLC17A7', 'EYA2', 'PDGFD', 'PTHLH', 'PVALB', 'SPARCL1', 'RSPO2', 'RMST', 'LMO3', 'TSHZ2', "CALB1", "CALB2", "NOS1", "TSHZ1", "OPRM1", "CHST9","GRM8", "PPP1R1B", 'GRIK3', 'CXCL14')
  380. pref = 'MOL_OPC_AllSpecies_AllTissues_human_pr_coding_orthologs'
  381. ####
  382. ## INTEGRATE ACROSS SPECIES
  383. ####
  384. #### use old seurat version
  385. # Split data
  386. seurM = glia_merged
  387. seurM[["RNA"]] = as(object = seurM[["RNA"]], Class = "Assay")
  388. seurM$id = paste0(seurM$orig.ident, '_', seurM$Tissue)
  389. seurML = SplitObject(seurM, split.by = "id")
  390. # normalize and identify variable features for each dataset independently
  391. seurML = lapply(X = seurML, FUN = function(x) {
  392. x = NormalizeData(x)
  393. x = FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
  394. })
  395. # select features that are repeatedly variable across datasets for integration run PCA on each
  396. # dataset using these features
  397. features = SelectIntegrationFeatures(object.list = seurML)
  398. print(paste0('Number of genes to use for integration: ', length(features)))
  399. seurML = lapply(X = seurML, FUN = function(x) {
  400. x = ScaleData(x, features = features, verbose = FALSE)
  401. x = RunPCA(x, features = features, verbose = FALSE, npcs = 30)
  402. })
  403. anchors = FindIntegrationAnchors(object.list = seurML, anchor.features = features, normalization.method = "LogNormalize", reduction = "rpca")
  404. # save memory prior integration
  405. gc()
  406. # this command creates an 'integrated' data assay
  407. #(kweg = floor(min(table(seurM$orig.ident))/10)*10) #90
  408. options(future.globals.maxSize = 16000 * 1024^2)
  409. allseur_integrated = IntegrateData(anchorset = anchors, k.weight = 30, normalization.method = 'LogNormalize')
  410. saveRDS(allseur_integrated, '/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/Integrated_rpca_MOL_OPC_AllSpecies_ALLTissues_human_pr_coding_orthologs.RDS')
  411. # Clustering
  412. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  413. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  414. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  415. # Basic Plots
  416. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MOL_OPC/CLUSTERING_1")
  417. pdf(paste0(pref, "_INTEGRATED_UMAP.pdf"))
  418. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  419. dev.off()
  420. DefaultAssay(allseur_integrated) <- "integrated"
  421. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  422. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  423. pdf(paste0(pref, "_INTEGRATED_CLUSTERS.pdf"))
  424. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  425. dev.off()
  426. pdf(paste0(pref, "_INTEGRATED_PRIMATE_ANNOT.pdf"))
  427. DimPlot(allseur_integrated, label = T, raster = T, group.by = 'newannot') + NoLegend()
  428. dev.off()
  429. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_INTEGRATED_STACK_SAMPLES'), wd = 20)
  430. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_INTEGRATED_STACK_SPECIES'))
  431. # Plot previously identified markers
  432. DefaultAssay(allseur_integrated) = 'RNA'
  433. allseur_integrated = NormalizeData(allseur_integrated)
  434. pdf(paste0(pref, "_INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  435. DotPlot(allseur_integrated, features = marksToPlot) +
  436. xlab('') +
  437. ylab('') +
  438. theme(axis.text.x=element_text(size=20, face = 'bold'),
  439. axis.text.y=element_text(size=20, face = 'bold'),
  440. legend.text = element_text(size=20, face = 'bold'),
  441. legend.title = element_text(size=20, face = 'bold')) +
  442. rotate_x_text(45)
  443. dev.off()
  444. pdf(paste0(pref, "_INTEGRATED_DEPTH.pdf"))
  445. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  446. rotate_x_text(90)
  447. dev.off()
  448. pdf(paste0(pref, "_INTEGRATED_NUCLEAR_FRACTION.pdf"))
  449. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  450. rotate_x_text(90) +
  451. theme(text=element_text(size=20, face = 'bold'))
  452. dev.off()
  453. saveRDS(allseur_integrated, paste0('/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MOL_OPC/CLUSTERING_1/', pref, '_integrated_CLUSTERING1.RDS'))
  454. ################# CLUSTERING_2 ##########################
  455. ##Cluster#,CellType
  456. #17*,Neu+MOL
  457. #19*,MOL+Ast
  458. #25*,Neu+MOL
  459. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MOL_OPC/CLUSTERING_2/")
  460. toremove = c(17,19,25)
  461. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  462. # Clustering
  463. DefaultAssay(allseur_integrated) = 'integrated'
  464. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  465. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  466. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  467. # Basic Plots
  468. pdf(paste0(pref, "_UMAP.pdf"))
  469. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  470. dev.off()
  471. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  472. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  473. pdf(paste0(pref, "_CLUSTERS.pdf"))
  474. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  475. dev.off()
  476. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  477. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  478. # Plot previously identified markers
  479. DefaultAssay(allseur_integrated) = 'RNA'
  480. allseur_integrated = NormalizeData(allseur_integrated)
  481. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  482. DotPlot(allseur_integrated, features = marksToPlot) +
  483. xlab('') +
  484. ylab('') +
  485. theme(axis.text.x=element_text(size=20, face = 'bold'),
  486. axis.text.y=element_text(size=20, face = 'bold'),
  487. legend.text = element_text(size=20, face = 'bold'),
  488. legend.title = element_text(size=20, face = 'bold')) +
  489. rotate_x_text(45)
  490. dev.off()
  491. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  492. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  493. rotate_x_text(90)
  494. dev.off()
  495. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  496. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  497. rotate_x_text(90) +
  498. theme(text=element_text(size=20, face = 'bold'))
  499. dev.off()
  500. # save
  501. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_2.RDS"))
  502. allseur_integrated= readRDS(paste0(pref,"_integrated_CLUSTERING_2.RDS"))
  503. ##################### CLUSTERING_3 #################
  504. #21*, MOL+micro
  505. #24*, neu+MOL
  506. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MOL_OPC/CLUSTERING_3/")
  507. toremove = c(21,24)
  508. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  509. # Clustering
  510. DefaultAssay(allseur_integrated) = 'integrated'
  511. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  512. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  513. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  514. # Basic Plots
  515. pdf(paste0(pref, "_UMAP.pdf"))
  516. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  517. dev.off()
  518. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  519. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  520. pdf(paste0(pref, "_CLUSTERS.pdf"))
  521. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  522. dev.off()
  523. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  524. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  525. # Plot previously identified markers
  526. DefaultAssay(allseur_integrated) = 'RNA'
  527. allseur_integrated = NormalizeData(allseur_integrated)
  528. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  529. DotPlot(allseur_integrated, features = marksToPlot) +
  530. xlab('') +
  531. ylab('') +
  532. theme(axis.text.x=element_text(size=20, face = 'bold'),
  533. axis.text.y=element_text(size=20, face = 'bold'),
  534. legend.text = element_text(size=20, face = 'bold'),
  535. legend.title = element_text(size=20, face = 'bold')) +
  536. rotate_x_text(45)
  537. dev.off()
  538. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  539. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  540. rotate_x_text(90)
  541. dev.off()
  542. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  543. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  544. rotate_x_text(90) +
  545. theme(text=element_text(size=20, face = 'bold'))
  546. dev.off()
  547. # save
  548. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_3.RDS"))
  549. ############### CLUSTERING_4 #################
  550. #21*,MOL+OPC
  551. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MOL_OPC/CLUSTERING_4/")
  552. toremove = c(21)
  553. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  554. # Clustering
  555. DefaultAssay(allseur_integrated) = 'integrated'
  556. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  557. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  558. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  559. # Basic Plots
  560. pdf(paste0(pref, "_UMAP.pdf"))
  561. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  562. dev.off()
  563. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  564. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  565. pdf(paste0(pref, "_CLUSTERS.pdf"))
  566. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  567. dev.off()
  568. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  569. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  570. # Plot previously identified markers
  571. DefaultAssay(allseur_integrated) = 'RNA'
  572. allseur_integrated = NormalizeData(allseur_integrated)
  573. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  574. DotPlot(allseur_integrated, features = marksToPlot) +
  575. xlab('') +
  576. ylab('') +
  577. theme(axis.text.x=element_text(size=20, face = 'bold'),
  578. axis.text.y=element_text(size=20, face = 'bold'),
  579. legend.text = element_text(size=20, face = 'bold'),
  580. legend.title = element_text(size=20, face = 'bold')) +
  581. rotate_x_text(45)
  582. dev.off()
  583. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  584. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  585. rotate_x_text(90)
  586. dev.off()
  587. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  588. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  589. rotate_x_text(90) +
  590. theme(text=element_text(size=20, face = 'bold'))
  591. dev.off()
  592. # save
  593. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_4.RDS"))
  594. ######################### ANNOTATE #################
  595. ###Custer#,cell_type_annotation
  596. #0,MOL
  597. #1,MOL
  598. #2,MOL
  599. #3,MOL
  600. #4,MOL
  601. #5,MOL
  602. #6,MOL
  603. #7,MOL
  604. #8,MOL
  605. #9,MOL
  606. #10,OPC
  607. #11,MOL
  608. #12,MOL
  609. #13,MOL
  610. #14,OPC
  611. #15,MOL
  612. #16,MOL
  613. #17,OPC
  614. #18,OPC
  615. #19,MOL
  616. #20,MOL
  617. #21,COP
  618. #22,OPC
  619. #23,OPC
  620. ## annotate
  621. (mapnames <-setNames(c("MOL","MOL","MOL","MOL","MOL","MOL","MOL","MOL","MOL",
  622. "MOL","OPC","MOL","MOL","MOL","OPC","MOL","MOL","OPC","OPC","MOL",
  623. "MOL","COP","OPC","OPC"),c(0:23)))
  624. # Create the broadannot
  625. allseur_integrated$MOL_OPC_annot = unname(mapnames[allseur_integrated[["seurat_clusters"]][,1]]) # to extract the annotations and not the cluster #s
  626. table(allseur_integrated$MOL_OPC_annot)
  627. # COP MOL OPC
  628. # 447 263193 28394
  629. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MOL_OPC/ANNOTATED")
  630. # QC PLOTS
  631. pdf(paste0(pref, "_Clusters.pdf"))
  632. DimPlot(allseur_integrated, group.by = 'MOL_OPC_annot', label = T, raster = T, label.size = 7) +
  633. NoLegend() +
  634. ggtitle('')
  635. dev.off()
  636. pdf(paste0(pref, "_Depth_Gene.pdf"))
  637. ggboxplot(allseur_integrated[[]], x = 'MOL_OPC_annot', y = 'nFeature_RNA') +
  638. rotate_x_text(90)
  639. dev.off()
  640. pdf(paste0(pref, "_Depth_UMI.pdf"))
  641. ggboxplot(allseur_integrated[[]], x = 'MOL_OPC_annot', y = 'nCount_RNA', ylim = c(0,20000)) +
  642. rotate_x_text(90) +
  643. theme(text=element_text(size=20, face = 'bold'))
  644. dev.off()
  645. pdf(paste0(pref, "_NuclearFraction.pdf"))
  646. ggboxplot(allseur_integrated[[]], x = 'MOL_OPC_annot', y = 'intronRat') +
  647. rotate_x_text(90) +
  648. theme(text=element_text(size=20, face = 'bold'))
  649. dev.off()
  650. # MARKER GENE PLOTS
  651. DefaultAssay(allseur_integrated) = 'RNA'
  652. seurM_corr = NormalizeData(allseur_integrated)
  653. pdf(paste0(pref, "_MarkersDotPlot.pdf"), width = 20, height = 10)
  654. DotPlot(allseur_integrated, group.by = "MOL_OPC_annot", features = marksToPlot) +
  655. xlab('') +
  656. ylab('') +
  657. theme(axis.text.x=element_text(size=20, face = 'bold'),
  658. axis.text.y=element_text(size=20, face = 'bold'),
  659. legend.text = element_text(size=20, face = 'bold'),
  660. legend.title = element_text(size=20, face = 'bold')) +
  661. rotate_x_text(45)
  662. dev.off()
  663. stackedbarplot(allseur_integrated[[]], groupx = 'MOL_OPC_annot', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  664. stackedbarplot(allseur_integrated[[]], groupx = 'MOL_OPC_annot', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  665. # save
  666. saveRDS(allseur_integrated, paste0(pref,"_integrated_ANNOTATED.RDS"))
  667. ### put these annots to the original seurat obj
  668. b = readRDS("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/merged_clean_AllCellTypes_AllTissues_seu.RDS")
  669. # Match cell names between objects
  670. common_cells <- intersect(rownames([email hidden]), rownames([email hidden]))
  671. # Update annotations for those cells
  672. b$detailed_annot = b$newannot_2
  673. b$detailed_annot[common_cells] <- allseur_integrated$MOL_OPC_annot[common_cells]
  674. b$is_mol = ifelse(rownames([email hidden]) %in% common_cells, "yes", "no")
  675. # Identify cells in b that are not in the integrated object
  676. b_keep <- subset(
  677. b,
  678. subset = !(newannot_2 %in% c("MOL", "OPC", "COP")) | is_mol == "yes")
  679. )
  680. # check
  681. Idents(b_keep) = b_keep$detailed_annot
  682. DotPlot(b_keep, features = marksToPlot) + rotate_x_text(45)
  683. # save
  684. saveRDS(b_keep,"/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/merged_clean_AllCellTypes_AllTissues_seu.RDS")
  685. ############################################
  686. ####### Astrocyte
  687. ################################################
  688. ### subset the genes and the MOL+OPC from each Species
  689. # subset cells and metadata
  690. # Subset Seurat object to only include 'Microglia' cells and exclude the specified 'id' values bcs they have <10 microglial cells
  691. seurM = subset(b_keep, subset = newannot_2 %in% c("Astrocyte")) # already orthologs only
  692. # Extract the count matrix from the Seurat object (default is "RNA" assay)
  693. mat = seurM@assays$RNA$counts
  694. new_mat <- mat[rownames(mat) %in% ortho_genes,]
  695. # generate new Seurat object
  696. glia_merged <- CreateSeuratObject(count = new_mat, meta.data = subset_b[[]])
  697. ####
  698. ## SET VARIABLES
  699. ####
  700. marksToPlot <- c('NRGN', 'SYT1', 'SNAP25', 'GAD1', 'GAD2', 'DRD1', 'DRD2', 'FOXP2', 'TAC1', 'PENK', 'SST', 'NPY', 'MOG', 'PLP1', 'MBP', 'MOBP', 'SLC1A2', 'SLC1A3', 'AQP4', 'CSF1R', 'ARHGAP15', 'PLD1','CASZ1', 'PTPRZ1', 'PCDH15', 'SOX6', 'FYN', 'BCAS1', 'ENPP6', 'GPR17', 'FLT1', 'DUSP1', 'COBLL1', 'CFTR', 'CHAT', 'ADARB2', 'LHX6', 'MEIS2', 'TAC3', 'VIP', 'TH', 'CCK', 'TTC34', 'CROCC', 'FHAD1', 'SOX4', 'PDGFRB', 'PDGFRA', 'SATB2', 'SLC17A7', 'EYA2', 'PDGFD', 'PTHLH', 'PVALB', 'SPARCL1', 'RSPO2', 'RMST', 'LMO3', 'TSHZ2', "CALB1", "CALB2", "NOS1", "TSHZ1", "OPRM1", "CHST9","GRM8", "PPP1R1B", 'GRIK3', 'CXCL14')
  701. pref = 'Astrocyte_AllSpecies_AllTissues_human_pr_coding_orthologs'
  702. ####
  703. ## INTEGRATE ACROSS SPECIES
  704. ####
  705. #### use old seurat version
  706. # Split data
  707. seurM = glia_merged
  708. seurM[["RNA"]] = as(object = seurM[["RNA"]], Class = "Assay")
  709. seurM$id = paste0(seurM$orig.ident, '_', seurM$Tissue)
  710. seurML = SplitObject(seurM, split.by = "id")
  711. # normalize and identify variable features for each dataset independently
  712. seurML = lapply(X = seurML, FUN = function(x) {
  713. x = NormalizeData(x)
  714. x = FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
  715. })
  716. # select features that are repeatedly variable across datasets for integration run PCA on each
  717. # dataset using these features
  718. features = SelectIntegrationFeatures(object.list = seurML)
  719. print(paste0('Number of genes to use for integration: ', length(features)))
  720. seurML = lapply(X = seurML, FUN = function(x) {
  721. x = ScaleData(x, features = features, verbose = FALSE)
  722. x = RunPCA(x, features = features, verbose = FALSE, npcs = 30)
  723. })
  724. anchors = FindIntegrationAnchors(object.list = seurML, anchor.features = features, normalization.method = "LogNormalize", reduction = "rpca")
  725. # save memory prior integration
  726. gc()
  727. # this command creates an 'integrated' data assay
  728. #(kweg = floor(min(table(seurM$orig.ident))/10)*10) #90
  729. options(future.globals.maxSize = 16000 * 1024^2)
  730. allseur_integrated = IntegrateData(anchorset = anchors, k.weight = 30, normalization.method = 'LogNormalize')
  731. saveRDS(allseur_integrated, '/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/Integrated_rpca_Astrocyte_AllSpecies_ALLTissues_human_pr_coding_orthologs.RDS')
  732. # Clustering
  733. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  734. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  735. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  736. # Basic Plots
  737. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_ASTROCYTE/CLUSTERING_1")
  738. pdf(paste0(pref, "_INTEGRATED_UMAP.pdf"))
  739. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  740. dev.off()
  741. DefaultAssay(allseur_integrated) <- "integrated"
  742. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  743. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  744. pdf(paste0(pref, "_INTEGRATED_CLUSTERS.pdf"))
  745. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  746. dev.off()
  747. pdf(paste0(pref, "_INTEGRATED_PRIMATE_ANNOT.pdf"))
  748. DimPlot(allseur_integrated, label = T, raster = T, group.by = 'newannot') + NoLegend()
  749. dev.off()
  750. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_INTEGRATED_STACK_SAMPLES'), wd = 20)
  751. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_INTEGRATED_STACK_SPECIES'))
  752. # Plot previously identified markers
  753. DefaultAssay(allseur_integrated) = 'RNA'
  754. allseur_integrated = NormalizeData(allseur_integrated)
  755. pdf(paste0(pref, "_INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  756. DotPlot(allseur_integrated, features = marksToPlot) +
  757. xlab('') +
  758. ylab('') +
  759. theme(axis.text.x=element_text(size=20, face = 'bold'),
  760. axis.text.y=element_text(size=20, face = 'bold'),
  761. legend.text = element_text(size=20, face = 'bold'),
  762. legend.title = element_text(size=20, face = 'bold')) +
  763. rotate_x_text(45)
  764. dev.off()
  765. pdf(paste0(pref, "_INTEGRATED_DEPTH.pdf"))
  766. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  767. rotate_x_text(90)
  768. dev.off()
  769. pdf(paste0(pref, "_INTEGRATED_NUCLEAR_FRACTION.pdf"))
  770. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  771. rotate_x_text(90) +
  772. theme(text=element_text(size=20, face = 'bold'))
  773. dev.off()
  774. saveRDS(allseur_integrated, paste0('/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_MOL_OPC/CLUSTERING_1/', pref, '_integrated_CLUSTERING1.RDS'))
  775. ################# CLUSTERING_2 ##########################
  776. ##Cluster#,CellType
  777. #10*,MOL+Ast
  778. #12*,MOL+Ast
  779. #13*,Neu+Ast
  780. #15*,MOL+Ast
  781. #21*,MOL+Ast
  782. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_ASTROCYTE/CLUSTERING_2/")
  783. toremove = c(10,12,13,15,21)
  784. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  785. # Clustering
  786. DefaultAssay(allseur_integrated) = 'integrated'
  787. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  788. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  789. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  790. # Basic Plots
  791. pdf(paste0(pref, "_UMAP.pdf"))
  792. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  793. dev.off()
  794. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  795. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  796. pdf(paste0(pref, "_CLUSTERS.pdf"))
  797. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  798. dev.off()
  799. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  800. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  801. # Plot previously identified markers
  802. DefaultAssay(allseur_integrated) = 'RNA'
  803. allseur_integrated = NormalizeData(allseur_integrated)
  804. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  805. DotPlot(allseur_integrated, features = marksToPlot) +
  806. xlab('') +
  807. ylab('') +
  808. theme(axis.text.x=element_text(size=20, face = 'bold'),
  809. axis.text.y=element_text(size=20, face = 'bold'),
  810. legend.text = element_text(size=20, face = 'bold'),
  811. legend.title = element_text(size=20, face = 'bold')) +
  812. rotate_x_text(45)
  813. dev.off()
  814. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  815. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  816. rotate_x_text(90)
  817. dev.off()
  818. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  819. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  820. rotate_x_text(90) +
  821. theme(text=element_text(size=20, face = 'bold'))
  822. dev.off()
  823. # save
  824. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_2.RDS"))
  825. ################# CLUSTERING_2 ##########################
  826. ##Cluster#,CellType
  827. #14*,Neu+Ast
  828. #15*,MOL+Ast
  829. #17*,Endo+Ast
  830. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_ASTROCYTE/CLUSTERING_3/")
  831. toremove = c(14,15,17)
  832. allseur_integrated = subset(allseur_integrated, subset = seurat_clusters %in% toremove, invert = T)
  833. # Clustering
  834. DefaultAssay(allseur_integrated) = 'integrated'
  835. allseur_integrated = ScaleData(allseur_integrated, verbose = FALSE)
  836. allseur_integrated = RunPCA(allseur_integrated, verbose = FALSE)
  837. allseur_integrated = RunUMAP(allseur_integrated, dims = 1:20, reduction = 'pca')
  838. # Basic Plots
  839. pdf(paste0(pref, "_UMAP.pdf"))
  840. DimPlot(allseur_integrated, group.by = 'Species', raster = T)
  841. dev.off()
  842. allseur_integrated = FindNeighbors(allseur_integrated, dims = 1:20, reduction = 'pca')
  843. allseur_integrated = FindClusters(allseur_integrated, resolution = 1)
  844. pdf(paste0(pref, "_CLUSTERS.pdf"))
  845. DimPlot(allseur_integrated, label = T, raster = T) + NoLegend()
  846. dev.off()
  847. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  848. stackedbarplot(allseur_integrated[[]], groupx = 'seurat_clusters', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  849. # Plot previously identified markers
  850. DefaultAssay(allseur_integrated) = 'RNA'
  851. allseur_integrated = NormalizeData(allseur_integrated)
  852. pdf(paste0(pref, "INTEGRATED_DOTPLOT.pdf"), width = 20, height = 10)
  853. DotPlot(allseur_integrated, features = marksToPlot) +
  854. xlab('') +
  855. ylab('') +
  856. theme(axis.text.x=element_text(size=20, face = 'bold'),
  857. axis.text.y=element_text(size=20, face = 'bold'),
  858. legend.text = element_text(size=20, face = 'bold'),
  859. legend.title = element_text(size=20, face = 'bold')) +
  860. rotate_x_text(45)
  861. dev.off()
  862. pdf(paste0(pref, "INTEGRATED_DEPTH.pdf"))
  863. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'nFeature_RNA', color = 'black') + NoLegend() +
  864. rotate_x_text(90)
  865. dev.off()
  866. pdf(paste0(pref, "INTEGRATED_NUCLEAR_FRACTION.pdf"))
  867. ggboxplot(allseur_integrated[[]], x = 'seurat_clusters', y = 'intronRat') +
  868. rotate_x_text(90) +
  869. theme(text=element_text(size=20, face = 'bold'))
  870. dev.off()
  871. # save
  872. saveRDS(allseur_integrated, paste0(pref,"_integrated_CLUSTERING_3.RDS"))
  873. ############ ANNOTATE #############
  874. (mapnames <-setNames(rep("Astrocyte", 22),c(0:21)))
  875. # Create the broadannot
  876. allseur_integrated$Ast_annot = unname(mapnames[allseur_integrated[["seurat_clusters"]][,1]]) # to extract the annotations and not the cluster #s
  877. table(allseur_integrated$Ast_annot)
  878. #Astrocyte
  879. # 64660
  880. setwd("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/01_ASTROCYTE/ANNOTATED")
  881. # QC PLOTS
  882. pdf(paste0(pref, "_Clusters.pdf"))
  883. DimPlot(allseur_integrated, group.by = 'Ast_annot', label = T, raster = T, label.size = 7) +
  884. NoLegend() +
  885. ggtitle('')
  886. dev.off()
  887. pdf(paste0(pref, "_Depth_Gene.pdf"))
  888. ggboxplot(allseur_integrated[[]], x = 'Ast_annot', y = 'nFeature_RNA') +
  889. rotate_x_text(90)
  890. dev.off()
  891. pdf(paste0(pref, "_Depth_UMI.pdf"))
  892. ggboxplot(allseur_integrated[[]], x = 'Ast_annot', y = 'nCount_RNA', ylim = c(0,20000)) +
  893. rotate_x_text(90) +
  894. theme(text=element_text(size=20, face = 'bold'))
  895. dev.off()
  896. pdf(paste0(pref, "_NuclearFraction.pdf"))
  897. ggboxplot(allseur_integrated[[]], x = 'Ast_annot', y = 'intronRat') +
  898. rotate_x_text(90) +
  899. theme(text=element_text(size=20, face = 'bold'))
  900. dev.off()
  901. # MARKER GENE PLOTS
  902. DefaultAssay(allseur_integrated) = 'RNA'
  903. seurM_corr = NormalizeData(allseur_integrated)
  904. pdf(paste0(pref, "_MarkersDotPlot.pdf"), width = 20, height = 10)
  905. DotPlot(allseur_integrated, group.by = "Ast_annot", features = marksToPlot) +
  906. xlab('') +
  907. ylab('') +
  908. theme(axis.text.x=element_text(size=20, face = 'bold'),
  909. axis.text.y=element_text(size=20, face = 'bold'),
  910. legend.text = element_text(size=20, face = 'bold'),
  911. legend.title = element_text(size=20, face = 'bold')) +
  912. rotate_x_text(45)
  913. dev.off()
  914. stackedbarplot(allseur_integrated[[]], groupx = 'Ast_annot', groupfill = 'orig.ident', paste0(pref, '_STACK_SAMPLES'), wd = 20)
  915. stackedbarplot(allseur_integrated[[]], groupx = 'Ast_annot', groupfill = 'Species', paste0(pref, '_STACK_SPECIES'))
  916. # save
  917. saveRDS(allseur_integrated, paste0(pref,"_integrated_ANNOTATED.RDS"))
  918. ## add these annotations to the original seu obj
  919. # extract the newest annotations
  920. # Match cell names between objects
  921. b_keep$is_ast = ifelse(rownames([email hidden]) %in% rownames([email hidden]), "yes", "no")
  922. # Identify cells in b that are not in the integrated object
  923. b_keep_2 = subset(b_keep, subset = newannot_2 != "Astrocyte" | is_ast == "yes")
  924. # check
  925. Idents(b_keep_2) = b_keep_2$detailed_annot
  926. DotPlot(b_keep_2, features = marksToPlot) + rotate_x_text(45)
  927. # save
  928. saveRDS(b_keep_2,"/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/merged_clean_AllCellTypes_AllTissues_seu.RDS")
  929. ####################### POST GLIA CLEANUP ###########################
  930. file_outdir = "/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/"
  931. species_list <- c("human", "chimp", "macaque", "marmoset", "mouse", "bat", "ferret")
  932. primates_list <- c("human", "chimp", "macaque", "marmoset")
  933. #### new obj AFTER GLIA CLEANUP
  934. b = readRDS("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/merged_clean_AllCellTypes_AllTissues_seu.RDS")
  935. b$CellType = b$detailed_annot
  936. b$CellType = gsub("COP", "OPC", b$CellType)
  937. # put the interneuron subtype annotations to this seu obj
  938. interneurons_seu = readRDS("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/Interneurons_AllSpecies_AllTissues_ANNOTATED.RDS")
  939. ## add these annotations to the original seu obj
  940. # extract the newest annotations
  941. # Match cell names between objects
  942. b$is_interneu = ifelse(rownames([email hidden]) %in% rownames([email hidden]), "yes", "no")
  943. # Identify cells in b that are not in the integrated object
  944. b_keep = subset(b, subset = detailed_annot != "Non_SPN" | is_interneu == "yes")
  945. # order the rownames of smaller seu obj according to the bigger one
  946. ordered_meta_interneurons_seu = [email hidden][match(rownames([email hidden]), rownames([email hidden])),]
  947. b_keep$is_interneu = ordered_meta_interneurons_seu$newannot
  948. b_keep$a = ifelse(is.na(b_keep$is_interneu), as.character(b_keep$detailed_annot), as.character(b_keep$is_interneu))
  949. # check
  950. table(b_keep$detailed_annot, b_keep$a)
  951. # re-assign
  952. b_keep$broadannot_2 = b_keep$detailed_annot
  953. b_keep$detailed_annot = b_keep$a
  954. # orgnize metadata
  955. b_keep$is_micro = NULL
  956. b_keep$is_mol = NULL
  957. b_keep$keep_cell = NULL
  958. b_keep$is_ast = NULL
  959. b_keep$is_interneu = NULL
  960. b_keep$a = NULL
  961. b_keep$broad_annot = NULL
  962. b_keep$tissue = NULL
  963. b_keep$id = paste0(b_keep$orig.ident, "_", b_keep$Tissue)
  964. ### remove human caudate sample
  965. b_keep_2 = subset(b_keep, subset = id %in% "Sample_242999_Caudate", invert = T)
  966. #### find the sex and age for all
  967. orig_meta <- [email hidden] # safe copy
  968. ### add info to the metadata
  969. a = orig_meta
  970. a[grep("v324", a$orig.ident),]$Sex = "Male"
  971. a[grep("v321", a$orig.ident),]$Sex = "Female"
  972. a$Sex = sub("female", "Female", a$Sex)
  973. a$Sex = sub("male", "Male", a$Sex)
  974. a[grep("Bat", a$Species),]$Sex = "Male"
  975. a[grep("Bat", a$Species),]$Age = "3y"
  976. a[grep("marm027", a$orig.ident),]$Sex = "Male"
  977. a[grep("marm028", a$orig.ident),]$Sex = "Female"
  978. a[grep("marm029", a$orig.ident),]$Sex = "Male"
  979. a[grep("marm027", a$orig.ident),]$Age = "2y4m"
  980. a[grep("marm028", a$orig.ident),]$Age = "3y2m"
  981. a[grep("marm029", a$orig.ident),]$Age = "2y6m"
  982. a[grep("v324", a$orig.ident),]$Age = "2035d"
  983. a[grep("v321", a$orig.ident),]$Age = "2051d"
  984. #a[grep("SRR13808459", a$orig.ident),]$Sex = "Female"
  985. a[grep("SRR13808462", a$orig.ident),]$Sex = "Female"
  986. a[grep("SRR13808463", a$orig.ident),]$Sex = "Female"
  987. #a[grep("SRR13808466", a$orig.ident),]$Sex = "Female"
  988. #a[grep("SRR13808467", a$orig.ident),]$Sex = "Female"
  989. a[grep("SRR11921037", a$orig.ident),]$Sex = "Female"
  990. a[grep("SRR11921038", a$orig.ident),]$Sex = "Female"
  991. a[grep("SRR11921037", a$orig.ident),]$Age = "42d"
  992. a[grep("SRR11921038", a$orig.ident),]$Age = "42d"
  993. patterns <- c(paste0("SRR1192100", 5:9), paste0("SRR119210", 10:12))
  994. pattern_all <- paste(patterns, collapse = "|")
  995. idx <- grep(pattern_all, a$orig.ident)
  996. a[idx, ]$Age <- "70d"
  997. a[idx, ]$Sex = "Male"
  998. a$sex = NULL
  999. a$age = NULL
  1000. a$cellbarc = str_split_i(rownames(a), "-", 1)
  1001. a$cellID = paste0(a$cellbarc, "_", a$id)
  1002. a$Sex = sub("FeMale", "Female", a$Sex)
  1003. ### add humanized ages
  1004. # read species traits taken from https://genomics.senescence.info/species/entry.php?species=Mus_musculus, https://genomics.senescence.info/species/entry.php?species=Mustela_nigripes, https://genomics.senescence.info/species/entry.php?species=Phyllostomus_hastatus, https://animaldiversity.org/accounts/Phyllostomus_hastatus/, https://genomics.senescence.info/species/entry.php?species=Phyllostomus_discolor
  1005. outdir = "/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/revision/"
  1006. species_traits = read.csv(paste0(outdir, "primate_lifeTraits.csv"))
  1007. sample_metadata = read.csv(paste0(outdir, "comparative_striatum_sample_metadata.csv"), sep = "\t")
  1008. sample_metadata$id = as.character(paste0(sample_metadata$Barcode.ID, "_", sample_metadata$Brain.Area))
  1009. a$id = as.character(a$id)
  1010. # add the ages in years to the single cell-level metadata
  1011. meta_df <- merge(a, sample_metadata, by = "id", all.x = TRUE)
  1012. meta_df$Age <- meta_df$Age.x
  1013. meta_df$Sex <- meta_df$Sex.x
  1014. meta_df$Species <- meta_df$Species.x
  1015. meta_df <- meta_df[, !grepl("\\.x$|\\.y$", names(meta_df))]
  1016. meta_df$Brain.Area = NULL
  1017. # Add orig.ident only if rownames are not already "cellbarc-orig.ident"
  1018. rownames(meta_df) <- ifelse(
  1019. grepl("[-_]", meta_df$cellbarc), # check for presence of "-" or "_"
  1020. meta_df$cellbarc, # if present, keep as is
  1021. paste0(meta_df$cellbarc, "-", meta_df$orig.ident) # else, append orig.ident
  1022. )
  1023. # restore original cell order (this prevents scrambling)
  1024. meta_df <- meta_df[rownames(a), ]
  1025. # Check if same set but different order
  1026. setequal(rownames(meta_df), rownames(a))
  1027. humanize_all_ages <- function(meta_df, species_traits) {
  1028. # Initialize vector for humanized ages (same length and order)
  1029. humanized_ages <- numeric(nrow(meta_df))
  1030. # Get unique species in the metadata
  1031. species_list <- unique(meta_df$Species)
  1032. for (species in species_list) {
  1033. # Convert ages to numerical
  1034. species_ages <- meta_df$Age_in_years[meta_df$Species == species]
  1035. species_ages_num <- as.numeric(species_ages)
  1036. if (species %in% c("Human")) {
  1037. # For humans, humanized age = original age
  1038. humanized_ages[meta_df$Species == species] <- species_ages_num
  1039. } else {
  1040. # Check if species exists in lifetraits
  1041. if (species %in% colnames(species_traits)) {
  1042. # Build linear model: species ~ Human (lifetraits)
  1043. model <- lm(species_traits[[species]] ~ species_traits$Human)
  1044. # Calculate humanized ages using the model coefficients
  1045. humanized <- (species_ages_num - model$coefficients[1]) / model$coefficients[2]
  1046. # Assign back to correct rows in humanized_ages vector
  1047. humanized_ages[meta_df$Species == species] <- humanized
  1048. } else {
  1049. warning(paste("Species", species, "not found in lifetraits. Assigning NA"))
  1050. humanized_ages[meta_df$Species == species] <- NA
  1051. }
  1052. }
  1053. }
  1054. return(humanized_ages)
  1055. }
  1056. meta_df$Humanized_age = humanize_all_ages(meta_df, species_traits)
  1057. # update the metadata of the seu obj
  1058. # Join by cell ID (ensure cell names match exactly)
  1059. [email hidden] = meta_df
  1060. # check
  1061. marksToPlot <- c('NRGN', 'SYT1', 'SNAP25', 'GAD1', 'GAD2', 'DRD1', 'DRD2', 'FOXP2', 'TAC1', 'PENK', 'SST', 'NPY', 'MOG', 'PLP1', 'MBP', 'MOBP', 'SLC1A2', 'SLC1A3', 'APOE', 'GPC5', 'GLI3', 'AQP4', 'CSF1R', 'ARHGAP15', 'PLDL1', 'CASZ1', 'PTPRZ1', 'PCDH15', 'SOX6', 'FYN', 'BCAS1', 'ENPP6', 'GPR17', 'FLT1', 'DUSP1', 'COBLL1', 'CFTR', 'CHAT', 'ADARB2', 'LHX6', 'MEIS2', 'TAC3', 'VIP', 'TH', 'CCK', 'TTC34', 'CROCC', 'FHAD1', 'SOX4', 'PDGFRB', 'PDGFRA', 'SATB2', 'SLC17A7', 'EYA2', 'PDGFD', 'PTHLH', 'PVALB', 'SPARCL1', 'RSPO2', 'RMST', 'LMO3', 'TSHZ2', "CALB1", "CALB2", "NOS1", "TSHZ1", "OPRM1", "CHST9","GRM8", "PPP1R1B", 'GRIK3', 'CXCL14')
  1062. # Plot previously identified markers
  1063. DefaultAssay(b_keep_2) = 'RNA'
  1064. b_keep_2 = NormalizeData(b_keep_2)
  1065. pdf(paste0("merged_clean_AllCellTypes_AllTissues_seu_detailedAnnot_DOTPLOT.pdf"), width = 20, height = 10)
  1066. DotPlot(b_keep_2, features = marksToPlot, group.by = "detailed_annot") +
  1067. xlab('') +
  1068. ylab('') +
  1069. theme(axis.text.x=element_text(size=20, face = 'bold'),
  1070. axis.text.y=element_text(size=20, face = 'bold'),
  1071. legend.text = element_text(size=20, face = 'bold'),
  1072. legend.title = element_text(size=20, face = 'bold')) +
  1073. rotate_x_text(45)
  1074. dev.off()
  1075. # save
  1076. saveRDS(b_keep_2,"/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/merged_clean_AllCellTypes_AllTissues_seu.RDS")
  1077. ##### generate pseudobulk counts
  1078. file_outdir = "/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/"
  1079. species_list <- c("human", "chimp", "macaque", "marmoset", "mouse", "bat", "ferret")
  1080. primates_list <- c("human", "chimp", "macaque", "marmoset")
  1081. #### new obj AFTER GLIA CLEANUP
  1082. b = readRDS("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/merged_clean_AllCellTypes_AllTissues_seu.RDS")
  1083. sub_obj_new_list = SplitObject(b, split.by = "Species")
  1084. names(sub_obj_new_list) = tolower(names(sub_obj_new_list))
  1085. meta_df = [email hidden]
  1086. ### run function to generate pseudobulk count matrices for each species and celltype. Keep cellTypes which are present in at least 3 of the samples for a given Species-Tissue as well as genes with at least 1 copy of at least 3 of the samples for a given Species-Tissue. Generate the pseudobulk count matrix for all species-cellTypes except ferret which has only 2 samples using utilities function: pseudobulk_species = function(seurObj, ctype, features = c())
  1087. pseudobulk_species
  1088. function(seurObj, ctype, n_copy, sample_number){
  1089. require(plyr)
  1090. require(dplyr)
  1091. require(tidyverse)
  1092. require(tidyr)
  1093. require(Seurat)
  1094. require(ggpubr)
  1095. require(reshape2)
  1096. require(data.table)
  1097. require(rio)
  1098. require(scran)
  1099. require(scater)
  1100. require(SingleCellExperiment)
  1101. require(edgeR)
  1102. require(DESeq2)
  1103. if(!('Sample' %in% colnames(seurObj[[]]))){stop('Please put your donors into Sample column')}
  1104. if(!('CellType' %in% colnames(seurObj[[]]))){stop('Please put your cell types into CellType column')}
  1105. # Load RNA
  1106. meta = [email hidden]
  1107. metakeep = c('CellType', 'Sample', 'Species')
  1108. meta = meta[,metakeep]
  1109. # Subset the given cell type
  1110. subSeur = subset(seurObj, subset = CellType %in% ctype)
  1111. # Create SCE assay
  1112. DefaultAssay(subSeur) = 'RNA'
  1113. subSCE = as.SingleCellExperiment(subSeur)
  1114. # Pseudobulk SCE assay
  1115. subGroups = colData(subSCE)[, c("Species", "Sample", "CellType")]
  1116. subPseudoSCE = sumCountsAcrossCells(subSCE, subGroups)
  1117. subGroups = colData(subPseudoSCE)[, c("Species", "Sample", "CellType")]
  1118. subGroups$Sample = factor(subGroups$Sample)
  1119. subAggMat = subPseudoSCE@assays@data$sum
  1120. colnames(subAggMat) = subGroups$Sample
  1121. # binarize the matrix
  1122. binary_subAggMat = as.matrix((subAggMat >= n_copy) + 0) # genes with at least "n_copy" copy(ies) will be 1
  1123. exp_list = list()
  1124. # Keep genes expressed in at least "sample_number" samples of any Tissue
  1125. for(tissue in unique(subSeur$Tissue)){
  1126. tissue_columns = grepl(tissue, colnames(binary_subAggMat), ignore.case = TRUE)
  1127. exp_list[[tissue]] = which(rowSums(binary_subAggMat[, tissue_columns]) >= sample_number) %>% names
  1128. }
  1129. expgns = Reduce(intersect, exp_list)
  1130. cat("Length of genes", unique(subSeur$Species), ctype, "=", length(expgns), "\n")
  1131. subAggMat = subAggMat[expgns,]
  1132. return(subAggMat)
  1133. }
  1134. pb_count_list = list()
  1135. for (sp in species_list) {
  1136. sub_obj_new = sub_obj_new_list[[sp]]
  1137. celltypes = unique(sub_obj_new$CellType)
  1138. for (ctype in celltypes) {
  1139. if (sp != "ferret") {
  1140. pb_count_list[[sp]][[ctype]] <- pseudobulk_species(
  1141. seurObj = sub_obj_new,
  1142. ctype = ctype,
  1143. n_copy = 1,
  1144. sample_number = 3
  1145. )
  1146. } else {
  1147. pb_count_list[["ferret"]][[ctype]] <- NULL
  1148. }
  1149. }
  1150. }
  1151. #save
  1152. saveRDS(pb_count_list, file = "/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/pseudobulk_count_matrices_AllSpecies_AllCellTypes_broadannot_PostgliaCleanup.RDS")
  1153. ### Genes were filtered to prep the pseudobulk counts (> 1 copy in >= 3 samples of that Species-Tissue) To continue with downstream analysis, get only the common genes across primates
  1154. common_genes_per_celltype = list()
  1155. primate_pb_count_list = pb_count_list[primates_list]
  1156. for (ctype in names(primate_pb_count_list$human)) {
  1157. # Extract the gene vectors for this cell type across all species
  1158. genes_across_species <- lapply(primate_pb_count_list, function(species_count) {
  1159. rownames(species_count[[ctype]])
  1160. })
  1161. # Remove any NULLs (if some species lack this cell type)
  1162. genes_across_species <- genes_across_species[!sapply(genes_across_species, is.null)]
  1163. # Take intersection across species
  1164. common_genes_per_celltype[[ctype]] <- Reduce(intersect, genes_across_species)
  1165. }
  1166. # Inspect results
  1167. str(common_genes_per_celltype)
  1168. # save
  1169. saveRDS(common_genes_per_celltype, file = "/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/pseudobulk_common_genes_withinPrimates_per_celltype_broadannot_postgliaCleanup.RDS")
  1170. common_genes_per_celltype = readRDS("/project/Neuroinformatics_Core/Konopka_lab/s422071/workdir_pr/s422071/projects/comparative_striatum/seu_objs/pseudobulk_common_genes_withinPrimates_per_celltype_broadannot_postgliaCleanup.RDS")
  1171. ##### subset each count matrix with these genes
  1172. sub_seu_pb_count_list = list()
  1173. pb_meta_list = list()
  1174. meta_df_list = list()
  1175. ## Generate singleCellExperiment object
  1176. for (sp in primates_list){
  1177. for (t in unique(sub_obj_new_list[[sp]]$Tissue)){
  1178. # change COP to OPC
  1179. sub_obj_new_list[[sp]]$CellType <- gsub("COP", "OPC", sub_obj_new_list[[sp]]$CellType)
  1180. for (ctype in unique(sub_obj_new_list[[sp]]$CellType)){
  1181. # get the seu obj
  1182. seu = sub_obj_new_list[[sp]]
  1183. # subset for the given cell type and tissue
  1184. sub_seu = subset(seu, subset = CellType %in% ctype & Tissue %in% t)
  1185. # subset pseudobulk count mat with common genes
  1186. sub_seu_pb_count = primate_pb_count_list[[sp]][[ctype]][, grepl(t, colnames(primate_pb_count_list[[sp]][[ctype]]))]
  1187. # subset the pseudocount matrix with common genes for each celltype
  1188. sub_seu_pb_count_list[[t]][[ctype]][[sp]] = sub_seu_pb_count[common_genes_per_celltype[[ctype]],]
  1189. # generate pseudobulk metadata
  1190. sub_seu_meta <- [email hidden] %>%
  1191. as.data.frame() %>%
  1192. dplyr::select(Species, Sample, Tissue, Sex, Age, Age_in_years, Humanized_age, CellType, id, nCount_RNA)
  1193. ## calculate the sum of the total UMI at the log scale for each sample
  1194. tibble_meta <- as_tibble(sub_seu_meta) %>%
  1195. dplyr::group_by(Sample) %>%
  1196. dplyr::summarise(
  1197. log10_sum_ncount_RNA = log10(sum(nCount_RNA, na.rm = TRUE)),
  1198. n = dplyr::n(),
  1199. .groups = "drop"
  1200. )
  1201. tibble_meta = as.data.frame(tibble_meta)
  1202. # aggregate based on sample
  1203. a <- sub_seu_meta %>% distinct(Sample, .keep_all = TRUE)
  1204. rownames(a) = a$Sample
  1205. # merge two dataframes
  1206. meta_df_sample = merge(a,tibble_meta ,by = "Sample", all.x = TRUE)
  1207. rownames(meta_df_sample) = meta_df_sample$Sample
  1208. # Check matching of matrix columns and metadata rows
  1209. all(colnames(sub_seu_pb_count) == rownames(meta_df_sample))
  1210. # if it says FALSE due to order not being the same. Order:
  1211. # order the metadata rownames based on the col names of the count matrix
  1212. #rownames(meta_df_sample) <- rownames(meta_df_sample)[order(match(rownames(meta_df_sample), colnames(sub_seu_pb_count)))]
  1213. # Check matching of matrix columns and metadata rows
  1214. #all(colnames(sub_seu_pb_count) == rownames(meta_df_sample))
  1215. # save in a list
  1216. pb_meta_list[[t]][[ctype]][[sp]] = meta_df_sample
  1217. meta_df_list[[t]][[ctype]][[sp]] = [email hidden]
  1218. #rownames(meta_df_list[[t]][[ctype]][[sp]]) <- meta_df_list[[t]][[ctype]][[sp]]$Sample
  1219. # get sub_seu_pb_count_list for the next step
  1220. }}}
  1221. saveRDS(pb_meta_list, file = paste0(file_outdir,"primates_pb_meta_list_PostgliaCleanup.RDS"))
  1222. saveRDS(meta_df_list, file = paste0(file_outdir,"primates_meta_df_list_PostgliaCleanup.RDS"))
  1223. saveRDS(sub_seu_pb_count_list, file = paste0(file_outdir,"primates_sub_seu_pb_count_list_PostgliaCleanup.RDS"))
  1224. ### generate a list of metadata and pseudobulk counts for the same tissue and celltype
  1225. merged_pb_meta <- list()
  1226. merged_sub_seu_pb_count <- list()
  1227. merged_meta_df <- list()
  1228. for (t in names(pb_meta_list)){
  1229. for (ctype in names(pb_meta_list[[t]])){
  1230. # Combine all species' metadata rows
  1231. merged_pb_meta[[t]][[ctype]] <- do.call(rbind, pb_meta_list[[t]][[ctype]])
  1232. merged_sub_seu_pb_count[[t]][[ctype]] <- do.call(cbind, sub_seu_pb_count_list[[t]][[ctype]])
  1233. merged_meta_df[[t]][[ctype]] <- do.call(rbind, meta_df_list[[t]][[ctype]])
  1234. }}
  1235. # save
  1236. saveRDS(merged_pb_meta, file = paste0(file_outdir,"primates_merged_pb_meta_PostgliaCleanup.RDS"))
  1237. saveRDS(merged_sub_seu_pb_count, file = paste0(file_outdir,"primates_merged_sub_seu_pb_count_PostgliaCleanup.RDS"))
  1238. saveRDS(merged_meta_df, file = paste0(file_outdir,"primates_merged_meta_df_PostgliaCleanup.RDS"))
  1239. ############################################################
  1240. sessionInfo()
  1241. R version 4.2.3 (2023-03-15)
  1242. Platform: x86_64-conda-linux-gnu (64-bit)
  1243. Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)
  1244. Matrix products: default
  1245. BLAS/LAPACK: /cm/shared/apps/rstudio-desktop/2022.12.0/lib/libopenblasp-r0.3.21.so
  1246. locale:
  1247. [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
  1248. [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
  1249. [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
  1250. [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
  1251. [9] LC_ADDRESS=C LC_TELEPHONE=C
  1252. [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
  1253. attached base packages:
  1254. [1] stats4 stats graphics grDevices utils datasets methods
  1255. [8] base
  1256. other attached packages:
  1257. [1] fastDummies_1.7.3 flashClust_1.01-2
  1258. [3] WGCNA_1.73 fastcluster_1.3.0
  1259. [5] dynamicTreeCut_1.63-1 curl_5.2.2
  1260. [7] Matrix.utils_0.9.8 variancePartition_1.28.9
  1261. [9] BiocParallel_1.32.5 edgeR_3.40.2
  1262. [11] limma_3.54.0 ggrepel_0.9.3
  1263. [13] DESeq2_1.38.3 harmony_1.1.0
  1264. [15] Rcpp_1.0.10 data.table_1.14.8
  1265. [17] rio_1.0.1 reshape2_1.4.4
  1266. [19] ggpubr_0.6.0 lubridate_1.9.3
  1267. [21] forcats_1.0.0 stringr_1.5.0
  1268. [23] purrr_1.0.1 readr_2.1.4
  1269. [25] tidyr_1.3.0 tibble_3.2.1
  1270. [27] tidyverse_2.0.0 plyr_1.8.9
  1271. [29] ggplot2_3.4.4 Matrix_1.6-5
  1272. [31] dplyr_1.1.4 DropletQC_0.0.0.9000
  1273. [33] DropletUtils_1.18.1 SingleCellExperiment_1.20.0
  1274. [35] SummarizedExperiment_1.28.0 Biobase_2.58.0
  1275. [37] GenomicRanges_1.50.0 GenomeInfoDb_1.34.9
  1276. [39] IRanges_2.32.0 S4Vectors_0.36.0
  1277. [41] BiocGenerics_0.44.0 MatrixGenerics_1.10.0
  1278. [43] matrixStats_0.63.0 rhdf5_2.42.1
  1279. [45] BPCells_0.3.1 Seurat_5.3.0
  1280. [47] SeuratObject_5.1.0 sp_1.6-0
  1281. [49] patchwork_1.3.0.9000
  1282. loaded via a namespace (and not attached):
  1283. [1] scattermore_1.2 R.methodsS3_1.8.2
  1284. [3] knitr_1.48 bit64_4.0.5
  1285. [5] irlba_2.3.5.1 DelayedArray_0.24.0
  1286. [7] R.utils_2.12.2 rpart_4.1.19
  1287. [9] KEGGREST_1.38.0 RCurl_1.98-1.12
  1288. [11] doParallel_1.0.17 generics_0.1.3
  1289. [13] preprocessCore_1.60.2 RhpcBLASctl_0.23-42
  1290. [15] cowplot_1.1.1 RSQLite_2.3.1
  1291. [17] RANN_2.6.1 future_1.33.1
  1292. [19] bit_4.0.5 tzdb_0.3.0
  1293. [21] spatstat.data_3.0-0 httpuv_1.6.9
  1294. [23] xfun_0.47 hms_1.1.2
  1295. [25] evaluate_0.20 promises_1.2.0.1
  1296. [27] fansi_1.0.6 progress_1.2.2
  1297. [29] caTools_1.18.2 igraph_1.4.2
  1298. [31] DBI_1.1.3 geneplotter_1.76.0
  1299. [33] htmlwidgets_1.6.2 spatstat.geom_3.0-6
  1300. [35] ellipsis_0.3.2 RSpectra_0.16-1
  1301. [37] backports_1.4.1 annotate_1.76.0
  1302. [39] aod_1.3.3 deldir_1.0-6
  1303. [41] sparseMatrixStats_1.10.0 vctrs_0.6.5
  1304. [43] ROCR_1.0-11 abind_1.4-5
  1305. [45] cachem_1.0.7 withr_2.5.2
  1306. [47] grr_0.9.5 progressr_0.13.0
  1307. [49] checkmate_2.3.0 sctransform_0.4.1
  1308. [51] prettyunits_1.1.1 mclust_6.0.0
  1309. [53] goftest_1.2-3 cluster_2.1.4
  1310. [55] dotCall64_1.1-0 lazyeval_0.2.2
  1311. [57] crayon_1.5.2 spatstat.explore_3.0-6
  1312. [59] pkgconfig_2.0.3 nlme_3.1-162
  1313. [61] nnet_7.3-18 rlang_1.1.4
  1314. [63] globals_0.16.2 lifecycle_1.0.3
  1315. [65] miniUI_0.1.1.1 polyclip_1.10-4
  1316. [67] RcppHNSW_0.4.1 lmtest_0.9-40
  1317. [69] carData_3.0-5 Rhdf5lib_1.20.0
  1318. [71] boot_1.3-28.1 zoo_1.8-11
  1319. [73] base64enc_0.1-3 ggridges_0.5.4
  1320. [75] png_0.1-8 viridisLite_0.4.1
  1321. [77] bitops_1.0-7 R.oo_1.25.0
  1322. [79] KernSmooth_2.23-20 spam_2.10-0
  1323. [81] rhdf5filters_1.10.1 Biostrings_2.66.0
  1324. [83] blob_1.2.3 DelayedMatrixStats_1.20.0
  1325. [85] parallelly_1.35.0 spatstat.random_3.1-3
  1326. [87] remaCor_0.0.16 rstatix_0.7.2
  1327. [89] ggsignif_0.6.4 beachmat_2.14.0
  1328. [91] scales_1.3.0 memoise_2.0.1
  1329. [93] magrittr_2.0.3 ica_1.0-3
  1330. [95] gplots_3.1.3 zlibbioc_1.44.0
  1331. [97] compiler_4.2.3 dqrng_0.3.0
  1332. [99] RColorBrewer_1.1-3 lme4_1.1-35.1
  1333. [101] fitdistrplus_1.1-8 cli_3.6.2
  1334. [103] XVector_0.38.0 listenv_0.9.0
  1335. [105] pbapply_1.7-0 htmlTable_2.4.2
  1336. [107] Formula_1.2-5 MASS_7.3-58.3
  1337. [109] tidyselect_1.2.0 stringi_1.7.12
  1338. [111] locfit_1.5-9.8 grid_4.2.3
  1339. [113] tools_4.2.3 timechange_0.2.0
  1340. [115] future.apply_1.10.0 parallel_4.2.3
  1341. [117] rstudioapi_0.14 foreign_0.8-85
  1342. [119] foreach_1.5.2 gridExtra_2.3
  1343. [121] EnvStats_2.8.1 farver_2.1.1
  1344. [123] Rtsne_0.16 digest_0.6.31
  1345. [125] shiny_1.7.4 car_3.1-2
  1346. [127] broom_1.0.3 scuttle_1.8.0
  1347. [129] later_1.3.0 RcppAnnoy_0.0.20
  1348. [131] httr_1.4.5 AnnotationDbi_1.60.2
  1349. [133] Rdpack_2.6 colorspace_2.1-0
  1350. [135] XML_3.99-0.14 tensor_1.5
  1351. [137] reticulate_1.42.0 splines_4.2.3
  1352. [139] uwot_0.1.14 spatstat.utils_3.1-4
  1353. [141] plotly_4.10.1 xtable_1.8-4
  1354. [143] jsonlite_1.8.4 nloptr_2.0.3
  1355. [145] R6_2.5.1 Hmisc_5.1-1
  1356. [147] pillar_1.9.0 htmltools_0.5.8.1
  1357. [149] mime_0.12 glue_1.6.2
  1358. [151] fastmap_1.1.1 minqa_1.2.6
  1359. [153] codetools_0.2-19 mvtnorm_1.2-3
  1360. [155] utf8_1.2.4 lattice_0.21-8
  1361. [157] spatstat.sparse_3.0-0 pbkrtest_0.5.2
  1362. [159] gtools_3.9.4 GO.db_3.16.0
  1363. [161] survival_3.5-3 rmarkdown_2.28
  1364. [163] munsell_0.5.0 GenomeInfoDbData_1.2.9
  1365. [165] iterators_1.0.14 impute_1.72.3
  1366. [167] HDF5Array_1.26.0 gtable_0.3.3
  1367. [169] rbibutils_2.2.16

00_prep_pseudobulk_counts.R at commit b8e3704, under MIT · at the source

Overview

  1. Department of Neurobiology, UCLA David Geffen School of Medicine, Los Angeles, CA USA
  2. Department of Neuroscience, Peter O’Donnell Jr. Brain Institute, UT Southwestern Medical Center, Dallas, TX USA
  3. Present Address: Division of Genetics and Genomics, Department of Pediatrics, Boston Children’s Hospital, Harvard Medical School, Boston, MA USA
  4. School of Biology, University of St Andrews, St Andrews, UK
  5. Keeling Center for Comparative Medicine and Research, The University of Texas, MD Anderson Cancer Center, Bastrop, TX USA
  6. Department of Anthropology and Center for the Advanced Study of Human Paleobiology, The George Washington University, Washington, DC USA
Journal: Nature communications, volume 17, issue 1, article 6793
Dates: received 27 April 2025; accepted 6 May 2026; published online 25 May 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1038/s41467-026-73305-8 · PMID 42185272 · PMCID PMC13385833 · OpenAlex W7162321241
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: genetics / omics (modality), human (organism), mouse (organism), other (organism), non-human primate (organism), cellular / molecular (subfield)
Methods: Statistics, Smoothing, state filtering, decompositions, Machine learning, Preprocessing, Connectivity, Spectral & time-frequency
Keywords: Molecular evolution, Genetics of the nervous system
MeSH: Corpus Striatum*, Animals, Callithrix, Chiroptera, Humans, Macaca mulatta, Male, Medium Spiny Neurons, Mice, Neuroglia, Neurons, Pan troglodytes, Species Specificity (* major topic)
Topic: Neurogenesis and neuroplasticity mechanisms (Developmental Neuroscience, Neuroscience), according to OpenAlex
Funding: U.S. Department of Health & Human Services | NIH | National Institute of Neurological Disorders and Stroke (NINDS) (NS115821, NS126143); NHGRI NIH HHS (R01 HG011641); NINDS NIH HHS (RF1 NS126143, R01 NS126143, R24 NS092988, UF1 NS115821); James S. McDonnell Foundation (McDonnell Foundation) (220020467); National Science Foundation (NSF) (DRL-2219759); U.S. Department of Health & Human Services | NIH | National Institute of Mental Health (NIMH) (MH134809, MH103517, MH126481); EC | EU Framework Programme for Research and Innovation H2020 | H2020 Euratom (H2020 Euratom Research and Training Programme 2014-2018) (101001702); NIMH NIH HHS (R01 MH103517, R01 MH126481, R01 MH134809); U.S. Department of Health & Human Services | NIH | National Human Genome Research Institute (NHGRI) (HG011641)
Citations: cited by 2 papers (Europe PMC); 101 references in the paper

Abstract

The dorsal striatum is important for highly specialized functions including movement, learning, and habit formation. However, it is not known if species-specialized behaviors are associated with cellular specializations in the striatum. Here, we compared single-nucleus RNA sequencing (snRNA-seq) data from human, chimpanzee, rhesus macaque, common marmoset, and pale spear-nosed bat caudate (CN) and putamen (Pu) separately as well as mouse caudoputamen (C-Pu), which represents divergence among species spanning approximately 94 million years of evolution. We observed a lower neuron-to-glia ratio in primate striata compared to non-primates, reflecting the allometric scaling of neuron density and relative glia density invariance in larger brains. Among neurons, eccentric spiny projection neurons (eSPNs) - an SPN of unknown function - showed significantly lower proportions in non-primate striata for both CN and Pu. Focusing on the heterogeneity within interneurons, we identified two bat striatal interneuron cell types that are nearly absent in other species: which express LMO3, and co-express FOXP2 and TSHZ2. Other striatal interneurons also exhibited differential abundance between primates and non-primates. In summary, we provide a comprehensive snRNA-seq dataset of dorsal striatum, identify two distinct, previously uncharacterized populations of bat interneurons, and uncover fundamental cellular composition differences between primate and non-primate striata.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repositories

Its files are read in the Code ↔ Paper reader above, with 23 matches between paragraphs and lines of code.

konopkalab/Comparative_striatum

License: MIT
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: b8e37042199a12756ee1ae145790fc9862f6cfc6, 15 April 2026
Languages: Shell (43), R (36), Python (3), Jupyter (2)
Size: 87 files, 84 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, 2 notebooks
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Seurat (36 files), ggpubr (34 files), reshape2 (34 files), tidyverse (34 files), Cell Ranger (24 files), data.table (19 files), ggplot2 (19 files), Harmony (18 files), DESeq2 (8 files), edgeR (8 files), anndata (5 files), Matplotlib (5 files), pandas (5 files), patchwork (5 files), rpy2 (5 files), Scanpy (5 files), WGCNA (5 files), SingleCellExperiment (4 files), clusterProfiler (3 files), NumPy (2 files), pheatmap (2 files), ComplexHeatmap (1 file), cowplot (1 file), SAMtools (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
86 files

Zenodo 19266844

License: MIT
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: the references
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Seurat (36 files), ggpubr (34 files), reshape2 (34 files), tidyverse (34 files), Cell Ranger (24 files), data.table (19 files), ggplot2 (19 files), Harmony (18 files), DESeq2 (8 files), edgeR (8 files), anndata (5 files), Matplotlib (5 files), pandas (5 files), patchwork (5 files), rpy2 (5 files), Scanpy (5 files), WGCNA (5 files), SingleCellExperiment (4 files), clusterProfiler (3 files), NumPy (2 files), pheatmap (2 files), ComplexHeatmap (1 file), cowplot (1 file), SAMtools (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers (HTTP 200)
  • 28 September 2026: the link answers (HTTP 200)
86 files
At the source:

Code availability

All the scripts used in the study were deposited to https://github.com/konopkalab/Comparative_striatum and Zenodo101.

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:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 168 scripts, each with its path and the digest of its content;
  • 23 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

Data Availability Statement

The human, chimpanzee, and pale spear-nosed bat dorsal striatum snRNA-seq data generated in this study have been deposited in the GEO database under accession code GSE293075 (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE293075). The processed data are available at UCSC cell browser [https://mammal-striatum-evo.cells.ucsc.edu]. The following published dorsal striatum snRNA-seq data used in this study were downloaded from the GEO database: rhesus macaque dataset with accession number GSE167920 (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE167920), marmoset datasets with accession numbers GSE151761 (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE151761) and GSE165578 (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE165578), mouse and ferret datasets with accession number GSE151761 (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE151761). Source data are provided with this paper.

All the scripts used in the study were deposited to https://github.com/konopkalab/Comparative_striatum and Zenodo101.

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, 28 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 12 authors, 2 keywords, 13 MeSH terms, 9 funders, 99 references.

Cite

This paper

Buyukkahraman, G., Caglayan, E., Hörpel, S. G., Zhang, Y., van Tussenbroek, I. A., Orozco, C. G., Oh, E., Hopkins, W. D., Sherwood, C. C., Roberts, T. F., Vernes, S. C., & Konopka, G. (2026). Comparative analysis of the cellular landscape in mammalian striatum. Nature communications, 17(1), 6793. https://doi.org/10.1038/s41467-026-73305-8

BibTeX

@article{buyukkahraman2026comparative,
author = {Buyukkahraman, Gozde and Caglayan, Emre and Hörpel, Stephen G and Zhang, Yaqiang and van Tussenbroek, Ine A and Orozco, Carlos G and Oh, Emily and Hopkins, William D and Sherwood, Chet C and Roberts, Todd F and Vernes, Sonja C and Konopka, Genevieve},
title = {{Comparative analysis of the cellular landscape in mammalian striatum}},
journal = {Nature communications},
year = {2026},
month = may,
volume = {17},
number = {1},
pages = {6793},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/s41467-026-73305-8},
url = {https://doi.org/10.1038/s41467-026-73305-8},
pmid = {42185272},
pmcid = {PMC13385833}
}

RIS

TY - JOUR
AU - Buyukkahraman, Gozde
AU - Caglayan, Emre
AU - Hörpel, Stephen G
AU - Zhang, Yaqiang
AU - van Tussenbroek, Ine A
AU - Orozco, Carlos G
AU - Oh, Emily
AU - Hopkins, William D
AU - Sherwood, Chet C
AU - Roberts, Todd F
AU - Vernes, Sonja C
AU - Konopka, Genevieve
TI - Comparative analysis of the cellular landscape in mammalian striatum
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/05/25
VL - 17
IS - 1
SP - 6793
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/s41467-026-73305-8
UR - https://doi.org/10.1038/s41467-026-73305-8
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41467-026-73305-8",
"type": "article-journal",
"title": "Comparative analysis of the cellular landscape in mammalian striatum",
"container-title": "Nature communications",
"author": [
{
"family": "Buyukkahraman",
"given": "Gozde"
},
{
"family": "Caglayan",
"given": "Emre"
},
{
"family": "Hörpel",
"given": "Stephen G"
},
{
"family": "Zhang",
"given": "Yaqiang"
},
{
"family": "van Tussenbroek",
"given": "Ine A"
},
{
"family": "Orozco",
"given": "Carlos G"
},
{
"family": "Oh",
"given": "Emily"
},
{
"family": "Hopkins",
"given": "William D"
},
{
"family": "Sherwood",
"given": "Chet C"
},
{
"family": "Roberts",
"given": "Todd F"
},
{
"family": "Vernes",
"given": "Sonja C"
},
{
"family": "Konopka",
"given": "Genevieve"
}
],
"container-title-short": "Nat Commun",
"volume": "17",
"issue": "1",
"page": "6793",
"DOI": "10.1038/s41467-026-73305-8",
"PMID": "42185272",
"PMCID": "PMC13385833",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41467-026-73305-8",
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
25
]
]
}
}

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.1016/j.xcrm.2026.102766 [code]
A longitudinal single-cell and spatial multiomic atlas of pediatric high-grade glioma.
Journal: Cell reports. Medicine
In common: rpy2, WGCNA, Harmony, 19 other tools, genetics / omics, cellular / molecular, 2 references
[2] doi:10.1038/s41586-026-10214-2 [code]
Multidimensional profiling of heterogeneity in supratentorial ependymomas.
Journal: Nature
In common: Cell Ranger, Harmony, SingleCellExperiment, 18 other tools, genetics / omics, mouse
[3] doi:10.1038/s41593-026-02300-5 [code]
Integrated single-cell and spatial transcriptomic profiling in ALS uncovers peripheral-to-central immune infiltration and reprogramming.
Journal: Nature neuroscience
In common: Cell Ranger, Harmony, SAMtools, 17 other tools, genetics / omics, cellular / molecular
[4] doi:10.1002/imt2.70163 [code]
Spatial multi-omics unveils sphingolipid metabolic reprogramming within the retinal pathological niche.
Journal: iMeta
In common: Harmony, SingleCellExperiment, edgeR, 17 other tools, genetics / omics, mouse, cellular / molecular
[5] doi:10.1016/j.celrep.2026.117073 [code]
Single-cell epigenomics uncovers heterochromatin instability and transcription factor dysfunction during mouse brain aging.
Journal: Cell reports
In common: rpy2, SAMtools, edgeR, 16 other tools, genetics / omics, mouse, cellular / molecular
[6] 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 psychiatry
In common: WGCNA, Harmony, SingleCellExperiment, 14 other tools, genetics / omics, cellular / molecular, 2 references
[7] doi:10.1016/j.cpblue.2026.100007 [code]
An integrated single-cell and spatial proteotranscriptomics atlas of fibroblast-driven immunoregulation within the human adult oral cavity.
Journal: Cell press blue
In common: rpy2, SingleCellExperiment, SAMtools, 16 other tools
[8] doi:10.1016/j.celrep.2026.117500 [code]
Spatio-molecular gene expression reflects dorsal anterior cingulate cortex structure and function in the human brain.
Journal: Cell reports
In common: Cell Ranger, Harmony, SingleCellExperiment, 13 other tools, genetics / omics, cellular / molecular, 1 reference
[9] doi:10.7554/elife.93640 [code]
Sibling chimerism among microglia in marmosets.
Journal: eLife
In common: Harmony, SingleCellExperiment, anndata, 12 other tools, non-human primate, genetics / omics, cellular / molecular, 3 references
[10] doi:10.1016/j.cell.2026.05.026 [code]
The critical role of the endogenous immune compartment after CAR T cell therapy in recurrent GBM.
Journal: Cell
In common: Harmony, SingleCellExperiment, edgeR, 13 other tools, genetics / omics, 3 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.

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.