OSCR

Cluster replicability in single-cell and single-nucleus atlases of the mouse brain.

Code ↔ Paper

18 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 18 matches · 2 of them tie a paragraph to a whole file, not to given lines: weak matches, whose lines are not tinted
  1. [1] § Results › Characterization of the reciprocal best hit cluster pairs ↔ R/Figure_3_examine_MERFISH_calls_for_recips.R, lines 145–218 · score 0.79 · Reproducible cell calls, detected reciprocally, diversity mismatch, clusters detected, posterior, cells mapped
  2. [2] § Results › Characterization of the reciprocal best hit cluster pairs ↔ R/Figure_3_examine_MERFISH_calls_for_recips.R, lines 145–218 · score 0.76 · reciprocal best hit, diversity mismatch, clusters detected, MERFISH cells, posterior, anterior
  3. [3] § Methods › MERFISH spatial data ↔ R/centroid_correlations.bigcat.R, lines 1–40 · score 0.76 · scrattch.bigcat, MERFISH C57BL6J, log2, Allen, centroids, correlated
  4. [4] § Results › Replicability of reciprocal clusters in additional mouse brain datasets ↔ R/examine_barseq_pretrained_results.R, lines 61–148 · score 0.75 · odds ratios, Slide seq, BARseq, reciprocal pair, CC, abbreviations
  5. [5] § Results › Replicability of reciprocal clusters in additional mouse brain datasets ↔ R/examine_barseq_pretrained_results.R, lines 61–148 · score 0.73 · odds ratio, Slide seq, BARseq clusters, CTX, pretrained, MERFISH
  6. [6] § Methods › Gene Ontology gene sets ↔ R/Figure_4_coordinated_expression_GO.R, lines 61–134 · score 0.72 · SynGO, 15–150, Ontology, mm, filtered, Gene
  7. [7] § Results › Evolutionary conservation of reciprocal clusters ↔ R/Figure_5_get_cross_species_results.R, lines 42–79 · score 0.68 · progenitor cells, cross species, reciprocal hit, evolutionary, coarse, conservation
  8. [8] § Methods › MERFISH spatial data ↔ R/Figure_3_examine_MERFISH_calls_for_recips.R, lines 1–45 · score 0.65 · MERFISH C57BL6J, space, bigcat, threshold, Allen, centroids
  9. [9] § Results › Evolutionary conservation of reciprocal clusters ↔ R/Figure_5_plot_boxplot_clustergraph.R, lines 47–129 · score 0.65 · cross species, MetaNeighbor, reciprocal hit, progenitor, evolutionary, distance
  10. [10] § Results › Replicability of reciprocal clusters in additional mouse brain datasets ↔ R/Figure_5_plot_boxplot_clustergraph.R, lines 47–129 · score 0.61 · clusters mapping, MetaNeighbor, CGE, MGE, Boxplots, Evolutionary
  11. [11] § Results › MetaNeighbor reveals cross-atlas cluster relationships ↔ python_notebooks/retina_split_half/compare_split_halves.R, the whole file · a weak match · score 0.59 · split half, split halves, reciprocal top hits, retina, HVG, match
  12. [12] § Results › Coordinated gene expression across the matched clusters ↔ R/Figure_4_coordinated_expression_GO.R, lines 61–134 · score 0.59 · gene expression correlation, SynGO annotated, HVG, Figure 4, matched, reciprocal
  13. [13] § Results › Coordinated gene expression across the matched clusters ↔ R/Figure_1_centroid_expression.R, lines 86–124 · score 0.57 · expression centroids, genome wide, Spearman correlation, cell
  14. [14] § Methods › Integration results from other studies ↔ R/Figure_1_and_2_compare_other_mappings.R, lines 45–92 · score 0.56 · AIBS_cluster_id, transfer, RNA, mappings, score, Matched
  15. [15] § Results › While effective in the whole brain context, marker genes do not separate similar clusters ↔ R/Figure_1_and_2_compare_other_mappings.R, lines 45–92 · score 0.55 · scRNA, snATAC, seq, median, mouse brain, mapped
  16. [16] § Results › Replicability of reciprocal clusters in additional mouse brain datasets ↔ R/run_on_barseq_pretrained.R, lines 41–124 · score 0.52 · BARseq, pretrained models, fast, mouse brain, single nucleus, cross
  17. [17] § Methods › Single-nucleus expression data ↔ R/Figure_1_and_2_compare_other_mappings.R, lines 142–199 · score 0.52 · braincelldata.org, Slide seq, nucleus, mice
  18. [18] § Results › MetaNeighbor reveals cross-atlas cluster relationships ↔ R/run_mix_HVG.R, the whole file · a weak match · score 0.52 · memory limits, Seurat, MixHVG, subset, genes, cells

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 · 442 lines · 26 KB · MIT · 3 matches

  1. library(tidyr)
  2. library(dplyr)
  3. library(ggplot2)
  4. library(readr)
  5. library(here)
  6. library(magrittr)
  7. library(conflicted)
  8. conflict_prefer("first", "dplyr")
  9. conflict_prefer("rename", "dplyr")
  10. conflict_prefer("select", "dplyr")
  11. conflict_prefer("filter", "dplyr")
  12. conflict_prefer("count", "dplyr")
  13. conflicts_prefer(base::union)
  14. base_folder <- here("results/full_run_ZengAWS.1698256033/") #updated Allen data - 2009 recips
  15. h5ad_base <- read_csv(here("results", "MERFISH500", "H5ad_calls.csv.gz")) #written out by centroid_correlations.bigcat.R
  16. h5ad_base %<>% mutate(slice = as.numeric(gsub(".*[.]", "", brain_section_label)))
  17. h5ad_base
  18. #uncomment/comment the below lines to generate data for the different top hit sets
  19. top_hits <- read_csv(paste0(base_folder, "top_hits.0.95.csv"))
  20. #top_hits <- read_csv(paste0(base_folder, "top_hits_asymmetric.0.99.best_vs_next.0.6.filtered.csv"))
  21. #Zeng_markers_on_Macosko_one_to_one_mapping.csv
  22. #top_hits <- read_csv(here("results/marker_results/Top_hit_format_for_Zeng_markers_on_Macosko_one_to_one_mapping.csv"))
  23. if ("...1" %in% colnames(top_hits)) { top_hits %<>% select(-`...1`) }
  24. top_hits %<>% rowwise() %>% mutate(first = sort(c(`Study_ID|Celltype_1`, `Study_ID|Celltype_2`))[2],
  25. second = sort(c(`Study_ID|Celltype_1`, `Study_ID|Celltype_2`))[1])
  26. top_hits %<>% mutate(`Study_ID|Celltype_1` = first, `Study_ID|Celltype_2` = second)
  27. top_hits %<>% select(-first, -second)
  28. top_hits %>% group_by(Match_type) %>% count()
  29. top_hits %<>% filter(Match_type == "Reciprocal_top_hit")
  30. top_hits %>% nrow()
  31. top_hits %<>% mutate(merged_name = paste0(`Study_ID|Celltype_1`, "__", `Study_ID|Celltype_2`))
  32. Zeng_calls_direct <- read_csv(here("data","whole_mouse_brain", "zeng", "MERFISH-C57BL6J-638850", "20230830", "cell_metadata.csv"))
  33. Zeng_calls_direct %>% pull(cluster_alias) %>% max() #confirm it's in the cl ID space
  34. Zeng_calls_direct %<>% mutate(cluster_alias = as.character(cluster_alias))
  35. Zeng_calls_direct %>% pull(cluster_alias) %>% unique() %>% length()
  36. Zeng_calls_direct %>% pull(average_correlation_score) %>% min() #confirm the threshold
  37. Zeng_calls_direct %<>% mutate(cluster_alias = paste0("Zeng|", cluster_alias))
  38. Zeng_calls_direct %<>% left_join(top_hits %>% select(cluster_alias = `Study_ID|Celltype_1`, merged_name))
  39. #add in merged name
  40. Zeng_calls_direct %<>% select(cell_label, x, y, z, Celltype_Zeng = cluster_alias, Zeng_merged_name = merged_name)
  41. #join with h5ad to cover all cells
  42. joined <- left_join(h5ad_base, Zeng_calls_direct)
  43. Macosko_calls_direct <- read_csv(here("results/MERFISH500/Macosko_predictions/joined_scores.df.full.csv"))
  44. Macosko_calls_direct %>% pull(prob) %>% min()
  45. Macosko_calls_direct %<>% filter(average_correlation_score > 0.5) #mirroring the Zeng threshold
  46. Macosko_calls_direct %>% pull(prob) %>% min()
  47. Macosko_calls_direct %>% pull(prob) %>% hist()
  48. Macosko_calls_direct %>% pull(average_correlation_score) %>% min()
  49. Macosko_calls_direct %<>% rename(cell_label = cell_id)
  50. Macosko_calls_direct %<>%
  51. separate(pred.cl, into = c("id", "Celltype_Macosko"), sep = "=")
  52. Macosko_calls_direct %<>% mutate(Celltype_Macosko = paste0("Macosko|", Celltype_Macosko))
  53. Macosko_calls_direct %<>% left_join(top_hits %>% select(Celltype_Macosko = `Study_ID|Celltype_2`, merged_name))
  54. Macosko_calls_direct %>% filter(!is.na(merged_name))
  55. Macosko_calls_direct %<>% select(cell_label, Celltype_Macosko, Macosko_merged_name = merged_name)
  56. joined <- left_join(joined, Macosko_calls_direct)
  57. joined %>% group_by(Zeng_merged_name == Macosko_merged_name) %>% count()
  58. joined %>% pull(Celltype_Macosko) %>% unique() %>% length()
  59. joined %>% pull(Celltype_Zeng) %>% unique() %>% length()
  60. joined %>% filter(!is.na(Celltype_Zeng)) %>% nrow()
  61. joined %>% filter(!is.na(Celltype_Macosko)) %>% nrow()
  62. #add in CCF annotations from the API
  63. ccf_annotations <- read_csv(here("data", "whole_mouse_brain", "zeng", "from_API", "ccf_coordinates_MERFISH-C57BL6J-638850.csv.gz"))
  64. base::intersect(joined$cell_label, ccf_annotations$cell_label) %>% length()
  65. ccf_annotations %>% group_by(parcellation_category) %>% count() %>% arrange(-n)
  66. ccf_annotations %>% group_by(parcellation_division) %>% count() %>% arrange(-n) %>% as.data.frame()
  67. ccf_annotations %>% group_by(parcellation_division, parcellation_category) %>% count() %>% arrange(-n) %>% as.data.frame()
  68. ccf_annotations %>% group_by(parcellation_division, parcellation_division_color, parcellation_category) %>% count() %>% arrange(-n) %>% as.data.frame()
  69. #group annotations with same color
  70. ccf_annotations %<>% mutate(parcellation_division_remap = parcellation_division)
  71. #VS is ventricular systems
  72. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(parcellation_category == "VS", "VS", parcellation_division_remap))
  73. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(parcellation_category == "fiber tracts", "fiber tracts", parcellation_division_remap))
  74. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(parcellation_category == "brain-unassigned", "unassigned", parcellation_division_remap))
  75. ccf_annotations %<>% mutate(parcellation_division_color = if_else(parcellation_category == "brain-unassigned", "#000000", parcellation_division_color))
  76. #manual mapping to match up with disscetion regions
  77. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(grepl("^ACA", parcellation_structure), "ACA", parcellation_division_remap))
  78. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(grepl("^RSP", parcellation_structure), "RSP", parcellation_division_remap))
  79. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(grepl("^AUD", parcellation_structure), "AUD", parcellation_division_remap))
  80. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(grepl("^ENT", parcellation_structure), "ENT", parcellation_division_remap))
  81. ccf_annotations %<>% mutate(parcellation_division_remap = if_else("MOp" == parcellation_structure, "MOp", parcellation_division_remap))
  82. ccf_annotations %<>% mutate(parcellation_division_remap = if_else("SUB" == parcellation_structure, "SUB", parcellation_division_remap))
  83. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(grepl("^SSp", parcellation_structure), "S1", parcellation_division_remap))
  84. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(grepl("^VIS", parcellation_structure), "VIS", parcellation_division_remap))
  85. ccf_annotations %<>% mutate(parcellation_division_remap = if_else("VISp" == parcellation_structure, "VISP", parcellation_division_remap))
  86. ccf_annotations %<>% mutate(parcellation_division_remap = if_else("MY" == parcellation_division, "BS", parcellation_division_remap))
  87. ccf_annotations %<>% mutate(parcellation_division_remap = if_else("P" == parcellation_division, "BS", parcellation_division_remap))
  88. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(parcellation_division == "STR"& parcellation_structure %in% c("LSc","LSr","LSv","SF","SH"),
  89. "LSX", parcellation_division_remap))
  90. ccf_annotations %<>% mutate(parcellation_division_remap = if_else(parcellation_division == "STR"& parcellation_structure %in% c("CP"),
  91. "STRd", parcellation_division_remap))
  92. ccf_annotations %>% group_by(parcellation_division, parcellation_division_color, parcellation_category, parcellation_division_remap) %>% count() %>% arrange(-n) %>% as.data.frame()
  93. ccf_annotations %>% group_by(parcellation_division_color, parcellation_division_remap) %>% count() %>% arrange(-n) %>% as.data.frame()
  94. colnames(ccf_annotations)
  95. joined %<>% left_join(ccf_annotations)
  96. #write out for Figure_3_examine_MERFISH_recip_centroids.R - could be reduced in size by filtering NA's
  97. joined %>% write_csv(paste0(base_folder, "spatial_per_cell_data.", top_hits %>% nrow(), "_pairs.csv.gz"))
  98. joined %<>% mutate(matching_reciprocal = Zeng_merged_name == Macosko_merged_name)
  99. joined %>% pull(matching_reciprocal) %>% sum(na.rm=T)
  100. joined %>% filter(matching_reciprocal) %>% group_by(Macosko_merged_name) %>% count() %>% arrange(-n)
  101. joined %>% group_by(is.na(parcellation_index), matching_reciprocal) %>% count()
  102. #this is filtered on the Zeng side
  103. slice_summary <- joined %>% group_by(slice) %>% summarize(total_cells = n(),
  104. Zeng_calls = sum(!is.na(Celltype_Zeng))/total_cells,
  105. Mac_calls = sum(!is.na(Celltype_Macosko))/total_cells,
  106. Zeng_recip_calls = sum(!is.na(Zeng_merged_name))/total_cells,
  107. Mac_recip_calls = sum(!is.na(Macosko_merged_name))/total_cells,
  108. matching_reciprocal = sum(matching_reciprocal, na.rm=T)/total_cells,
  109. unique_merged_names = na.omit(union(Zeng_merged_name, Macosko_merged_name)) %>% unique() %>% length(),
  110. unique_clusters_all = na.omit(union(Celltype_Zeng, Celltype_Macosko)) %>% unique() %>% length(),
  111. proportion_merged_names = unique_merged_names/na.omit(union(joined$Zeng_merged_name, joined$Macosko_merged_name)) %>% unique() %>% length(),
  112. proportion_clusters_seen = unique_clusters_all/na.omit(union(joined$Celltype_Zeng, joined$Celltype_Macosko)) %>% unique() %>% length()
  113. )
  114. cor.test(slice_summary$proportion_clusters_seen, slice_summary$proportion_merged_names) #0.96 correlation
  115. cor.test(slice_summary$proportion_clusters_seen, slice_summary$matching_reciprocal, m='s') #0.5 correlation
  116. #write out
  117. slice_summary %>% select(slice, total_cells, proportion_Zeng_recip_calls = Zeng_recip_calls, proportion_Mac_recip_calls = Mac_recip_calls, cells_with_matching_reciprocal_calls = matching_reciprocal,
  118. detected_reciprocal_clusters = unique_merged_names, proportion_of_all_reciprocals = proportion_merged_names) %>% write_csv(paste0(base_folder, "spatial_slice_stats.", top_hits %>% nrow(), "_pairs.csv"))
  119. correlation <- cor(slice_summary$unique_clusters_all, slice_summary$matching_reciprocal,m='s')
  120. for_line_plot <- slice_summary %>% select(slice,matching_reciprocal,proportion_clusters_seen) %>% pivot_longer(cols=c(matching_reciprocal, proportion_clusters_seen))
  121. for_line_plot %<>% mutate(name = if_else(name == "matching_reciprocal", "MERFISH cells mapped to reciprocal pairs","Clusters detected"))
  122. for_line_plot %<>% mutate(slice_factor = factor(slice, levels = for_line_plot %>% pull(slice) %>% unique() %>% sort(decreasing = T)))
  123. for_line_plot %<>% mutate(slice_numeric = as.numeric(slice_factor))
  124. target_slices <- for_line_plot %>% filter(slice_factor %in% c(14, 24, 40, 60)) %>% pull(slice_factor) %>% unique()
  125. target_slices_numeric <- for_line_plot %>% filter(slice_factor %in% c(14, 24, 40, 60)) %>% pull(slice_numeric) %>% unique()
  126. pdf(paste0(base_folder, "spatial_slice_stats.", top_hits %>% nrow(), "_pairs.pdf"), height=5, width = 11)
  127. ggplot(data= for_line_plot, aes(x=slice_numeric, y=value, color = name)) +
  128. #geom_vline(xintercept = target_slices_numeric, color="darkgray") +
  129. geom_line() + geom_point() +
  130. theme_bw() + theme(legend.position = "right") + labs(color="") + ylab("Proportion") +
  131. xlab("Slice") + scale_x_continuous(labels = c("Anterior", "Posterior"), breaks = c(1,59)) +
  132. annotate("text",
  133. x = 1,
  134. y = 0.6,
  135. label = paste0("r: ", correlation %>% format(digits = 2)),
  136. hjust = 0,
  137. vjust = 1
  138. ) + scale_color_manual(values=c("#795695", "#f2ba88"))
  139. dev.off()
  140. for_line_plot %>% write_csv(paste0(base_folder, "/figure_source_data_files/Figure_3d.csv"))
  141. #split by the two datasets
  142. total_Zeng <- joined$Celltype_Zeng %>% unique() %>% length()
  143. total_Mac <- joined$Celltype_Macosko %>% unique() %>% length()
  144. #need to set some Zeng cell types to NA to match size
  145. joined_cell_count_matched <- joined
  146. joined_cell_count_matched %<>% select(cell_label, slice, Celltype_Zeng, Celltype_Macosko)
  147. IDs_to_remove_calls <- joined_cell_count_matched %>% filter(!is.na(Celltype_Zeng)) %>% sample_n(joined_cell_count_matched %>% filter(!is.na(Celltype_Macosko)) %>% nrow()) %>% pull(cell_label)
  148. joined_cell_count_matched %<>% mutate(Celltype_Zeng = if_else(cell_label %in% IDs_to_remove_calls, Celltype_Zeng, NA))
  149. joined_cell_count_matched %>% group_by(!is.na(Celltype_Zeng)) %>% count()
  150. joined_cell_count_matched %>% group_by(!is.na(Celltype_Macosko)) %>% count()
  151. #need to match the same number of cells for Zeng as Macosko
  152. slice_summary_extra_counts <- joined_cell_count_matched %>% group_by(slice) %>% summarize(
  153. unique_clusters_Zeng = na.omit(Celltype_Zeng) %>% unique() %>% length(),
  154. unique_clusters_Mac = na.omit(Celltype_Macosko) %>% unique() %>% length(),
  155. value = unique_clusters_Zeng/total_Zeng,
  156. unique_clusters_Mac_prop = unique_clusters_Mac/total_Mac,
  157. detected_cluster_difference = unique_clusters_Zeng - unique_clusters_Mac
  158. )
  159. cor.test(slice_summary_extra_counts$unique_clusters_Mac, slice_summary_extra_counts$unique_clusters_Zeng,m='s')
  160. #add in reciprocal best hits
  161. slice_summary_extra_counts %<>% inner_join(slice_summary %>% select(slice, matching_reciprocal))
  162. cor.test(slice_summary_extra_counts$detected_cluster_difference, slice_summary_extra_counts$matching_reciprocal, m='s')
  163. cor.test(slice_summary_extra_counts$unique_clusters_Zeng, slice_summary_extra_counts$matching_reciprocal, m='s')
  164. cor.test(slice_summary_extra_counts$unique_clusters_Mac, slice_summary_extra_counts$matching_reciprocal, m='s')
  165. plot(slice_summary_extra_counts$detected_cluster_difference, slice_summary_extra_counts$matching_reciprocal, m='s')
  166. correlation <- cor(slice_summary_extra_counts$detected_cluster_difference, slice_summary_extra_counts$matching_reciprocal, m='s')
  167. pdf(paste0(base_folder, "spatial_cluster_count_vs_recips.pdf"), height=5, width = 5)
  168. ggplot(data = slice_summary_extra_counts, aes(x = detected_cluster_difference, y = matching_reciprocal)) +
  169. geom_point() + theme_bw() +
  170. xlab("Diversity mismatch\n(excess clusters detected in cells vs. nuclei derived mappings)") +
  171. ylab("Reproducable cell calls\n(proportion of cells with matching reciprocal status)") +
  172. annotate("text",
  173. x = 700,
  174. y = 0.45,
  175. label = paste0("r: ", correlation %>% format(digits = 2)),
  176. hjust = 0,
  177. vjust = 1
  178. )
  179. dev.off()
  180. slice_summary_extra_counts %>% write_csv(paste0(base_folder, "/figure_source_data_files/Figure_3e.csv"))
  181. #it would be better if we had x y z for all cells - missing 394k that weren't mapped in Zeng
  182. joined %>% filter(is.na(x)) %>% nrow()
  183. for_plot <- joined %>% filter(!is.na(x)) %>% select(cell_label, x, y, Celltype_Macosko, Celltype_Zeng, Zeng_merged_name, Macosko_merged_name, slice, matching_reciprocal)
  184. # Plot one reciprocal
  185. for_plot %<>% filter(slice %in% c(18,19))
  186. for_plot %<>% mutate(slice = paste0("Slice ", slice))
  187. for_plot %>% filter(Zeng_merged_name == "Zeng|2670__Macosko|CholEx_Tcf24_Oxtr")
  188. #find small set of cells with recip match
  189. #CholEx_Tcf24_Oxtr
  190. joined %>% filter(Celltype_Macosko == "Macosko|CholEx_Tcf24_Oxtr") %>% pull(Zeng_merged_name) %>% length()
  191. joined %>% filter(Celltype_Macosko == "Macosko|CholEx_Tcf24_Oxtr") %>% group_by(Celltype_Zeng) %>% count()
  192. joined %>% filter(Celltype_Macosko == "Macosko|CholEx_Tcf24_Oxtr") %>% group_by(slice) %>% count()
  193. joined %>% filter(Zeng_merged_name == "Zeng|2670__Macosko|CholEx_Tcf24_Oxtr")%>% group_by(slice) %>% count()
  194. joined %>% filter(Celltype_Zeng == "Zeng|2670") %>% group_by(Celltype_Zeng) %>% count()
  195. pdf(paste0(base_folder, "spatial_CholEx_Tcf24_Oxtr.pdf"), height=5, width = 10)
  196. ggplot(data = for_plot, aes(x=x, y=-1*y)) + geom_point(size=.03, color ="gray90") + theme_classic() +
  197. #geom_point(data = for_plot %>% filter(Celltype_Macosko == "Macosko|CholEx_Tcf24_Oxtr", Zeng_merged_name != "Zeng|2670__Macosko|CholEx_Tcf24_Oxtr"), size = 0.7, color="#E21E25") + #c("#4450A2", "#E21E25"))
  198. geom_point(data = for_plot %>% filter(Zeng_merged_name == "Zeng|2670__Macosko|CholEx_Tcf24_Oxtr"), size = 0.9, color="black") +
  199. geom_point(data = for_plot %>% filter(Celltype_Zeng == "Zeng|2670", is.na(Celltype_Macosko) | Celltype_Macosko != "Macosko|CholEx_Tcf24_Oxtr"), size = 0.9, color="#4450A2") + #c("#4450A2", "#E21E25"))
  200. coord_equal() + theme(legend.position="none") +
  201. facet_wrap(. ~ slice) +
  202. theme(axis.title.x=element_blank(),
  203. axis.text.x=element_blank(),
  204. axis.ticks.x=element_blank()) +
  205. theme(axis.title.y=element_blank(),
  206. axis.text.y=element_blank(),
  207. axis.ticks.y=element_blank()) +
  208. theme(
  209. axis.line = element_line(color = 'white'),
  210. plot.background = element_blank(),
  211. panel.grid.minor = element_blank(),
  212. panel.grid.major = element_blank(),
  213. panel.border = element_blank()
  214. )
  215. dev.off()
  216. #Figure 5 plotting three clusters that lined up with the BARseq data. The Macosko data is pulled manually from the website.
  217. for_plot <- joined %>% filter(!is.na(x)) %>% select(cell_label, x, y, Celltype_Macosko, Celltype_Zeng, Zeng_merged_name, Macosko_merged_name, slice, matching_reciprocal)
  218. target_clusters_for_pdf <- c("2866", "5231", "4218")
  219. target_cluster <- "4218"
  220. target_cluster <- paste0("Zeng|", target_cluster)
  221. max_slice <- for_plot %>% filter(Celltype_Zeng == target_cluster) %>% group_by(slice) %>% count() %>% ungroup() %>% slice_max(n) %>% pull(slice)
  222. if (target_cluster == "Zeng|4218") { max_slice <- 24 } #this slice best fits the barseq
  223. if (target_cluster == "Zeng|5231") { max_slice <- 30 } #this slice best fits the barseq
  224. pdf(paste0(base_folder, "spatial_", target_cluster,"_slice_", max_slice,".pdf"), height=5, width = 6)
  225. for_plot <- joined %>% filter(!is.na(x)) %>% select(cell_label, x, y, Celltype_Macosko, Celltype_Zeng, Zeng_merged_name, Macosko_merged_name, slice, matching_reciprocal)
  226. for_plot %<>% filter(slice == max_slice)
  227. ggplot(data = for_plot, aes(x=x, y=-1*y)) + geom_point(size=.03, color ="gray90") + theme_classic() +
  228. geom_point(data = for_plot %>% filter(Celltype_Zeng == target_cluster), size = 0.15, color="#4450A2") +
  229. coord_equal() + theme(legend.position="none") +
  230. theme(axis.title.x=element_blank(),
  231. axis.text.x=element_blank(),
  232. axis.ticks.x=element_blank()) +
  233. theme(axis.title.y=element_blank(),
  234. axis.text.y=element_blank(),
  235. axis.ticks.y=element_blank()) +
  236. theme(
  237. axis.line = element_line(color = 'white'),
  238. plot.background = element_blank(),
  239. panel.grid.minor = element_blank(),
  240. panel.grid.major = element_blank(),
  241. panel.border = element_blank()
  242. )
  243. dev.off()
  244. ## plot the reciprocal hit cells
  245. for_plot <- joined %>% filter(!is.na(x)) %>% select(cell_label, x, y, Zeng_merged_name, Macosko_merged_name, slice, matching_reciprocal, parcellation_division_remap, parcellation_division_color)
  246. #convert na's to unassigned
  247. for_plot %<>% mutate(parcellation_division_remap = if_else(is.na(parcellation_division_remap), "unassigned", parcellation_division_remap))
  248. for_plot %<>% mutate(parcellation_division_color = if_else(is.na(parcellation_division_color), "#000000", parcellation_division_color))
  249. set.seed(42)
  250. for_plot %>% filter(slice == 40) %>% group_by(matching_reciprocal) %>% count()
  251. #target_slices <- c(14, 24, 40, 60)
  252. #target_slices <- c("46", '45', '43', '42' ,"40", '39','38', "37")
  253. for_plot %<>% filter(slice %in% target_slices)
  254. for_plot %>% pull(slice) %>% unique() %>% length()
  255. for_plot %<>% mutate(slice_factor = factor(slice, levels = for_plot %>% pull(slice) %>% unique() %>% sort(decreasing = T)))
  256. for_plot %<>% mutate(matching_reciprocal = if_else(is.na(matching_reciprocal), FALSE, matching_reciprocal))
  257. pdf(paste0(base_folder, "spatial_four_recips.", top_hits %>% nrow(), "_pairs.pdf"), height=7, width = 30)
  258. ggplot(data = for_plot, aes(x = x, y = -1 * y, color = factor(matching_reciprocal))) +
  259. geom_point(size=.02) +
  260. geom_point(data = for_plot %>% filter(matching_reciprocal), size = 0.02, color="black") +
  261. theme_classic() +
  262. coord_equal() +
  263. facet_wrap(. ~ slice_factor, nrow = 1) +
  264. theme(
  265. axis.title.x = element_blank(),
  266. axis.text.x = element_blank(),
  267. axis.ticks.x = element_blank(),
  268. axis.title.y = element_blank(),
  269. axis.text.y = element_blank(),
  270. axis.ticks.y = element_blank(),
  271. axis.line = element_line(color = 'white'),
  272. plot.background = element_blank(),
  273. panel.grid.minor = element_blank(),
  274. panel.grid.major = element_blank(),
  275. panel.border = element_blank()
  276. ) +
  277. scale_color_manual(
  278. values = c("gray", "black"),
  279. labels = c("Non-matching", "Matching"),
  280. name = "Reciprocal status",
  281. guide = guide_legend(override.aes = list(size = 5))
  282. )
  283. dev.off()
  284. #Coarse region atlas color
  285. for_plot %<>% filter(!parcellation_division_remap %in% c("fiber tracts", "unassigned", "VS"))
  286. region_colors <- for_plot %>% select(parcellation_division_remap, parcellation_division_color) %>% distinct() %>% as.data.frame()
  287. #division colored, all points with data
  288. pdf(paste0(base_folder, "MERFISH_colored_divsions.pdf"), height=7, width = 30)
  289. ggplot(data = for_plot, aes(x = x, y = -1 * y, color = parcellation_division_color)) +
  290. geom_point(size = 0.02) +
  291. scale_color_identity(
  292. name = "Structure",
  293. labels = region_colors$parcellation_division_remap,
  294. breaks = region_colors$parcellation_division_color,
  295. guide = guide_legend(override.aes = list(size = 5))
  296. #guide = 'legend'
  297. ) +
  298. coord_equal() +
  299. theme_classic() +
  300. facet_wrap(. ~ slice_factor, nrow = 1) +
  301. theme(
  302. axis.title.x = element_blank(),
  303. axis.text.x = element_blank(),
  304. axis.ticks.x = element_blank(),
  305. axis.title.y = element_blank(),
  306. axis.text.y = element_blank(),
  307. axis.ticks.y = element_blank(),
  308. axis.line = element_line(color = 'white'),
  309. plot.background = element_blank(),
  310. panel.grid.minor = element_blank(),
  311. panel.grid.major = element_blank(),
  312. panel.border = element_blank()
  313. )
  314. dev.off()
  315. ################################
  316. ################################
  317. #cut up into bins for heatmap view
  318. ################################
  319. ################################
  320. for_plot <- joined %>% filter(!is.na(x)) %>% select(cell_label, x, y, slice, matching_reciprocal)
  321. for_plot %>% pull(x) %>% range()
  322. for_plot %>% pull(y) %>% range()
  323. ratio <- (max(for_plot %>% pull(y)) - min(for_plot %>% pull(y)))/(max(for_plot %>% pull(x)) - min(for_plot %>% pull(x)))
  324. x_bins = 110
  325. y_bins = round(x_bins * ratio)
  326. for_plot %<>% mutate(bin_x = cut_interval(x, n = x_bins))
  327. for_plot %<>% mutate(bin_y = cut_interval(-1*y, n = y_bins))
  328. for_plot %<>% group_by(bin_x, bin_y, slice) %>% summarize(n=n(), prop_recip = sum(matching_reciprocal, na.rm=T)/n())
  329. for_plot %<>% filter(slice %in% target_slices)
  330. for_plot %<>% mutate(slice_factor = factor(slice, levels = for_plot %>% pull(slice) %>% unique() %>% sort(decreasing = T)))
  331. pdf(paste0(base_folder, "spatial_four_recips_proportions.", top_hits %>% nrow(), "_pairs.pdf"), height=7, width = 32)
  332. ggplot(data=for_plot, aes(x=bin_x, y=bin_y, fill = prop_recip) ) +
  333. geom_tile() + scale_fill_continuous(type = "viridis", na.value='white') + theme_bw() +
  334. labs(fill = "P(reciprocal match)") + coord_equal(expand=FALSE) +
  335. theme(axis.title.x=element_blank(),
  336. axis.text.x=element_blank(),
  337. axis.ticks.x=element_blank()) +
  338. theme(axis.title.y=element_blank(),
  339. axis.text.y=element_blank(),
  340. axis.ticks.y=element_blank()) +
  341. theme(
  342. axis.line = element_line(color = 'white'),
  343. plot.background = element_blank(),
  344. panel.grid.minor = element_blank(),
  345. panel.grid.major = element_blank(),
  346. panel.border = element_blank()
  347. ) + facet_wrap(.~slice_factor, nrow=1)
  348. dev.off()
  349. ##########################
  350. #test enrichment by coarse region
  351. ###########################
  352. joined %<>% mutate(matching_reciprocal = if_else(is.na(matching_reciprocal), FALSE, matching_reciprocal))
  353. whole_dataset <- joined %>% group_by(matching_reciprocal) %>% count()
  354. whole_dataset %<>% pivot_wider(names_from=matching_reciprocal, values_from=n, names_prefix = "dataset_recip_hit_")
  355. by_region <- joined %>% mutate(parcellation_division_remap = if_else(is.na(parcellation_division_remap), "unassigned", parcellation_division_remap)) %>%
  356. group_by(parcellation_division_remap, matching_reciprocal) %>% count()
  357. by_region %<>% pivot_wider(names_from=matching_reciprocal, values_from=n, names_prefix = "recip_hit_")
  358. by_region %<>% mutate(dataset_recip_hit_FALSE = whole_dataset %>% pull(dataset_recip_hit_FALSE))
  359. by_region %<>% mutate(dataset_recip_hit_TRUE = whole_dataset %>% pull(dataset_recip_hit_TRUE))
  360. by_region %<>% mutate(total_cells_in_region = recip_hit_TRUE + recip_hit_FALSE)
  361. by_region %<>% mutate(percent_recip = recip_hit_TRUE / total_cells_in_region)
  362. by_region %<>% ungroup() %>% mutate(dataset_total_cells = sum(total_cells_in_region))
  363. by_region %<>% mutate(dataset_prop_recip = dataset_recip_hit_TRUE/ dataset_total_cells)
  364. #duplicaed code from regional_enrichment_tests
  365. by_region %<>% mutate(p_enriched = phyper(recip_hit_TRUE, dataset_recip_hit_TRUE, dataset_recip_hit_FALSE, total_cells_in_region, lower.tail = FALSE) +
  366. dhyper(recip_hit_TRUE, dataset_recip_hit_TRUE, dataset_recip_hit_FALSE, total_cells_in_region))
  367. by_region %<>% mutate(p_depleted = phyper(recip_hit_TRUE, dataset_recip_hit_TRUE, dataset_recip_hit_FALSE, total_cells_in_region, lower.tail = TRUE))
  368. by_region %<>% mutate(difference_from_dataset_average = percent_recip-dataset_prop_recip)
  369. by_region %>% as.data.frame()
  370. by_region %<>% mutate(Dataset= "MERFISH")
  371. by_region %<>% mutate(fold_change = percent_recip/dataset_prop_recip) #not used
  372. by_region %<>% ungroup()
  373. dir.create(here(base_folder, "top_hit_enrichments"))
  374. #used for plotting in regional_enrichment_tests.R
  375. by_region %>% write_csv(here(base_folder, "top_hit_enrichments", paste0("MERFISH_regional_enrichment_results.", top_hits %>% nrow(), "_pairs.csv")))

