h-motifs and their significance#

The 26 h-motifs (Lee et al. 2020) classify how three connected hyperedges overlap. Counting them in the wire harness space and comparing with degree- and size-preserving randomizations (configuration model) gives a significance profile: patterns of nested and chained activities are over-represented with respect to chance.

import matplotlib.pyplot as plt

import hatvis as hv
from hatvis.plotting import plot_motif_profile

H = hv.datasets.load_wire_harness()
# [snippet:motifs]
cat = hv.motifs.h_motif_catalog()
z = hv.motifs.motif_zscores(H, hv.motifs.h_motifs, n_samples=30, random_state=0)
# [/snippet:motifs]
print(cat.head(3))
print(f"{(cat['closed']).sum()} closed and {(~cat['closed']).sum()} open h-motifs")
print(z[z["observed"] > 0].sort_values("z", ascending=False).head(6).round(2))
    A  B  C  AB  BC  AC  ABC  closed
h1  0  0  0   0   1   1    0   False
h2  0  0  0   0   1   1    1    True
h3  0  0  0   1   1   1    0    True
20 closed and 6 open h-motifs
     observed  null mean  null std     z  profile
h9         96      21.27     10.63  7.03     0.24
h2          4       0.70      0.92  3.61     0.13
h4          4       0.50      1.04  3.36     0.12
h8         96      39.23     18.12  3.13     0.11
h18       128     152.73     40.56 -0.61    -0.02
h12        12      26.33     14.06 -1.02    -0.04
fig, ax = plt.subplots(figsize=(9, 3.4))
plot_motif_profile(z, ax=ax, title="h-motif z-scores, wire harness vs. configuration model")
plt.tight_layout()
h-motif z-scores, wire harness vs. configuration model

Total running time of the script: (0 minutes 33.889 seconds)

Gallery generated by Sphinx-Gallery