OSCR

Wnt activation and dual SMAD inhibition for induction and maintenance of hindbrain-like neural stem cell from hiPSCs.

Code ↔ Paper

3 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 3 matches
  1. [1] § Results › scRNA-seq of early- and late-passage number Hb-LiNSCs reveals distinct cell populations ↔ scRNAseq_HbL-iNSCs.ipynb, lines 702 to 730 · score 0.73 · stem cells, HOXB8, HES5, HOXB2, NES, HOXB7 · Report a mismatch
  2. [2] § Results › Induction of Hb-LiNSCs ↔ scRNAseq_HbL-iNSCs.ipynb, lines 427 to 470 · score 0.69 · cellular component, biological process, upregulated genes, Augmented, GO, PanglaoDB · Report a mismatch
  3. [3] § Results › Transcriptional differences between early- and late-passage Hb-LiNSCs ↔ scRNAseq_HbL-iNSCs.ipynb, lines 427 to 470 · score 0.60 · GO biological process, upregulated genes, Augmented, PanglaoDB, human, Hb · 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

Jupyter notebook · 1,188 lines · 37 KB · CC-BY-4.0 · 3 matches

  1. # %%
  2. import scanpy as sc #important note: the source code for scanpy heatmap was modified locally to suite the visual preferences (Ziadoon Al-Akashi)
  3. import anndata as ad
  4. import numpy as np
  5. import pandas as pd
  6. import matplotlib.pyplot as plt
  7. import seaborn as sns
  8. from sklearn.preprocessing import StandardScaler
  9. import os
  10. from matplotlib.colors import Normalize
  11. import gseapy as gp
  12. from typing import Union, Optional, Tuple, Mapping
  13. from matplotlib.colors import Normalize
  14. import matplotlib.gridspec as gridspec
  15. from matplotlib.patches import Patch
  16. from matplotlib.lines import Line2D
  17. # %% [markdown]
  18. # # Reading and processing
  19. # %%
  20. data_folder = 'E:/scRNA seq Data/'
  21. # %%
  22. ribo_url = "http://software.broadinstitute.org/gsea/msigdb/download_geneset.jsp?geneSetName=KEGG_RIBOSOME&fileType=txt"
  23. ribo_genes = pd.read_table(ribo_url, skiprows=2, header = None, names=['gene'])
  24. ribo_genes
  25. # %%
  26. all_adata = []
  27. h5_paths = [
  28. data_folder + 'ACL_iNSCs_PN5',
  29. data_folder + 'ACL_iNSCs_PN21',
  30. data_folder + 'ACL_iNSCs_PN41',
  31. data_folder + 'ACL_iNSCs_PN59',
  32. ]
  33. # %%
  34. def read_and_append_data(path, all_adata):
  35. adata = sc.read_10x_mtx(path, var_names="gene_symbols", cache=True)
  36. sample_name = path.split('_')[2]
  37. adata.obs['Sample'] = sample_name
  38. all_adata.append(adata)
  39. def process_data(all_adata, ribo_genes):
  40. for i, adata in enumerate(all_adata):
  41. print(f"Before filtering - Number of cells: {adata.n_obs}")
  42. sc.pp.filter_cells(adata, min_genes=400)
  43. adata.var['mt'] = adata.var_names.str.startswith('MT-')
  44. adata.var['ribo'] = adata.var_names.isin(ribo_genes['gene'])
  45. sc.pp.calculate_qc_metrics(adata, qc_vars=['mt', 'ribo'], percent_top=None, log1p=False, inplace=True)
  46. upper_lim = np.quantile(adata.obs.n_genes_by_counts.values, 0.98)
  47. adata = adata[adata.obs.n_genes_by_counts < upper_lim]
  48. adata = adata[adata.obs.pct_counts_mt < 10, :].copy()
  49. all_adata[i] = adata
  50. print(f"After filtering - Number of cells: {adata.n_obs}")
  51. return all_adata
  52. # %%
  53. for path in h5_paths:
  54. read_and_append_data(path, all_adata)
  55. # %%
  56. processed_data = process_data(all_adata, ribo_genes)
  57. # %%
  58. all_adata[1]
  59. # %%
  60. concatenated_processed_data = ad.concat(all_adata)
  61. # %%
  62. concatenated_processed_data.obs_names_make_unique()
  63. # %%
  64. concatenated_processed_data.obs.sort_values('n_genes_by_counts')
  65. # %%
  66. sc.pl.violin(concatenated_processed_data,
  67. ['n_genes_by_counts', 'total_counts', 'pct_counts_mt', 'pct_counts_ribo'],
  68. jitter=0.4,
  69. multi_panel=True)
  70. # %%
  71. import scrublet as scr
  72. # %%
  73. adata_for_scrublet = concatenated_processed_data.copy()
  74. # %%
  75. scrub = scr.Scrublet(adata_for_scrublet.X)
  76. # %%
  77. doublet_scores, predicted_doublets = scrub.scrub_doublets()
  78. plt.hist(doublet_scores, bins=50, color='blue', edgecolor='black')
  79. plt.xlabel('Doublet Scores')
  80. plt.ylabel('Frequency')
  81. plt.title('Distribution of Doublet Scores')
  82. plt.show()
  83. # %%
  84. concatenated_processed_data.obs['doublet_scores'] = doublet_scores
  85. # %%
  86. concatenated_processed_data = concatenated_processed_data[~predicted_doublets, :]
  87. # %%
  88. adata = concatenated_processed_data.copy()
  89. # %% [markdown]
  90. # # Normalize and highy variable genes
  91. # %%
  92. sc.pp.normalize_total(adata, target_sum=1e4)
  93. sc.pp.log1p(adata)
  94. sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=2, min_disp=0.5)
  95. adata.raw = adata
  96. adata_raw = sc.AnnData(X=adata.raw.X, obs=adata.obs, var=adata.var, uns=adata.uns)
  97. adata = adata[:, adata.var.highly_variable]
  98. # %%
  99. sc.set_figure_params(transparent=True, fontsize=12)
  100. custom_palette = sns.color_palette("hls", 4)
  101. sns.set_palette('colorblind')
  102. # %%
  103. sc.pp.scale(adata, max_value=10)
  104. sc.tl.pca(adata, svd_solver='arpack')
  105. sc.pl.pca_variance_ratio(adata, log=False, n_pcs=50, save=True)
  106. # %%
  107. sc.pl.pca(adata, color='Sample', save='final_PCA_.png')
  108. # %%
  109. adata.obs
  110. # %%
  111. sc.pp.neighbors(adata, n_neighbors=16, n_pcs=20)
  112. # Compute UMAP
  113. sc.tl.umap(adata)
  114. sc.tl.leiden(adata, resolution=0.8)
  115. # %%
  116. file_path = "final_processed_adata.h5ad"
  117. # %%
  118. #adata.write(file_path)
  119. # %%
  120. adata = sc.read(file_path)
  121. # %%
  122. color_s = ['#800000', '#9A6324', '#808000', '#469990', '#000075', '#e6194B', '#f58231', '#ffe119', '#bfef45', '#3cb44b', '#42d4f4', '#4363d8', '#911eb4', '#f032e6', '#a9a9a9', '#fabed4', '#ffd8b1']
  123. legend_handles = [Line2D([0], [0], marker='o', color='w', markerfacecolor=color, markersize=10, label=f'{i}') for i, color in enumerate(color_s)]
  124. fig, ax = plt.subplots(figsize=(1, 1))
  125. ax.axis('off')
  126. ax.legend(handles=legend_handles, ncol=3, loc='center')
  127. plt.savefig('legend_clusters.png', bbox_inches='tight', transparent=True, dpi=300)
  128. plt.show()
  129. # %%
  130. # UMAP Leiden
  131. color_s = ['#800000', '#9A6324', '#808000', '#469990', '#000075','#e6194B', '#f58231', '#ffe119', '#bfef45', '#3cb44b',
  132. '#42d4f4', '#4363d8', '#911eb4', '#f032e6', '#a9a9a9','#fabed4', '#ffd8b1', '#aaffc3', '#dcbeff']
  133. sc.set_figure_params(transparent=True, dpi=80, fontsize=14, dpi_save=300, figsize=(10, 8))
  134. sns.set_palette("deep")
  135. plt.figure(figsize=(10, 8))
  136. sc.pl.umap(adata,
  137. color=['leiden'],
  138. palette=color_s,
  139. use_raw=False,
  140. title=[''],
  141. legend_loc=False,
  142. legend_fontsize=8,
  143. legend_fontoutline=2,
  144. #frameon=False,
  145. size=30,
  146. alpha=1,
  147. linewidth=0.5,
  148. show=False
  149. )
  150. plt.title('Leiden Clusters', fontsize=20)
  151. plt.xlabel('UMAP1', fontsize=20)
  152. plt.ylabel('UMAP2', fontsize=20)
  153. plt.gca().spines['top'].set_visible(False)
  154. plt.gca().spines['right'].set_visible(False)
  155. plt.savefig('final_umap_leiden_res8.png', bbox_inches='tight', dpi=300)
  156. plt.show()
  157. # %%
  158. color_s1 = {'PN5': 'darkred', 'PN21': 'purple', 'PN41': 'darkorange', 'PN59': 'gold'}
  159. # %%
  160. color_s1 = {'PN5': 'darkred', 'PN21': 'purple', 'PN41': 'darkorange', 'PN59': 'gold'}
  161. legend_handles1 = [Line2D([0], [0], marker='o', color='w', markerfacecolor=color, markersize=10, label=label) for label, color in color_s1.items()]
  162. fig, ax = plt.subplots(figsize=(1, 1))
  163. ax.axis('off')
  164. ax.legend(handles=legend_handles1, ncol=1, loc='center')
  165. plt.savefig('legend_clusters_sample.png', bbox_inches='tight', transparent=True, dpi=300)
  166. plt.show()
  167. # %%
  168. # UMAP Samples
  169. sc.set_figure_params(transparent=True, dpi=80, fontsize=14, dpi_save=300, figsize=(10, 8))
  170. sns.set_palette("deep")
  171. plt.figure(figsize=(10, 8))
  172. sc.pl.umap(adata,
  173. color='Sample',
  174. palette=color_s1,
  175. use_raw=False,
  176. title=[''],
  177. legend_loc=False,
  178. size=30,
  179. alpha=0.8,
  180. linewidth=0.5,
  181. show=False
  182. )
  183. #plt.title('Samples', fontsize=20)
  184. plt.xlabel('UMAP1', fontsize=20)
  185. plt.ylabel('UMAP2', fontsize=20)
  186. plt.gca().spines['top'].set_visible(False)
  187. plt.gca().spines['right'].set_visible(False)
  188. plt.savefig('final_umap_sample_res3.png', bbox_inches='tight', dpi=300)
  189. plt.show()
  190. # %%
  191. # Sub UMAP Samples
  192. sc.set_figure_params(transparent=True, dpi=80, fontsize=14, dpi_save=300)
  193. sns.set_palette("deep")
  194. fig, axs = plt.subplots(4, 1, figsize=(2, 5), sharex=True, sharey=True)
  195. sample_groups = ['PN5', 'PN21', 'PN41', 'PN59']
  196. for i, sample_group in enumerate(sample_groups):
  197. ax = axs[i]
  198. sc.pl.umap(adata, color=['Sample'],
  199. groups=[sample_group],
  200. title=[''],
  201. size=2,
  202. alpha=0.8,
  203. linewidth=0.1,
  204. legend_loc=None,
  205. show=False,
  206. ax=ax)
  207. ax.set_xlabel('')
  208. ax.set_ylabel('')
  209. ax.spines['top'].set_visible(True)
  210. ax.spines['right'].set_visible(True)
  211. ax.spines['bottom'].set_visible(True)
  212. ax.spines['left'].set_visible(True)
  213. ax.set_xticks([])
  214. ax.set_yticks([])
  215. ax.set_aspect('equal')
  216. plt.subplots_adjust(hspace=0.05)
  217. plt.savefig('combined_umap_plots_column_with_boxes.png', bbox_inches='tight', dpi=300)
  218. plt.show()
  219. # %%
  220. sample_counts = adata.obs['Sample'].value_counts()
  221. print(sample_counts)
  222. # %%
  223. sample_counts = adata.obs['Sample'].value_counts()
  224. sample_counts = sample_counts.sort_index(ascending=False)
  225. plt.figure(figsize=(4, 4))
  226. ax = plt.axes()
  227. sample_counts.plot(kind='barh', color=[color_s1.get(sample, 'slategray') for sample in sample_counts.index], ax=ax)
  228. ax.grid(False)
  229. plt.xlabel('Number of cells')
  230. alpha=0.8
  231. ax.spines['top'].set_visible(False)
  232. ax.spines['right'].set_visible(False)
  233. #ax.spines['bottom'].set_visible(False)
  234. #ax.spines['left'].set_visible(False)
  235. for i, value in enumerate(sample_counts):
  236. plt.text(value + 0.05, i, str(value), ha='left', va='center')
  237. plt.xlim(0, 5500)
  238. plt.savefig('final_number_of_cells_in_sample.png', bbox_inches='tight', dpi=300, transparent=True)
  239. plt.show()
  240. # %%
  241. genes_to_plot = ['HOXB9', 'HOXB4', 'HOXB2', 'LMX1B', 'TH', 'NEFL', 'SOX1', 'NES', 'SOX2', 'HES5']
  242. num_genes = len(genes_to_plot)
  243. num_cols = min(5, num_genes)
  244. num_rows = -(-num_genes // num_cols)
  245. fig, axs = plt.subplots(num_rows, num_cols, figsize=(3 * num_cols, 3 * num_rows), sharex=True, sharey=True)
  246. sc.set_figure_params(transparent=True, dpi=300, fontsize=20)
  247. for gene, ax in zip(genes_to_plot, axs.flatten()):
  248. sc.pl.umap(adata,
  249. color=gene,
  250. cmap='rocket_r',
  251. frameon=False,
  252. vmin=0,
  253. size=5,
  254. use_raw=True,
  255. alpha=0.8,
  256. linewidth=0.8,
  257. legend_fontsize=1,
  258. show=False,
  259. ax=ax
  260. )
  261. ax.set_aspect('equal')
  262. for ax in axs.flatten()[num_genes:]:
  263. ax.remove()
  264. #plt.savefig('final_genes_on_clusters.png', bbox_inches='tight', dpi=300)
  265. plt.show()
  266. # %%
  267. sc.tl.rank_genes_groups(adata, groupby='Sample',reference='PN59', method='wilcoxon', use_raw=True)
  268. # %%
  269. sc.set_figure_params(dpi=300)
  270. sc.pl.rank_genes_groups(adata, n_genes=25, sharey=False, show=False, ncols=3)
  271. plt.savefig('final_wilcoxon ranked genes vs. PN59.png', bbox_inches='tight', dpi=300, transparent=True)
  272. # %%
  273. top_n_genes = 25
  274. marker_genes_df = pd.DataFrame(adata.uns['rank_genes_groups']['names']).head(top_n_genes)
  275. file_path = 'final_wilcoxon_sample_25.csv'
  276. marker_genes_df.to_csv(file_path, index=False)
  277. marker_genes_df
  278. # %%
  279. #subset = adata[adata.obs['Sample'].isin(['PN5', 'PN59'])].copy()
  280. #sc.tl.rank_genes_groups(subset, groupby='Sample', method='t-test', use_raw=True)
  281. # %%
  282. dedf = sc.get.rank_genes_groups_df(adata, group='PN5', key='rank_genes_groups')
  283. upreg_df = dedf[(dedf.pvals < 0.05) & (dedf.logfoldchanges > 1.5)]
  284. downreg_df = dedf[(dedf.pvals < 0.05) & (dedf.logfoldchanges < -1.5)]
  285. upreg_df = upreg_df.sort_values('logfoldchanges', ascending=False).reset_index(drop=True)
  286. downreg_df = downreg_df.sort_values('logfoldchanges', ascending=True).reset_index(drop=True)
  287. upreg_genes = upreg_df.names.tolist()
  288. downreg_genes = downreg_df.names.tolist()
  289. upreg_genes10 = upreg_df[:25].names.tolist()
  290. downreg_genes10 = downreg_df[:25].names.tolist()
  291. # %%
  292. fig, ax1 = plt.subplots(figsize=(12, 10))
  293. ax2 = ax1.twinx()
  294. ax1.barh(range(len(upreg_genes10)), upreg_df[:25]['logfoldchanges'], color='darkgreen', label='Upregulated', alpha=0.7)
  295. ax2.barh(range(len(downreg_genes10)), downreg_df[:25]['logfoldchanges'], color='darkred', label='Downregulated', alpha=0.7)
  296. ax1.axvline(x=0, color='black', linestyle='-')
  297. ax1.set_yticks(range(len(downreg_genes10)))
  298. ax1.set_yticklabels(downreg_genes10)
  299. ax2.set_yticks(range(len(upreg_genes10)))
  300. ax2.set_yticklabels(upreg_genes10)
  301. ax1.set_xlabel('Log-Fold Change')
  302. ax1.set_xlim([-30, 30])
  303. lines, labels = ax1.get_legend_handles_labels()
  304. lines2, labels2 = ax2.get_legend_handles_labels()
  305. ax1.legend(lines + lines2, labels + labels2, loc='upper right', fontsize=14)
  306. ax1.grid(False)
  307. ax2.grid(False)
  308. ax1.spines['top'].set_visible(False)
  309. ax1.spines['right'].set_visible(False)
  310. ax1.spines['left'].set_visible(False)
  311. ax2.spines['top'].set_visible(False)
  312. ax2.spines['right'].set_visible(False)
  313. ax2.spines['left'].set_visible(False)
  314. #plt.suptitle('', fontsize=20, y=0.95)
  315. plt.title('PN5 vs. PN59 (Top 25 DEGs)', fontsize=20)
  316. plt.tight_layout()
  317. plt.savefig('final_top25_DEGs.png', bbox_inches='tight', dpi=300, transparent=True)
  318. plt.show()
  319. # %%
  320. from adjustText import adjust_text
  321. # %%
  322. #subset_genes = pd.DataFrame(subset.uns['rank_genes_groups']['names'])
  323. #subset_genes
  324. # %%
  325. gp.get_library_name()
  326. # %%
  327. upreg_df_new = pd.DataFrame({'SigUpreg': upreg_genes})
  328. downreg_df_new = pd.DataFrame({'SigDownreg': downreg_genes})
  329. # %%
  330. num_clusters = upreg_df_new.shape[1]
  331. background_gene_list = adata.raw.var_names.tolist()
  332. gene_sets = ['PanglaoDB_Augmented_2021', 'GO_Biological_Process_2023', 'GO_Cellular_Component_2023' ]
  333. for cluster_number, cluster_name in enumerate(upreg_df_new.columns):
  334. if cluster_number >= num_clusters:
  335. break
  336. fig, axes = plt.subplots(1, 3, figsize=(40, 10))
  337. plt.subplots_adjust(wspace=1.5, hspace=2)
  338. plt.suptitle('PN5 vs. PN59 upregulated genes ($\it{p}$ < 0.05)', fontsize=36, fontweight='bold', y=1.02)
  339. for gene_set, ax in zip(gene_sets, axes.flatten()):
  340. gene_list = upreg_df_new[cluster_name].dropna().tolist()
  341. if not gene_list:
  342. continue
  343. enr_results = gp.enrichr(gene_list=gene_list,
  344. gene_sets=[gene_set],
  345. organism='human',
  346. outdir=None,
  347. background=background_gene_list)
  348. enr_results_sorted = enr_results.results.sort_values(by='P-value')
  349. top_terms = enr_results_sorted.head(10)['Term'].apply(lambda x: x[:50] + '...' if len(x) > 35 else x)
  350. top_p_values = enr_results_sorted.head(10)['P-value']
  351. ax.barh(top_terms, -1 * np.log10(top_p_values), color='slategray')
  352. ax.set_xlabel('-log10(p-value)', fontsize=18)
  353. ax.set_title(gene_set, fontsize=26)
  354. ax.tick_params(axis='y', labelsize=26)
  355. ax.xaxis.grid(False)
  356. ax.yaxis.grid(False)
  357. ax.spines['top'].set_visible(False)
  358. ax.spines['right'].set_visible(False)
  359. ax.set_aspect('auto')
  360. ax.set_ylim([-0.5, 10])
  361. plt.tight_layout()
  362. plt.savefig(f'final_{cluster_name}_analysis_PN5vsPN59.png', bbox_inches='tight', dpi=300, transparent=True)
  363. plt.show()
  364. # %%
  365. num_clusters = downreg_df_new.shape[1]
  366. background_gene_list = adata.raw.var_names.tolist()
  367. gene_sets = ['PanglaoDB_Augmented_2021', 'GO_Biological_Process_2023', 'GO_Cellular_Component_2023' ]
  368. for cluster_number, cluster_name in enumerate(downreg_df_new.columns):
  369. if cluster_number >= num_clusters:
  370. break
  371. fig, axes = plt.subplots(1, 3, figsize=(40, 10))
  372. plt.subplots_adjust(wspace=1.5, hspace=2)
  373. plt.suptitle('PN5 vs. PN59 downregulated genes ($\it{p}$ < 0.05)', fontsize=36, fontweight='bold', y=1.02)
  374. for gene_set, ax in zip(gene_sets, axes.flatten()):
  375. gene_list = downreg_df_new[cluster_name].dropna().tolist()
  376. if not gene_list:
  377. continue
  378. enr_results = gp.enrichr(gene_list=gene_list,
  379. gene_sets=[gene_set],
  380. organism='human',
  381. outdir=None,
  382. background=background_gene_list)
  383. enr_results_sorted = enr_results.results.sort_values(by='P-value')
  384. top_terms = enr_results_sorted.head(10)['Term'].apply(lambda x: x[:50] + '...' if len(x) > 35 else x)
  385. top_p_values = enr_results_sorted.head(10)['P-value']
  386. ax.barh(top_terms, -1 * np.log10(top_p_values), color='slategray')
  387. ax.set_xlabel('-log10(p-value)', fontsize=18)
  388. ax.set_title(gene_set, fontsize=26)
  389. ax.tick_params(axis='y', labelsize=26)
  390. ax.xaxis.grid(False)
  391. ax.yaxis.grid(False)
  392. ax.spines['top'].set_visible(False)
  393. ax.spines['right'].set_visible(False)
  394. ax.set_aspect('auto')
  395. ax.set_ylim([-0.5, 10])
  396. plt.tight_layout()
  397. plt.savefig(f'final_{cluster_name}_analysis_PN5vsPN59.png', bbox_inches='tight', dpi=300, transparent=True)
  398. plt.show()
  399. # %%
  400. #selected_genes = subset.raw[:, genes_to_show].X.toarray()
  401. #sample_labels = subset.obs['Sample'].tolist()
  402. #df = pd.DataFrame(selected_genes, columns=genes_to_show)
  403. #df['Sample'] = sample_labels
  404. # %%
  405. #df.set_index('Sample', inplace=True)
  406. #df_zscore = df.apply(zscore)
  407. #gene_list
  408. # %%
  409. color_s2 = {'Hindbrain - Differentiated':'#469990',
  410. 'Hindbrain - SCs':'#9A6324',
  411. 'Hindbrain - Serotonergic':'#800000',
  412. 'Midbrain - Dopaminergic':'#808000',
  413. 'Motor neurons':'#000075',
  414. 'Neural - SCs':'#e6194B',
  415. 'Serotonergic':'#f58231',
  416. 'Spinal - GABAergic':'#ffe119',
  417. 'Spinal - SCs':'#bfef45',
  418. 'Spinal - Schwann SCs':'#3cb44b',
  419. }
  420. legend_handles3 = [Line2D([0], [0], marker='o', color='w', markerfacecolor=color, markersize=10, label=label) for label, color in color_s2.items()]
  421. fig, ax = plt.subplots(figsize=(1, 1))
  422. ax.axis('off')
  423. ax.legend(handles=legend_handles3, ncol=1, loc='center', frameon=False)
  424. plt.savefig('legend_celltype.png', bbox_inches='tight', transparent=True, dpi=300)
  425. plt.show()
  426. # %%
  427. color_s2 = ['#469990',
  428. '#9A6324',
  429. '#800000',
  430. '#808000',
  431. '#000075',
  432. '#e6194B',
  433. '#f58231',
  434. '#ffe119',
  435. '#bfef45',
  436. '#3cb44b',
  437. ]
  438. # %%
  439. cluster_names = {
  440. '0': 'Hindbrain - SCs',
  441. '1': 'Hindbrain - SCs',
  442. '2': 'Hindbrain - SCs',
  443. '3': 'Hindbrain - SCs',
  444. '4': 'Hindbrain - SCs',
  445. '5': 'Motor neurons',
  446. '6': 'Spinal - SCs',
  447. '7': 'Hindbrain - SCs',
  448. '8': 'Midbrain - Dopaminergic',
  449. '9': 'Spinal - SCs',
  450. '10': 'Spinal - SCs',
  451. '11': 'Hindbrain - Serotonergic',
  452. '12': 'Spinal - Schwann SCs',
  453. '13': 'Spinal - GABAergic',
  454. '14': 'Neural - SCs',
  455. '15': 'Serotonergic',
  456. '16': 'Hindbrain - Differentiated',
  457. }
  458. adata.obs['cell_type'] = adata.obs['leiden'].map(cluster_names)
  459. # UMAP cell_types
  460. sc.set_figure_params(transparent=True, dpi=80, fontsize=14, dpi_save=300, figsize=(10, 8))
  461. sns.set_palette("deep")
  462. plt.figure(figsize=(10, 8))
  463. sc.pl.umap(adata,
  464. color='cell_type',
  465. palette=color_s2,
  466. use_raw=False,
  467. title=[''],
  468. frameon=False,
  469. legend_loc=False,
  470. legend_fontsize=16,
  471. #legend_fontoutline=1,
  472. size=30,
  473. alpha=0.8,
  474. linewidth=0.5,
  475. show=False
  476. )
  477. #plt.title('Samples', fontsize=20)
  478. #plt.xlabel('UMAP1', fontsize=20)
  479. #plt.ylabel('UMAP2', fontsize=20)
  480. #plt.gca().spines['top'].set_visible(False)
  481. #plt.gca().spines['right'].set_visible(False)
  482. ax.set_aspect('equal')
  483. plt.savefig('final__celltypes_NSCs.png', bbox_inches='tight', dpi=300)
  484. plt.show()
  485. # %%
  486. cell_type_counts = adata.obs['cell_type'].value_counts()
  487. print(cell_type_counts)
  488. # %%
  489. cell_type_counts = adata.obs['cell_type'].value_counts()
  490. plt.figure(figsize=(8, 6))
  491. ax = plt.axes()
  492. bars = cell_type_counts.plot(kind='barh', color=color_t, ax=ax)
  493. ax.grid(False)
  494. ax.spines['top'].set_visible(False)
  495. ax.spines['right'].set_visible(False)
  496. #ax.spines['bottom'].set_visible(False)
  497. #ax.spines['left'].set_visible(False)
  498. plt.xlabel('Number of Cells')
  499. for i, value in enumerate(cell_type_counts):
  500. plt.text(value + 0.05, i, str(value), ha='left', va='center')
  501. plt.savefig('final_number_of_cells_in_celltype.png', bbox_inches='tight', dpi=300, transparent=True)
  502. plt.show()
  503. # %%
  504. sc.tl.rank_genes_groups(adata, groupby='Sample', method='wilcoxon', use_raw=True)
  505. # %%
  506. #sns.set_palette("rocket")
  507. fig, ax = plt.subplots(figsize=(0.2, 2)) # Adjust the figsize as needed for your design
  508. bar_lgd = plt.scatter([0, 1], [0, 1], c=[0, 1], cmap="rocket")
  509. cbar = plt.colorbar(bar_lgd, cax=ax, orientation='vertical', ticks=[0, 1])
  510. cbar.set_label('Scaled expression', rotation=270, labelpad=10, fontsize=10)
  511. cbar.ax.tick_params(labelsize=12)
  512. cbar.ax.set_yticklabels(['0', '1'])
  513. ax.set_xticks([])
  514. ax.set_xticklabels([])
  515. plt.savefig('legend_heatmap.png', bbox_inches='tight', transparent=True, dpi=300)
  516. plt.show()
  517. # %%
  518. sc.set_figure_params(transparent=True, fontsize=14, dpi_save=300)
  519. sc.pl.rank_genes_groups_heatmap(adata,
  520. n_genes=10,
  521. groupby='Sample',
  522. cmap='rocket',
  523. dendrogram=True,
  524. figsize=(6, 10),
  525. use_raw=True,
  526. swap_axes=True,
  527. show_gene_labels=True,
  528. standard_scale='var',
  529. show=False,
  530. save='final_top10genes_heatmap.png'
  531. )
  532. # %%
  533. sc.tl.dendrogram(adata, 'Sample', n_pcs=20)
  534. axes_list = sc.pl.correlation_matrix(adata, 'Sample', show=False)
  535. for ax in axes_list:
  536. ax.yaxis.grid(False)
  537. ax.xaxis.grid(False)
  538. #plt.savefig('correlation_matrix.png', bbox_inches='tight', dpi=300, transparent=True)
  539. plt.show()
  540. # %% [markdown]
  541. # # markers in clusters
  542. # %%
  543. #finding markers in clusters
  544. sc.tl.rank_genes_groups(adata, groupby='leiden', method='t-test')
  545. sc.pl.rank_genes_groups(adata, n_genes=25, sharey=False, show=False, ncols=3)
  546. plt.savefig('final_t-test ranked genes leiden.png', bbox_inches='tight', dpi=300, transparent=True)
  547. # %%
  548. color_s2 = ['#0fbabd', '#efd39b', '#fbbd3c', '#bc131f', '#876c56']
  549. # %%
  550. sc.set_figure_params(transparent=True, dpi=80, fontsize=14, dpi_save=300, figsize=(10, 8))
  551. selected_genes = {
  552. 'Forebrain' :['SIX3', 'FOXG1', 'SP8', 'EOMES'],
  553. 'Midbrain':['CLSTN2', 'PTPRO','LMX1B', 'FGF8', 'WNT5A', 'EN2'],
  554. 'Hindbrain':['HOXB4', 'HOXB2', 'HOXA2', 'ERBB4', 'GBX2', 'PAX3'],
  555. 'Spinal\ncord':['HOXB9', 'HOXB8', 'HOXB7', 'HOXB6', 'CADPS2'],
  556. 'Seroton-\nergic' :['FEV', 'TPH2', 'SLC6A4','HTR7', 'HTR2A'],
  557. 'GABA-\nergic' :['GAD1', 'GAD2', 'SLC6A1'],
  558. 'Dopamin-\nergic' :['TH', 'SLC6A3'],
  559. 'Neural stem cells':['SOX1', 'SOX2', 'DLL1', 'FABP7', 'HES5', 'NES','PAX6', 'NOTCH1'],
  560. 'Differentiated ':['L1CAM','MAP2', 'TUBB3', 'NEFM', 'NEFL'],
  561. 'Schwann\ncells' :['MPZ', 'SOX10', 'S100B'],
  562. 'Motor\nneurons' :['LHX3', 'NKX6-1', 'AQP4'],
  563. }
  564. sc.pl.matrixplot(adata,
  565. selected_genes,
  566. #use_raw = False,
  567. groupby='leiden',
  568. dendrogram=True,
  569. cmap='Reds',
  570. #swap_axes=True,
  571. standard_scale='var',
  572. var_group_rotation=0,
  573. colorbar_title='column scaled\nexpression',
  574. #save='final_matrixplot.png'
  575. )
  576. # %%
  577. num_tot_cells = adata.obs.groupby(['Sample']).count()
  578. num_tot_cells = dict(zip(num_tot_cells.index, num_tot_cells.n_genes))
  579. cell_type_counts = adata.obs.groupby(['Sample', 'cell_type']).count()
  580. cell_type_counts = cell_type_counts[cell_type_counts.sum(axis=1)>0].reset_index()
  581. cell_type_counts = cell_type_counts.rename(columns={'Sample': 'sample_column_name'})
  582. cell_type_counts['total_cells'] = cell_type_counts['sample_column_name'].map(num_tot_cells).astype(int)
  583. cell_type_counts['frequency'] = cell_type_counts.leiden/cell_type_counts.total_cells
  584. # %%
  585. leiden_counts = adata.obs['leiden'].value_counts()
  586. total_cells = len(adata.obs)
  587. percentage_cells = (leiden_counts / total_cells) * 100
  588. plt.figure(figsize=(10, 6))
  589. ax = plt.axes() # Get the current axes
  590. percentage_cells.plot(kind='bar', color='skyblue', ax=ax)
  591. ax.grid(False) # Turn off the grid
  592. plt.title('Percentage of Cells in Each Cell Type Cluster')
  593. plt.xlabel('leiden cluster')
  594. plt.ylabel('Percentage of Cells')
  595. plt.xticks(rotation=45, ha='right')
  596. plt.savefig('final_percentage_of_cells.png', bbox_inches='tight', dpi=300)
  597. plt.show()
  598. # %%
  599. agg_data = adata.obs.groupby(['cell_type', 'Sample']).size().unstack().fillna(0)
  600. agg_data_normalized = agg_data.div(agg_data.sum(axis=1), axis=0) * 100
  601. colors = [color_s1[sample] for sample in agg_data_normalized.columns]
  602. plt.figure(figsize=(12, 8))
  603. plt.gca().set_facecolor('none')
  604. for i, sample in enumerate(agg_data_normalized.columns):
  605. plt.bar(
  606. agg_data_normalized.index,
  607. agg_data_normalized[sample],
  608. label=sample,
  609. color=colors[i],
  610. width=0.8,
  611. bottom=agg_data_normalized.iloc[:, :i].sum(axis=1),
  612. alpha=0.8
  613. )
  614. # Customization
  615. plt.ylabel('Percentage of cells', fontsize=20)
  616. plt.legend(bbox_to_anchor=(0.99, 1.024), loc='upper left', fontsize=30)
  617. plt.xticks(rotation=45, ha='right', fontsize=36)
  618. plt.yticks(fontsize=20)
  619. plt.ylim(0, 100)
  620. plt.grid(False)
  621. plt.savefig('final_Cell_Proportion.png', bbox_inches='tight', transparent=True, dpi=300)
  622. plt.show()
  623. # %%
  624. agg_data_normalized
  625. # %%
  626. my_order = ['6', '9', '10', '2', '12', '3', '7', '4', '0', '1', '14', '5', '16', '15', '11', '8', '13']
  627. #my_order = my_order[::-1]
  628. percentage_cells = percentage_cells.loc[my_order]
  629. fig, ax = plt.subplots(figsize=(2, 6))
  630. bars = ax.barh(percentage_cells.index, percentage_cells, color='black')
  631. ax.invert_yaxis()
  632. ax.yaxis.tick_right()
  633. ax.yaxis.set_label_position("right")
  634. ax.set_xlim(0, 25)
  635. ax.invert_xaxis()
  636. ax.yaxis.set_label_position("left")
  637. plt.ylabel('cluster')
  638. plt.xlabel('Percentage of Cells')
  639. plt.grid(False)
  640. for bar in bars:
  641. plt.text(bar.get_width() +8, bar.get_y() + bar.get_height() / 2, f'{bar.get_width():.1f}%',
  642. va='center', ha='left', fontsize=10, color='black')
  643. plt.show()
  644. # %%
  645. gene_index = np.where(adata.raw.var_names == 'HOXB9')[0]
  646. expressing_cells = np.sum(adata.raw.X[:, gene_index] > 0)
  647. print(f"The number of cells expressing SIX3 is: {expressing_cells}")
  648. # %%
  649. cell_genes = [gene for gene_list in selected_genes.values() for gene in gene_list]
  650. # Filter out non-gene entries
  651. gene_names = [gene for gene in cell_genes if isinstance(gene, str)]
  652. # Calculate the number of expressing cells for each gene
  653. expressing_cells_counts = []
  654. for gene in gene_names:
  655. gene_index = np.where(adata.raw.var_names == gene)[0]
  656. expressing_cells = np.sum(adata.raw.X[:, gene_index] > 0)
  657. expressing_cells_counts.append(expressing_cells)
  658. # Create a bar plot
  659. plt.figure(figsize=(22, 1))
  660. bars = plt.bar(gene_names, expressing_cells_counts, color='slategray')
  661. plt.xticks(rotation=90, ha='center')
  662. plt.grid(False)
  663. plt.gca().spines['top'].set_visible(False)
  664. plt.gca().spines['right'].set_visible(False)
  665. plt.gca().spines['bottom'].set_visible(False)
  666. plt.gca().spines['left'].set_visible(False)
  667. plt.yticks([])
  668. plt.tick_params(axis='y', which='both', left=False)
  669. plt.ylabel('Number of cells', fontsize=16, ha='center', va='center')
  670. # Add text labels on top of each bar
  671. for bar, count in zip(bars, expressing_cells_counts):
  672. plt.text(bar.get_x() + bar.get_width() / 2, bar.get_height() + 20, str(count),fontsize=14, ha='center', va='bottom', rotation=90)
  673. plt.show()
  674. # %%
  675. sc.set_figure_params(fontsize=20)
  676. fig = plt.figure(figsize=(22, 8))
  677. gs = gridspec.GridSpec(1, 2, width_ratios=[0.1, 1], height_ratios=[0.01]) # 1 row, 2 columns, with different widths
  678. ax = plt.subplot(gs[0])
  679. bars = ax.barh(percentage_cells.index, percentage_cells, color='black')
  680. ax.invert_yaxis()
  681. ax.yaxis.tick_right()
  682. ax.yaxis.set_label_position("right")
  683. ax.set_xlim(0, 20)
  684. ax.invert_xaxis()
  685. plt.xlabel('Percentage of cells')
  686. ax.yaxis.set_label_position("left")
  687. plt.ylabel('Clusters')
  688. plt.grid(False)
  689. for bar in bars:
  690. plt.text(bar.get_width() + 5, bar.get_y() + bar.get_height() / 2, f'{bar.get_width():.1f}%',
  691. va='center', ha='left', fontsize=14, color='black')
  692. ax.set_yticks([])
  693. ax.set_yticklabels([])
  694. ax.spines['top'].set_visible(False)
  695. ax.spines['right'].set_visible(False)
  696. ax.spines['bottom'].set_visible(True)
  697. ax.spines['left'].set_visible(False)
  698. ax_matrixplot = plt.subplot(gs[1])
  699. gs.update(right=0.90)
  700. plt.subplots_adjust(left=0.01, right=0.1, wspace=0.05)
  701. bar_plot_height = 0.705
  702. ax.set_position([ax.get_position().x0, ax.get_position().y0, ax.get_position().width, bar_plot_height])
  703. bar_plot_position = ax.get_position()
  704. new_bar_plot_position = [bar_plot_position.x0, bar_plot_position.y0 - 0.025, bar_plot_position.width, bar_plot_position.height]
  705. ax.set_position(new_bar_plot_position)
  706. sc.pl.matrixplot(adata, selected_genes, groupby='leiden', dendrogram=True, cmap='Reds',
  707. standard_scale='var', var_group_rotation=90, colorbar_title='column scaled\nexpression',
  708. ax=ax_matrixplot, show = False)
  709. plt.savefig('final_matrix_with_bar_plot.png', bbox_inches='tight', transparent=True, dpi=300)
  710. plt.show()
  711. # %%
  712. #pie charts
  713. sample_names = adata.obs['Sample'].unique()
  714. color_s1 = {'PN5': 'darkred', 'PN21': 'purple', 'PN41': 'darkorange', 'PN59': 'gold'}
  715. num_genes = len(cell_genes)
  716. fig, axes = plt.subplots(1, num_genes, figsize=(3 * num_genes, 3))
  717. for gene, ax in zip(cell_genes, axes):
  718. if gene not in adata.raw.var_names:
  719. print(f"Skipping gene '{gene}' as it is not present in the raw data.")
  720. continue
  721. expressing_cells_counts = []
  722. for sample in sample_names:
  723. sample_cells = adata.obs['Sample'] == sample
  724. gene_index = np.where(adata.raw.var_names == gene)[0]
  725. expressing_cells = np.sum((adata.raw.X[sample_cells, gene_index] > 0).A)
  726. expressing_cells_counts.append(expressing_cells)
  727. total_cells_per_sample = np.sum(adata.obs['Sample'].isin(sample_names))
  728. # Check if the total number of expressing cells is less than 10
  729. if np.sum(expressing_cells_counts) < 10:
  730. ax.pie([1], colors=['lightgrey'], autopct='', startangle=90)
  731. ax.set_title(f'{gene} Expression (< 10 cells)')
  732. continue
  733. percentage_expression = [count / total_cells_per_sample * 100 for count in expressing_cells_counts]
  734. colors = [color_s1.get(sample, 'gray') for sample in sample_names]
  735. ax.pie(percentage_expression, autopct='', startangle=90, colors=colors)
  736. ax.set_title(f'{gene}')
  737. plt.tight_layout()
  738. plt.show()
  739. # %%
  740. cell_genes = [gene for gene_list in selected_genes.values() for gene in gene_list]
  741. def plot_gene_pie(ax, gene, adata, color_s1):
  742. if gene not in adata.raw.var_names:
  743. print(f"Skipping gene '{gene}' as it is not present in the raw data.")
  744. return
  745. expressing_cells_counts = []
  746. for sample in sample_names:
  747. sample_cells = adata.obs['Sample'] == sample
  748. gene_index = np.where(adata.raw.var_names == gene)[0]
  749. expressing_cells = np.sum((adata.raw.X[sample_cells, gene_index] > 0).A)
  750. expressing_cells_counts.append(expressing_cells)
  751. total_cells_per_sample = np.sum(adata.obs['Sample'].isin(sample_names))
  752. if np.sum(expressing_cells_counts) < 10:
  753. ax.pie([1], colors=['lightgrey'], autopct='', startangle=90)
  754. ax.set_title('')
  755. ax.axis('equal')
  756. ax.set_xticks([])
  757. ax.set_yticks([])
  758. ax.set_facecolor('None')
  759. return
  760. percentage_expression = [count / total_cells_per_sample * 100 for count in expressing_cells_counts]
  761. colors = [color_s1.get(sample, 'gray') for sample in sample_names]
  762. ax.pie(percentage_expression, autopct='', startangle=90, colors=colors)
  763. ax.set_title('')
  764. ax.axis('equal')
  765. ax.set_xticks([])
  766. ax.set_yticks([])
  767. ax.set_facecolor('None')
  768. sample_names = adata.obs['Sample'].unique()
  769. color_s1 = {'PN5': 'darkred', 'PN21': 'purple', 'PN41': 'darkorange', 'PN59': 'gold'}
  770. num_genes = len(cell_genes)
  771. fig, axes = plt.subplots(1, num_genes, figsize=(3 * num_genes, 3))
  772. for i, gene in enumerate(cell_genes):
  773. ax_pie = axes[i]
  774. plot_gene_pie(ax_pie, gene, adata, color_s1)
  775. plt.subplots_adjust(wspace=0)
  776. plt.show()
  777. # %%
  778. sc.set_figure_params(fontsize=20)
  779. fig = plt.figure(figsize=(40, 14))
  780. gs = gridspec.GridSpec(2, 2, width_ratios=[0.1, 1], height_ratios=[1, 1])
  781. # Bar plot on the left
  782. ax_left = plt.subplot(gs[1, 0])
  783. bars_left = ax_left.barh(percentage_cells.index, percentage_cells, color='black')
  784. ax_left.invert_yaxis()
  785. ax_left.yaxis.tick_right()
  786. ax_left.yaxis.set_label_position("right")
  787. ax_left.set_xlim(0, 20)
  788. ax_left.invert_xaxis()
  789. ax_left.set_xlabel('Percentage of cells')
  790. ax_left.yaxis.set_label_position("left")
  791. ax_left.set_ylabel('Clusters')
  792. ax_left.grid(False)
  793. for bar in bars_left:
  794. plt.text(bar.get_width() + 5, bar.get_y() + bar.get_height() / 2, f'{bar.get_width():.1f}%',
  795. va='center', ha='left', fontsize=14, color='black')
  796. ax_left.set_yticks([])
  797. ax_left.set_yticklabels([])
  798. ax_left.spines['top'].set_visible(False)
  799. ax_left.spines['right'].set_visible(False)
  800. ax_left.spines['bottom'].set_visible(True)
  801. ax_left.spines['left'].set_visible(False)
  802. # Matrix plot in the center
  803. ax_matrixplot = plt.subplot(gs[1, 1])
  804. sc.pl.matrixplot(adata, selected_genes, groupby='leiden', dendrogram=True, cmap='Reds',
  805. standard_scale='var', var_group_rotation=90, colorbar_title='column scaled\nexpression',
  806. ax=ax_matrixplot, show=False)
  807. # Bar plot on top
  808. ax_top = plt.subplot(gs[0, 1])
  809. bars_top = ax_top.bar(gene_names, expressing_cells_counts, color='slategray')
  810. ax_top.set_xticks([])
  811. ax_top.grid(False)
  812. ax_top.spines['top'].set_visible(False)
  813. ax_top.spines['right'].set_visible(False)
  814. ax_top.spines['bottom'].set_visible(False)
  815. ax_top.spines['left'].set_visible(False)
  816. ax_top.tick_params(axis='y', which='both', left=False, labelleft=False)
  817. for bar, count in zip(bars_top, expressing_cells_counts):
  818. ax_top.text(bar.get_x() + bar.get_width() / 2, bar.get_height() + 20, str(count),
  819. fontsize=14, ha='center', va='bottom', rotation=90)
  820. ax_top.set_ylabel('Number of cells', fontsize=16, ha='right', va='center', rotation=0)
  821. gs.update(right=0.90)
  822. gs.update(bottom=0.1, top=1, wspace=0.05, hspace=0.1)
  823. ax_left_pos = ax_left.get_position()
  824. ax_left.set_position([ax_left_pos.x0 - 0.03, ax_left_pos.y0 - 0.02, ax_left_pos.width * 1.5, ax_left_pos.height*0.94])
  825. ax_top_pos = ax_top.get_position()
  826. ax_top.set_position([ax_top_pos.x0 - 0.028, ax_top_pos.y0 - -0.13, ax_top_pos.width* 0.965, ax_top_pos.height* 0.2])
  827. ax_matrixplot_pos = ax_matrixplot.get_position()
  828. ax_matrixplot.set_position([ax_matrixplot_pos.x0, ax_matrixplot_pos.y0, ax_matrixplot_pos.width, ax_matrixplot_pos.height])
  829. plt.show()
  830. # %%
  831. sc.set_figure_params(fontsize=20)
  832. fig = plt.figure(figsize=(40, 18))
  833. gs = gridspec.GridSpec(3, 2, width_ratios=[0.1, 1], height_ratios=[1, 1, 1])
  834. ax_left = plt.subplot(gs[2, 0])
  835. bars_left = ax_left.barh(percentage_cells.index, percentage_cells, color='black')
  836. ax_left.invert_yaxis()
  837. ax_left.yaxis.tick_right()
  838. ax_left.yaxis.set_label_position("right")
  839. ax_left.set_xlim(0, 20)
  840. ax_left.invert_xaxis()
  841. ax_left.set_xlabel('Percentage of cells')
  842. ax_left.yaxis.set_label_position("left")
  843. ax_left.set_ylabel('Clusters')
  844. ax_left.grid(False)
  845. for bar in bars_left:
  846. plt.text(bar.get_width() + 5, bar.get_y() + bar.get_height() / 2, f'{bar.get_width():.1f}%',
  847. va='center', ha='left', fontsize=14, color='black')
  848. ax_left.set_yticks([])
  849. ax_left.set_yticklabels([])
  850. ax_left.spines['top'].set_visible(False)
  851. ax_left.spines['right'].set_visible(False)
  852. ax_left.spines['bottom'].set_visible(True)
  853. ax_left.spines['left'].set_visible(False)
  854. ax_left.set_zorder(2)
  855. ax_matrixplot = plt.subplot(gs[2, 1])
  856. sc.pl.matrixplot(adata, selected_genes, groupby='leiden', dendrogram=True, cmap='Reds',
  857. standard_scale='var', var_group_rotation=0, colorbar_title='column scaled\nexpression',
  858. ax=ax_matrixplot, show=False)
  859. ax_matrixplot.set_rasterization_zorder(2)
  860. ax_top = plt.subplot(gs[0, 1])
  861. bars_top = ax_top.bar(gene_names, expressing_cells_counts, color='slategray')
  862. ax_top.set_xticks([])
  863. ax_top.grid(False)
  864. ax_top.spines['top'].set_visible(False)
  865. ax_top.spines['right'].set_visible(False)
  866. ax_top.spines['bottom'].set_visible(False)
  867. ax_top.spines['left'].set_visible(False)
  868. ax_top.tick_params(axis='y', which='both', left=False, labelleft=False)
  869. for bar, count in zip(bars_top, expressing_cells_counts):
  870. ax_top.text(bar.get_x() + bar.get_width() / 2, bar.get_height() + 20, str(count),
  871. fontsize=14, ha='center', va='bottom', rotation=90)
  872. ax_top.set_ylabel('Number of cells', fontsize=16, ha='right', va='center', rotation=0)
  873. sample_names = adata.obs['Sample'].unique()
  874. color_s1 = {'PN5': 'darkred', 'PN21': 'purple', 'PN41': 'darkorange', 'PN59': 'gold'}
  875. num_genes = len(cell_genes)
  876. ax_pie = plt.subplot(gs[1, 0:2])
  877. total_width = 0.8
  878. width_per_pie = total_width / num_genes
  879. for i, gene in enumerate(cell_genes):
  880. ax_pie_sub = ax_pie.inset_axes([i * width_per_pie, 0, width_per_pie, 1])
  881. plot_gene_pie(ax_pie_sub, gene, adata, color_s1)
  882. ax_pie.grid(False)
  883. ax_pie.set_frame_on(False)
  884. ax_pie.set_xticks([])
  885. ax_pie.set_yticks([])
  886. ax_pie.spines['top'].set_visible(False)
  887. ax_pie.spines['right'].set_visible(False)
  888. ax_pie.spines['bottom'].set_visible(False)
  889. ax_pie.spines['left'].set_visible(False)
  890. gs.update(right=0.90)
  891. gs.update(bottom=0.1, top=1, wspace=0.05, hspace=0.1)
  892. ax_left_pos = ax_left.get_position()
  893. ax_left.set_position([ax_left_pos.x0 -0.009, ax_left_pos.y0 - 0.011, ax_left_pos.width * 1.2, ax_left_pos.height*0.94])
  894. ax_top_pos = ax_top.get_position()
  895. ax_top.set_position([ax_top_pos.x0 - 0.0278, ax_top_pos.y0 - 0.28, ax_top_pos.width* 0.965, ax_top_pos.height* 0.2])
  896. ax_matrixplot_pos = ax_matrixplot.get_position()
  897. ax_matrixplot.set_position([ax_matrixplot_pos.x0, ax_matrixplot_pos.y0, ax_matrixplot_pos.width, ax_matrixplot_pos.height])
  898. ax_pie_pos = ax_pie.get_position()
  899. ax_pie.set_position([ax_pie_pos.x0 + 0.081, ax_pie_pos.y0 -0.14, ax_pie_pos.width*0.975, ax_pie_pos.height])
  900. plt.savefig('final_heatmap.png', bbox_inches='tight', transparent=True, dpi=300)
  901. plt.show()
  902. # %%
  903. legend_handles2 = [Line2D([0], [0], marker='o', color='w', markerfacecolor=color, markersize=10, label=label) for label, color in color_s1.items()]
  904. legend_handles2.append(Patch(color='lightgrey', label='< 10 cells'))
  905. fig, ax = plt.subplots(figsize=(1, 1))
  906. ax.axis('off')
  907. ax.legend(handles=legend_handles2, ncol=1, loc='center')
  908. plt.savefig('legend_heatmap.png', bbox_inches='tight', transparent=True, dpi=300)
  909. plt.show()

scRNAseq_HbL-iNSCs.ipynb, under CC-BY-4.0 · at the source

Overview

Authors: Ziadoon Al-Akashi1, Denise Zujur1, Nicholas Boyd-Gibbins1, Nathalie Eileen Wiguna1, Masato Nakagawa2, Tetsuhiro Kikuchi1, Asuka Morizane1,3, Jun Takahashi1, Makoto Ikeya1
  1. Department of Clinical Application, Center for iPS Cell Research and Application (CiRA), Kyoto University, 53 Kawahara-cho, Shogoin, Sakyo-ku, Kyoto 606-8507, Japan
  2. Department of Life Science Frontiers, Center for iPS Cell Research and Application (CiRA), Kyoto University, 53 Kawahara-cho, Shogoin, Sakyo-ku, Kyoto 606-8507, Japan
  3. Department of Regenerative Medicine, Center for Clinical Research and Innovation, Kobe City Medical Center General Hospital, Hyogo, Japan
Journal: Cell reports methods, volume 6, issue 4, article 101372
Dates: received 23 May 2025; accepted 27 February 2026; published online 30 March 2026; in print April 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1016/j.crmeth.2026.101372 · PMID 41916305 · PMCID PMC13107045 · OpenAlex W7143485316
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: human (organism)
Methods: Spectral & time-frequency
Keywords: hindbrain, neural stem cell, neuron, pluripotent stem cell
MeSH: Induced Pluripotent Stem Cells*, Neural Stem Cells*, Rhombencephalon*, Smad Proteins*, Wnt Proteins*, Wnt Signaling Pathway*, Animals, Cell Differentiation, Humans, Pyrazoles, Pyridines, Pyrimidines (* major topic)
Topic: Neurogenesis and neuroplasticity mechanisms (Developmental Neuroscience, Neuroscience), according to OpenAlex
Funding: Japan Agency for Medical Research and Development (JP23bm1323001, JP15bm0104001); Otsuka Toshimi Scholarship Foundation; Japan Society for the Promotion of Science (16H05447); Japan Science and Technology Agency (JPMJSP2110)
Citations: not cited yet (Europe PMC); 22 references in the paper
Research resources: RRID:CVCL_LJ39

Abstract

Neurons exhibit region-specific identities corresponding to functional distinctions across different brain areas. Region-restricted neural stem cells (NSCs) have previously been generated from pluripotent stem cells; however, maintaining their regional identity over extended passages remains challenging. Here, we report the generation of hindbrain-like induced NSCs (Hb-LiNSCs) with upregulated hindbrain-specific markers and downregulated forebrain, midbrain, and spinal cord markers under xeno-free and basic fibroblast growth factor (bFGF)-free conditions using three chemicals—CHIR99021 (at a high concentration), a potent activator of the Wnt pathway; A-83-01, a potent inhibitor of the TGF-β/Activin/Nodal pathway; and LDN193189, a potent inhibitor of the bone morphogenetic protein pathway. Hb-LiNSCs maintained their chromosomal integrity, multipotency, and differentiation capacity even after long-term culture for more than 60 weeks. This approach enhances our understanding of neurodevelopmental and neurodegenerative processes in the hindbrain region and paves the way for developing targeted cell-based therapy as well as disease modeling for drug discovery.

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

Repository

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

Zenodo 18653633

License: CC-BY-4.0
State: the link answers, verified on 30 September 2026
Evidence: files inventoried
Languages: R (4), Jupyter (1)
Size: 5 files, 5 scripts
Software Heritage: not checked
Found in: “Data and code availability”
Holds: 5 notebooks
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: anndata (1 file), Matplotlib (1 file), NumPy (1 file), pandas (1 file), Scanpy (1 file), scikit-learn (1 file), seaborn (1 file)
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
  • 30 September 2026: the link answers (HTTP 200)
5 files

The paper's code and data availability statement is in the Data section.

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;
  • 5 scripts, each with its path and the digest of its content;
  • 3 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 and code availability

Single-cell RNAseq data and RNAseq data generated in this study have been deposited to GEO: GSE317025 (https://ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE317025) and GSE317319 (https://ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE317319). We used RNAseq data of human iPSCs deposited to GEO: GSE206128 (https://ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE206128). They are publicly available as of the date of publication. Other data and images that support the findings of this study are available on request from the lead contact.

The code for generating most of the figures can be found at https://doi.org/10.5281/zenodo.18653633.

Any additional information required to reanalyze the data reported in this paper is available from the lead contact upon request.

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

Versions

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

Version 1, 30 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 9 authors, 4 keywords, 12 MeSH terms, 4 funders, 22 references, 1 RRID.

Cite

This paper

Al-Akashi, Z., Zujur, D., Boyd-Gibbins, N., Wiguna, N. E., Nakagawa, M., Kikuchi, T., Morizane, A., Takahashi, J., & Ikeya, M. (2026). Wnt activation and dual SMAD inhibition for induction and maintenance of hindbrain-like neural stem cell from hiPSCs. Cell reports methods, 6(4), 101372. https://doi.org/10.1016/j.crmeth.2026.101372

BibTeX

@article{alakashi2026wnt,
author = {Al-Akashi, Ziadoon and Zujur, Denise and Boyd-Gibbins, Nicholas and Wiguna, Nathalie Eileen and Nakagawa, Masato and Kikuchi, Tetsuhiro and Morizane, Asuka and Takahashi, Jun and Ikeya, Makoto},
title = {{Wnt activation and dual SMAD inhibition for induction and maintenance of hindbrain-like neural stem cell from hiPSCs}},
journal = {Cell reports methods},
year = {2026},
month = mar,
volume = {6},
number = {4},
pages = {101372},
publisher = {Elsevier},
issn = {2667-2375},
doi = {10.1016/j.crmeth.2026.101372},
url = {https://doi.org/10.1016/j.crmeth.2026.101372},
pmid = {41916305},
pmcid = {PMC13107045}
}

RIS

TY - JOUR
AU - Al-Akashi, Ziadoon
AU - Zujur, Denise
AU - Boyd-Gibbins, Nicholas
AU - Wiguna, Nathalie Eileen
AU - Nakagawa, Masato
AU - Kikuchi, Tetsuhiro
AU - Morizane, Asuka
AU - Takahashi, Jun
AU - Ikeya, Makoto
TI - Wnt activation and dual SMAD inhibition for induction and maintenance of hindbrain-like neural stem cell from hiPSCs
T2 - Cell reports methods
J2 - Cell Rep Methods
PY - 2026
DA - 2026/03/30
VL - 6
IS - 4
SP - 101372
SN - 2667-2375
PB - Elsevier
DO - 10.1016/j.crmeth.2026.101372
UR - https://doi.org/10.1016/j.crmeth.2026.101372
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.crmeth.2026.101372",
"type": "article-journal",
"title": "Wnt activation and dual SMAD inhibition for induction and maintenance of hindbrain-like neural stem cell from hiPSCs",
"container-title": "Cell reports methods",
"author": [
{
"family": "Al-Akashi",
"given": "Ziadoon"
},
{
"family": "Zujur",
"given": "Denise"
},
{
"family": "Boyd-Gibbins",
"given": "Nicholas"
},
{
"family": "Wiguna",
"given": "Nathalie Eileen"
},
{
"family": "Nakagawa",
"given": "Masato"
},
{
"family": "Kikuchi",
"given": "Tetsuhiro"
},
{
"family": "Morizane",
"given": "Asuka"
},
{
"family": "Takahashi",
"given": "Jun"
},
{
"family": "Ikeya",
"given": "Makoto"
}
],
"container-title-short": "Cell Rep Methods",
"volume": "6",
"issue": "4",
"page": "101372",
"DOI": "10.1016/j.crmeth.2026.101372",
"PMID": "41916305",
"PMCID": "PMC13107045",
"ISSN": "2667-2375",
"publisher": "Elsevier",
"URL": "https://doi.org/10.1016/j.crmeth.2026.101372",
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
30
]
]
}
}

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/s41592-024-02412-5 [code]
A polarized FGF8 source specifies frontotemporal signatures in spatially oriented cell populations of cortical assembloids.
Journal: Nature methods
In common: anndata, Scanpy, seaborn, 4 other tools, 3 references
[2] doi:10.1038/s41586-025-09151-3 [code]
Morphodynamics of human early brain organoid development.
Journal: Nature
In common: anndata, Scanpy, seaborn, 4 other tools, 2 references
[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: anndata, Scanpy, seaborn, 4 other tools, 2 references
[4] doi:10.1126/sciadv.adq4731 [code]
An ancient apical patterning system sets the position of the forebrain in chordates.
Journal: Science advances
In common: anndata, Scanpy, seaborn, 3 other tools, 3 references
[5] doi:10.1242/dev.202545 [code]
Exploiting spatiotemporal regulation of FZD5 during neural patterning for efficient ventral midbrain specification.
Journal: Development (Cambridge, England)
In common: anndata, Scanpy, seaborn, 4 other tools, 2 references
[6] doi:10.1016/j.celrep.2025.116498 [code]
In vivo differentiation of embryonic cells devoid of key reprogramming factors.
Journal: Cell reports
In common: anndata, Scanpy, seaborn, 4 other tools, 2 references
[7] doi:10.1038/s41593-026-02200-8 [code]
Distinct radial glia subtypes regulate midbrain dopaminergic neuron development.
Journal: Nature neuroscience
In common: Scanpy, seaborn, pandas, 2 other tools, 3 references
[8] doi:10.1016/j.isci.2025.114482
Embryonic lineage-specific iPSC-derived mesenchymal stem/stromal cells exhibit different morphologies and intrinsic functions.
Journal: iScience
In common: 2 references, author Makoto Ikeya
[9] doi:10.7554/elife.102819 [code]
A single-cell atlas of spatial and temporal gene expression in the mouse cranial neural plate.
Journal: eLife
In common: Scanpy, seaborn, scikit-learn, 3 other tools, 2 references
[10] doi:10.1093/nargab/lqae100 [code]
SIRV: spatial inference of RNA velocity at the single-cell resolution.
Journal: NAR genomics and bioinformatics
In common: Scanpy, seaborn, scikit-learn, 3 other tools, 2 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

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.1016/j.crmeth.2026.101372.svg)](https://openscicode.org/badge/doi/10.1016/j.crmeth.2026.101372)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1016/j.crmeth.2026.101372.svg
   :target: https://openscicode.org/badge/doi/10.1016/j.crmeth.2026.101372
   :alt: OSCR

.. oscr-badge:end
HTML
<!-- oscr-badge:start -->
<a href="https://openscicode.org/badge/doi/10.1016/j.crmeth.2026.101372"><img src="https://openscicode.org/badge/doi/10.1016/j.crmeth.2026.101372.svg" alt="OSCR"></a>
<!-- oscr-badge:end -->

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)

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