Figure_3_examine_MERFISH_calls_for_recips.R at commit 36d803e, under MIT · at the source

Overview

  1. Department of Physiology and Terrence Donnelly Centre for Cellular and Biomolecular Research, University of Toronto,Toronto, ON Canada
Institutions: University of Toronto (Canada)
Journal: Nature communications, volume 17, issue 1, article 7869
Dates: received 10 April 2025; accepted 28 May 2026; published online 23 June 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41467-026-74171-0 · PMID 42331798 · PMCID PMC13444128 · OpenAlex W4407932243
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: genetics / omics (modality), mouse (organism), cellular / molecular (subfield)
Methods: Preprocessing, Machine learning
Keywords: Molecular neuroscience, Cellular neuroscience, Genetics of the nervous system
MeSH: Brain*, Cell Nucleus*, Single-Cell Analysis*, Animals, Cluster Analysis, Gene Expression Profiling, Mice, Sequence Analysis, RNA, Single-Cell Gene Expression Analysis, Transcriptome (* major topic)
Topic: Single-cell and spatial transcriptomics (Molecular Biology, Biochemistry, Genetics and Molecular Biology), according to OpenAlex
Funding: National Institute of Mental Health (U24MH130968, R01MH133181, R01MH113005)
Citations: not cited yet (Europe PMC); 43 references in the paper
Research resources: The study used 317 adult C57BL/6J RRID:IMSR_JAX:000664, Gene Ontology RRID:SCR_002811, RRID:SCR_016727, The December 2023 version of SynGO RRID:SCR_017330, The provided Common Coordinate Framework RRID:SCR_020999, RRID:SCR_021162, RRID:SCR_024440

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.

