### Database information
[https://www.start.umd.edu/gtd/downloads/Codebook.pdf](https://www.start.umd.edu/gtd/downloads/Codebook.pdf)
### Analysis on data set
[https://www.kaggle.com/START-UMD/gtd#globalterrorismdb_0718dist.csv] (https://www.kaggle.com/START-UMD/gtd#globalterrorismdb_0718dist.csv)
### Adapted from
[https://wormlabcaltech.github.io/Angeles_Leighton_2016/RNASeqAnalysis.html] (https://wormlabcaltech.github.io/Angeles_Leighton_2016/RNASeqAnalysis.html)
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
# import tissue_enrichment_analysis as tea
# import pyrnaseq_graphics as rsq
import scipy.stats as stats
import matplotlib as mpl
from IPython.core.display import HTML
# bokeh
import bokeh
# import bokeh.charts
# import bokeh.charts.utils
import bokeh.io
import bokeh.models
import bokeh.palettes
import bokeh.plotting
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import file_html
# Display graphics in this notebook
bokeh.io.output_notebook()
def make_expression_axes(tooltips, title,
xlabel, ylabel):
"""A function to plot the bokeh single mutant comparisons."""
# Make the hover tool
hover = bokeh.models.HoverTool(tooltips=tooltips,
names=['circles'])
# Create figure
p = bokeh.plotting.figure(title=title, plot_width=650,
plot_height=450)
p.xgrid.grid_line_color = 'white'
p.ygrid.grid_line_color = 'white'
p.xaxis.axis_label = xlabel
p.yaxis.axis_label = ylabel
# Add the hover tool
p.add_tools(hover)
return p
def add_points(p, df1, x, y, se_x, color='blue', alpha=0.2, outline=False):
# Define colors in a dictionary to access them with
# the key from the pandas groupby funciton.
df = df1.copy()
transformed_q = -df[y].apply(np.log10)
df['transformed_q'] = transformed_q
# FEATURE_delta_MEAN_IC50
df['transform_e'] = list(np.sign(df[se_x])*df[x])
source1 = bokeh.models.ColumnDataSource(df)
# Specify data source
p.circle(x='transform_e', y='transformed_q', size=7,
alpha=alpha, source=source1,
color=color, name='circles')
if outline:
p.circle(x='transform_e', y='transformed_q', size=7,
alpha=1,
source=source1, color='black',
fill_color=None, name='outlines')
# prettify
p.background_fill_color = "#DFDFE5"
p.background_fill_alpha = 0.5
return p
def selector(df,psig,fdrsig):
"""A function to separate tfs from everything else"""
sig_p = (df['ANOVA_FEATURE_pval'] < psig)
sig_fdr = (df['ANOVA_FEATURE_FDR'] < fdrsig)
to_plot_yes = df[sig_p & sig_fdr]
to_plot_not = df[~sig_p & ~sig_fdr]
return to_plot_not, to_plot_yes
def replace_drugname(df):
df = df.replace({'nkill':'Number People Killed',
'nkillus':'Number US People Killed',
'success':'Success',
'propvalue':'Damaged Property Value',
'nwound':'Number Wounded',
'nwoundus':'Number US Wounded',
'nhostkid':'Number Kidnapped Hostage',
'nhostkidus':'Number Kidnapped US Hostage',
'ndays':'Days Kidnapped Hostage',
'nreleased':'Number Hostage Released',
'ransomamt':'Ransom Amount',
'ransomamtus':'Ransom Amount from US sources',
'ransompaid':'Amount Ransom Paid',
'ransompaidus':'Amount Ransom Paid by US sources'},inplace=True)
menadf = pd.read_csv('mideastnorthaf/html_gdsc_anova/OUTPUT/results.csv')
replace_drugname(menadf)
menadf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'Middle East North Africa ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(menadf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
noramdf = pd.read_csv('northam/html_gdsc_anova/OUTPUT/results.csv')
replace_drugname(noramdf)
noramdf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'North America ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(noramdf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
souamdf = pd.read_csv('southam/html_gdsc_anova/OUTPUT/results.csv')
replace_drugname(souamdf)
souamdf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'South America ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(souamdf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
cenamdf = pd.read_csv('cenam-carib/html_gdsc_anova/OUTPUT/results.csv')
replace_drugname(cenamdf)
cenamdf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'Central America & Caribbean ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(cenamdf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
easteudf = pd.read_csv('easteu/html_gdsc_anova/OUTPUT/results.csv')
replace_drugname(easteudf)
easteudf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'Eastern Europe ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(easteudf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
westeudf = pd.read_csv('westeu/html_gdsc_anova/OUTPUT/results.csv')
westeudf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'Western Europe ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(westeudf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
soasiadf = pd.read_csv('southasia/html_gdsc_anova/OUTPUT/results.csv')
soasiadf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'South Asia ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(soasiadf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
soeastasiadf = pd.read_csv('southeastasia/html_gdsc_anova/OUTPUT/results.csv')
soeastasiadf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'Southeast Asia ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(soeastasiadf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)
subafdf = pd.read_csv('subaf/html_gdsc_anova/OUTPUT/results.csv')
subafdf
tooltips = [('Feature', '@FEATURE'),('Label','@DRUG_NAME')]
p = make_expression_axes( tooltips, 'Sub-Saharan Africa ANOVA associations',
'Signed Effect Size', '-log(Q)')
to_plot_not, to_plot_yes = selector(subafdf,0.001,25)
p = add_points(p, to_plot_not, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#1a9641')
p = add_points(p, to_plot_yes, 'FEATURE_IC50_effect_size', 'ANOVA_FEATURE_pval', 'FEATURE_delta_MEAN_IC50', color='#fc8d59', alpha=0.6, outline=True)
html = file_html(p, CDN, "my plot")
HTML(html)