OSCR

Charting the transition from in vitro gliogenesis to the in vivo maturation of human glial progenitor cells transplanted into the hypomyelinated mouse brain.

Code ↔ Paper

32 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.

26 blocks of code here have a permanent identifier (oscr:b:…), listed with the matches below: citable for good, with a page of its own. Select a match and press Cite to copy it. What a block identifier is.

The 32 matches · 1 of them tie a paragraph to a whole file without given lines: a weak match, whose lines are not tinted
  1. [1] § Results › Context-dependent differentiation of human GPCs in callosal white matter ↔ Scripts/21_Invitro_Invivo_Analysis_withATAC.Rmd, lines 309 to 401 · score 0.96 · MYCN signaling, THRA signaling, TCF7L2, SOX11 signaling, EGR2 signaling, cell contact · block oscr:b:H7YFWTZ2NJ9QW-D · Report a mismatch
  2. [2] § Methods › Bulk CUT&Tag analysis ↔ Scripts/06_CUT&Tag_genomicCoverage.sh, lines 83 to 168 · score 0.90 · computeMatrix, plotHeatmap, H3K27ac, H3K27me3, H3K4me3, deeptools · block oscr:b:74TTVSB2CH69B-G · Report a mismatch
  3. [3] § Results › Resident mouse brain cells drive the specification and differentiation of human GPCs in vivo ↔ Scripts/25_NicheNet_Analysis_and_Figure.Rmd, lines 398 to 441 · score 0.90 · IL1A, IL1B, APOE, EBI3, ICAM1, MMP13 · block oscr:b:QNBR5HMJVNHRA-U · Report a mismatch
  4. [4] § Methods › Xenium processing and analysis ↔ Scripts/28_Xenium_Inital_Analysis.ipynb, lines 439 to 475 · score 0.89 · cross reactive genes, perfect human genes, negative score, composite score, human probe, penalize · Report a mismatch
  5. [5] § Methods › scATAC-seq of human GPCs ↔ Scripts/20_scATAC_Analysis.Rmd, lines 116 to 141 · score 0.85 · blacklist ratio, nucleosome signal, TSS enrichment, fragments, scATAC, log · block oscr:b:FGGXBKFBDA360-6 · Report a mismatch
  6. [6] § Methods › Xenium processing and analysis ↔ Scripts/26_Process_MagicBlast_Output.Rmd, lines 27 to 56 · score 0.85 · Magic BLAST, mouse genome, human genome, composite score, human probe, alignment · block oscr:b:E2X7CP1SQXRRT-2 · Report a mismatch
  7. [7] § Methods › Integration with external fetal scRNA-/snRNA-seq datasets ↔ Scripts/17_Invitro_Integration_van_Bruggen.Rmd, lines 156 to 211 · score 0.82 · van Bruggen, FindTransferAnchors, TransferData, RPCA, external, query · block oscr:b:D0SXSZ5Q1B7H7-D · Report a mismatch
  8. [8] § Methods › Bulk CUT & Tag of human PSCs or GPCs ↔ Scripts/06_CUT&Tag_genomicCoverage.sh, lines 83 to 168 · score 0.82 · CUT Tag, H3K27ac, H3K27me3, H3K4me3, chromatin, histone · block oscr:b:74TTVSB2CH69B-G · Report a mismatch
  9. [9] § Methods › Cell-cell interaction analysis ↔ Scripts/25_NicheNet_Analysis_and_Figure.Rmd, lines 96 to 160 · score 0.81 · niche de, sender cells, receiver cells, NicheNet, vitro GPC4, Seurat · block oscr:b:WBP28QABFCXA3-Q · Report a mismatch
  10. [10] § Methods › Bulk CUT&Tag analysis ↔ Scripts/05_CUT&Tag_scRNA_Intersection.Rmd, lines 78 to 163 · score 0.79 · GeneHancer, DiffBind, promoter region, log2fc, database, enhancers · block oscr:b:JZAB3TCAV1JFA-1 · Report a mismatch
  11. [11] § Results › Context-dependent differentiation of human GPCs in callosal white matter ↔ Scripts/21_Invitro_Invivo_Analysis_withATAC.Rmd, lines 403 to 444 · score 0.78 · CAMK2N1, vivo GPC4, NNAT, DCX, FOS, JUNB · block oscr:b:AY7NYAGCQ4H19-C · Report a mismatch
  12. [12] § Results › hESC-derived hGPCs are transcriptionally analogous to fetal glial progenitors ↔ Scripts/18_Label_Transfer_Figure_Generation.R, the whole file · a weak match · score 0.77 · van Bruggen, wk GA, 17–41, IPCs, RG, Velmeshev · block oscr:b:EH4JS8Q42XRX7-M · Report a mismatch
  13. [13] § Methods › Integration with external fetal scRNA-/snRNA-seq datasets ↔ Scripts/15_Invitro_Integration_Ramos.Rmd, lines 256 to 307 · score 0.76 · FindTransferAnchors, TransferData, Ramos, RPCA, external, query · block oscr:b:VMC0CS57JSD93-4 · Report a mismatch
  14. [14] § Results › Resident mouse brain cells drive the specification and differentiation of human GPCs in vivo ↔ Scripts/25_NicheNet_Analysis_and_Figure.Rmd, lines 648 to 714 · score 0.75 · ligand target networks, SULF2, BAMBI, CSPG4, CSPG5, TNR · block oscr:b:3WT1PQ950DF1C-T · Report a mismatch
  15. [15] § Methods › Cell-cell interaction analysis ↔ Scripts/25_NicheNet_Analysis_and_Figure.Rmd, lines 648 to 714 · score 0.74 · ligand target weights, NicheNet, ligand activity, niches, receiver, activation · block oscr:b:3WT1PQ950DF1C-T · Report a mismatch
  16. [16] § Results › hGPCs are comprised of distinct stage-defined subpopulations ↔ Scripts/25_NicheNet_Analysis_and_Figure.Rmd, lines 60 to 74 · score 0.70 · dual species, immature oligodendrocytes, maOL, imOL, cell · block oscr:b:SEW8W2KKM2YRJ-D · Report a mismatch
  17. [17] § Results › Human donor cells can be recovered from host brains as glia, without residual pluripotent stem cells ↔ Scripts/19_Invivo_Analysis.Rmd, lines 784 to 823 · score 0.66 · cGPC, imAstrocyte, cAPC, maOL, imOL, canonical · block oscr:b:0NS5S0DXMBJFX-Z · Report a mismatch
  18. [18] § Methods › Bulk CUT & Tag of human PSCs or GPCs ↔ Scripts/05_CUT&Tag_scRNA_Intersection.Rmd, lines 78 to 163 · score 0.66 · K4me3, CUT Tag, histone mark, chromatin, Bulk · block oscr:b:JZAB3TCAV1JFA-1 · Report a mismatch
  19. [19] § Results › hESC-derived hGPCs are transcriptionally analogous to fetal glial progenitors ↔ Scripts/18_Label_Transfer_Figure_Generation.Rmd, lines 127 to 156 · score 0.64 · van Bruggen, wk GA, RG, OPC, fetal, 8–10 · block oscr:b:NQJW6J6JE9H4G-5 · Report a mismatch
  20. [20] § Results › Transcriptionally-distinct cycling pools of bipotential and astrocyte-biased progenitors appear in vivo ↔ Scripts/19_Invivo_Analysis.Rmd, lines 910 to 940 · score 0.63 · cGPC, cAPC, Log2FC, NXPH1, PLLP, CNTN1 · block oscr:b:G4Q5ZHCPGN0A3-M · Report a mismatch
  21. [21] § Results › A distinct set of transcriptional regulators directs human astrocytic differentiation in vivo ↔ Scripts/29_Xenium_Figure_Construction.Rmd, lines 122 to 154 · score 0.59 · SLC1A3, SLC1A2, EGFR, AQP4, SOX9, OLIG2 · block oscr:b:PDEYDY120Q1ZV-P · Report a mismatch
  22. [22] § Methods › Identification of transcription factor regulons ↔ Scripts/21_Invitro_Invivo_Analysis_withATAC.Rmd, lines 535 to 667 · score 0.58 · pySCENIC, transcription factor, AUC, repressive, regulons, log2 · block oscr:b:JRY7J8HD0K6GD-N · Report a mismatch
  23. [23] § Results › Downstream regulators drive human oligodendrocytic maturation and myelination in vivo ↔ Scripts/19_Invivo_Analysis.Rmd, lines 329 to 388 · score 0.58 · regulon target, transcription factor, maOL, imOL, TF, networks · block oscr:b:D6MJ4WCPRERPC-7 · Report a mismatch
  24. [24] § Methods › Pseudotime analysis ↔ Scripts/19_Invivo_Analysis.Rmd, lines 673 to 719 · score 0.58 · fitGAM, regulon activity, slingshot, pseudotime, Gene expression, Scores · block oscr:b:262WSA6R3MECE-I · Report a mismatch
  25. [25] § Results › Human donor cells can be recovered from host brains as glia, without residual pluripotent stem cells ↔ Scripts/19_Invivo_Analysis.Rmd, lines 970 to 1022 · score 0.57 · SLC1A2, cAPC, MOBP, MKI67, AQP4, BCAS1 · block oscr:b:6DH7NMS037ES4-6 · Report a mismatch
  26. [26] § Results › In vitro GPC differentiation yields compositions free of pluripotent signatures ↔ Scripts/07_PSC_vs_GPC_Figure_Assembly.Rmd, lines 111 to 164 · score 0.57 · co expressed, LIN28A, POU5F1, PSCs, vitro, GPC · block oscr:b:RFRXYEMKDB6B8-M · Report a mismatch
  27. [27] § Results › In vitro GPC differentiation yields compositions free of pluripotent signatures ↔ Scripts/07_PSC_vs_GPC_Figure_Assembly.Rmd, lines 111 to 164 · score 0.56 · PSC stage, LIN28A, POU5F1, GPC stage, vitro, cells · block oscr:b:RFRXYEMKDB6B8-M · Report a mismatch
  28. [28] § Methods › Xenium processing and analysis ↔ Scripts/27_Xenium_Read_and_Crop.ipynb, lines 221 to 234 · score 0.55 · interactive session, engrafted human cells, napari, Xenium, WA09, subset · Report a mismatch
  29. [29] § Results › Predictive trajectory modeling of transplanted hGPC differentiation trajectories ↔ Scripts/14_Invitro_Analysis.Rmd, lines 496 to 506 · score 0.55 · BCL11B, mature NPCs, MEIS2, SYT1 · block oscr:b:YK6YRBTY04C2Y-6 · Report a mismatch
  30. [30] § Methods › Alignment and preprocessing of scRNA-seq samples ↔ Scripts/24_NicheNet_Processing.Rmd, lines 193 to 242 · score 0.54 · dual species, Seurat, human genes, mouse, cell · block oscr:b:K0F788PF916MD-9 · Report a mismatch
  31. [31] § Methods › FACS isolation of chimeric white matter cells for scRNA-Seq ↔ Scripts/01_Processing.Rmd, lines 29 to 67 · score 0.51 · tagged C27s, EGFP, mouse, human, cells · block oscr:b:T0DV1A159SMJA-I · Report a mismatch
  32. [32] § Methods › Pseudotime analysis ↔ Scripts/12_Invitro_Invivo_Processing.Rmd, lines 134 to 155 · score 0.51 · terminal cells, AGT, NSG2, DLX5, MOBP, palantir · block oscr:b:93FF3ZXRB14M7-N · Report a mismatch

Paper

Loaded from Europe PMC by your browser; OSCR does not store it: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

R Markdown · 833 lines · 36 KB · MIT · 5 matches

  1. ---
  2. title: "Differential NicheNet Analysis of in vivo and in vitro hGPCs"
  3. author: "John Mariani"
  4. date: "3/6/2023"
  5. output: github_document
  6. ---
  7. ```{r setup, include=FALSE}
  8. knitr::opts_chunk$set(echo = TRUE)
  9. knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file())
  10. ```
  11. ## Load in Libraries
  12. ```{r}
  13. library(dplyr)
  14. library(Seurat)
  15. library(devtools)
  16. library(patchwork)
  17. library(dplyr)
  18. library(SeuratDisk)
  19. library(biomaRt)
  20. library(Matrix)
  21. library(nichenetr)
  22. library(RColorBrewer)
  23. library(scPlottingTools)
  24. library(data.table)
  25. options(future.globals.maxSize = 16000 * 1024^2)
  26. ```
  27. ## Read in Human and Mouse Counts
  28. ```{r}
  29. source("Scripts/HelperFunctions.r")
  30. dualSpecies <- readRDS("output/RDS/finalNiche.rds")
  31. ```
  32. ## Read in NicheNetV2 Databases
  33. ```{r}
  34. ligand_target_matrix = readRDS("data_for_import/NicheNet/ligand_target_matrix_nsga2r_final.rds")
  35. lr_network = readRDS("data_for_import/NicheNet/lr_network_human_21122021.rds")
  36. lr_network = lr_network %>% mutate(bonafide = ! database %in% c("ppi_prediction","ppi_prediction_go"))
  37. lr_network = lr_network %>% dplyr::rename(ligand = from, receptor = to) %>% distinct(ligand, receptor, bonafide)
  38. weighted_networks = readRDS("data_for_import/NicheNet/weighted_networks_nsga2r_final.rds")
  39. ```
  40. ## Make counts to edit
  41. ```{r}
  42. dualSpecies$stage2 <- dualSpecies$stage
  43. dualSpecies$stage2 <- gsub(x = dualSpecies$stage2, pattern = "In Vitro - GPC Stage", replacement = "In Vitro")
  44. unique(dualSpecies$stage2)
  45. dualSpecies$cellStage <- paste0(dualSpecies$stage2, " ", dualSpecies$cellType)
  46. dualSpecies$cellStage <- gsub(x = dualSpecies$cellStage, pattern = "Immature Oligodendrocyte", replacement = "imOL")
  47. dualSpecies$cellStage <- gsub(x = dualSpecies$cellStage, pattern = "Mature Oligodendrocyte", replacement = "maOL")
  48. table(dualSpecies$cellStage)
  49. ```
  50. ## Showing ligand differences between in vitro cell states
  51. ```{r}
  52. ligands <- unique(lr_network$ligand)
  53. GPC1 <- read.delim("output/DE/GPC1.vs.Rest.sig.txt")
  54. GPC2 <- read.delim("output/DE/GPC2.vs.Rest.sig.txt")
  55. GPC3 <- read.delim("output/DE/GPC3.vs.Rest.sig.txt")
  56. GPC4 <- read.delim("output/DE/GPC4.vs.Rest.sig.txt")
  57. NPC <- read.delim("output/DE/NPC.vs.Rest.sig.txt")
  58. invitroStateMarkers <- rbind(GPC1, GPC2, GPC3, GPC4, NPC)
  59. invitroStateLigands <- invitroStateMarkers[invitroStateMarkers$gene %in% ligands,]
  60. invitroStateLigands <- invitroStateLigands[!duplicated(invitroStateLigands$gene),]
  61. ```
  62. ```{r, warning=F}
  63. niches = list(
  64. "In Vivo" = list(
  65. "sender" = c("In Vivo Astrocyte","In Vivo imOL", "In Vivo maOL", "In Vivo Mouse Astrocyte", "In Vivo Mouse Endothelial", "In Vivo Mouse Ependymal", "In Vivo Mouse Macrophage", "In Vivo Mouse GPC", "In Vivo Mouse imOL", "In Vivo Mouse maOL", "In Vivo Mouse Microglia", "In Vivo Mouse NPC", "In Vivo Mouse Pericyte"),
  66. "receiver" = c("In Vivo GPC4")),
  67. "In Vitro" = list(
  68. "sender" = c("In Vitro GPC1","In Vitro GPC2", "In Vitro GPC3", "In Vitro NPC"),
  69. "receiver" = c("In Vitro GPC4"))
  70. )
  71. Idents(dualSpecies) <- dualSpecies$cellStage
  72. one2oneGenes <- read.csv("data_for_import/NicheNet/one2oneGenes.csv")
  73. #DE_sender = calculate_niche_de(seurat_obj = dualSpecies %>% subset(features = lr_network$ligand %>% intersect(one2oneGenes$x)), niches = niches, type = "sender", assay_oi = "RNA") # only ligands important for sender cell types
  74. #write.csv(DE_sender, "output/NicheNet/DE_sender.csv", quote = F, row.names = F)
  75. DE_sender <- read.csv("output/NicheNet/DE_sender.csv")
  76. DE_sender$sender <- gsub(x = DE_sender$sender, pattern = "Immature Oligodendrocyte", replacement = "imOL")
  77. DE_sender$sender_other_niche <- gsub(x = DE_sender$sender_other_niche, pattern = "Immature Oligodendrocyte", replacement = "imOL")
  78. DE_sender$sender <- gsub(x = DE_sender$sender, pattern = "Mature Oligodendrocyte", replacement = "maOL")
  79. DE_sender$sender_other_niche <- gsub(x = DE_sender$sender_other_niche, pattern = "Mature Oligodendrocyte", replacement = "maOL")
  80. DE_sender$sender <- gsub(x = DE_sender$sender, pattern = "Immature Oligo", replacement = "imOL")
  81. DE_sender$sender_other_niche <- gsub(x = DE_sender$sender_other_niche, pattern = "Immature Oligo", replacement = "imOL")
  82. DE_sender$sender <- gsub(x = DE_sender$sender, pattern = "Mature Oligo", replacement = "maOL")
  83. DE_sender$sender_other_niche <- gsub(x = DE_sender$sender_other_niche, pattern = "Mature Oligo", replacement = "maOL")
  84. deGPC4 <- read.delim("output/DE/Invivo.vs.Invitro.GPC4.txt")
  85. deGPC4.sig <- read.delim("output/DE/Invivo.vs.Invitro.GPC4.sig.txt")
  86. deGPC4 <- deGPC4[complete.cases(deGPC4),]
  87. deGPC4 <- rbind(deGPC4, deGPC4.sig[deGPC4.sig$gene %not in% deGPC4$gene,])
  88. #Format Prior Differential Expression for receiver cells
  89. pct.expr <- DotPlot(dualSpecies, features = deGPC4$gene, idents = c("In Vivo GPC4", "In Vitro GPC4"), group.by = "cellStage")$data
  90. pct.expr.invivo <- pct.expr[pct.expr$id == "In Vivo GPC4",]
  91. pct.expr.invitro <- pct.expr[pct.expr$id == "In Vitro GPC4",]
  92. DE_receiver_invivo <- data.frame(gene = deGPC4$gene, p_val = deGPC4$FDR, avg_log2FC = deGPC4$logFC, pct.1 = pct.expr.invivo$pct.exp, pct.2 = pct.expr.invitro$pct.exp, p_val_adj = deGPC4$FDR, receiver = "In Vivo GPC4", receiver_other_niche = "In Vitro GPC4")
  93. DE_receiver_invitro <- data.frame(gene = deGPC4$gene, p_val = deGPC4$FDR, avg_log2FC = (deGPC4$logFC*-1), pct.1 = pct.expr.invitro$pct.exp, pct.2 = pct.expr.invivo$pct.exp, p_val_adj = deGPC4$FDR, receiver = "In Vitro GPC4", receiver_other_niche = "In Vivo GPC4")
  94. DE_receiver <- rbind(DE_receiver_invivo, DE_receiver_invitro)
  95. DE_receiver_receptors <- DE_receiver[DE_receiver$gene %in% lr_network$receptor,]
  96. #DE_receiver = calculate_niche_de(seurat_obj = dualSpecies %>% subset(features = lr_network$receptor %>% unique()), niches = niches, type = "receiver", assay_oi = "RNA") # only receptors now, later on: DE analysis to find targets
  97. DE_sender = DE_sender %>% mutate(avg_log2FC = ifelse(avg_log2FC == Inf, max(avg_log2FC[is.finite(avg_log2FC)]), ifelse(avg_log2FC == -Inf, min(avg_log2FC[is.finite(avg_log2FC)]), avg_log2FC)))
  98. DE_receiver_receptors = DE_receiver_receptors %>% mutate(avg_log2FC = ifelse(avg_log2FC == Inf, max(avg_log2FC[is.finite(avg_log2FC)]), ifelse(avg_log2FC == -Inf, min(avg_log2FC[is.finite(avg_log2FC)]), avg_log2FC)))
  99. ```
  100. ```{r}
  101. expression_pct = 10
  102. DE_sender_processed = process_niche_de(DE_table = DE_sender, niches = niches, expression_pct = expression_pct, type = "sender")
  103. DE_receiver_processed = process_niche_de(DE_table = DE_receiver_receptors, niches = niches, expression_pct = expression_pct, type = "receiver")
  104. specificity_score_LR_pairs = "min_lfc"
  105. DE_sender_receiver = combine_sender_receiver_de(DE_sender_processed, DE_receiver_processed, lr_network, specificity_score = specificity_score_LR_pairs)
  106. ```
  107. ```{r}
  108. lfc_cutoff = 0.25 # recommended for 10x as min_lfc cutoff.
  109. specificity_score_targets = "min_lfc"
  110. #DE_receiver_targets = calculate_niche_de_targets(seurat_obj = dualSpecies, niches = niches, lfc_cutoff = lfc_cutoff, expression_pct = expression_pct, assay_oi = "RNA")
  111. DE_receiver_processed_targets = process_receiver_target_de(DE_receiver = DE_receiver, niches = niches, expression_pct = expression_pct, specificity_score = specificity_score_targets)
  112. background = DE_receiver_processed_targets %>% pull(target) %>% unique()
  113. geneset_InVivo = DE_receiver_processed_targets %>% filter(receiver == niches$`In Vivo`$receiver & target_score >= lfc_cutoff & target_significant == 1 & target_present == 1) %>% pull(target) %>% unique()
  114. geneset_Invitro = DE_receiver_processed_targets %>% filter(receiver == niches$`In Vitro`$receiver & target_score >= lfc_cutoff & target_significant == 1 & target_present == 1) %>% pull(target) %>% unique()
  115. geneset_InVivo %>% setdiff(rownames(ligand_target_matrix))
  116. geneset_Invitro %>% setdiff(rownames(ligand_target_matrix))
  117. ```
  118. ```{r, warning=F}
  119. top_n_target = 1000
  120. niche_geneset_list = list(
  121. "In_Vivo_niche" = list(
  122. "receiver" = "In Vivo GPC4",
  123. "geneset" = geneset_InVivo,
  124. "background" = background),
  125. "In_Vitro_niche" = list(
  126. "receiver" = "In Vitro GPC4",
  127. "geneset" = geneset_Invitro ,
  128. "background" = background))
  129. ligand_activities_targets = get_ligand_activities_targets(niche_geneset_list = niche_geneset_list, ligand_target_matrix = ligand_target_matrix, top_n_target = top_n_target)
  130. #write.table(ligand_activities_targets, "output/NicheNet/ligand_activities_targets.txt", sep = "\t", row.names = F, quote = F)
  131. ```
  132. ```{r}
  133. features_oi = union(lr_network$ligand, lr_network$receptor) %>% union(ligand_activities_targets$target) %>% setdiff(NA)
  134. dotplot = suppressWarnings(Seurat::DotPlot(dualSpecies %>% subset(idents = niches %>% unlist() %>% unique()), features = features_oi, assay = "RNA"))
  135. exprs_tbl = dotplot$data %>% as_tibble()
  136. exprs_tbl = exprs_tbl %>% dplyr::rename(celltype = id, gene = features.plot, expression = avg.exp, expression_scaled = avg.exp.scaled, fraction = pct.exp) %>%
  137. mutate(fraction = fraction/100) %>% as_tibble() %>% dplyr::select(celltype, gene, expression, expression_scaled, fraction) %>% distinct() %>% arrange(gene) %>% mutate(gene = as.character(gene))
  138. exprs_tbl_ligand = exprs_tbl %>% filter(gene %in% lr_network$ligand) %>% dplyr::rename(sender = celltype, ligand = gene, ligand_expression = expression, ligand_expression_scaled = expression_scaled, ligand_fraction = fraction)
  139. exprs_tbl_receptor = exprs_tbl %>% filter(gene %in% lr_network$receptor) %>% dplyr::rename(receiver = celltype, receptor = gene, receptor_expression = expression, receptor_expression_scaled = expression_scaled, receptor_fraction = fraction)
  140. exprs_tbl_target = exprs_tbl %>% filter(gene %in% ligand_activities_targets$target) %>% dplyr::rename(receiver = celltype, target = gene, target_expression = expression, target_expression_scaled = expression_scaled, target_fraction = fraction)
  141. exprs_tbl_ligand = exprs_tbl_ligand %>% mutate(scaled_ligand_expression_scaled = scale_quantile_adapted(ligand_expression_scaled)) %>% mutate(ligand_fraction_adapted = ligand_fraction) %>% mutate_cond(ligand_fraction >= expression_pct, ligand_fraction_adapted = expression_pct) %>% mutate(scaled_ligand_fraction_adapted = scale_quantile_adapted(ligand_fraction_adapted))
  142. exprs_tbl_receptor = exprs_tbl_receptor %>% mutate(scaled_receptor_expression_scaled = scale_quantile_adapted(receptor_expression_scaled)) %>% mutate(receptor_fraction_adapted = receptor_fraction) %>% mutate_cond(receptor_fraction >= expression_pct, receptor_fraction_adapted = expression_pct) %>% mutate(scaled_receptor_fraction_adapted = scale_quantile_adapted(receptor_fraction_adapted))
  143. ```
  144. ```{r}
  145. exprs_sender_receiver = lr_network %>%
  146. inner_join(exprs_tbl_ligand, by = c("ligand")) %>%
  147. inner_join(exprs_tbl_receptor, by = c("receptor")) %>% inner_join(DE_sender_receiver %>% distinct(niche, sender, receiver))
  148. ligand_scaled_receptor_expression_fraction_df = exprs_sender_receiver %>% group_by(ligand, receiver) %>% mutate(rank_receptor_expression = dense_rank(receptor_expression), rank_receptor_fraction = dense_rank(receptor_fraction)) %>% mutate(ligand_scaled_receptor_expression_fraction = 0.5*( (rank_receptor_fraction / max(rank_receptor_fraction)) + ((rank_receptor_expression / max(rank_receptor_expression))) ) ) %>% distinct(ligand, receptor, receiver, ligand_scaled_receptor_expression_fraction, bonafide) %>% distinct() %>% ungroup()
  149. # No Spatial info
  150. spatial_info = tibble(celltype_region_oi = NA, celltype_other_region = NA) %>% mutate(niche = niches %>% names() %>% head(1), celltype_type = "sender")
  151. ```
  152. ## No Spatial info
  153. ```{r}
  154. include_spatial_info_sender = F # if not spatial info to include: put this to false
  155. include_spatial_info_receiver = FALSE # if spatial info to include: put this to true
  156. if(include_spatial_info_sender == FALSE & include_spatial_info_receiver == FALSE){
  157. spatial_info = tibble(celltype_region_oi = NA, celltype_other_region = NA) %>% mutate(niche = niches %>% names() %>% head(1), celltype_type = "sender")
  158. }
  159. if(include_spatial_info_sender == TRUE){
  160. sender_spatial_DE = calculate_spatial_DE(seurat_obj = seurat_obj %>% subset(features = lr_network$ligand %>% unique()), spatial_info = spatial_info %>% filter(celltype_type == "sender"), assay_oi = assay_oi)
  161. sender_spatial_DE_processed = process_spatial_de(DE_table = sender_spatial_DE, type = "sender", lr_network = lr_network, expression_pct = expression_pct, specificity_score = specificity_score_spatial)
  162. # add a neutral spatial score for sender celltypes in which the spatial is not known / not of importance
  163. sender_spatial_DE_others = get_non_spatial_de(niches = niches, spatial_info = spatial_info, type = "sender", lr_network = lr_network)
  164. sender_spatial_DE_processed = sender_spatial_DE_processed %>% bind_rows(sender_spatial_DE_others)
  165. sender_spatial_DE_processed = sender_spatial_DE_processed %>% mutate(scaled_ligand_score_spatial = scale_quantile_adapted(ligand_score_spatial))
  166. } else {
  167. # # add a neutral spatial score for all sender celltypes (for none of them, spatial is relevant in this case)
  168. sender_spatial_DE_processed = get_non_spatial_de(niches = niches, spatial_info = spatial_info, type = "sender", lr_network = lr_network)
  169. sender_spatial_DE_processed = sender_spatial_DE_processed %>% mutate(scaled_ligand_score_spatial = scale_quantile_adapted(ligand_score_spatial))
  170. }
  171. if(include_spatial_info_receiver == TRUE){
  172. receiver_spatial_DE = calculate_spatial_DE(seurat_obj = seurat_obj %>% subset(features = lr_network$receptor %>% unique()), spatial_info = spatial_info %>% filter(celltype_type == "receiver"), assay_oi = assay_oi)
  173. receiver_spatial_DE_processed = process_spatial_de(DE_table = receiver_spatial_DE, type = "receiver", lr_network = lr_network, expression_pct = expression_pct, specificity_score = specificity_score_spatial)
  174. # add a neutral spatial score for receiver celltypes in which the spatial is not known / not of importance
  175. receiver_spatial_DE_others = get_non_spatial_de(niches = niches, spatial_info = spatial_info, type = "receiver", lr_network = lr_network)
  176. receiver_spatial_DE_processed = receiver_spatial_DE_processed %>% bind_rows(receiver_spatial_DE_others)
  177. receiver_spatial_DE_processed = receiver_spatial_DE_processed %>% mutate(scaled_receptor_score_spatial = scale_quantile_adapted(receptor_score_spatial))
  178. } else {
  179. # # add a neutral spatial score for all receiver celltypes (for none of them, spatial is relevant in this case)
  180. receiver_spatial_DE_processed = get_non_spatial_de(niches = niches, spatial_info = spatial_info, type = "receiver", lr_network = lr_network)
  181. receiver_spatial_DE_processed = receiver_spatial_DE_processed %>% mutate(scaled_receptor_score_spatial = scale_quantile_adapted(receptor_score_spatial))
  182. }
  183. ```
  184. ```{r}
  185. prioritizing_weights = c("scaled_ligand_score" = 5,
  186. "scaled_ligand_expression_scaled" = 1,
  187. "ligand_fraction" = 1,
  188. "scaled_ligand_score_spatial" = 0,
  189. "scaled_receptor_score" = 0.5,
  190. "scaled_receptor_expression_scaled" = 0.5,
  191. "receptor_fraction" = 1,
  192. "ligand_scaled_receptor_expression_fraction" = 1,
  193. "scaled_receptor_score_spatial" = 0,
  194. "scaled_activity" = 0,
  195. "scaled_activity_normalized" = 1,
  196. "bona_fide" = 1)
  197. output = list(DE_sender_receiver = DE_sender_receiver, ligand_scaled_receptor_expression_fraction_df = ligand_scaled_receptor_expression_fraction_df, sender_spatial_DE_processed = sender_spatial_DE_processed, receiver_spatial_DE_processed = receiver_spatial_DE_processed,
  198. ligand_activities_targets = ligand_activities_targets, DE_receiver_processed_targets = DE_receiver_processed_targets, exprs_tbl_ligand = exprs_tbl_ligand, exprs_tbl_receptor = exprs_tbl_receptor, exprs_tbl_target = exprs_tbl_target)
  199. prioritization_tables = get_prioritization_tables(output, prioritizing_weights)
  200. prioritization_tables$prioritization_tbl_ligand_receptor %>% filter(receiver == niches[[1]]$receiver) %>% head(10)
  201. prioritization_tables$prioritization_tbl_ligand_receptor %>% filter(receiver == niches[[2]]$receiver) %>% head(10)
  202. prioritization_tables$prioritization_tbl_ligand_receptor = prioritization_tables$prioritization_tbl_ligand_receptor %>% mutate(receiver = factor(receiver, levels = c("In Vivo GPC4", "In Vitro GPC4")), niche = factor(niche, levels = c("In Vivo","In Vitro")))
  203. prioritization_tables$prioritization_tbl_ligand_target = prioritization_tables$prioritization_tbl_ligand_target %>% mutate(receiver = factor(receiver, levels = c("In Vivo GPC4", "In Vitro GPC4")), niche = factor(niche, levels = c("In Vivo", "In Vitro")))
  204. ```
  205. ## Ligand Activities for picking targets
  206. ```{r}
  207. ligandActivities <- ligand_activities_targets[!duplicated(ligand_activities_targets[c("ligand", "receiver")]),]
  208. ligandActivities <- ligandActivities[,-c(4:5)]
  209. ligandActivitiesInVivo <- ligandActivities[ligandActivities$receiver == "In Vivo GPC4",]
  210. ligandActivitiesInVitro <- ligandActivities[ligandActivities$receiver == "In Vitro GPC4",]
  211. ligandActivitiesInVivo <- ligandActivitiesInVivo[,-4]
  212. ligandActivitiesInVitro <- ligandActivitiesInVitro[,-4]
  213. names(ligandActivitiesInVivo)[2:6] <- paste(names(ligandActivitiesInVivo)[2:6], "InVivo", sep = "_")
  214. names(ligandActivitiesInVitro)[2:6] <- paste(names(ligandActivitiesInVitro)[2:6], "InVitro", sep = "_")
  215. ligandActivities <- merge(ligandActivitiesInVivo, ligandActivitiesInVitro, by.x = 1, by.y = 1)
  216. ligandActivities <- ligandActivities[,c(1,2,7,3,8,4,9,5,10,6,11)]
  217. ligandActivities$activity_normalized_diff <- ligandActivities$activity_normalized_InVivo - ligandActivities$activity_normalized_InVitro
  218. ligandActivities$activity_normalized_div <- ligandActivities$activity_normalized_InVivo / ligandActivities$activity_normalized_InVitro
  219. # ligandActivities$aupr_corrected_diff <- ligandActivities$aupr_corrected_InVivo - ligandActivities$aupr_corrected_InVitro
  220. # ligandActivities$aupr_corrected_div <- ligandActivities$aupr_corrected_InVivo / ligandActivities$aupr_corrected_InVitro
  221. #
  222. # ligandActivities$activity_diff <- ligandActivities$activity_InVivo - ligandActivities$activity_InVitro
  223. # ligandActivities$activity_div <- ligandActivities$activity_InVivo / ligandActivities$activity_InVitro
  224. #
  225. #
  226. # ligandActivities$scaled_activity_normalized_diff <- ligandActivities$scaled_activity_normalized_InVivo - ligandActivities$scaled_activity_normalized_InVitro
  227. # ligandActivities$scaled_activity_normalized_div <- ligandActivities$scaled_activity_normalized_InVivo / ligandActivities$scaled_activity_normalized_InVitro
  228. ligandActivities <- ligandActivities[order(ligandActivities$activity_normalized_diff, decreasing = T),]
  229. pri <- prioritization_tables$prioritization_tbl_ligand_receptor
  230. priInvivo <- pri[pri$niche == "In Vivo",]
  231. priInvivo <- priInvivo[priInvivo$receptor_fraction > .1,]
  232. priInvivo <- priInvivo[priInvivo$ligand %in% ligandActivities[ligandActivities$activity_normalized_diff > 0.6,]$ligand,]
  233. priInvivo <- priInvivo[order(priInvivo$ligand_score, decreasing = T),]
  234. #priInvivo <- priInvivo[priInvivo$receptor %in% deGPC4[deGPC4$logFC > 0,]$gene,]
  235. ligandActivitiesInvivoReceptor <- ligandActivities[ligandActivities$ligand %in% priInvivo$ligand,]
  236. ligandActivitiesInvivoReceptor <- ligandActivitiesInvivoReceptor[ligandActivitiesInvivoReceptor$activity_normalized_diff > 0.6,]
  237. # Differentially regulated in vitro ligands
  238. ligandActivitiesInvivoReceptor[ligandActivitiesInvivoReceptor$ligand %in% invitroStateLigands$gene,]
  239. ```
  240. ## Ligand Activity and Expression for plots
  241. ```{r}
  242. plotting_tbl <- exprs_tbl
  243. plotting_tbl$stage <- ifelse(grepl("Vivo",plotting_tbl$celltype),"In Vivo","In Vitro")
  244. plotting_tbl$species <- ifelse(grepl("Mouse",plotting_tbl$celltype),"Mouse","Human")
  245. plotting_tbl$ct <- gsub(pattern = "In Vitro ", replacement = "", plotting_tbl$celltype)
  246. plotting_tbl$ct <- gsub(pattern = "In Vivo ", replacement = "", plotting_tbl$ct)
  247. plotting_tbl$ct <- gsub(pattern = "Mouse ", replacement = "", plotting_tbl$ct)
  248. unique(plotting_tbl$ct)
  249. temp <- unique(plotting_tbl$ct)
  250. temp
  251. names(temp) <- c("imOL", "maOL", "Astrocyte", "GPC1", "GPC2", "NPC", "GPC3", "GPC", "Microglia", "Ependymal", "Endothelial", "Pericyte", "Macrophage", "GPC4")
  252. temp
  253. plotting_tbl$ctRenamed <- plyr::mapvalues(plotting_tbl$ct, from = temp, to = names(temp))
  254. unique(plotting_tbl$ctRenamed)
  255. plotting_tbl$ctRenamed <- factor(plotting_tbl$ctRenamed, levels = c("GPC1", "GPC2", "GPC3", "GPC4", "GPC", "imOL", "maOL", "Astrocyte", "Microglia", "Macrophage", "NPC", "Ependymal", "Endothelial", "Pericyte"))
  256. write.table(plotting_tbl, "output/NicheNet/plotting_tbl.txt", row.names = F, quote = F, sep = "\t")
  257. ligandsCurated <- c("PDGFA", "OSM", "IL1A", "CSF1", "EGF", "TNF", "EBI3", "IL1B", "NOG", "SLITRK1", "TNFSF10", "GHRH", "TGFB1", "GAS6", "ICAM1", "EDN1", "CCN2", "DSCAM", "MMP13", "ADM", "APOE", "OCLN", "HBEGF", "FGF1")
  258. #ligandsCurated <- ligandActivitiesInvivoReceptor$ligand[81:95]
  259. # ligandsActivity <- c("SLITRK1", "PDGFA", "OSM", "LRRC4", "IL1A", "IFNK", "EGF", "EBI3", "CSF1", "CMTM8", "CLCF1",
  260. # "TNFSF10", "TNF", "NOG", "GAS6", "DSCAM", "DKK3", "BDNF")
  261. #
  262. # ligandsScore <- c("APOE", "CCN2", "DKK3", "EBI3", "GAS6", "ICAM1", "IL1A", "OCLN", "OSM", "PDGFA", "PGF", "TNFSF10", "FGF1",)
  263. #
  264. # ligandsCurated <- unique(c(ligandsActivity, ligandsScore))
  265. ```
  266. ```{r}
  267. ligandOrder <- rev(ligandActivities[ligandActivities$ligand %in% ligandsCurated,]$ligand)
  268. ligandPlot <- plotting_tbl[plotting_tbl$gene %in% ligandsCurated,]
  269. ligandPlot$gene <- factor(ligandPlot$gene, levels = ligandOrder)
  270. activityPlot <- ligandActivities[ligandActivities$ligand %in% ligandsCurated,]
  271. activityPlot$ligand <- factor(activityPlot$ligand, levels = ligandOrder)
  272. ```
  273. ## Ligand Activity and Expression plot
  274. ```{r,fig.width = 10.5, fig.height=10}
  275. ligandActivityGG <- ggplot(activityPlot, aes(x = "In Vivo", y = ligand, fill = scale(activity_normalized_diff))) +
  276. geom_tile(colour = "black") +
  277. viridis::scale_fill_viridis(option = "D", expand = c(0,0)) +
  278. scale_x_discrete(expand = c(0,0)) +
  279. scale_y_discrete(expand = c(0,0)) +
  280. theme_bw() +
  281. theme_manuscript +
  282. theme(axis.title = element_blank(), legend.title = element_blank(), legend.position = "left", axis.text.y = element_blank()) +
  283. labs(title = "Ligand Activity", tag = "C")
  284. ligandExpressionGG <- ggplot(ligandPlot, aes(x = ctRenamed, y = gene, colour = expression_scaled, size = ifelse(fraction==0, NA, fraction))) +
  285. geom_point() +
  286. viridis::scale_color_viridis(option = "D") +
  287. facet_grid(rows = ~species + stage, scales = "free", space = "free") +
  288. theme_bw() +
  289. theme_manuscript +
  290. theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = .5), legend.position = "bottom", axis.title = element_blank(), legend.title = element_blank()) +
  291. scale_size(range = c(0,4)) +
  292. labs(title = "Ligand Expression", tag = "D")
  293. (ligandActivityGG | ligandExpressionGG) + plot_layout(widths = c(.5,10))
  294. ```
  295. ## Circos
  296. ```{r}
  297. curatedCircos <- c("PDGFA", "IL1A", "OSM", "EBI3", "TGFB1", "TNF", "MMP13", "GAS6", "HBEGF", "ICAM1", "IL1B", "APOE", "EGF", "CSF1", "NOG", "ADM", "TNFSF10", "OCLN", "EDN1", "ADM")
  298. curatedCircos <- c("PDGFA", "OSM", "IL1A", "EBI3", "EGF", "CSF1", "TGFB1", "TNF", "ICAM1", "OCLN")
  299. tempPri <- prioritization_tables$prioritization_tbl_ligand_receptor
  300. tempPri <- tempPri[tempPri$sender %not in% c("In Vivo Mouse NPC", "In Vivo imOL", "In Vivo maOL", "In Vivo Mouse GPC", "In Vivo Mouse Ependymal", "In Vivo Astrocyte"),]
  301. tempPri <- tempPri[tempPri$niche == "In Vivo",]
  302. tempPri <- tempPri[tempPri$receptor_fraction > .1,]
  303. top_ligand_receptor_niche_df = tempPri %>% dplyr::select(niche, sender, receiver, ligand, receptor, prioritization_score) %>% group_by(ligand, receptor) %>% top_n(1, prioritization_score) %>% ungroup() %>% dplyr::select(ligand, receptor, niche)
  304. prioritized_tbl_oi = tempPri %>% dplyr::filter(ligand %in% curatedCircos) %>% dplyr::select(niche, sender, receiver, ligand, receptor, ligand_receptor, prioritization_score) %>% distinct() %>% inner_join(top_ligand_receptor_niche_df) %>% group_by(ligand) %>% dplyr::filter(receiver == "In Vivo GPC4") %>% top_n(2, prioritization_score) %>% ungroup()
  305. unique(prioritized_tbl_oi$sender)
  306. colors_sender <- c("#00BF7D","#D89000", "#E76BF3", "#00B0F6", "#00BFC4", "#39B600", "#A3A500")
  307. names(colors_sender) <- unique(prioritized_tbl_oi$sender)
  308. colors_receiver <- "turquoise"
  309. names(colors_receiver) <- unique(prioritized_tbl_oi$receiver)
  310. circos_output = make_circos_lr(prioritized_tbl_oi, colors_sender, colors_receiver)
  311. unique(prioritized_tbl_oi$sender)
  312. circos_output = make_circos_lr(prioritized_tbl_oi, colors_sender, colors_receiver)
  313. ```
  314. ## Receptors for Supp Table
  315. ```{r}
  316. receptorSup <- pri
  317. receptorSup <- receptorSup[,c(2,5,6,18,20)]
  318. receptorSup <- receptorSup[!duplicated(receptorSup),]
  319. receptorSup <- receptorSup[order(receptorSup$receptor, receptorSup$ligand),]
  320. #write.table(receptorSup, "output/NicheNet/receptorSuppTable.txt", quote = F, row.names = F, sep = "\t")
  321. ```
  322. ## Receptor Expression for plotting
  323. ```{r}
  324. ##
  325. tempDF <- pri[pri$ligand %in% ligandsCurated,]
  326. length(unique(tempDF$receptor))
  327. tempDF <- tempDF[,c(1, 4:6, 18:20)]
  328. tempDF <- tempDF[!duplicated(tempDF),]
  329. unique(tempDF$receptor)
  330. tempDF <- tempDF[tempDF$receptor %in% priInvivo$receptor,]
  331. tempDF$niche <- factor(tempDF$niche, levels = c("In Vivo", "In Vitro"))
  332. #activityPlot <- activityPlot[activityPlot$ligand %not in% ligandRemove,]
  333. #ligandPlot <- ligandPlot[ligandPlot$gene %not in% ligandRemove,]
  334. tempDF$ligand_receptor <- factor(tempDF$ligand_receptor, levels = unique(tempDF[order(tempDF$ligand, tempDF$receptor),]$ligand_receptor))
  335. tempDF$receptor_fraction <- tempDF$receptor_fraction * 100
  336. ```
  337. ## Receptor Plot
  338. ```{r, fig.width = 15, fig.height = 6}
  339. receptorGG <- ggplot(tempDF, aes(y = niche, x = ligand_receptor, fill = receptor_expression_scaled, size = ifelse(receptor_fraction==0, NA, receptor_fraction))) +
  340. geom_point(color = "black", pch = 21) +
  341. theme_bw() +
  342. theme_manuscript +
  343. scale_fill_gradientn(colors = PurpleAndYellow()) +
  344. theme(legend.position = "right", panel.spacing=unit(0, "lines"), axis.title = element_blank(), axis.text = element_text(angle = 90, hjust = 1)) +
  345. scale_size(range = c(0,20)) +
  346. labs(tag = "C", title = "In Vivo and In Vitro GPC Receptor Expression of Curated Ligands", size = "% Expressed", fill = "Scaled Expression") +
  347. guides(colour = guide_colorbar(title.position = "top", title.theme = element_text(size = axisTitleSize)),
  348. size = guide_legend(title.position = "top", title.theme = element_text(size = axisTitleSize)))
  349. receptorGG
  350. ```
  351. ## Combined Plots
  352. ```{r, fig.width = 8.5, fig.height = 11}
  353. mouse <- readRDS("output/RDS/mouse.rds")
  354. mouseDim <- DimPlotCustom(mouse, group.by = "cellType", label = T) + theme_bw() + theme_manuscript + theme(legend.position = "bottom") + labs(tag = "A")
  355. # This will limit which come from the next function
  356. mouseMarkers <- c("Pdgfra", "Ptprz1",
  357. "Gpr17", "Bcas1",
  358. "Nkx6-2", "Mog",
  359. "Gfap", "Aqp4",
  360. "P2ry12", "Itgam",
  361. "Cldn5", "Pecam1",
  362. "Acta2", "Des",
  363. "Dlx2", "Elavl4",
  364. "Pf4", "Cd163",
  365. "Tmem212", "Ccdc153")
  366. #You can extract percent expression from this seurat function... providing features makes it way faster. $data is what you want
  367. mouseDotPlot <- DotPlot(mouse, features = mouseMarkers)$data
  368. # For ordering in the plot
  369. mouseLevels <- c("GPC", "imOL", "maOL", "Astrocyte", "Microglia", "Endothelial", "Pericyte", "NPC", "Macrophage", "Ependymal")
  370. mouseDotPlot$id <- factor(mouseDotPlot$id , levels = rev(mouseLevels))
  371. figMouseB <- ggplot(mouseDotPlot, aes(size = pct.exp, color = avg.exp.scaled, y = id, x = features.plot)) +
  372. geom_point() +
  373. scale_size_area() +
  374. viridis::scale_color_viridis() +
  375. theme_bw() +
  376. theme_manuscript +
  377. theme(axis.title = element_blank(), axis.text.x = element_text(angle = 90, hjust = 1, vjust = .5), legend.position = "bottom") +
  378. labs(tag = "B", title = "Canonical Marker Expression", size = "% Expressed", colour = "Scaled Expression") +
  379. guides(colour = guide_colorbar(title.position = "top", title.theme = element_text(size = axisTitleSize)),
  380. size = guide_legend(title.position = "top", title.theme = element_text(size = axisTitleSize))) +
  381. scale_size(range = c(0,4))
  382. figMouseB
  383. top <- (mouseDim | figMouseB) + plot_layout(widths = c(1,1.5))
  384. middle <- (ligandActivityGG | ligandExpressionGG) + plot_layout(widths = c(.5,10))
  385. ```
  386. ```{r, fig.width = 17, fig.height = 26}
  387. (top / middle / receptorGG )
  388. #ggsave("output/Figures/Nichenet/nichenet_figure.pdf", width = 8.5, height = 12)
  389. ```
  390. ## Ligand, receptor, target Network construction
  391. ```{r}
  392. invivoNetwork <- ligand_activities_targets[ligand_activities_targets$ligand %in% tempDF$ligand,]
  393. invivoNetwork <- invivoNetwork[invivoNetwork$receiver == "In Vivo GPC4",]
  394. sigRegulons <- read.csv("output/DE/sigRegulons.csv")
  395. sigRegulons <- sigRegulons[sigRegulons$Gene_Log2FC >0 & sigRegulons$AUC_Log2FC > 0,]
  396. oligoTargets <- c("KLF6", "CCND1", "MBP", "CSPG4", "SULF2", "PCDH9", "BCAS1", "GPR17", "SEMA3E", "CA10", "OMG", "PLP1", "BAMBI", "CSPG5", "S100B", "APOD", "NRXN1", "TNR", "PLLP", "CNP", "CNTN1", "SOX10", "OLIG1", "OLIG2", "NKX2-2","PTPRZ1", "LUZP2" )
  397. regulonEdges <- invivoNetwork[invivoNetwork$target %in% sigRegulons$Gene,]
  398. regulonEdges$type <- "Regulon"
  399. regulonEdges$tempLigand <- paste0(regulonEdges$ligand, "_", regulonEdges$type)
  400. regulonEdges$tempTarget <- paste0(regulonEdges$target, "_", regulonEdges$type)
  401. regulonNodes <- data.frame(node = unique(c(regulonEdges$ligand, regulonEdges$target)),
  402. network = "Regulon")
  403. oligoEdges <- invivoNetwork[invivoNetwork$target %in% oligoTargets,]
  404. oligoEdges$type <- "Oligo"
  405. oligoEdges$tempLigand <- paste0(oligoEdges$ligand, "_", oligoEdges$type)
  406. oligoEdges$tempTarget <- paste0(oligoEdges$target, "_", oligoEdges$type)
  407. oligoNodes <- data.frame(node = unique(c(oligoEdges$ligand, oligoEdges$target)),
  408. network = "Oligo")
  409. receptorEdges <- invivoNetwork[invivoNetwork$target %in% tempDF$receptor,]
  410. receptorEdges$type <- "Receptor"
  411. receptorEdges$tempLigand <- paste0(receptorEdges$ligand, "_", receptorEdges$type)
  412. receptorEdges$tempTarget <- paste0(receptorEdges$target, "_", receptorEdges$type)
  413. receptorNodes <- data.frame(node = unique(c(receptorEdges$ligand, receptorEdges$target)),
  414. network = "Receptor")
  415. invivoNetworkFilt <- rbindlist(list(regulonEdges, oligoEdges, receptorEdges))
  416. invivoNetworkFilt <- invivoNetworkFilt[invivoNetworkFilt$ligand_target_weight > 0.05,]
  417. invivoNodes <- rbindlist(list(regulonNodes, oligoNodes, receptorNodes))
  418. invivoNodes$type <- "Gene Target"
  419. invivoNodes$type <- ifelse(invivoNodes$node %in% tempDF$receptor, "Receptor", invivoNodes$type)
  420. invivoNodes$type <- ifelse(invivoNodes$node %in% tempDF$ligand, "Ligand", invivoNodes$type)
  421. invivoNodes$type <- ifelse(invivoNodes$node %in% sigRegulons$Gene, "Regulon", invivoNodes$type)
  422. invivoNodes <- merge(invivoNodes, deGPC4.sig, by.x = "node", by.y = "gene", all.x = T)
  423. invivoNodes <- invivoNodes[,c(1,2,3,6)]
  424. invivoNodes$tempNode <- paste0(invivoNodes$node, "_", invivoNodes$network)
  425. invivoNodes
  426. TF_Functions <- read.csv("data_for_import/TF_Functions.csv")
  427. invivoNodes[invivoNodes$type == "Regulon" & invivoNodes$node %not in% c(TF_Functions$Activators, TF_Functions$Repressors),]
  428. invivoNodes <- invivoNodes[invivoNodes$node %not in% TF_Functions$Repressors,]
  429. invivoNetworkFilt <- invivoNetworkFilt[invivoNetworkFilt$target %not in% TF_Functions$Repressors,]
  430. #write.table(invivoNetworkFilt, "output/Networks/NicheNet/invivoNetworkNichenet.txt", sep = "\t", quote = F, row.names = F)
  431. #write.table(invivoNodes, "output/Networks/NicheNet/invivoNodesNichenet.txt", sep = "\t", quote = F, row.names = F)
  432. ```
  433. # Supplementary
  434. ```{r}
  435. dimLeidenFig <- DimPlotCustom(mouse, group.by = "leidenClusters", ncol = 1, label = T, pt.size = 3) & theme_bw() & theme_manuscript & NoLegend() & ggtitle("In Vivo Mouse Leiden Clusters") & labs(tag = "A")
  436. dimLeidenFig
  437. ```
  438. ## Leiden Markers
  439. ```{r, fig.width = 11, fig.height = 10.5}
  440. DefaultAssay(mouse) <- "RNA"
  441. canonicalMarkers <- c("Pdgfra", "Ptprz1",
  442. "Gpr17", "Bcas1",
  443. "Nkx6-2", "Mog",
  444. "Gfap", "Aqp4",
  445. "P2ry12", "Itgam",
  446. "Cldn5", "Pecam1",
  447. "Acta2", "Des",
  448. "Dlx2", "Elavl4",
  449. "Pf4", "Cd163",
  450. "Tmem212", "Ccdc153")
  451. markerDotPlotSupp <- DotPlot(mouse, features = canonicalMarkers, group.by = "leidenClusters")$data
  452. leidenTemp <- c("0" = "maOL",
  453. "1" = "maOL",
  454. "2" = "maOL",
  455. "3" = "maOL",
  456. "4" = "maOL",
  457. "5" = "maOL",
  458. "6" = "maOL",
  459. "7" = "Endothelial",
  460. "8" = "maOL",
  461. "9" = "maOL",
  462. "10" = "maOL",
  463. "11" = "maOL",
  464. "12" = "maOL",
  465. "13" = "Microglia",
  466. "14" = "imOL",
  467. "15" = "GPC",
  468. "16" = "Astrocyte",
  469. "17" = "NPC",
  470. "18" = "Ependymal",
  471. "19" = "Pericyte",
  472. "20" = "Macrophage")
  473. leidenTemp <- paste0(0:20, " - ", leidenTemp)
  474. names(leidenTemp) <- 0:20
  475. markerDotPlotSupp$id <- plyr::mapvalues(as.character(markerDotPlotSupp$id), from = names(leidenTemp), to = leidenTemp)
  476. markerDotPlotSupp$id <- factor(markerDotPlotSupp$id, levels = rev(c("15 - GPC",
  477. "14 - imOL",
  478. "5 - maOL",
  479. "0 - maOL",
  480. "1 - maOL",
  481. "2 - maOL",
  482. "3 - maOL",
  483. "4 - maOL",
  484. "6 - maOL",
  485. "8 - maOL",
  486. "9 - maOL",
  487. "10 - maOL",
  488. "11 - maOL",
  489. "12 - maOL",
  490. "16 - Astrocyte",
  491. "13 - Microglia",
  492. "7 - Endothelial",
  493. "19 - Pericyte",
  494. "17 - NPC",
  495. "20 - Macrophage",
  496. "18 - Ependymal")))
  497. figSuppMarkerPlot<- ggplot(markerDotPlotSupp, aes(size = pct.exp, fill = avg.exp.scaled, y = id, x = features.plot)) +
  498. geom_point(color = "black", pch = 21) +
  499. scale_size_area(max_size = 15) +
  500. scale_fill_gradientn(colors = PurpleAndYellow()) +
  501. theme_bw() +
  502. theme_manuscript +
  503. theme(axis.title = element_blank(), axis.text.x = element_text(angle = 90, hjust = 1, vjust = .5), legend.position = "right", panel.spacing=unit(0, "lines")) +
  504. labs(tag = "B", title = "Canonical Marker Expression", size = "% Expressed", fill = "Scaled Expression") +
  505. guides(colour = guide_colorbar(title.position = "top", title.theme = element_text(size = axisTitleSize)),
  506. size = guide_legend(title.position = "top", title.theme = element_text(size = axisTitleSize)))
  507. figSuppMarkerPlot
  508. ```
  509. ## Piece together
  510. ```{r, fig.width=30, fig.height = 20}
  511. ((dimLeidenFig | figSuppMarkerPlot) / receptorGG) + plot_layout(heights = c(1,.25))
  512. #ggsave("output/Figures/Nichenet/nichenetSupplement.pdf", width = 30, height = 20)
  513. ```
  514. ```{r}
  515. sessionInfo()
  516. ```

25_NicheNet_Analysis_and_Figure.Rmd at commit 760cd2f, under MIT · at the source

Overview

Authors: John N. Mariani1, Steven J. Schanz1, Benjamin Mansky1, Xiaolu Wei1, Carter C. Long1, Devin Chandler-Militello1, Hannah E. Aichelman1, Nguyen P. T. Huynh1,2, Steven A. Goldman1,2
  1. Center for Translational Neuromedicine, University of Rochester Medical Center,Rochester, NY USA
  2. Center for Translational Neuromedicine, University of Copenhagen Faculty of Health,Copenhagen, Denmark
Institutions: University of Rochester Medicine (United States); University of Copenhagen (Denmark)
Journal: Nature communications, volume 17, issue 1, article 5609
Dates: received 12 April 2025; accepted 31 March 2026; published online 23 April 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41467-026-71803-3 · PMID 42026046 · PMCID PMC13315746 · OpenAlex W7155386802
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: genetics / omics (modality), human (organism), mouse (organism), multiple sclerosis (population), cellular / molecular (subfield)
Methods: Connectivity, Statistics, Smoothing, state filtering, decompositions, Preprocessing
Keywords: Gliogenesis, Oligodendrocyte, Astrocyte, Multiple sclerosis, Stem-cell differentiation
MeSH: Brain*, Neuroglia*, Stem Cell Transplantation*, Animals, Astrocytes, Cell Differentiation, Humans, Mice, Myelin Sheath, Oligodendroglia, Pluripotent Stem Cells, Single-Cell Gene Expression Analysis (* major topic)
Topic: Neurogenesis and neuroplasticity mechanisms (Developmental Neuroscience, Neuroscience), according to OpenAlex
Citations: not cited yet (Europe PMC); 138 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

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