Repositories

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

gillislab/mouse_brain_cluster_replicability

License: MIT
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 36d803ebff43d0df95c01c94a7d832f15af28a58, 29 April 2026
Languages: R (29), Jupyter (21)
Size: 238 files, 50 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, 21 notebooks
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: tidyverse (28 files), anndata (21 files), NumPy (21 files), pandas (21 files), Scanpy (21 files), ggplot2 (19 files), reshape2 (13 files), SciPy (6 files), SingleCellExperiment (6 files), circlize (2 files), data.table (2 files), ComplexHeatmap (1 file), igraph (1 file), Seurat (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
52 files

Zenodo 19901057

License: MIT
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
At the source:

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-74171-0.

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;
  • 50 scripts, each with its path and the digest of its content;
  • 18 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 paper has a 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-74171-0.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 3 authors, 3 keywords, 10 MeSH terms, 1 funder, 40 references, 7 RRIDs.

Cite

This paper

French, L., Suresh, H., & Gillis, J. (2026). Cluster replicability in single-cell and single-nucleus atlases of the mouse brain. Nature communications, 17(1), 7869. https://doi.org/10.1038/s41467-026-74171-0

BibTeX

@article{french2026cluster,
author = {French, Leon and Suresh, Hamsini and Gillis, Jesse},
title = {{Cluster replicability in single-cell and single-nucleus atlases of the mouse brain}},
journal = {Nature communications},
year = {2026},
month = jun,
volume = {17},
number = {1},
pages = {7869},
publisher = {Nature Publishing Group},
issn = {2041-1723},
doi = {10.1038/s41467-026-74171-0},
url = {https://doi.org/10.1038/s41467-026-74171-0},
pmid = {42331798},
pmcid = {PMC13444128}
}

RIS

TY - JOUR
AU - French, Leon
AU - Suresh, Hamsini
AU - Gillis, Jesse
TI - Cluster replicability in single-cell and single-nucleus atlases of the mouse brain
T2 - Nature communications
J2 - Nat Commun
PY - 2026
DA - 2026/06/23
VL - 17
IS - 1
SP - 7869
SN - 2041-1723
PB - Nature Publishing Group
DO - 10.1038/s41467-026-74171-0
UR - https://doi.org/10.1038/s41467-026-74171-0
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41467-026-74171-0",
"type": "article-journal",
"title": "Cluster replicability in single-cell and single-nucleus atlases of the mouse brain",
"container-title": "Nature communications",
"author": [
{
"family": "French",
"given": "Leon"
},
{
"family": "Suresh",
"given": "Hamsini"
},
{
"family": "Gillis",
"given": "Jesse"
}
],
"container-title-short": "Nat Commun",
"volume": "17",
"issue": "1",
"page": "7869",
"DOI": "10.1038/s41467-026-74171-0",
"PMID": "42331798",
"PMCID": "PMC13444128",
"ISSN": "2041-1723",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41467-026-74171-0",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
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.1126/sciadv.aeg3223 [code]
The extreme diversity of retinal amacrine cells has deep evolutionary roots.
Journal: Science advances
In common: anndata, igraph, circlize, 10 other tools, genetics / omics, cellular / molecular, 4 references
[2] doi:10.1371/journal.pbio.3003757 [code]
Cell type-agnostic transcriptomic signatures enable uniform comparisons of neural maturation.
Journal: PLoS biology
In common: anndata, igraph, circlize, 8 other tools, genetics / omics, mouse, 2 references, author Jesse Gillis
[3] doi:10.1038/s42003-026-10034-0 [code]
Region- and cell type-specific changes in gene expression in the cerebellum after classical fear conditioning.
Journal: Communications biology
In common: SingleCellExperiment, anndata, circlize, 10 other tools, genetics / omics, mouse, cellular / molecular, 2 references
[4] 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: SingleCellExperiment, anndata, igraph, 11 other tools, genetics / omics, cellular / molecular, 1 reference
[5] doi:10.1186/s13059-026-04177-w [code]
Genomic sequence evolution underlying human neocortical interareal diversification.
Journal: Genome biology
In common: anndata, igraph, circlize, 10 other tools, genetics / omics, mouse, cellular / molecular, 2 references
[6] doi:10.1002/imt2.70163 [code]
Spatial multi-omics unveils sphingolipid metabolic reprogramming within the retinal pathological niche.
Journal: iMeta
In common: SingleCellExperiment, anndata, igraph, 11 other tools, genetics / omics, mouse, cellular / molecular
[7] doi:10.1038/s41586-026-10214-2 [code]
Multidimensional profiling of heterogeneity in supratentorial ependymomas.
Journal: Nature
In common: SingleCellExperiment, anndata, igraph, 11 other tools, genetics / omics, mouse
[8] doi:10.1016/j.xcrm.2026.102651 [code]
Integrative CSF profiling identifies disease-specific immune responses in leptomeningeal disease.
Journal: Cell reports. Medicine
In common: SingleCellExperiment, anndata, igraph, 11 other tools, genetics / omics, cellular / molecular
[9] doi:10.1038/s41586-026-10629-x [code]
Whole-genome duplication shaped cell-type evolution in the vertebrate brain.
Journal: Nature
In common: anndata, igraph, circlize, 8 other tools, genetics / omics, mouse, cellular / molecular, 3 references
[10] doi:10.1038/s41592-026-03194-8 [code]
Beyond benchmarking: an expert-guided consensus approach to spatially aware clustering.
Journal: Nature methods
In common: SingleCellExperiment, anndata, igraph, 9 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.