methods = ['nnm-sparse', 'nnm', 'rpca']
method_labels = {
"rpca" : "Clorinn (RPCA)",
"nnm" : "Clorinn (NNM)",
"nnm-sparse" : "Clorinn (NNM-Sparse)",
"truncated_svd": "DeGAs",
"factorgo": "FactorGO",
}
fig = plt.figure(figsize = (36,10))
axs = [fig.add_subplot(131), fig.add_subplot(132), fig.add_subplot(133)]
for i, method in enumerate(methods):
method_resdir = os.path.join(result_dir, method, "noRx")
with (open(f"{method_resdir}/pca_comps.pkl", "rb")) as fh:
U, S, V = pickle.load(fh)
S_squared = np.square(S)
explained_variance = np.cumsum(S_squared / np.sum(S_squared))
axs[i].plot(np.arange(500), explained_variance[:500])
axs[i].axvline(x = 200, linestyle='dashed', color = 'grey')
axs[i].axhline(y = explained_variance[199], linestyle='dashed', color = 'grey')
axs[i].set_xlabel("Number of factors")
if i == 0:
axs[i].set_ylabel("Cumulative explained variance")
axs[i].set_title(method_labels[method], pad = 15)
plt.savefig('../plots/colormann-manuscript/panukb_explained_variance.pdf', bbox_inches='tight')
plt.show()