def screen_zscore(series, axis=None, z_score=False, plot=True):
"""
Calculate screen z score (difference between positive and negative controls).
"""
Z = lambda pos, neg: 1 - (3 * (np.std(pos) + np.std(neg)) / (abs(np.mean(pos) - np.mean(neg))))
if z_score:
series = (series - series.mean()) / series.std()
pos = series.ix[series.index[series.index.str.contains("Essential")]]
neg = series.ix[series.index[series.index.str.contains("CTRL")]]
z = Z(pos, neg)
# Plot
if plot:
pos.name = None
neg.name = None
if axis is None:
fig, axis = plt.subplots(1)
sns.distplot(pos, ax=axis, label="positive controls")
sns.distplot(neg, ax=axis, label="negative controls; screen Z-score = {}".format(z))
return z
评论列表
文章目录