In [1]:
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from cycler import cycler
import seaborn as sns
%matplotlib inline
%config InlineBackend.figure_format='retina' # for hi-dpi displays
from matplotlib.ticker import MultipleLocator, FormatStrFormatter, AutoMinorLocator
In [2]:
import re
from collections import defaultdict
from mpl_toolkits.mplot3d import Axes3D
from numpy import pi, cos, sin
In [3]:
figure_size = (5, 4)
default_figure = lambda: plt.subplots(figsize=figure_size)
save_figures = True
def savefig(filename, **kwargs):
if not save_figures:
return
import os
dir_ = 'figures/'
kwargs_ = dict(dpi=300, bbox_inches='tight')
#frameon=True, facecolor='white', transparent=False)
kwargs_.update(kwargs)
plt.savefig(dir_ + filename, **kwargs_)
In [4]:
sns.set_style('whitegrid')
In [5]:
sns.palplot(sns.color_palette())
In [6]:
PR_mspotx = pd.read_csv('results/Multispot 5samples PR all channels - Xavier.csv',
index_col=(0,1))
PR_mspotx = PR_mspotx.applymap(lambda x: float(re.sub('(\(.+\))?', '', x)))
PR_mspotx
Out[6]:
In [7]:
PR_mspotxt = PR_mspotx.reset_index()
PR_mspotxt.head(3)
Out[7]:
In [8]:
PR_mspotxtt = pd.melt(PR_mspotxt, id_vars=['Sample', 'Method'], var_name='Channel', value_name='PR')
PR_mspotxtt.head(3)
Out[8]:
In [9]:
fig, ax = plt.subplots(figsize=(15,3.5))
PR_mspotx.plot.bar(ax=ax)
Out[9]:
In [10]:
sns.swarmplot(x="Sample", y="PR", hue='Method', data=PR_mspotxtt);
In [11]:
sns.swarmplot(x="Channel", y="PR", hue='Method', data=PR_mspotxtt);
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
plt.gca().yaxis.set_minor_locator(AutoMinorLocator(4))
plt.grid(b=True, which='minor', axis='y', linestyle='-', lw=0.5, color='0.9')
In [12]:
meth_cy = iter(cycler('color', sns.color_palette()))
meth_cy_dict = defaultdict(lambda : next(meth_cy))
fig, ax = plt.subplots(figsize=(6, 6))
for sample in ('7d', '12d', '17d', '22d', '27d'):
for method in ('Gauss', 'KDE', 'SNA'):
E0 = PR_mspotx.loc[(sample, method)]
E0.plot(ax=ax, lw=2, **meth_cy_dict[method])
plt.legend(['Gauss', 'KDE', 'SNA'],bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
plt.xlabel("Channel")
plt.gca().yaxis.set_minor_locator(AutoMinorLocator(4))
plt.grid(b=True, which='minor', axis='y', linestyle='-', lw=0.5, color='0.9')
In [13]:
PR_mspot = pd.read_csv('results/Multi-spot - dsDNA - PR - all_samples all_ch.csv',
index_col=0)
PR_mspot
Out[13]:
In [14]:
PR_mspott = pd.melt(PR_mspot.reset_index(), id_vars='Sample', var_name='Channel', value_name='PR')
PR_mspott.head(3)
Out[14]:
In [15]:
sns.swarmplot(x="Channel", y="PR", hue='Sample', marker='s', data=PR_mspott);
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
plt.gca().yaxis.set_minor_locator(AutoMinorLocator(4))
plt.grid(b=True, which='minor', axis='y', linestyle='-', lw=0.5, color='0.9')
In [16]:
fig, ax = plt.subplots(1, 2, figsize=(14, 4))
plt.subplots_adjust(wspace=0.35)
sns.swarmplot(x="Channel", y="PR", hue='Sample', data=PR_mspotxtt, ax=ax[0]);
sns.swarmplot(x="Channel", y="PR", hue='Method', data=PR_mspotxtt, ax=ax[1]);
for a in ax:
a.legend(bbox_to_anchor=(1.02, 1), loc=2, borderaxespad=0.);
a.yaxis.set_minor_locator(AutoMinorLocator(4))
a.grid(b=True, which='minor', axis='y', linestyle='-', lw=0.5, color='0.9')
In [24]:
sns.stripplot(x="Channel", y="PR", hue='Sample', marker='*', size=9, lw=0.5, data=PR_mspott);
sns.stripplot(x="Channel", y="PR", hue='Sample', lw=0.5, data=PR_mspotxtt.query('Method=="Gauss"'));
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.);
plt.gca().yaxis.set_minor_locator(AutoMinorLocator(4))
plt.grid(b=True, which='minor', axis='y', linestyle='-', lw=0.5, color='0.9')
In [18]:
100*(PR_mspot.max(1) - PR_mspot.min(1))
Out[18]:
In [19]:
100*(PR_mspotx.query('Method=="Gauss"').max(1) - PR_mspotx.query('Method=="Gauss"').min(1))
Out[19]:
In [ ]: