.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/08_higher_order/plot_28_h_motifs.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_08_higher_order_plot_28_h_motifs.py: 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. .. GENERATED FROM PYTHON SOURCE LINES 13-27 .. code-block:: Python 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)) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 .. GENERATED FROM PYTHON SOURCE LINES 28-31 .. code-block:: Python 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() .. image-sg:: /auto_examples/08_higher_order/images/sphx_glr_plot_28_h_motifs_001.png :alt: h-motif z-scores, wire harness vs. configuration model :srcset: /auto_examples/08_higher_order/images/sphx_glr_plot_28_h_motifs_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 33.889 seconds) .. _sphx_glr_download_auto_examples_08_higher_order_plot_28_h_motifs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/hatvis/main?urlpath=lab/tree/notebooks/auto_examples/08_higher_order/plot_28_h_motifs.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_28_h_motifs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_28_h_motifs.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_28_h_motifs.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_