CTNGoldmanLab/Glial_Chimera_Maturation

License: MIT
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Commit: 760cd2f41c90ccfb279b633e2943e03526a0c510, 12 November 2025
Languages: R (24), Jupyter (7), Shell (1)
Size: 227 files, 32 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, 28 notebooks
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: tidyverse (20 files), ggplot2 (17 files), patchwork (17 files), Seurat (17 files), data.table (12 files), Matplotlib (7 files), NumPy (7 files), Scanpy (7 files), PyTorch (4 files), pandas (3 files), anndata (2 files), BEDTools (2 files), cowplot (2 files), h5py (2 files), pheatmap (2 files), SciPy (2 files), seaborn (2 files), Squidpy (2 files), deepTools (1 file), DESeq2 (1 file), ggpubr (1 file), Numba (1 file), Plotly (1 file), reticulate (1 file), SAMtools (1 file), scikit-learn (1 file)
Availability: 1 check, the latest on 29 September 2026: the link answers
  • 29 September 2026: the link answers
34 files

Code availability statement

The paper has a code availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s41467-026-71803-3.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

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

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1038/s41467-026-71803-3.

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

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

Cite

This paper

Mariani, J. N., Schanz, S. J., Mansky, B., Wei, X., Long, C. C., Chandler-Militello, D., Aichelman, H. E., Huynh, N. P. T., & Goldman, S. A. (2026). Charting the transition from in vitro gliogenesis to the in vivo maturation of human glial progenitor cells transplanted into the hypomyelinated mouse brain. Nature communications, 17(1), 5609. https://doi.org/10.1038/s41467-026-71803-3

