-
Notifications
You must be signed in to change notification settings - Fork 1
/
Figure_1_Figure_Supplement_4.py
67 lines (50 loc) · 2.36 KB
/
Figure_1_Figure_Supplement_4.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
62
63
64
65
66
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jul 5 17:17:18 2022
@author: scottrk
"""
import os
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.patches as Patch
import seaborn as sns
from compile_data import summary_import
color_cycle = ['#ff9200', '#0433ff', '#932191', '#935200', '#008e00', 'gold']
fc = color_cycle*2
#ec = color_cycle + ['#000000'] * 6
fig, ax = plt.subplots(ncols=1, constrained_layout=True, figsize=(15, 8))
if not os.path.isfile("data/imported_data/summary_data_wide.csv"):
if not os.path.isdir("data/imported_data/"):
os.mkdir("data/imported_data")
summary_data = summary_import("data/Mouse_aging_mtDNA_summary.csv")
else:
summary_data = pd.read_csv("data/imported_data/summary_data_wide.csv",
index_col=0)
data = summary_data.query("Treatment in ['NT', 'perf'] & Age=='Old' & Tissue not in ['EC', 'R', 'He']")
plot = sns.barplot(x="Tissue", y="Total_SNV_Freq", hue="Treatment", data=data,
order=['K', 'L', 'Hi', 'C', 'M', 'B'],
ci='sd', edgecolor='black', lw=1.2, errwidth=1.5,
capsize=0.1, errcolor='black', ax=ax)
sns.stripplot(x="Tissue", y="Total_SNV_Freq", hue="Treatment", data=data,
order=['K', 'L', 'Hi', 'C', 'M', 'B'], dodge=True, ax=plot,
alpha=0.7, color='black')
for i in range(12):
plot.patches[i].set_facecolor(fc[i])
#plot.patches[i].set_edgecolor(ec[i])
if i < 5:
r, g, b, a = plot.patches[i].get_facecolor()
plot.patches[i].set_facecolor((r, g, b, .15))
plot.patches[i].set_edgecolor((r, g, b, 1))
plot.patches[i].set(lw=2.4)
legend = [Patch.Patch(facecolor='lightgrey', edgecolor='black', label='Old'),
Patch.Patch(facecolor='dimgrey', edgecolor='black', label='Old Perfused')]
plot.legend(handles=legend, fontsize='xx-large', loc='upper right')
plot.set_ylabel("SNV Mutation Frequency ($\mathregular{10^{-6}}$)", fontsize=20)
plot.set_xlabel("Tissue", fontsize=20)
plot.set_xticklabels(['Kidney', 'Liver', 'Hippo.', 'Cerebel.', 'Sk. Muscle', 'Blood'])
plot.tick_params(labelsize=18)
if not os.path.isdir("figures"):
os.mkdir("figures/")
fig.savefig('figures/Figure_1_Figure_Supplement_4.png', dpi=600, facecolor='white')
fig.savefig('figures/Figure_1_Figure_Supplement_4.pdf', dpi=600, facecolor='white')