fig, ax = plt.subplots(ncols=3, nrows=2) fig.suptitle("Chro " + str(chro)) for r, rep in enumerate(reps): FULL_STRUC_STRING = "Generated_Structures/cardio_full_rep_" + str( rep ) + "_eta_1000_alpha_0.6_lr_0.0001_epoch_400_res_1_step_15_chro_" + str( chro) + ".npy" MIS_STRUC_STRING = "Generated_Structures/cardio_missing_2_rep_" + str( rep ) + "_eta_1000_alpha_0.6_lr_0.0001_epoch_400_res_1_step_15_chro_" + str( chro) + ".npy" CONTACT_STRING = "Real_Data/Cardiomyocyte/RUES2/By_Chros/*_MES_Rep" + str( rep) + "_500KB_" + str(chro) CONTACT_STRING = glob.glob(CONTACT_STRING)[0] mat_contacts[r] = ut.loadConstraintAsMat(CONTACT_STRING, res=1) mat_mis_struc[r] = ut.loadStrucAtTimeAsMat(MIS_STRUC_STRING, time) mat_full_struc[r] = ut.loadStrucAtTimeAsMat(FULL_STRUC_STRING, time) for r, rep in enumerate(reps): ax[r, 0].set_ylabel("Rep " + str(rep)) ax[r, 0].imshow(np.clip(mat_contacts[r], 0, 30), cmap="Reds") ax[r, 1].imshow(np.clip(mat_mis_struc[r], 0, 10), cmap="Reds") ax[r, 2].imshow(np.clip(mat_full_struc[r], 0, 10), cmap="Reds") ax[1, 0].set_xlabel("Hi-C") ax[1, 1].set_xlabel("Recon") ax[1, 2].set_xlabel("Interp") print("CHRO" + str(chro)) print(spearmanr(mat_contacts[0], mat_contacts[0], axis=None)) print(spearmanr(mat_contacts[0], mat_full_struc[0], axis=None)) print(spearmanr(mat_contacts[0], mat_mis_struc[0], axis=None)) print(spearmanr(mat_contacts[0], mat_contacts[1], axis=None))
chro_full_spears = np.load("Fig_Scripts/iPSC_SPC_ful.npy", allow_pickle=True).item() pdb.set_trace() for chro in CHROS: if chro in chro_mis_spears.keys(): continue for r, rep in enumerate(reps): for day in DAY_LABELS: CONTACT_STRING = "Real_Data/iPluripotent/day_"+day+"_rep_"+str(rep)+"_chro_"+str(chro) print(CONTACT_STRING) mat_contacts[r, day] = ut.loadConstraintAsMat(CONTACT_STRING) for m, mis in enumerate(MISS): MIS_STRUC_STRING = "Generated_Structures/ipsc_missing_"+str(mis)+"_rep_"+str(rep)+"_eta_"+str(eta)+"_alpha_"+str(alpha)+"_lr_"+str(lr)+"_epoch_"+str(epoch)+"_res_"+str(res)+"_step_"+str(step)+"_chro_"+str(chro)+".npy" FULL_STRUC_STRING = "Generated_Structures/ipsc_full_rep_"+str(rep)+"_eta_"+str(eta)+"_alpha_"+str(alpha)+"_lr_" +str(lr)+"_epoch_"+str(epoch)+"_res_"+str(res)+"_step_"+str(step)+"_chro_"+str(chro)+".npy" print(MIS_STRUC_STRING) mat_mis_struc[r, mis] = ut.loadStrucAtTimeAsMat(MIS_STRUC_STRING, MIS_TIMES[m]) mat_full_struc[r, mis] = ut.loadStrucAtTimeAsMat(FULL_STRUC_STRING, MIS_TIMES[m]) mis_spears = np.zeros((len(reps), len(MISS), len(DAY_LABELS))) full_spears = np.zeros((len(reps), len(MISS), len(DAY_LABELS))) for r, rep in enumerate(reps): for m, mis in enumerate(MISS): for d, day in enumerate(DAY_LABELS): mis_spears[r,m,d] = spearmanr(mat_mis_struc[0,mis], mat_contacts[0,day], axis=None)[0] full_spears[r,m,d] = spearmanr(mat_full_struc[0,mis], mat_contacts[0,day], axis=None)[0] chro_mis_spears[chro]=mis_spears chro_full_spears[chro]=full_spears pdb.set_trace() np.save("Fig_Scripts/iPSC_SPC_mis",chro_mis_spears)
epoch = 400 reps = [1, 2] mat_contacts = {} mat_mis_struc = {} mat_full_struc = {} rep = 1 FULL_STRUC_STRING = "Generated_Structures/ipsc_full_rep_" + str( rep) + "_eta_" + str(eta) + "_alpha_" + str(alpha) + "_lr_" + str(lr) FULL_STRUC_STRING += "_epoch_" + str(epoch) + "_res_" + str( res) + "_step_" + str(step) + "_chro_" + str(chro) + ".npy" for t, (time, day) in enumerate( zip([0, 4, 8, 12, 16, 20], ['B', 'D2', 'D4', 'D6', 'D8', 'ES'])): mat_full_struc[t] = ut.loadStrucAtTimeAsMat(FULL_STRUC_STRING, time) CONTACT_STRING = "Real_Data/iPluripotent/day_" + str( day) + "_rep_" + str(rep) + "_chro_" + str(chro) mat_contacts[t] = ut.loadConstraintAsMat(CONTACT_STRING) for d, day in enumerate(['B', 'D2', 'D4', 'D6', 'D8', 'ES']): for t, time in enumerate([0, 4, 8, 12, 16, 20]): print( str(day) + "/" + str(time) + ":" + str( spearmanr(mat_full_struc[t], mat_contacts[d], axis=None) [0])) fig, ax = plt.subplots(2, 6, gridspec_kw={'wspace': 0.0, 'hspace': 0.0}) for t, time in enumerate([0, 4, 8, 12, 16, 20]): ax[0, t].imshow(np.clip(mat_full_struc[t], 0, 10), cmap="PuBuGn") ax[1, t].imshow(np.clip(mat_contacts[t], 0, 30), cmap="YlOrRd")
import pdb from scipy.stats import pearsonr from scipy.stats import spearmanr import numpy as np import matplotlib.pyplot as plt from Utils import util as ut fig, ax = plt.subplots(6, 6) for day, time in zip([0, 1, 2, 3, 4, 5], [0, 4, 8, 12, 16, 20]): real1 = 1 / ut.loadConstraintAsMat( "Synthetic_Data/Synthetic_Contact_Maps/struc1_" + str(day) + ".txt", res=100000) real2 = 1 / ut.loadConstraintAsMat( "Synthetic_Data/Synthetic_Contact_Maps/struc2_" + str(day) + ".txt", res=100000) full1 = 1 / ut.loadStrucAtTimeAsMat( "Generated_Structures/synthetic_full_rep_1_eta_10_alpha_1.0_lr_0.01_epoch_1000_res_100000_step_21_chro_all.npy", time) full2 = 1 / ut.loadStrucAtTimeAsMat( "Generated_Structures/synthetic_full_rep_2_eta_10_alpha_1.0_lr_0.01_epoch_1000_res_100000_step_21_chro_all.npy", time) if day == 0 or day == 5: struc1 = 1 / ut.loadStrucAtTimeAsMat( "Generated_Structures/synthetic_full_rep_1_eta_10_alpha_1.0_lr_0.01_epoch_1000_res_100000_step_21_chro_all.npy", time) struc2 = 1 / ut.loadStrucAtTimeAsMat( "Generated_Structures/synthetic_full_rep_2_eta_10_alpha_1.0_lr_0.01_epoch_1000_res_100000_step_21_chro_all.npy", time) else: struc1 = 1 / ut.loadStrucAtTimeAsMat( "Generated_Structures/synthetic_missing_" + str(day) + "_rep_1_eta_10_alpha_1.0_lr_0.01_epoch_1000_res_100000_step_21_chro_all.npy",