Created
December 13, 2018 11:14
-
-
Save wdecoster/bd9ac9baa8f561952332ce756b0ec1e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import pandas as pd | |
import seaborn as sns | |
import matplotlib.pyplot as plt | |
from math import ceil | |
df_al = pickle.load(open("alignment.pickle", "rb")) | |
df_sum = pickle.load(open("summary.pickle", "rb")) | |
df_al_sel = df_al[df_al["lengths"] > 200][["readIDs", "percentIdentity"]].set_index('readIDs') | |
df_sum_sel = df_sum[["readIDs", "start_time"]].set_index('readIDs') | |
df = df_sum_sel.join(df_al_sel, how="inner") | |
maxtime = df["start_time"].max().total_seconds() | |
df['timebin'] = pd.cut( | |
x=df["start_time"], | |
bins=ceil((maxtime / 3600) / 3), | |
labels=[str(i) + "-" + str(i + 3) for i in range(0, 168, 3) if not i > (maxtime / 3600)]) | |
ax = sns.violinplot( | |
x=df["timebin"], | |
y=df["percentIdentity"], | |
inner=None, | |
cut=0, | |
linewidth=0) | |
ax.set( | |
xlabel='Interval (hours)', | |
ylabel="Percent identity", | |
title="Percent identity over time") | |
plt.xticks(rotation=45, ha='center', fontsize=8) | |
plt.ylim(50, 100) | |
fig = ax.get_figure() | |
fig.savefig( | |
fname="percentIdentityOverTimeViolin.png", | |
format="png", | |
bbox_inches='tight') | |
plt.close("all") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment