.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/biology/plot_cell_cycle_arrest.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_biology_plot_cell_cycle_arrest.py: Cell cycle arrest ================= This example visualises protein protein interactions involved in the "cell cycle arrest" pathway. It also shows how to use ``iplotx`` to combine network plots with other matplotlib chart types. .. GENERATED FROM PYTHON SOURCE LINES 9-61 .. image-sg:: /gallery/biology/images/sphx_glr_plot_cell_cycle_arrest_001.png :alt: plot cell cycle arrest :srcset: /gallery/biology/images/sphx_glr_plot_cell_cycle_arrest_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import pandas as pd import networkx as nx import matplotlib.pyplot as plt import iplotx as ipx node_data = pd.read_csv("data/cell_cycle_arrest_string_network_coordinates.tsv", sep="\t", index_col=0) edge_data = pd.read_csv("data/cell_cycle_arrest_string_interactions_short.tsv", sep="\t") g = nx.Graph() g.add_edges_from(edge_data.iloc[:, :2].values) layout = node_data[["x_position", "y_position"]] node_data["color_ipx"] = [list(map(lambda x: float(x) / 256.0, x[4:-1].split(","))) for x in node_data["color"]] node_data["label_color"] = ["white" if np.mean(x) < 0.4 else "black" for x in node_data["color_ipx"]] fig = plt.figure(figsize=(9, 6)) ax = plt.subplot2grid((2, 3), (0, 0), colspan=2, rowspan=2) ax2 = plt.subplot2grid((2, 3), (0, 2)) ax3 = plt.subplot2grid((2, 3), (1, 2)) ipx.network( g, layout=layout, ax=ax, vertex_labels=True, vertex_marker="r", vertex_size="label", vertex_facecolor=node_data["color_ipx"].to_dict(), vertex_label_color=node_data["label_color"].to_dict(), vertex_edgecolor="k", vertex_linewidth=0.5, edge_alpha=0.2, vertex_zorder=3, ) degrees = np.bincount(list(dict(g.degree()).values())) bindegs = np.arange(len(degrees)) ax2.bar(bindegs, degrees, color="gray") ax2.set_xlabel("Node degree") ax2.set_ylabel("Number of\nproteins") pagerank = list(nx.pagerank(g).values()) ax3.ecdf(pagerank, color="black", complementary=True) ax3.axvline(0.1, ls="--", lw=2, color="tomato") ax3.set_xlabel("Node PageRank") ax3.set_ylabel("Cumulative") fig.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.238 seconds) .. _sphx_glr_download_gallery_biology_plot_cell_cycle_arrest.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cell_cycle_arrest.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cell_cycle_arrest.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_cell_cycle_arrest.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_