<jupyter_start><jupyter_text>Pie chart for molecular function analysisMolecular function categories were assigned to each differentially expressed gene through analysis of PATHER GO-Slim annotations  Import packages<jupyter_code># Import data handling and plotting packages
from math import pi
import pandas as pd
import bokeh
import bokeh.io
from bokeh.transform import cumsum
import bokeh.plotting
from bokeh.plotting import figure
bokeh.io.output_notebook()
from bokeh.io import export_png
# Manually assemble dataframe from Molecular Function Analysis
# See Fig3D_PATHER_MolecFunc_GeneList.xlsx for details
x = {
    'Transcriptional regulation': 23,
    'Structural and cytoskeletal': 19,
    'Signal transduction': 12,
    'Catalytic activity': 7,
    'Metabolic function': 6,
    'Post-transcriptional regulation': 5,
    'Cell cycle regulation': 4,
    'Cell junction/adhesion': 4,
    'Other': 4,
}

#Assemble pie chart
data = pd.Series(x).reset_index(name='gene_count').rename(columns={'index':'molec_function'})
data['angle'] = data['gene_count']/data['gene_count'].sum() * 2*pi
data['color'] = ['#08306b', '#08519c', '#2171b5', '#4292c6', '#6baed6', '#9ecae1', '#c6dbef', '#deebf7', '#f7fbff']

p = figure(plot_height=350, title="dnBMPR1A DEGs Molecular Functions", toolbar_location=None,
           tools="hover", tooltips="@molec_function: @gene_count", x_range=(-0.5, 1.0), 
      frame_height=500, frame_width=800)

p.wedge(x=0, y=1, radius=0.4,
        start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
        line_color="white", line_width=5, fill_color='color', legend_field='molec_function', source=data)

p.axis.axis_label=None
p.axis.visible=False
p.grid.grid_line_color = None

export_png(p, filename="plots/dnBMPR1A_DEGS_MolecularFunctions_PieChart.png")

bokeh.io.show(p)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13012958963282936, 'fraction_numerical': 0.032937365010799136, 'mean_word_length': 5.992452830188679, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '266800', 'license': 'MIT', 'n_tokens_mistral': 697, 'n_tokens_neox': 625, 'n_words': 146, 'path': 'Fig3_RNASeq/2_Python_Plotting/Fig3D_MolecularFunction_Pie.ipynb', 'repo_name': 'mpiacentino/2021-Transcriptome-profiling-reveals-BMP-target-genes-during-midbrain-neural-crest-delamination', 'size': '1852'}