plt.scatter(prior_samples['mu'][0,:,0,1],np.array(prior_samples['data_target'])[0,:,0,1]) #for one gene across all cells, unspliced (0) or spliced (1)plt.loglog()np.corrcoef(prior_samples['mu'][0,:,0,1],np.array(prior_samples['data_target'])[0,:,0,1])
#prior_samples['predictions_rearranged'][0,:,0,:,:].shapeplt.scatter(prior_samples['predictions_rearranged'][0,:,0,0,1],prior_samples['mu'][0,:,0,1]) #for one gene across all cells, unspliced (0) or spliced (1)plt.plot(prior_samples['predictions_rearranged'][0,:,0,0,1],prior_samples['predictions_rearranged'][0,:,0,0,1],color='black')plt.loglog()np.corrcoef(prior_samples['mu'][0,:,0,1],prior_samples['predictions_rearranged'][0,:,0,0,1])plt.xlabel('Bio. mu (prior)')plt.ylabel('Sampled mu (prior)')
T_c = np.mean(prior_samples['T_c'], axis =0)adata_rna.obs['Time'] = T_c - np.min(T_c)sc.pp.pca(adata_rna)sc.pl.pca(adata_rna,color=["Time", 'celltype'],ncols =2,size =100*adata_rna.obs['n_cells'],cmap ='inferno',title ='Time since initial condition in hours')
2.1 Make new adata with prior samples and new model_input
# #Check that data remained the same# plt.scatter(prior_samples['mu'][0,:,0,1],model_input['data'][:,0,1]) #for one gene across all cells, unspliced (0) or spliced (1)# plt.loglog()
#Check if prior_samples had mu, alpha_cg, T_c , predictions_rearranged
#Low correlation between mu and data generatedplt.scatter(prior_samples['mu'][0,:,0,1],model_input['data'][:,0,1]) #for one gene across all cells, unspliced (0) or spliced (1)plt.loglog()
# import pickle# # Load the dictionary from the file# with open("/g/stegle/aivazidis/data/posterior_RNA1layer_2500epochs_1.pkl", "rb") as f:# posterior = pickle.load(f)
fig = cd.predictions_vs_data( model_input['data'], posterior['deterministic']['mu'], ylabel ='Posterior Predictions', title ='Posterior vs Data',)
fig = cd.predictions_vs_data( model_input['data'], posterior['deterministic']['predictions_rearranged'][:,:,0,:,:], ylabel ='Posterior Predictions', title ='Posterior vs Data',)
T_c = np.mean(posterior['deterministic']['T_c'], axis =0)adata_rna.obs['Time'] = T_c - np.min(T_c)sc.pp.pca(adata_rna)sc.pl.pca(adata_rna,color=["Time", 'celltype'],ncols =2,size =100*adata_rna.obs['n_cells'],cmap ='inferno',title ='Time since initial condition in hours')
sc.pl.umap(adata_rna,color=["Time", 'celltype'],ncols =2,size =100*adata_rna.obs['n_cells'],cmap ='inferno',title ='Time since initial condition in hours')
fig = cd.posterior_data_geneset( posterior, model_input, adata_rna, ['Satb2', 'Eomes', 'Stmn2', 'Hopx'], plot_alpha=True)#Is this single-nucleus seq?#Update to have all rates
# import pickle# # Save the dictionary to a file# with open("/g/stegle/aivazidis/data/posterior_RNA1layer_2500epochs_1.pkl", "wb") as f:# pickle.dump(posterior, f)
# import pickle# # Load the dictionary from the file# with open("/g/stegle/aivazidis/data/posterior_RNA1layer_2500epochs_1.pkl", "rb") as f:# posterior = pickle.load(f)
fig = cd.predictions_vs_data( model_input['data'], posterior['deterministic']['mu'], ylabel ='Posterior Predictions', title ='Posterior vs Data',)
fig = cd.predictions_vs_data( model_input['data'], posterior['deterministic']['predictions_rearranged'][:,:,0,:,:], ylabel ='Posterior Predictions', title ='Posterior vs Data',)#why are 'biological' mu predictions lower than mu after sampling?
T_c = np.mean(posterior['deterministic']['T_c'], axis =0)adata_rna.obs['Time'] = T_c - np.min(T_c)sc.pp.pca(adata_rna)sc.pl.pca(adata_rna,color=["Time", 'time_info','state_info'],ncols =3,size =100*adata_rna.obs['n_cells'],cmap ='inferno',title ='Time since initial condition in hours')
fig = cd.predictions_vs_data( model_input_test['data'], posterior_test['deterministic']['mu'], ylabel ='Posterior Predictions', title ='Posterior vs Data (Test)',)
fig = cd.predictions_vs_data( model_input_test['data'], posterior_test['deterministic']['predictions_rearranged'][:,:,0,:,:], ylabel ='Posterior Predictions', title ='Posterior vs Data (Test)',)#why are 'biological' mu predictions lower than mu after sampling?
T_c = np.mean(posterior_test['deterministic']['T_c'], axis =0)adata_rna_test.obs['Time'] = T_c - np.min(T_c)sc.pp.pca(adata_rna_test)sc.pl.pca(adata_rna_test,color=["Time", 'time_info','state_info'],ncols =3,size =100*adata_rna_test.obs['n_cells'],cmap ='inferno',title ='Time since initial condition in hours')