-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsift_fig_correction.py
More file actions
93 lines (79 loc) · 3.34 KB
/
Copy pathsift_fig_correction.py
File metadata and controls
93 lines (79 loc) · 3.34 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# This script will make a new figure to count number of deleterious mutations
# rather than having the SIFT score on the y axis and the mito location or gene
# name on x axis.
# First we will import the necesarry modules.
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from statannotations.Annotator import Annotator
from statsmodels.stats.multicomp import pairwise_tukeyhsd
from scipy.stats import f_oneway
import scipy.stats as stat
from scikit_posthocs import posthoc_tukey
from io import StringIO
import os.path
# Define paths.
All = './All/'
No_1 = './No_1Mo/'
PK = './Only_PKO/'
# Read in the deleterious file as a dataframe.
df = pd.read_excel('Del_SIFT.xlsx')
# Rename the 'POS' Column to 'Mitochondrial Position'
df = df.rename(columns ={'POS' : 'Mitochondrial Position'})
# Only keep the string in GENE-NAME after mt-
df['GENE-NAME'] = df['GENE-NAME'].str.split('-').str[1]
# Rename Syn to Synaptosome.
df = df.replace('Syn', 'Synaptosome')
# Create a count column so that the deleterious mutations can be counted and
# have stats applied.
df['count'] = 0
# Since we are currently only interested in Polg and Polg-PKO (WT too, but none
# are deleterious), we will eliminate the other groups.
df1 = df[df.Strain != 'WT\n1Mo']
df1 = df1[df1.Strain != 'PKO\n1Mo']
df2 = df1[df1.Strain != 'Polg-W402A']
# Separate by sample type and group by strain and name so that stats can be
# done on them..
Synall = df[df['Sample_type'] == 'Synaptosome']
WBHall = df[df['Sample_type'] == 'Homogenate']
Synall = Synall.groupby(['Name', 'Strain','GENE-NAME', 'REF-ALLELE',
'ALT-ALLELE']).mean().reset_index()
WBHall = WBHall.groupby(['Name','Strain', 'GENE-NAME', 'REF-ALLELE',
'ALT-ALLELE']).mean().reset_index()
Synno1mo = df1[df1['Sample_type'] == 'Synaptosome']
WBHno1mo = df1[df1['Sample_type'] == 'Homogenate']
Synno1mo = Synno1mo.groupby(['Name', 'Strain','GENE-NAME', 'REF-ALLELE',
'ALT-ALLELE']).mean().reset_index()
WBHno1mo = WBHno1mo.groupby(['Name','Strain', 'GENE-NAME', 'REF-ALLELE',
'ALT-ALLELE']).mean().reset_index()
# create a heatmap so that the genes that have deleterious mutations can be
# compared between groups.
fig, axes = plt.subplots(1,1, figsize=(8,8))
sns.set_palette('colorblind')
sns.heatmap(pd.crosstab(Synall['GENE-NAME'], Synall['Strain']), annot=True,
cmap='YlGnBu')
plt.suptitle ('Synaptosome', weight='bold')
plt.yticks(rotation=0)
plt.savefig(os.path.join(All,'Heatmap_All_Syn_Del.png'))
fig, axes = plt.subplots(1,1, figsize=(8,8))
sns.heatmap(pd.crosstab(WBHall['GENE-NAME'], WBHall['Strain']), annot=True,
cmap='YlGnBu')
plt.suptitle ('Homogenate', weight='bold')
plt.yticks(rotation=0)
plt.savefig(os.path.join(All,'Heatmap_WBH_Del.png'))
# create a heatmap so that the genes that have deleterious mutations can be
# compared between groups.
fig, axes = plt.subplots(1,1, figsize=(8,8))
sns.set_palette('colorblind')
sns.heatmap(pd.crosstab(Synno1mo['GENE-NAME'], Synno1mo['Strain']), annot=True,
cmap='YlGnBu')
plt.suptitle ('Synaptosome', weight='bold')
plt.yticks(rotation=0)
plt.savefig(os.path.join(No_1,'Heatmap_Syn_Del.png'))
fig, axes = plt.subplots(1,1, figsize=(8,8))
sns.heatmap(pd.crosstab(WBHno1mo['GENE-NAME'], WBHno1mo['Strain']), annot=True,
cmap='YlGnBu')
plt.suptitle ('Homogenate', weight='bold')
plt.yticks(rotation=0)
plt.savefig(os.path.join(No_1,'Heatmap_WBH_Del.png'))