<jupyter_start><jupyter_text>Drosophila Example - PCA on gene interaction graph<jupyter_code>import numpy as np
import pandas as pd
pd.set_option('display.max_rows', 50)
pd.set_option('display.max_columns', 50)
pd.set_option('display.width', 100)
from cycler import cycler
import matplotlib as mpl
mpl.rcParams['font.family'] = 'Helvetica'
mpl.rcParams['mathtext.fontset'] = 'cm'
mpl.rcParams['mathtext.rm'] = 'serif'
import matplotlib.pyplot as plt
import matplotlib.patches as mp
import shapely.geometry as sg
import descartes
from cycler import cycler
#DeEnModule imports
import deenmodule as dem
from deenmodule.datasets import load_drosophila_pca
# Load PCA DataFrames
df_pca, df_s = load_drosophila_pca()
display(df_pca)
display(df_s)
# Calculates DeEn (this takes a little while)
df_en, df_dec = dem.DeEnModule(df_pca)
display(df_en)
display(df_dec)<jupyter_output><empty_output><jupyter_text>Explained variance ratio<jupyter_code>fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(5,3))
#
df_s.iloc[:10].plot(kind='bar', ax=ax, zorder=3)
ax.set_ylabel("123")
ax.grid(zorder=1)<jupyter_output><empty_output><jupyter_text><jupyter_code>fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(8.5,8.5))
cyc = (cycler(edgecolor=['#1f77b4', '#ff7f0e', '#2ca02c']) + cycler(linestyle=['solid', 'dashed', 'dotted']))()
for dim, ax in zip(range(1,10), axes.flatten()):
    xdim = '{dim:d}c'.format(dim=dim)
    ydim = '{dim:d}c'.format(dim=(dim + 1))
    #
    ax.plot(0, 0, color='darkgray', marker='x', ms=16)
    #
    ax.axhline(y=0, c='black', lw=0.75, ls='-.', zorder=2)
    ax.axvline(x=0, c='black', lw=0.75, ls='-.', zorder=2)
    #
    df_pca.plot(x=xdim, y=ydim, c='gray', kind='scatter', ax=ax, rasterized=True)
    #
    ax.set_title('Components {xdim} and {ydim}'.format(xdim=dim, ydim=dim + 1))
    ax.set_xlabel('Component {xdim:d}'.format(xdim=dim))
    ax.set_ylabel('Component {ydim:d}'.format(ydim=dim + 1))
    #
    # Radius Circles
    df_en_tmp = df_en.loc[((df_en['dim'] == dim) & (df_en['circle-rank'].notnull())), :]
    sg_circles = {}
    for idx, cut_rank, radius in df_en_tmp[['circle-rank','radius-start']].to_records():
        # Shapely Circle
        #sg_circle = sg.Point(0, 0).buffer(radius)
        #sg_circles[cut_rank] = sg_circle
        # Matplotlib Circle
        props = next(cyc)
        mpl_circle = mp.Circle((0, 0), radius=radius, facecolor='none', zorder=6, **props)
        ax.add_patch(mpl_circle)

    #
    ax.grid(zorder=1)
plt.tight_layout()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1717572391907973, 'fraction_numerical': 0.023403411344704483, 'mean_word_length': 5.121359223300971, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '310108', 'license': 'MIT', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1015, 'n_words': 181, 'path': 'tutorials/Drosophila Example.ipynb', 'repo_name': 'rionbr/EnDeModule', 'size': '2521'}