OSCR

Brain injury reactivates a developmental program driving genesis and integration of transient LGE-class interneurons.

Code ↔ Paper

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

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

The 5 matches
  1. [1] § Results › Astrocyte-generated striatal and cortical neuroblasts belong to the LGE interneurons class ↔ mouse/MouseWbGeKDCbAdult4_cellrank.py, lines 123 to 202 · score 0.63 · CGE_NR2F2, OB_MEIS2, LGE_MEIS2, PROX1, mapped, adult · block oscr:b:B18E3AWDH4GC2-B · Report a mismatch
  2. [2] § Results › Astrocyte-generated striatal and cortical neuroblasts belong to the LGE interneurons class ↔ mouse/MouseWbGeKDCbAdult.py, lines 200 to 257 · score 0.60 · CGE_NR2F2, OB_MEIS2, LGE_MEIS2, PROX1, adult, PAX6 · block oscr:b:G3V58RF75J5TJ-8 · Report a mismatch
  3. [3] § Results › Astrocyte-generated striatal and cortical neuroblasts belong to the LGE interneurons class ↔ mouse/MouseWbGeKDCbAdult2.py, lines 124 to 212 · score 0.57 · NR2F2, LGE_MEIS2, nkx2, ERBB4, LHX6, Prox1 · block oscr:b:2XQN5W1SV25BP-K · Report a mismatch
  4. [4] § STAR★Methods › Method details › scRNA-seq quality control and clustering ↔ merge/QvMWbGeKDCb.py, lines 120 to 186 · score 0.57 · Cell Cycle scores, log, subsetting, batches, PCA, PCs · block oscr:b:RN0H4X2VVQ54F-6 · Report a mismatch
  5. [5] § STAR★Methods › Method details › scRNA-seq quality control and clustering ↔ mouse/MouseWbGeKDCb1Subset.py, lines 204 to 249 · score 0.51 · Cell Cycle scores, subsetting, Rank, log, batches, genes · block oscr:b:JPT46X478HY3Q-K · 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

