in poincare_maps.py [0:0]
def plot_pseudotime(self, data, markesnames, labels, file_name=None, fs=8, idx=[], pm_pseudotime=None,colors_dict=None):
if pm_pseudotime is None:
pm_pseudotime = self.distances[self.iroot, :]
if colors_dict is None:
colors_dict = dict(zip(np.unique(labels), self.colors_palette[:len(np.unique(labels))]))
if len(idx):
# preserve global colors
pm_pseudotime = pm_pseudotime[idx]
data = data[idx, :]
labels = labels[idx]
n_plt = len(markesnames)
# n2 = int(np.sqrt(n_plt))
n2 = 3
n1 = n_plt // n2
if n1*n2 < n_plt:
n1 += 1
if n1 == 1:
n1 = 2
if n2 == 1:
n2 = 2
pl_size = 2
fig, axs = plt.subplots(n1, n2, sharey=False, figsize=(n2*pl_size + 2, n1*pl_size))
i = 0
for i1 in range(n1):
for i2 in range(n2):
axs[i1, i2].grid('off')
axs[i1, i2].yaxis.set_tick_params(labelsize=fs)
axs[i1, i2].xaxis.set_tick_params(labelsize=fs)
if i < n_plt:
marker = markesnames[i]
for j, label in enumerate(np.unique(labels)):
idx = np.where(labels == label)[0]
axs[i1, i2].plot(pm_pseudotime[idx], data[idx, i], marker='o', markerfacecolor='none', c=colors_dict[label], linestyle='', ms=2, label=marker)
axs[i1, i2].set_title(marker, fontsize=fs)
i += 1
if i == n_plt:
axs[i1, i2].legend(np.unique(labels), loc='center left', bbox_to_anchor=(1, 0.5), fontsize=fs)
else:
axs[i1, i2].axis('off')
axs[i1, i2].legend(np.unique(labels), loc='center left', bbox_to_anchor=(1, 0.5), fontsize=fs)
# for ax in axs.flat:
# ax.set(xlabel='pseudotime')
# # Hide x labels and tick labels for top plots and y ticks for right plots.
# for ax in axs.flat:
# ax.label_outer()
plt.xlabel('pseudotime', fontsize=fs)
fig.tight_layout()
if file_name:
plt.savefig(file_name + '.pdf', format='pdf')
plt.show()
plt.close(fig)