/
figS9.py
61 lines (52 loc) · 1.88 KB
/
figS9.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# For numerical computing
import numpy as np
import scipy.stats
# For plotting
import matplotlib.pyplot as plt
import seaborn as sns
# Custom written utilities
import mwc_induction_utils as mwc
mwc.set_plotting_style()
# For OS interaction and reading of data files.
import glob
import pandas as pd
# Load example flow cytometry data
flow_data = pd.read_csv(
'../../data/20160813_O2_example_flow_cloud.csv', comment='#')
# Set the colors
colors = sns.color_palette('colorblind', n_colors=7)
colors[4] = sns.xkcd_palette(['dusty purple'])[0]
# Set the range of alpha.
alpha_range = [0.8, 0.6, 0.4, 0.25, 0.05]
# Generate an understandable legend.
plt.close('all')
fig = plt.figure()
plt.plot([], [], 'ko', label=r'100$^\mathrm{th}$')
for i, a in enumerate(alpha_range):
plt.plot([], [], 'o', color=colors[i], label=str(
int(a * 100)) + r'$^\mathrm{th}$')
leg = plt.legend(title=r'percentile', ncol=1, loc='upper left',
fontsize=14, bbox_to_anchor=(1.0, 1.0))
leg.get_title().set_fontsize('15')
plt.plot(flow_data['FSC-A'], flow_data['SSC-A'],
'ko', markersize=2, rasterized=True)
# plt.xscale('log')
# plt.yscale('log')
plt.xlabel('forward scatter (a.u.)')
plt.ylabel('side scatter (a.u.)')
# Plot the selected cells for a range of alpha
for i, a in enumerate(alpha_range):
gated_cells = mwc.auto_gauss_gate(np.log(flow_data), a)
plt.plot(np.exp(gated_cells['FSC-A']), np.exp(gated_cells['SSC-A']), 'o',
markersize=2, color=colors[i], rasterized=True)
plt.tight_layout()
plt.xscale('log')
plt.yscale('log')
plt.ylim([0.5 * np.min(flow_data['SSC-A']), 1.2 * np.max(flow_data['SSC-A'])])
plt.xlim([0.5 * np.min(flow_data['FSC-A']), 1.2 * np.max(flow_data['FSC-A'])])
# plt.margins(0.2)
# Save the figure.
mwc.scale_plot(fig, 'single_plot_wide')
plt.tight_layout()
fig.set_size_inches(4, 3)
plt.savefig('../../figures/SI_figs/figS9.pdf', bbox_inches='tight')