Python · 703 lines · 32 KB · no license · 1 match

  1. import os
  2. import scanpy
  3. import anndata
  4. import scanpy as sc
  5. import pandas as pd
  6. import numpy as np
  7. import scipy
  8. from scipy import stats
  9. import re
  10. import sklearn
  11. import matplotlib
  12. import matplotlib.pyplot as plt
  13. matplotlib.use('Agg')
  14. from collections import Counter
  15. import random
  16. import seaborn
  17. import sys
  18. import shutil
  19. import scvelo as scv
  20. import cellrank as cr
  21. import tqdm
  22. import bbknn
  23. #Load my pipeline functions
  24. import importlib
  25. import importlib.util
  26. spec = importlib.util.spec_from_file_location("ScanpyUtilsMT", os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../utils/ScanpyUtilsMT.py"))
  27. sc_utils = importlib.util.module_from_spec(spec)
  28. spec.loader.exec_module(sc_utils)
  29. sc.settings.figdir='/wynton/group/ye/mtschmitz/figures/mouseWbGeAdult2/'
  30. scv.settings.figdir='/wynton/group/ye/mtschmitz/figures/mouseWbGeAdult2/'
  31. sc.settings.file_format_figs='pdf'
  32. sc.settings.autosave=True
  33. sc.settings.autoshow=False
  34. equalize=False
  35. if equalize:
  36. sc.settings.figdir='/wynton/group/ye/mtschmitz/figures/mouseWbGeAdult2ET/'
  37. scv.settings.figdir='/wynton/group/ye/mtschmitz/figures/mouseWbGeAdult2ET/'
  38. #adata=sc.read('/wynton/group/ye/mtschmitz/macaquedevbrain/CAT202002_h5ad/KDCbVelocityDYNAMICALMouseWbGeAdult.h5ad')
  39. if equalize:
  40. adata=sc.read('/wynton/group/ye/mtschmitz/macaquedevbrain/CAT202002_h5ad/KDCbVelocityEqualizeTerminalsDYNAMICALMouseWbGeAdult.h5ad')
  41. else:
  42. adata=sc.read('/wynton/group/ye/mtschmitz/macaquedevbrain/CAT202002_h5ad/KDCbVelocityDYNAMICALMouseWbGeAdult.h5ad')
  43. #adata=sc.read('/wynton/group/ye/mtschmitz/macaquedevbrain/CAT202002_h5ad/KDCbVelocityDYNAMICALsmallMouseWbGeAdult.h5ad')
  44. adata=adata[:,np.isfinite(adata.X.mean(0))]
  45. adata.obs['agg_supervised_name']='nan'
  46. adata.obs['old_leiden']='nan'
  47. supercell=pd.read_csv('/wynton/group/ye/mtschmitz/macaquedevbrain/MouseAdultAggSupervised.txt')
  48. adata=adata[~adata.obs.index.duplicated(),:]
  49. supercell=supercell.loc[supercell['agg_supervised_name']!='nan',:]
  50. ind=adata.obs.index[adata.obs.index.isin(supercell['full_cellname'])]
  51. supercell.index=supercell['full_cellname']
  52. supercell=supercell.loc[~supercell.index.duplicated(),:]
  53. supercell=supercell.loc[ind,:]
  54. adata.obs.loc[ind,'agg_supervised_name']=supercell['agg_supervised_name']
  55. adata.obs.loc[ind,'old_leiden']=supercell['leiden']
  56. adata.obs['agg_supervised_name']=adata.obs['agg_supervised_name'].astype(str)
  57. adata.obs['old_leiden']=adata.obs['old_leiden'].astype(str)
  58. #adata.obs['agg_supervised_name']=adata.obs['agg_supervised_name']+"___"+adata.obs['old_leiden']
  59. sc.pl.umap(adata,color=['agg_supervised_name'])
  60. SPNgenes=['ISL1','TAC1','PDYN','NRXN1','EBF1','NPY1R','PCP4','DRD1','DRD2','PENK','ADORA2A','GPR6','FOXP1','FOXP2','FOXP4','CASZ1','OTOF','OPRM1','PBX3']
  61. scanpy.pl.matrixplot(adata[adata.obs.agg_supervised_name.str.contains('FOXP|SPN'),:],groupby='agg_supervised_name',var_names=SPNgenes,cmap='coolwarm',dendrogram=True,use_raw=False,standard_scale='var',save='LGEonlyeSPNgenes')
  62. sc.tl.dendrogram(adata,groupby='agg_supervised_name')
  63. df_plot = adata.obs.groupby(['agg_supervised_name', 'region']).size().reset_index().pivot(columns='region', index='agg_supervised_name', values=0).apply(lambda g: g / g.sum(),1)
  64. df_plot=df_plot.loc[adata.uns["dendrogram_agg_supervised_name"]['categories_ordered'],:]
  65. these_colors=[region_color_dict[x] for x in df_plot.columns]
  66. ax = df_plot.plot(kind='bar', legend=False,stacked=True,color=these_colors)
  67. plt.legend(loc='center left', bbox_to_anchor=(1.0, 0.5))
  68. plt.ylabel('proportion of cells in region')
  69. ax.grid(False)
  70. ax.get_figure().savefig(os.path.join(sc.settings.figdir,'supervisedNameRegionsStackBar.pdf'), bbox_inches="tight")
  71. """
  72. hierarchy_key='agg_supervised_name'
  73. sufficient_cells=adata.obs[hierarchy_key].value_counts().index[adata.obs[hierarchy_key].value_counts()>10]
  74. adata=adata[adata.obs[hierarchy_key].isin(sufficient_cells),:]
  75. adata.obs[hierarchy_key].cat.remove_unused_categories(inplace=True)
  76. rgs=sc.tl.rank_genes_groups(adata,groupby=hierarchy_key,method='logreg',use_raw=False,copy=True).uns['rank_genes_groups']#,penalty='elasticnet',solver='saga')#or penalty='l1'
  77. result=rgs
  78. groups = result['names'].dtype.names
  79. df=pd.DataFrame({group + '_' + key[:1]: result[key][group] for group in groups for key in ['names', 'scores']})
  80. df.to_csv(os.path.join(sc.settings.figdir,"LogReg"+hierarchy_key+"Norm.csv"))
  81. topgenes=df.iloc[0:4,['_n' in x for x in df.columns]].T.values
  82. cols=df.columns[['_n' in x for x in df.columns]]
  83. cols=[re.sub('_n','',x) for x in cols]
  84. topdict=dict(zip(cols,topgenes))
  85. sc.tl.dendrogram(adata,groupby=hierarchy_key)
  86. var_dict=dict(zip(adata.uns["dendrogram_"+hierarchy_key]['categories_ordered'],[topdict[x] for x in adata.uns["dendrogram_"+hierarchy_key]['categories_ordered']]))
  87. sc.pl.matrixplot(adata,groupby=hierarchy_key,var_names=var_dict,save='top_degenes'+hierarchy_key,cmap='RdBu_r',use_raw=False,dendrogram=True)
  88. hierarchy_key='old_leiden'
  89. sufficient_cells=adata.obs[hierarchy_key].value_counts().index[adata.obs[hierarchy_key].value_counts()>10]
  90. adata=adata[adata.obs[hierarchy_key].isin(sufficient_cells),:]
  91. adata.obs[hierarchy_key].cat.remove_unused_categories(inplace=True)
  92. rgs=sc.tl.rank_genes_groups(adata,groupby=hierarchy_key,method='logreg',use_raw=False,copy=True).uns['rank_genes_groups']#,penalty='elasticnet',solver='saga')#or penalty='l1'
  93. result=rgs
  94. groups = result['names'].dtype.names
  95. df=pd.DataFrame({group + '_' + key[:1]: result[key][group] for group in groups for key in ['names', 'scores']})
  96. df.to_csv(os.path.join(sc.settings.figdir,"LogReg"+hierarchy_key+"Norm.csv"))
  97. topgenes=df.iloc[0:4,['_n' in x for x in df.columns]].T.values
  98. cols=df.columns[['_n' in x for x in df.columns]]
  99. cols=[re.sub('_n','',x) for x in cols]
  100. topdict=dict(zip(cols,topgenes))
  101. sc.tl.dendrogram(adata,groupby=hierarchy_key)
  102. var_dict=dict(zip(adata.uns["dendrogram_"+hierarchy_key]['categories_ordered'],[topdict[x] for x in adata.uns["dendrogram_"+hierarchy_key]['categories_ordered']]))
  103. sc.pl.matrixplot(adata,groupby=hierarchy_key,var_names=var_dict,save='top_degenes'+hierarchy_key,cmap='RdBu_r',use_raw=False,dendrogram=True)
  104. sc.pl.violin(adata, ['n_genes'],groupby='dataset_name',
  105. jitter=0.4, multi_panel=True,rotation=90,stripplot=False,save='QC')
  106. print('QC')
  107. print(adata)
  108. mouseMSNs=pd.read_csv('/wynton/group/ye/mtschmitz/macaquedevbrain/FOXTSHZ1mouseAdultStriatumMSNMarkers.txt',sep='\s')
  109. mouseMSNs.index=mouseMSNs['Class']
  110. mouseMSNs=mouseMSNs.iloc[:,3:]
  111. mouseMSNs=mouseMSNs.div(mouseMSNs.max(0),axis=1)
  112. mouseMSNs=mouseMSNs.loc[['Neuron_dSPN_Drd1','Neuron_iSPN_Adora2a','Neuron_SPN_BNST_Amygdala_Otof'],:]
  113. mouseMSNs.drop('Syt6',inplace=True,axis=1)
  114. scanpy.pl.matrixplot(adata[adata.obs.agg_supervised_name.str.contains('FOXP|SPN'),:],groupby='agg_supervised_name',var_names=[re.sub('\.1','',x.upper()) for x in mouseMSNs.columns],cmap='coolwarm',dendrogram=True,use_raw=False,standard_scale='var',save='LGEonlyeSPNgenes')
  115. """
  116. paldict={'CGE_NR2F2/PROX1': 'slategray',
  117. 'G1-phase_SLC1A3/ATP1A1': '#17344c',
  118. 'G2-M_UBE2C/ASPM': '#19122b',
  119. 'LGE_FOXP1/ISL1': 'cyan',
  120. 'LGE_FOXP1/PENK': 'navy',
  121. 'LGE_FOXP2/TSHZ1': 'goldenrod',
  122. 'LGE_MEIS2/PAX6': 'orangered',
  123. 'LGE_MEIS2/PAX6/SCGN': 'orange',
  124. 'LGE-OB_MEIS2/PAX6': 'red',
  125. 'MGE_CRABP1/MAF': 'indigo',
  126. 'MGE_CRABP1/TAC3': 'fuchsia',
  127. 'MGE_LHX6/MAF': 'darksalmon',
  128. 'MGE_LHX6/NPY': 'maroon',
  129. 'RMTW_ZIC1/RELN': 'yellow',
  130. 'S-phase_MCM4/H43C': 'lawngreen',
  131. 'Transition': '#3c7632',
  132. 'VMF_ZIC1/ZIC2': 'teal',
  133. 'VMF_CRABP1/LHX8':'skyblue',
  134. 'VMF_NR2F2/LHX6':'lightseagreen',
  135. 'VMF_LHX1/POU6F2':'seagreen',
  136. 'VMF_TMEM163/OTP':'lightsteelblue',
  137. 'VMF_PEG10/DLK1':'steelblue',
  138. 'LGE_FOXP1/ISL1/NPY1R':'mediumpurple',
  139. 'nan':'white',
  140. 'Str_LHX8/CHAT':'olivedrab',
  141. 'Amy/Hypo_HAP1/PEG10':'darkslateblue',
  142. 'GP_GBX1/GABRA1':'teal',
  143. 'vSTR_HAP1/ZIC1':'darkslategray',
  144. 'Excitatory':'whitesmoke',
  145. 'Ctx_PROX1/LAMP5':'darkgoldenrod',
  146. 'Ctx_LHX6/LAMP5':'rosybrown',
  147. 'OB-GC_RPRM':'palegoldenrod',
  148. 'OB-GC_STXBP6/PENK':'olive',
  149. 'OB-PGC_FOXP2/CALB1':'aquamarine',
  150. 'OB-PGC_TH/SCGN':'orange',
  151. 'OB-PGC_ZIC':'saddlebrown',
  152. 'Ctx_LHX6/PVALB':'hotpink',
  153. 'Ctx_PROX1/SNCG':'lightslategray',
  154. 'Ctx_LHX6/SST':'salmon',
  155. 'Ctx/BN_SST/CHODL':'maroon',
  156. 'Ctx_CCK/VIP':'tan',
  157. 'Ctx_NR2F2/PAX6':'sienna',
  158. 'Ctx_PVALB/VIPR2':'lightcoral',
  159. 'BN-eSPN_FOXP2/TSHZ1':'springgreen',
  160. 'Str-dSPN_FOXP1/ISL1':'cyan',
  161. 'Str-iSPN_FOXP1/PENK':'navy',
  162. 'vStr_DRD1/NPY1R':'violet',
  163. 'Str-IN_CRABP1/MAF':'black',
  164. 'Glia':'lightgoldenrodyellow',
  165. 'OB-GC NR2F2/PENK':'brown',
  166. 'Ctx_LAMP5/NDNF':'khaki',
  167. 'Ctx_SST/NDNF':'peachpuff',
  168. 'Ctx_CCK/DPY19L1':'dimgray'}
  169. sc.pl.umap(adata,color=['agg_supervised_name'])
  170. my_pal=[paldict[x] for x in adata.obs['agg_supervised_name'].cat.categories]
  171. sc.pl.umap(adata,color=['old_leiden'],legend_loc='on data',legend_fontsize=4,palette=my_pal,save='old_leiden')
  172. sc.pl.umap(adata,color=['agg_supervised_name'],legend_loc='on data',legend_fontsize=4,palette=my_pal,save='agg_supervised_adult')
  173. sc.pl.umap(adata,color='latent_time',save='_linear_latent_time',color_map=matplotlib.cm.RdYlBu_r)
  174. ingenes=['VIP','VIPR2','SNCG','CCK','LAMP5','PROX1','NR2F2','SLC17A6','SLC17A7','MEIS2','TSHZ1','DLX2','DLX6','GAD1','GAD2','PAX6','ETV1','SCGN','TH','TRH','FOXP1','FOXP2','ISL1','PENK','ZIC1','RPRM','CRH','CALB1','CALB2','LHX6','LHX8','MAF','CRABP1','PVALB','SST','NPY','NPY1R','CHODL','CORT']
  175. ingenes=[x for x in ingenes if x in adata.var.index]
  176. sc.pl.umap(adata,color=ingenes,save='_INgenes2',use_raw=False)
  177. ingenes=['VIP','VIPR2','SNCG','CCK','LAMP5','PROX1','NR2F2','SLC17A6','SLC17A7','MEIS2','TSHZ1','DLX2','DLX6','GAD1','GAD2','PAX6','ETV1','SCGN','TH','TRH','FOXP1','FOXP2','ISL1','PENK','ZIC1','RPRM','CRH','CALB1','CALB2','LHX6','LHX8','MAF','CRABP1','PVALB','SST','NPY','NPY1R','CHODL','CORT']
  178. ingenes=[x for x in ingenes if x in adata.var.index]
  179. sc.pl.umap(adata,color=ingenes,save='_INgenes',use_raw=False)
  180. transition_matrix=scv.utils.get_transition_matrix(adata,vkey='linear_velocity',self_transitions=True)
  181. transition_matrix=transition_matrix.astype(np.float64)
  182. #transition_matrix=(transition_matrix.T/transition_matrix.sum(1)).T
  183. transition_matrix[np.arange(0,transition_matrix.shape[0]),transition_matrix.argmax(1).A1]+=(1.0-transition_matrix.sum(1).A1)
  184. print(np.allclose(np.sum(transition_matrix, axis=1), 1.0))
  185. vk = cr.tl.kernels.PrecomputedKernel(transition_matrix,adata=adata)
  186. #vk = cr.tl.kernels.VelocityKernel(adata,vkey='linear_velocity')
  187. ck = cr.tl.kernels.ConnectivityKernel(adata)
  188. ck.compute_transition_matrix()
  189. vk.compute_transition_matrix()
  190. ckvk=vk+ck
  191. ckvk.compute_transition_matrix()
  192. d={}
  193. for c in adata.obs.agg_supervised_name.unique():
  194. if not any([x in c.upper() for x in ['MGE','RMTW','CGE','LGE','VMF','G2-M','S-PHASE','GLIA','NAN','TRANSITION','EXCITATORY']]):
  195. print(c)
  196. select_cells=adata.obs.agg_supervised_name.isin([c])
  197. d[c]=[adata.obs.index[i] for i in range(adata.shape[0]) if select_cells[i]]
  198. terminal_states=list(d.keys())#+['MGE_CRABP1/MAF']
  199. g=cr.tl.estimators.CFLARE(ckvk)
  200. g.compute_eigendecomposition()
  201. g.set_terminal_states(d,cluster_key='agg_supervised_name')
  202. #comment these two to go fast
  203. g.compute_absorption_probabilities(show_progress_bar=True)
  204. g.compute_lineage_drivers()
  205. l=[]
  206. for c in g.lineage_drivers.columns:
  207. print(c)
  208. col=g.lineage_drivers[c]
  209. srt=col.sort_values(ascending=False)
  210. l.append(srt.index)
  211. l.append(srt)
  212. df=pd.DataFrame(l,index=np.repeat(g.lineage_drivers.columns,2)).T
  213. df.to_csv(os.path.join(sc.settings.figdir,"lineage_drivers.csv"))
  214. probDF=pd.DataFrame(g.absorption_probabilities,columns=g.absorption_probabilities.names,index=adata.obs.index)
  215. probDF['supervised_name']=list(adata.obs['agg_supervised_name'])
  216. probDF.index=adata.obs.index
  217. adata.obs['Adult']=adata.obs.agg_supervised_name.isin(adata.uns['to_terminal_states_names']).fillna(value=False)
  218. probDF.loc[list(adata.obs['Adult']),:]=np.nan
  219. adata.obs['Adult']=adata.obs['Adult'].astype(str)
  220. #adata.obs['eSPN_prob']=probDF['eSPN']
  221. #adata.obs['Lamp5_prob']=probDF['Lamp5']
  222. #adata.obs['Pvalb_prob']=probDF['Pvalb']
  223. #adata.obs['Sst_prob']=probDF['Sst']
  224. #adata.obs['dSPN_prob']=probDF['dSPN']
  225. #adata.obs['iSPN_prob']=probDF['iSPN']
  226. """trim=0.05
  227. trimmedProbDF=probDF[(probDF<1-trim)]#& (probDF>trim)
  228. probDF=(probDF-trimmedProbDF.mean(0))/trimmedProbDF.std(0)
  229. """
  230. #adata.obs['predicted_end']=probDF.idxmax(1)
  231. #sc.pl.umap(adata,color=['eSPN_prob','Lamp5_prob','Pvalb_prob','Sst_prob','iSPN_prob','dSPN_prob'],use_raw=False,save='CFLARE_probabilities')
  232. #g.plot_absorption_probabilities(same_plot=False, size=50, lineages=terminal_states[0:min(18,len(terminal_states))],basis='X_umap',save='CFLARE_all_probabiliities')
  233. #sc.pl.umap(adata,color=['predicted_end'],use_raw=False,save='CFLARE_predicted_end')
  234. adata.obs.drop('terminal_states_probs',axis=1,inplace=True)
  235. adata.write('/wynton/home/ye/mschmitz1/CFLARE'+str(equalize)+'mouseAdult2.h5ad')
  236. qvmdata=sc.read('/wynton/group/ye/mtschmitz/macaquedevbrain/CAT202002_h5ad/KDCbProcessedQvMMotor.h5ad')
  237. nz0=qvmdata.uns['neighbors']['distances'].nonzero()[0]
  238. nz1=qvmdata.uns['neighbors']['distances'].nonzero()[1]
  239. nz0i=qvmdata.obs.index[nz0]
  240. nz1i=qvmdata.obs.index[nz1]
  241. results=[nz0,
  242. nz1,
  243. qvmdata.obs.loc[nz0i,'species'],
  244. qvmdata.obs.loc[nz1i,'species'],
  245. qvmdata.obs.loc[nz0i,'supervised_name'],
  246. qvmdata.obs.loc[nz1i,'supervised_name']]
  247. df=pd.DataFrame(results,index=['ind1','ind2','species1','species2','classname1','classname2']).T
  248. mat=df.groupby('ind1')['classname2'].value_counts(dropna=False).unstack('classname2').fillna(0)
  249. #mat=mat.loc[:,mat.columns!='nan']
  250. crossdf=df.loc[(df['species1']=='Macaque')&(df['species2']=='Mouse'),:]
  251. crossdf2=df.loc[(df['species2']=='Macaque')&(df['species1']=='Mouse'),:]
  252. #crossdf=crossdf.loc[:,['ind1','ind2','classname1','classname2']]
  253. #crossdf2=crossdf2.loc[:,['ind1','ind2','classname1','classname2']]
  254. crossdf2.columns=['ind2','ind1','species1','species2','classname1','classname2']
  255. mnndf=pd.concat([crossdf,crossdf2],)
  256. mnndf['combo']=mnndf['ind1'].astype(str)+'_'+mnndf['ind2'].astype(str)
  257. mnndf=mnndf.rename({'classname1':'classname2','classname2':'classname1'},axis=1)
  258. mnndf=mnndf.loc[~mnndf['classname1'].str.contains('phase|G2-M|Transition'),:]
  259. mnndf=mnndf.loc[~mnndf['classname2'].str.contains('phase|G2-M|Transition'),:]
  260. cdfsums=mnndf.loc[mnndf['combo'].duplicated(),:].groupby('classname1')['classname2'].value_counts(normalize=True)
  261. sankeydf=cdfsums.unstack().stack().reset_index()
  262. adata.obs['agg_supervised_name'].cat.remove_unused_categories(inplace=True)
  263. ##################Forwards
  264. """
  265. devclusters=[c for c in adata.obs.agg_supervised_name.unique() if any([x in str(c).upper() for x in ['MGE','RMTW','CGE','LGE','VMF','G2-M','S-PHASE','GLIA','NAN','TRANSITION','Excitatory']])]
  266. adata.obs['Adult']=adata.obs.dataset_name.str.contains('BICCN|OB|konopkka|adult')|~adata.obs.agg_supervised_name.isin(devclusters)
  267. adultframe=adata.obs.loc[~adata.obs['Adult'],:]
  268. adultframe['agg_supervised_name'].cat.remove_unused_categories(inplace=True)
  269. adultframesums=adultframe.groupby(['agg_supervised_name'])['predicted_end'].value_counts(normalize=True)
  270. adultsankeydf=adultframesums.unstack().stack().reset_index()"""
  271. ###################Backwards
  272. #print(adata.obs)
  273. #print(adata.obs.index)
  274. #print(probDF.sort_values(c,ascending = False))
  275. #print(adata.obs.index[probDF.sort_values(c,ascending = False).index[:500]])
  276. ##########Backwards top N mapping
  277. max_cells_in_category=1000
  278. vcs=probDF['supervised_name'].value_counts()
  279. print(vcs)
  280. for t in vcs.index:
  281. print(t)
  282. print(vcs[t])
  283. print(max(vcs[t]-max_cells_in_category,0))
  284. destroy=np.random.choice(probDF.index[probDF['supervised_name']==t],size=max(vcs[t]-max_cells_in_category,0),replace=False)
  285. probDF=probDF.loc[~probDF.index.isin(destroy),:]
  286. topinds={}
  287. for c in probDF.columns:
  288. topinds[c]=list(adata.obs.loc[probDF.sort_values(c,ascending = False).index[:100],'agg_supervised_name'])
  289. adultsankeydf=pd.DataFrame(topinds).apply(lambda x: x.value_counts(normalize=True)).stack().reset_index()
  290. adultsankeydf.columns=['agg_supervised_name','predicted_end',0]
  291. ##########Backwards mean absorbtion normalized
  292. """
  293. probDF['supervised_name']=list(adata.obs['supervised_name'])
  294. meanDF=probDF.fillna(np.inf).groupby(['supervised_name']).mean().replace(np.inf, 0)
  295. meanDF=meanDF/meanDF.sum(0)
  296. #meanDF=meanDF.loc[meanDF.index.str.contains('VMF|LGE|MGE|CGE|RMTW'),:]
  297. adultsankeydf=meanDF.stack().reset_index()
  298. adultsankeydf.columns=['agg_supervised_name','predicted_end',0]
  299. """
  300. adultsankeydf=adultsankeydf.loc[adultsankeydf['agg_supervised_name'].str.contains('MGE|CGE|VMF|LGE|RMTW'),:]
  301. adultsankeydf=adultsankeydf.loc[~adultsankeydf['agg_supervised_name'].str.contains('supervised'),:]
  302. adultsankeydf=adultsankeydf.loc[~adultsankeydf['predicted_end'].str.contains('supervised'),:]
  303. cn1dict=dict(zip(sankeydf['classname1'].unique(),range(len(sankeydf['classname1'].unique()))))
  304. cn1len=len(sankeydf['classname1'].unique())
  305. cn2dict=dict(zip(sankeydf['classname2'].unique(),np.array(range(len(sankeydf['classname2'].unique())))+cn1len))
  306. cn2len=len(sankeydf['classname2'].unique())
  307. cn3dict=dict(zip(adultsankeydf['predicted_end'].unique(),np.array(range(len(adultsankeydf['predicted_end'].unique())))+cn1len+cn2len))
  308. cn3len=len(adultsankeydf['predicted_end'].unique())
  309. overalldict=dict(zip(list(cn1dict.keys())+list(cn2dict.keys())+list(cn3dict.keys()),list(cn1dict.values())+list(cn2dict.values())+list(cn3dict.values())))
  310. paldict={'CGE_NR2F2/PROX1': 'slategray',
  311. 'G1-phase_SLC1A3/ATP1A1': '#17344c',
  312. 'G2-M_UBE2C/ASPM': '#19122b',
  313. 'LGE_FOXP1/ISL1': 'cyan',
  314. 'LGE_FOXP1/PENK': 'navy',
  315. 'LGE_FOXP2/TSHZ1': 'goldenrod',
  316. 'LGE_MEIS2/PAX6': 'orangered',
  317. 'LGE_MEIS2/PAX6/SCGN': 'orange',
  318. 'LGE-OB_MEIS2/PAX6': 'red',
  319. 'MGE_CRABP1/MAF': 'indigo',
  320. 'MGE_CRABP1/TAC3': 'fuchsia',
  321. 'MGE_LHX6/MAF': 'darksalmon',
  322. 'MGE_LHX6/NPY': 'maroon',
  323. 'RMTW_ZIC1/RELN': 'yellow',
  324. 'S-phase_MCM4/H43C': 'lawngreen',
  325. 'Transition': '#3c7632',
  326. 'VMF_ZIC1/ZIC2': 'teal',
  327. 'VMF_CRABP1/LHX8':'skyblue',
  328. 'VMF_NR2F2/LHX6':'lightseagreen',
  329. 'VMF_LHX1/POU6F2':'seagreen',
  330. 'VMF_TMEM163/OTP':'lightsteelblue',
  331. 'VMF_PEG10/DLK1':'steelblue',
  332. 'LGE_FOXP1/ISL1/NPY1R':'mediumpurple',
  333. 'nan':'white',
  334. 'Str_LHX8/CHAT':'olivedrab',
  335. 'Amy/Hypo_HAP1/PEG10':'darkslateblue',
  336. 'GP_GBX1/GABRA1':'teal',
  337. 'vSTR_HAP1/ZIC1':'darkslategray',
  338. 'Excitatory':'whitesmoke',
  339. 'Ctx_PROX1/LAMP5':'darkgoldenrod',
  340. 'Ctx_LHX6/LAMP5':'rosybrown',
  341. 'OB-GC_RPRM':'palegoldenrod',
  342. 'OB-GC_STXBP6/PENK':'olive',
  343. 'OB-PGC_FOXP2/CALB1':'aquamarine',
  344. 'OB-PGC_TH/SCGN':'orange',
  345. 'OB-PGC_ZIC':'saddlebrown',
  346. 'Ctx_LHX6/PVALB':'hotpink',
  347. 'Ctx_PROX1/SNCG':'lightslategray',
  348. 'Ctx_LHX6/SST':'salmon',
  349. 'Ctx/BN_SST/CHODL':'maroon',
  350. 'Ctx_CCK/VIP':'tan',
  351. 'Ctx_NR2F2/PAX6':'sienna',
  352. 'Ctx_PVALB/VIPR2':'lightcoral',
  353. 'BN-eSPN_FOXP2/TSHZ1':'springgreen',
  354. 'Str-dSPN_FOXP1/ISL1':'cyan',
  355. 'Str-iSPN_FOXP1/PENK':'navy',
  356. 'vStr_DRD1/NPY1R':'violet',
  357. 'Str-IN_CRABP1/MAF':'black',
  358. 'Glia':'lightgoldenrodyellow',
  359. 'OB-GC NR2F2/PENK':'brown',
  360. 'Ctx_LAMP5/NDNF':'khaki',
  361. 'Ctx_SST/NDNF':'peachpuff',
  362. 'Ctx_CCK/DPY19L1':'dimgray'}
  363. #my_pal=[paldict[x] for x in supercell['agg_supervised_name'].unique()]
  364. my_pal=[paldict[x] for x in adata.obs['agg_supervised_name'].cat.categories]
  365. nodenames=list(cn1dict.keys())+list(cn2dict.keys())+list(cn3dict.keys())
  366. nodecolors=[paldict[x] for x in nodenames]
  367. alphacolors=['rgba'+str(matplotlib.colors.to_rgba(paldict[x],alpha=.59999999999999)) for x in paldict.keys()]
  368. paldict=dict(zip(paldict.keys(),alphacolors))
  369. toclass=list(sankeydf['classname1'])+list(adultsankeydf['predicted_end'])
  370. fromclass=list(sankeydf['classname1'])+list(adultsankeydf['agg_supervised_name'])
  371. values=list(sankeydf[0])+list(adultsankeydf[0])
  372. color=[paldict[x] for x in toclass]
  373. #linkcolor=[paldict[y] for x,y in zip(sankeydf[0]**2,sankeydf['classname1'])]
  374. linkcolor=[re.sub('0.59999999999999','%.2f' %x ,paldict[y]) for x,y in zip(values,fromclass)]
  375. import plotly
  376. import plotly.graph_objects as go
  377. fig = go.Figure(data=[go.Sankey(
  378. node = dict(
  379. pad = 5,
  380. thickness = 30,
  381. line = dict(color = "black", width = 0.5),
  382. label = nodenames,
  383. color = nodecolors
  384. ),
  385. link = dict(
  386. source = [cn1dict[x] for x in sankeydf['classname1']]+[cn2dict[x] for x in adultsankeydf['agg_supervised_name']],
  387. target = [cn2dict[x] for x in sankeydf['classname2']]+[cn3dict[x] for x in adultsankeydf['predicted_end']],
  388. value = values,
  389. color=linkcolor
  390. #color=[paldict[x] for x in sankeydf['classname1']]
  391. ))])
  392. fig.update_layout(title_text="Cross Species MNN", font_size=20)
  393. import plotly.io as pio
  394. os.environ["PATH"] = os.environ["PATH"] +':/wynton/home/ye/mschmitz1/utils/miniconda3/envs/cellrank/bin/'
  395. pio.write_image(fig, os.path.join(sc.settings.figdir,'CFLARE_Sankey.pdf'),width=1200,height=1200)
  396. del adata.obsm['to_terminal_states']
  397. del adata.uns['to_terminal_states_names']
  398. del g
  399. #g=cr.tl.estimators.CFLARE(ck)
  400. g = cr.tl.estimators.GPCCA(ckvk)
  401. #g.compute_eigendecomposition()
  402. g.compute_schur(n_components=50)
  403. g.set_terminal_states(d,cluster_key='agg_supervised_name')
  404. g.compute_absorption_probabilities(show_progress_bar=True)
  405. probDF=pd.DataFrame(g.absorption_probabilities,columns=g.absorption_probabilities.names,index=adata.obs.index)
  406. g.plot_absorption_probabilities(same_plot=False, size=50, basis='X_umap',lineages=terminal_states[0:min(18,len(terminal_states))],save='GPCCA_all_probabiliities')
  407. probDF['supervised_name']=list(adata.obs['agg_supervised_name'])
  408. probDF.index=adata.obs.index
  409. adata.obs['Adult']=adata.obs.agg_supervised_name.isin(adata.uns['to_terminal_states_names']).fillna(value=False)
  410. probDF.loc[list(adata.obs['Adult']),:]=np.nan
  411. adata.obs['Adult']=adata.obs['Adult'].astype(str)
  412. #adata.obs['eSPN_prob']=probDF['eSPN']
  413. #adata.obs['Lamp5_prob']=probDF['Lamp5']
  414. #adata.obs['Pvalb_prob']=probDF['Pvalb']
  415. #adata.obs['Sst_prob']=probDF['Sst']
  416. #adata.obs['dSPN_prob']=probDF['dSPN']
  417. #adata.obs['iSPN_prob']=probDF['iSPN']
  418. """trim=0.05
  419. trimmedProbDF=probDF[(probDF<1-trim)]#& (probDF>trim)
  420. probDF=(probDF-trimmedProbDF.mean(0))/trimmedProbDF.std(0)
  421. """
  422. #adata.obs['predicted_end']=probDF.idxmax(1)
  423. #sc.pl.umap(adata,color=['eSPN_prob','Lamp5_prob','Pvalb_prob','Sst_prob','iSPN_prob','dSPN_prob'],use_raw=False,save='GPPCA_probabilities')
  424. #sc.pl.umap(adata,color=['predicted_end'],use_raw=False,save='GPPCA_predicted_end')
  425. adata.obs.drop('terminal_states_probs',axis=1,inplace=True)
  426. adata.write('/wynton/home/ye/mschmitz1/GPCCA'+str(equalize)+'mouseAdult2.h5ad')
  427. nz0=qvmdata.uns['neighbors']['distances'].nonzero()[0]
  428. nz1=qvmdata.uns['neighbors']['distances'].nonzero()[1]
  429. nz0i=qvmdata.obs.index[nz0]
  430. nz1i=qvmdata.obs.index[nz1]
  431. results=[nz0,
  432. nz1,
  433. qvmdata.obs.loc[nz0i,'species'],
  434. qvmdata.obs.loc[nz1i,'species'],
  435. qvmdata.obs.loc[nz0i,'supervised_name'],
  436. qvmdata.obs.loc[nz1i,'supervised_name']]
  437. df=pd.DataFrame(results,index=['ind1','ind2','species1','species2','classname1','classname2']).T
  438. mat=df.groupby('ind1')['classname2'].value_counts(dropna=False).unstack('classname2').fillna(0)
  439. #mat=mat.loc[:,mat.columns!='nan']
  440. crossdf=df.loc[(df['species1']=='Macaque')&(df['species2']=='Mouse'),:]
  441. crossdf2=df.loc[(df['species2']=='Macaque')&(df['species1']=='Mouse'),:]
  442. #crossdf=crossdf.loc[:,['ind1','ind2','classname1','classname2']]
  443. #crossdf2=crossdf2.loc[:,['ind1','ind2','classname1','classname2']]
  444. crossdf2.columns=['ind2','ind1','species1','species2','classname1','classname2']
  445. mnndf=pd.concat([crossdf,crossdf2],)
  446. mnndf['combo']=mnndf['ind1'].astype(str)+'_'+mnndf['ind2'].astype(str)
  447. mnndf=mnndf.rename({'classname1':'classname2','classname2':'classname1'},axis=1)
  448. mnndf=mnndf.loc[~mnndf['classname1'].str.contains('phase|G2-M|Transition'),:]
  449. mnndf=mnndf.loc[~mnndf['classname2'].str.contains('phase|G2-M|Transition'),:]
  450. cdfsums=mnndf.loc[mnndf['combo'].duplicated(),:].groupby('classname1')['classname2'].value_counts(normalize=True)
  451. sankeydf=cdfsums.unstack().stack().reset_index()
  452. adata.obs['agg_supervised_name'].cat.remove_unused_categories(inplace=True)
  453. ##################Forwards
  454. """
  455. devclusters=[c for c in adata.obs.agg_supervised_name.unique() if any([x in str(c).upper() for x in ['MGE','RMTW','CGE','LGE','VMF','G2-M','S-PHASE','GLIA','NAN','TRANSITION','Excitatory']])]
  456. adata.obs['Adult']=adata.obs.dataset_name.str.contains('BICCN|OB|konopkka|adult')|~adata.obs.agg_supervised_name.isin(devclusters)
  457. adultframe=adata.obs.loc[~adata.obs['Adult'],:]
  458. adultframe['agg_supervised_name'].cat.remove_unused_categories(inplace=True)
  459. adultframesums=adultframe.groupby(['agg_supervised_name'])['predicted_end'].value_counts(normalize=True)
  460. adultsankeydf=adultframesums.unstack().stack().reset_index()"""
  461. ###################Backwards
  462. max_cells_in_category=1000
  463. vcs=probDF['supervised_name'].value_counts()
  464. for t in vcs.index:
  465. print(t)
  466. print(vcs[t])
  467. print(max(vcs[t]-max_cells_in_category,0))
  468. destroy=np.random.choice(probDF.index[probDF['supervised_name']==t],size=max(vcs[t]-max_cells_in_category,0),replace=False)
  469. probDF=probDF.loc[~probDF.index.isin(destroy),:]
  470. topinds={}
  471. for c in probDF.columns:
  472. topinds[c]=list(adata.obs.loc[probDF.sort_values(c,ascending = False).index[:100],'agg_supervised_name'])
  473. adultsankeydf=pd.DataFrame(topinds).apply(lambda x: x.value_counts(normalize=True)).stack().reset_index()
  474. adultsankeydf.columns=['agg_supervised_name','predicted_end',0]
  475. ##########Backwards mean absorbtion normalized
  476. """
  477. probDF['supervised_name']=list(adata.obs['supervised_name'])
  478. meanDF=probDF.fillna(np.inf).groupby(['supervised_name']).mean().replace(np.inf, 0)
  479. meanDF=meanDF/meanDF.sum(0)
  480. #meanDF=meanDF.loc[meanDF.index.str.contains('VMF|LGE|MGE|CGE|RMTW'),:]
  481. adultsankeydf=meanDF.stack().reset_index()
  482. adultsankeydf.columns=['agg_supervised_name','predicted_end',0]
  483. """
  484. adultsankeydf=adultsankeydf.loc[adultsankeydf['agg_supervised_name'].str.contains('MGE|CGE|VMF|LGE|RMTW'),:]
  485. adultsankeydf=adultsankeydf.loc[~adultsankeydf['agg_supervised_name'].str.contains('supervised'),:]
  486. adultsankeydf=adultsankeydf.loc[~adultsankeydf['predicted_end'].str.contains('supervised'),:]
  487. cn1dict=dict(zip(sankeydf['classname1'].unique(),range(len(sankeydf['classname1'].unique()))))
  488. cn1len=len(sankeydf['classname1'].unique())
  489. cn2dict=dict(zip(sankeydf['classname2'].unique(),np.array(range(len(sankeydf['classname2'].unique())))+cn1len))
  490. cn2len=len(sankeydf['classname2'].unique())
  491. cn3dict=dict(zip(adultsankeydf['predicted_end'].unique(),np.array(range(len(adultsankeydf['predicted_end'].unique())))+cn1len+cn2len))
  492. cn3len=len(adultsankeydf['predicted_end'].unique())
  493. overalldict=dict(zip(list(cn1dict.keys())+list(cn2dict.keys())+list(cn3dict.keys()),list(cn1dict.values())+list(cn2dict.values())+list(cn3dict.values())))
  494. paldict={'CGE_NR2F2/PROX1': 'slategray',
  495. 'G1-phase_SLC1A3/ATP1A1': '#17344c',
  496. 'G2-M_UBE2C/ASPM': '#19122b',
  497. 'LGE_FOXP1/ISL1': 'cyan',
  498. 'LGE_FOXP1/PENK': 'navy',
  499. 'LGE_FOXP2/TSHZ1': 'goldenrod',
  500. 'LGE_MEIS2/PAX6': 'orangered',
  501. 'LGE_MEIS2/PAX6/SCGN': 'orange',
  502. 'LGE-OB_MEIS2/PAX6': 'red',
  503. 'MGE_CRABP1/MAF': 'indigo',
  504. 'MGE_CRABP1/TAC3': 'fuchsia',
  505. 'MGE_LHX6/MAF': 'darksalmon',
  506. 'MGE_LHX6/NPY': 'maroon',
  507. 'RMTW_ZIC1/RELN': 'yellow',
  508. 'S-phase_MCM4/H43C': 'lawngreen',
  509. 'Transition': '#3c7632',
  510. 'VMF_ZIC1/ZIC2': 'teal',
  511. 'VMF_CRABP1/LHX8':'skyblue',
  512. 'VMF_NR2F2/LHX6':'lightseagreen',
  513. 'VMF_LHX1/POU6F2':'seagreen',
  514. 'VMF_TMEM163/OTP':'lightsteelblue',
  515. 'VMF_PEG10/DLK1':'steelblue',
  516. 'LGE_FOXP1/ISL1/NPY1R':'mediumpurple',
  517. 'nan':'white',
  518. 'Str_LHX8/CHAT':'olivedrab',
  519. 'Amy/Hypo_HAP1/PEG10':'darkslateblue',
  520. 'GP_GBX1/GABRA1':'teal',
  521. 'vSTR_HAP1/ZIC1':'darkslategray',
  522. 'Excitatory':'whitesmoke',
  523. 'Ctx_PROX1/LAMP5':'darkgoldenrod',
  524. 'Ctx_LHX6/LAMP5':'rosybrown',
  525. 'OB-GC_RPRM':'palegoldenrod',
  526. 'OB-GC_STXBP6/PENK':'olive',
  527. 'OB-PGC_FOXP2/CALB1':'aquamarine',
  528. 'OB-PGC_TH/SCGN':'orange',
  529. 'OB-PGC_ZIC':'saddlebrown',
  530. 'Ctx_LHX6/PVALB':'hotpink',
  531. 'Ctx_PROX1/SNCG':'lightslategray',
  532. 'Ctx_LHX6/SST':'salmon',
  533. 'Ctx/BN_SST/CHODL':'maroon',
  534. 'Ctx_CCK/VIP':'tan',
  535. 'Ctx_NR2F2/PAX6':'sienna',
  536. 'Ctx_PVALB/VIPR2':'lightcoral',
  537. 'BN-eSPN_FOXP2/TSHZ1':'springgreen',
  538. 'Str-dSPN_FOXP1/ISL1':'cyan',
  539. 'Str-iSPN_FOXP1/PENK':'navy',
  540. 'vStr_DRD1/NPY1R':'violet',
  541. 'Str-IN_CRABP1/MAF':'black',
  542. 'Glia':'lightgoldenrodyellow',
  543. 'OB-GC NR2F2/PENK':'brown',
  544. 'Ctx_LAMP5/NDNF':'khaki',
  545. 'Ctx_SST/NDNF':'peachpuff',
  546. 'Ctx_CCK/DPY19L1':'dimgray'}
  547. #my_pal=[paldict[x] for x in supercell['agg_supervised_name'].unique()]
  548. my_pal=[paldict[x] for x in adata.obs['agg_supervised_name'].cat.categories]
  549. nodenames=list(cn1dict.keys())+list(cn2dict.keys())+list(cn3dict.keys())
  550. nodecolors=[paldict[x] for x in nodenames]
  551. alphacolors=['rgba'+str(matplotlib.colors.to_rgba(paldict[x],alpha=.59999999999999)) for x in paldict.keys()]
  552. paldict=dict(zip(paldict.keys(),alphacolors))
  553. toclass=list(sankeydf['classname1'])+list(adultsankeydf['predicted_end'])
  554. fromclass=list(sankeydf['classname1'])+list(adultsankeydf['agg_supervised_name'])
  555. values=list(sankeydf[0])+list(adultsankeydf[0])
  556. color=[paldict[x] for x in toclass]
  557. #linkcolor=[paldict[y] for x,y in zip(sankeydf[0]**2,sankeydf['classname1'])]
  558. linkcolor=[re.sub('0.59999999999999','%.2f' %x ,paldict[y]) for x,y in zip(values,fromclass)]
  559. import plotly
  560. import plotly.graph_objects as go
  561. fig = go.Figure(data=[go.Sankey(
  562. node = dict(
  563. pad = 5,
  564. thickness = 30,
  565. line = dict(color = "black", width = 0.5),
  566. label = nodenames,
  567. color = nodecolors
  568. ),
  569. link = dict(
  570. source = [cn1dict[x] for x in sankeydf['classname1']]+[cn2dict[x] for x in adultsankeydf['agg_supervised_name']],
  571. target = [cn2dict[x] for x in sankeydf['classname2']]+[cn3dict[x] for x in adultsankeydf['predicted_end']],
  572. value = values,
  573. color=linkcolor
  574. #color=[paldict[x] for x in sankeydf['classname1']]
  575. ))])
  576. fig.update_layout(title_text="Cross Species MNN", font_size=20)
  577. import plotly.io as pio
  578. os.environ["PATH"] = os.environ["PATH"] +':/wynton/home/ye/mschmitz1/utils/miniconda3/envs/cellrank/bin/'
  579. pio.write_image(fig, os.path.join(sc.settings.figdir,'GPCCA_Sankey.pdf'),width=1200,height=1200)
  580. del adata.obsm['to_terminal_states']
  581. del adata.uns['to_terminal_states_names']
  582. del g
  583. g = cr.tl.estimators.GPCCA(ckvk)
  584. #g.compute_eigendecomposition()
  585. g.compute_schur(n_components=100,method='krylov')
  586. print('Schur complete',flush=True)
  587. g.plot_spectrum(real_only=True,save='spectrum')
  588. g.compute_macrostates(n_states=50, n_cells=30,cluster_key="agg_supervised_name")
  589. print('Macrostates computed', flush=True)
  590. #adata.write('/wynton/home/ye/mschmitz1/GPCCAmacrostatesmouseAdult2.h5ad')
  591. adata.uns['macrostates']=list(g.macrostates.cat.categories)
  592. g.set_terminal_states_from_macrostates([y for y in adata.uns['macrostates'].unique() if any([x in y for x in terminal_states])])
  593. g.compute_absorption_probabilities()
  594. probDF=pd.DataFrame(g.absorption_probabilities,columns=g.absorption_probabilities.names,index=adata.obs.index)
  595. adata.obs['predicted_end']=probDF.idxmax(1)
  596. #sc.pl.umap(adata,color=['eSPN_prob','Lamp5_prob','Pvalb_prob','Sst_prob','iSPN_prob','dSPN_prob'],use_raw=False,save='GPCCA_macrostates_selected_probabilities')
  597. sc.pl.umap(adata,color=['predicted_end'],use_raw=False,save='GPCCA_macrostates_predicted_end')
  598. g.plot_absorption_probabilities(same_plot=False, size=50,lineages=terminal_states[0:min(18,len(terminal_states))], basis='X_umap',save='GPCCA_macrostates_all_probabiliities')
  599. cr.tl.initial_states(adata, cluster_key='agg_supervised_name')
  600. cr.pl.initial_states(adata, discrete=True,save='GPCCA_macrostates_initial states')
  601. adata.obs.drop('terminal_states_probs',axis=1,inplace=True)
  602. #adata.write('/wynton/home/ye/mschmitz1/GPCCAmacrostatesmouseAdult2.h5ad')
  603. del adata.obsm['to_terminal_states']
  604. del adata.uns['to_terminal_states_names']
  605. del g

MouseWbGeKDCbAdult4_cellrank.py at commit 616c738, no license · at the source

Overview

Authors: G Nato1,2, M Fogli1,3, N Marichal4,5, V Cerrato1,2, G Turrini1,2, V Proserpio3,6, I Ghia1,3, G Zanotto1,3, I Molineris3, M Bergami7,8,9,10, S Oliviero3,6,11, P Peretto1,3, B Berninger4,5,12,13, A Buffo1,2, F Luzzati1,3
13 affiliations
  1. Neuroscience Institute Cavalieri Ottolenghi, Orbassano, Turin, Italy
  2. Department of Neurosciences “Rita Levi Montalcini”, University of Turin, Turin, Italy
  3. Department of Life Sciences and System Biology, University of Turin, Turin, Italy
  4. Centre for Developmental Neurobiology, Institute of Psychiatry, Psychology & Neuroscience, King’s College London, London, UK
  5. Institute of Physiological Chemistry, University Medical Center Johannes Gutenberg University, Mainz, Germany
  6. Molecular Biotechnology Center “Guido Tarone”, University of Turin, Turin, Italy
  7. Cologne Excellence Cluster on Cellular Stress Responses in Aging-Associated Diseases, University of Cologne, Cologne, Germany
  8. Center for Molecular Medicine, 50931 Cologne, Germany
  9. Institute of Genetics, University of Cologne, Cologne, Germany
  10. University of Cologne, Faculty of Medicine and University Hospital Cologne, Cologne, Germany
  11. Italian Institute for Genomic Medicine, Candiolo, Turin, Italy
  12. MRC Centre for Neurodevelopmental Disorders, Institute of Psychiatry, Psychology & Neuroscience, King’s College London, London, UK
  13. Focus Program Translational Neurosciences, Johannes Gutenberg University, Mainz, Germany
Journal: Stem cell reports, volume 21, issue 8, article 103015
Dates: received 19 September 2025; accepted 17 June 2026; published online 16 July 2026; in print August 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1016/j.stemcr.2026.103015 · PMID 42462713 · PMCID PMC13476880 · OpenAlex W4414705307
Open access: gold, a free copy (OpenAlex)
Status: code verified (how the code is found and verified)
Categories: mouse (organism)
Methods: Statistics, Smoothing, state filtering, decompositions, Machine learning, Connectivity, Evoked potentials
Keywords: reactive neurogenesis, circuit integration, dormant stem cells, cell fate specification, lateral ganglionic eminence interneurons, cortico-striatal-thalamic circuits, neuronal identity, neurorepair, astrocyte neural stem cell potential, postnatal development
MeSH: Interneurons*, Neurogenesis*, Animals, Astrocytes, Cell Differentiation, Gene Expression Regulation, Developmental, Mice, Neural Stem Cells, Neurodevelopment, PAX6 Transcription Factor, Telencephalon (* major topic)
Topic: Neonatal Respiratory Health Research (Pulmonary and Respiratory Medicine, Medicine), according to OpenAlex
Funding: Compagnia di San Paolo (S1618); Dipartimenti di Eccellenza (2023-2027, 2018–2022); European Regional Development Fund (2018-2022, HORIZON2020, 874758); Deutsche Forschungsgemeinschaft (2018-2022, 357058359); Ministero dell’Istruzione, dell’Università e della Ricerca (2023/2027, 20182022); Università degli Studi di Torino; HORIZON EUROPE Framework Programme; Ministero dell'Istruzione e del Merito
Citations: not cited yet (Europe PMC); 107 references in the paper
Research resources: Chicken polyclonal anti-GFP (1:1000) RRID:AB_10000240, RRID:AB_10000321, Guinea Pig polyclonal anti-DCX (1:1500) RRID:AB_1586992, RRID:AB_1964214, RRID:AB_2064130, Goat polyclonal anti-DCX (1:2000) RRID:AB_2088494, Rabbit polyclonal anti-FOXP2 (1:1000) RRID:AB_2107107, Mouse monoclonal anti-MEIS1/2/3 (1:250) RRID:AB_2143143, Goat polyclonal anti-SOX9 (1:1200) RRID:AB_2194160, RRID:AB_2195374, Rabbit polyclonal anti-RFP (1:1000) RRID:AB_2209751, RRID:AB_2247211, Mouse monoclonal anti-NeuN (1:1000) RRID:AB_2298772, RRID:AB_2307351, RRID:AB_2307443, RRID:AB_2315777, RRID:AB_2340375, RRID:AB_2340432, RRID:AB_2340437, RRID:AB_2340470, RRID:AB_2340681, RRID:AB_2340684, RRID:AB_2341099, Rabbit anti-cleaved caspase 3 (Asp175) RRID:AB_2341188, RRID:AB_2492288, Goat polyclonal anti-human ErbB4 (1:250) RRID:AB_354620, Monoclonal mouse anti-DARPP-32 (1:1000) RRID:AB_398980, RRID:AB_531793, RRID:AB_609566, Rabbit anti-IBA1 (1:1000) RRID:AB_839504, Rabbit anti-Sp8 (1:8000) RRID:AB_877304, Fiji RRID:SCR_002285, Imaris RRID:SCR_007370

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 5 matches between paragraphs and lines of code.

bunbunet

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: the link answers
Software Heritage: not checked
Found in: “Data and 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: github.com/bunbunet

mtvector/dev-and-evo-of-primate-inhibitory-neurons

License: none: the authors keep all their rights
State: the link answers, verified on 15 November 2026
Evidence: files inventoried
Commit: 616c7381a136fceec3da4e2d9f2710a0b664abf0, 8 November 2022
Languages: Python (35), Jupyter (2), Shell (1), JavaScript (1)
Size: 79 files, 39 scripts
Software Heritage: archived
Found in: the text, “Public datasets”
Holds: README, 1 notebook
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (36 files), Matplotlib (34 files), pandas (34 files), scikit-learn (34 files), seaborn (32 files), SciPy (31 files), Scanpy (29 files), anndata (27 files), scVelo (27 files), Numba (10 files), NetworkX (6 files), statsmodels (6 files), h5py (2 files), ImageJ / Fiji (2 files), Plotly (2 files), OpenCV (1 file), tifffile (1 file)
Availability: 2 checks, the latest on 15 November 2026: the link answers
  • 15 November 2026: the link answers
  • 27 September 2026: the link answers
40 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:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 39 scripts, each with its path and the digest of its content;
  • 5 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Code and data availability statement

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

Read it in the paper: doi.org/10.1016/j.stemcr.2026.103015.

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 2, 28 September 2026

  • Authors: added F Luzzati (0000-0003-0648-9989); removed F Luzzati
  • Funding: added Compagnia di San Paolo: S1618; Dipartimenti di Eccellenza: 2023-2027, 2018–2022; European Commission: 2018-2022, HORIZON2020, 874758; Deutsche Forschungsgemeinschaft: 2018-2022, 357058359; Ministero dell’Istruzione, dell’Università e della Ricerca: 2023/2027, 20182022; Università degli Studi di Torino; HORIZON EUROPE Framework Programme; Ministero dell'Istruzione e del Merito

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 15 authors, 10 keywords, 11 MeSH terms, 102 references, 33 RRIDs.

Cite

This paper

Nato, G., Fogli, M., Marichal, N., Cerrato, V., Turrini, G., Proserpio, V., Ghia, I., Zanotto, G., Molineris, I., Bergami, M., Oliviero, S., Peretto, P., Berninger, B., Buffo, A., & Luzzati, F. (2026). Brain injury reactivates a developmental program driving genesis and integration of transient LGE-class interneurons. Stem cell reports, 21(8), 103015. https://doi.org/10.1016/j.stemcr.2026.103015

BibTeX

@article{nato2026brain,
author = {Nato, G and Fogli, M and Marichal, N and Cerrato, V and Turrini, G and Proserpio, V and Ghia, I and Zanotto, G and Molineris, I and Bergami, M and Oliviero, S and Peretto, P and Berninger, B and Buffo, A and Luzzati, F},
title = {{Brain injury reactivates a developmental program driving genesis and integration of transient LGE-class interneurons}},
journal = {Stem cell reports},
year = {2026},
month = jul,
volume = {21},
number = {8},
pages = {103015},
publisher = {Elsevier},
issn = {2213-6711},
doi = {10.1016/j.stemcr.2026.103015},
url = {https://doi.org/10.1016/j.stemcr.2026.103015},
pmid = {42462713},
pmcid = {PMC13476880}
}

RIS

TY - JOUR
AU - Nato, G
AU - Fogli, M
AU - Marichal, N
AU - Cerrato, V
AU - Turrini, G
AU - Proserpio, V
AU - Ghia, I
AU - Zanotto, G
AU - Molineris, I
AU - Bergami, M
AU - Oliviero, S
AU - Peretto, P
AU - Berninger, B
AU - Buffo, A
AU - Luzzati, F
TI - Brain injury reactivates a developmental program driving genesis and integration of transient LGE-class interneurons
T2 - Stem cell reports
J2 - Stem Cell Reports
PY - 2026
DA - 2026/07/16
VL - 21
IS - 8
SP - 103015
SN - 2213-6711
PB - Elsevier
DO - 10.1016/j.stemcr.2026.103015
UR - https://doi.org/10.1016/j.stemcr.2026.103015
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.stemcr.2026.103015",
"type": "article-journal",
"title": "Brain injury reactivates a developmental program driving genesis and integration of transient LGE-class interneurons",
"container-title": "Stem cell reports",
"author": [
{
"family": "Nato",
"given": "G"
},
{
"family": "Fogli",
"given": "M"
},
{
"family": "Marichal",
"given": "N"
},
{
"family": "Cerrato",
"given": "V"
},
{
"family": "Turrini",
"given": "G"
},
{
"family": "Proserpio",
"given": "V"
},
{
"family": "Ghia",
"given": "I"
},
{
"family": "Zanotto",
"given": "G"
},
{
"family": "Molineris",
"given": "I"
},
{
"family": "Bergami",
"given": "M"
},
{
"family": "Oliviero",
"given": "S"
},
{
"family": "Peretto",
"given": "P"
},
{
"family": "Berninger",
"given": "B"
},
{
"family": "Buffo",
"given": "A"
},
{
"family": "Luzzati",
"given": "F"
}
],
"container-title-short": "Stem Cell Reports",
"volume": "21",
"issue": "8",
"page": "103015",
"DOI": "10.1016/j.stemcr.2026.103015",
"PMID": "42462713",
"PMCID": "PMC13476880",
"ISSN": "2213-6711",
"publisher": "Elsevier",
"URL": "https://doi.org/10.1016/j.stemcr.2026.103015",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
16
]
]
}
}

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

