qbiocode.apps.quvine.analysis.analyze module#

Summary#

Functions:

cca_correlation

effective_rank

knn_overlap

knn_sets

normalize

plot_singular_values

Plot the log singular-value spectrum, optionally writing it to filename.

procrustes_residual

rsa_corr

spectral_info

Singular-value spectra and effective ranks for a list of embeddings.

Reference#

normalize(embedding, eps=1e-08)[source]#
procrustes_residual(Z1, Z2)[source]#
cca_correlation(Z1, Z2, n_components=10)[source]#
rsa_corr(Z1, Z2)[source]#
knn_sets(Z, k=10)[source]#
knn_overlap(Z1, Z2, k=10)[source]#
effective_rank(s)[source]#
plot_singular_values(singular_values, label='concatenate', filename=None, show=False)[source]#

Plot the log singular-value spectrum, optionally writing it to filename.

Parameters:
  • singular_values – Singular values in descending order.

  • label – Legend label for the series.

  • filename – Where to write the figure; nothing is written when None.

  • show – Whether to call plt.show(). Defaults to False because this is library code – under a GUI backend show blocks until a human closes the window, and it is ignored under a non-interactive one.

Returns:

the figure, already closed but still savable.

Return type:

matplotlib.figure.Figure

spectral_info(embeddings, labels, plot_flag=False, outdir='.', show=False)[source]#

Singular-value spectra and effective ranks for a list of embeddings.

Parameters:
  • embeddings – Embedding matrices to compare.

  • labels – One label per embedding, used in the legend and the result keys.

  • plot_flag – Whether to draw and write the three spectrum figures.

  • outdir – Directory the figures are written to. Previously they went to the process’s current working directory under fixed names, so two runs from the same directory silently overwrote each other’s plots.

  • show – Whether to call plt.show(); see plot_singular_values().

Returns:

{label: effective_rank}.

Return type:

dict