forked from lfkrapp/easy-pancake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_functions.py
27 lines (20 loc) · 1.07 KB
/
plot_functions.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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
plt.style.use('ggplot')
def plot_kmeans_centers(model, n_clust, pos=plt):
for k in range(n_clust):
n_entries = np.sum(model.labels_ == k)
pos.plot(model.cluster_centers_[k,:], label='c'+str(k)+' ('+str(n_entries)+')')
pos.legend(loc='best')
def plot_clust(model, df1, df2, l, pos = plt):
pos.plot(np.arange(10), df1.iloc[np.where(model.labels_==l)].values.T, color=(1.0,0.0,0.0,0.1))
pos.plot(np.arange(10), df2.iloc[np.where(model.labels_==l)].values.T, color=(0.0,0.0,1.0,0.1))
red = mpatches.Patch(color='red', label='prot')
blue = mpatches.Patch(color='blue', label='mRNA')
pos.legend(handles=[red,blue], loc='best')
def plot_clust_avg(model, df1, df2, l, pos = plt):
pos.plot(pd.DataFrame(df1.iloc[np.where(model.labels_==l)].values).mean(), label = "protein")
pos.plot(pd.DataFrame(df2.iloc[np.where(model.labels_==l)].values).mean(), label = "mRNA")
pos.legend(loc='best')