Similar papers

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

[1] doi:10.1016/j.stemcr.2024.08.006 [code]
Dynamic spatiotemporal activation of a pervasive neurogenic competence in striatal astrocytes supports continuous neurogenesis following injury.
Journal: Stem cell reports
In common: ImageJ / Fiji, mouse, 16 references, 2 authors
[2] doi:10.1038/s41586-022-04510-w [code]
The development and evolution of inhibitory neurons in primate cerebrum.
Journal: Nature
In common: ImageJ / Fiji, scVelo, tifffile, 14 other tools, mouse, 6 references
[3] 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: scVelo, tifffile, anndata, 12 other tools, 3 references
[4] doi:10.1038/s41586-024-08453-2 [code]
Mapping cells through time and space with moscot.
Journal: Nature
In common: scVelo, anndata, Scanpy, 9 other tools, mouse, 5 references
[5] doi:10.1038/s41467-025-62528-w [code]
Cross-species comparison reveals therapeutic vulnerabilities halting glioblastoma progression.
Journal: Nature communications
In common: anndata, Scanpy, seaborn, 5 other tools, mouse, 8 references
[6] doi:10.1038/s41586-022-05246-3 [code]
Embryo model completes gastrulation to neurulation and organogenesis.
Journal: Nature
In common: scVelo, anndata, Scanpy, 10 other tools, mouse, 2 references
[7] doi:10.1038/s41467-024-50414-w [code]
Interneuron diversity in the human dorsal striatum.
Journal: Nature communications
In common: tifffile, anndata, Scanpy, 7 other tools, mouse, 5 references
[8] doi:10.1371/journal.pbio.3001563 [code]
Pax6 limits the competence of developing cerebral cortical cells to respond to inductive intercellular signals.
Journal: PLoS biology
In common: scVelo, anndata, Scanpy, 8 other tools, 3 references
[9] doi:10.1093/bib/bbae250 [code]
Benchmarking mapping algorithms for cell-type annotating in mouse brain by integrating single-nucleus RNA-seq and Stereo-seq data.
Journal: Briefings in bioinformatics
In common: anndata, Scanpy, Numba, 9 other tools, mouse, 3 references
[10] doi:10.1038/s41593-025-01987-2 [code]
An expanded subventricular zone supports postnatal cortical interneuron migration in gyrencephalic brains.
Journal: Nature neuroscience
In common: scVelo, anndata, Scanpy, 3 other tools, mouse, 6 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.stemcr.2026.103015.svg)](https://openscicode.org/badge/doi/10.1016/j.stemcr.2026.103015)
<!-- oscr-badge:end -->
reStructuredText
.. oscr-badge:start

.. image:: https://openscicode.org/badge/doi/10.1016/j.stemcr.2026.103015.svg
   :target: https://openscicode.org/badge/doi/10.1016/j.stemcr.2026.103015
   :alt: OSCR

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

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

If you choose to, you can have the badge kept up to date for you, with oscr badge --write from the command line or with the GitHub Action in your repository's workflows. Every other form and option (a card, AsciiDoc, LaTeX, shields.io) is on the badge page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: code errors and mismatches between the code and the paper about this paper and its code, from readers and its authors, beside the paper and its tracing map.

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

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

Report a reproduction failure (signed in)

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

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