BibTeX

@article{mariani2026charting,
author = {Mariani, John N. and Schanz, Steven J. and Mansky, Benjamin and Wei, Xiaolu and Long, Carter C. and Chandler-Militello, Devin and Aichelman, Hannah E. and Huynh, Nguyen P. T. and Goldman, Steven A.},
title = {{Charting the transition from in vitro gliogenesis to the in vivo maturation of human glial progenitor cells transplanted into the hypomyelinated mouse brain}},
journal = {Nature communications},
year = {2026},
month = apr,
volume = {17},
number = {1},
pages = {5609},
publisher = {Nature Portfolio},
issn = {2041-1723},
doi = {10.1038/s41467-026-71803-3},
url = {https://doi.org/10.1038/s41467-026-71803-3},
pmid = {42026046},
pmcid = {PMC13315746}
}

RIS

TY - JOUR
AU - Mariani, John N.
AU - Schanz, Steven J.
AU - Mansky, Benjamin
AU - Wei, Xiaolu
AU - Long, Carter C.
AU - Chandler-Militello, Devin
AU - Aichelman, Hannah E.
AU - Huynh, Nguyen P. T.
AU - Goldman, Steven A.
TI - Charting the transition from in vitro gliogenesis to the in vivo maturation of human glial progenitor cells transplanted into the hypomyelinated mouse brain
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/04/23
VL - 17
IS - 1
SP - 5609
SN - 2041-1723
PB - Nature Portfolio
DO - 10.1038/s41467-026-71803-3
UR - https://doi.org/10.1038/s41467-026-71803-3
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41467-026-71803-3",
"type": "article-journal",
"title": "Charting the transition from in vitro gliogenesis to the in vivo maturation of human glial progenitor cells transplanted into the hypomyelinated mouse brain",
"container-title": "Nature communications",
"author": [
{
"family": "Mariani",
"given": "John N."
},
{
"family": "Schanz",
"given": "Steven J."
},
{
"family": "Mansky",
"given": "Benjamin"
},
{
"family": "Wei",
"given": "Xiaolu"
},
{
"family": "Long",
"given": "Carter C."
},
{
"family": "Chandler-Militello",
"given": "Devin"
},
{
"family": "Aichelman",
"given": "Hannah E."
},
{
"family": "Huynh",
"given": "Nguyen P. T."
},
{
"family": "Goldman",
"given": "Steven A."
}
],
"container-title-short": "Nat Commun",
"volume": "17",
"issue": "1",
"page": "5609",
"DOI": "10.1038/s41467-026-71803-3",
"PMID": "42026046",
"PMCID": "PMC13315746",
"ISSN": "2041-1723",
"publisher": "Nature Portfolio",
"URL": "https://doi.org/10.1038/s41467-026-71803-3",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
23
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1038/s41587-023-01798-5 [code]
Young glial progenitor cells competitively replace aged and diseased human glia in the adult chimeric mouse brain.
Journal: Nature biotechnology
In common: anndata, Scanpy, Seurat, 8 other tools, mouse, cellular / molecular, 16 references, 2 authors
[2] doi:10.1002/glia.24291
Glial progenitor cells of the adult human white and grey matter are contextually distinct.
Journal: Glia
In common: mouse, cellular / molecular, 20 references, 2 authors
[3] doi:10.1038/s41593-026-02208-0 [code]
Single-nucleus epigenomic profiling of the adult human central nervous system unveils epigenetic memory of developmental programs.
Journal: Nature neuroscience
In common: deepTools, reticulate, BEDTools, 15 other tools, genetics / omics, 12 references
[4] doi:10.1016/j.celrep.2024.115149 [code]
Single-nucleus and spatial landscape of the sub-ventricular zone in human glioblastoma.
Journal: Cell reports
In common: Squidpy, reticulate, SAMtools, 21 other tools, cellular / molecular, 2 references
[5] doi:10.1186/s13059-026-04177-w [code]
Genomic sequence evolution underlying human neocortical interareal diversification.
Journal: Genome biology
In common: Squidpy, reticulate, BEDTools, 16 other tools, genetics / omics, mouse, cellular / molecular, 7 references
[6] doi:10.1038/s41467-023-41033-y [code]
Divergent single cell transcriptome and epigenome alterations in ALS and FTD patients with C9orf72 mutation.
Journal: Nature communications
In common: deepTools, BEDTools, SAMtools, 16 other tools, genetics / omics, cellular / molecular, 7 references
[7] doi:10.1038/s41592-023-01938-4 [code]
SCENIC+: single-cell multiomic inference of enhancers and gene regulatory networks.
Journal: Nature methods
In common: BEDTools, anndata, Scanpy, 16 other tools, genetics / omics, mouse, cellular / molecular, 5 references
[8] doi:10.1038/s41586-025-09083-y [code]
Single-cell transcriptomic and chromatin dynamics of the human brain in PTSD.
Journal: Nature
In common: Squidpy, reticulate, BEDTools, 16 other tools, genetics / omics, cellular / molecular, 4 references
[9] doi:10.1073/pnas.2303647120 [code]
Quantifying common and distinct information in single-cell multimodal data with Tilted Canonical Correlation Analysis.
Journal: Proceedings of the National Academy of Sciences of the United States of America
In common: deepTools, reticulate, BEDTools, 17 other tools, genetics / omics, cellular / molecular, 2 references
[10] doi:10.1038/s42003-025-08859-2 [code]
Single-cell DNA methylation analysis tool Amethyst resolves distinct non-CG methylation patterns in human astrocytes and oligodendrocytes.
Journal: Communications biology
In common: BEDTools, anndata, Scanpy, 16 other tools, genetics / omics, cellular / molecular, 5 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.

Add the badge to the code's README

OSCR: the badge of this paper

If you are an author or a maintainer of this paper's code, you can add this badge. It says what OSCR knows of the paper (its code, its validated tracing map) and links the code to this page. Paste one of these snippets under the README's title. Keep the two marks around it, so that the badge can be replaced in place and is never added twice. OSCR changes nothing in your repository.

Markdown
<!-- oscr-badge:start -->
[![OSCR](https://openscicode.org/badge/doi/10.1038/s41467-026-71803-3.svg)](https://openscicode.org/badge/doi/10.1038/s41467-026-71803-3)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1038/s41467-026-71803-3.svg
   :target: https://openscicode.org/badge/doi/10.1038/s41467-026-71803-3
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1038/s41467-026-71803-3"><img src="https://openscicode.org/badge/doi/10.1038/s41467-026-71803-3.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

On GitHub, open the README, choose Edit (the pencil), paste the snippet under the title, then "Commit changes".

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge 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: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

Report a mismatch between the code and the paper · Report a code error (signed in)

Reproductions: reports from readers who ran the authors' code and did not get the paper's result, what they ran, with which environment, commit and data.

Report a reproduction failure (signed in)

Versions of its code: the releases of its code tied to a version of this paper (the preprint, the accepted manuscript, the version of record…), each with the tracing map versioned with it.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.