Spaces:
Sleeping
Sleeping
Delete interactive.py
Browse files- interactive.py +0 -166
interactive.py
DELETED
|
@@ -1,166 +0,0 @@
|
|
| 1 |
-
# %%
|
| 2 |
-
from collections import defaultdict
|
| 3 |
-
|
| 4 |
-
import altair as alt
|
| 5 |
-
import matplotlib.pyplot as plt
|
| 6 |
-
import pandas as pd
|
| 7 |
-
from cmap import Colormap
|
| 8 |
-
import polars as pl
|
| 9 |
-
|
| 10 |
-
#%%
|
| 11 |
-
|
| 12 |
-
df = pl.read_csv("example_data_bk.csv")
|
| 13 |
-
df.columns
|
| 14 |
-
|
| 15 |
-
df_crop = df[:, :3]
|
| 16 |
-
df_crop
|
| 17 |
-
|
| 18 |
-
df_crop.write_csv("example_data.csv")
|
| 19 |
-
#%%
|
| 20 |
-
|
| 21 |
-
# %%
|
| 22 |
-
kwargs = {"comment": "#", "header": [0, 1], "index_col": 0}
|
| 23 |
-
df = pd.read_csv("fit_result_batch.csv", **kwargs)
|
| 24 |
-
# %%
|
| 25 |
-
df
|
| 26 |
-
# %%
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
df_wt = df["SecB WT apo"].reset_index()
|
| 30 |
-
df_dimer = df["SecB his dimer apo"].reset_index()
|
| 31 |
-
|
| 32 |
-
AA_categories = {
|
| 33 |
-
"pos": ["R", "H", "K"],
|
| 34 |
-
"neg": ["D", "E"],
|
| 35 |
-
"aromatic": ["F", "W", "Y"],
|
| 36 |
-
"polar": ["S", "T", "N", "Q"],
|
| 37 |
-
"nonpolar": ["A", "V", "I", "L", "M"],
|
| 38 |
-
"other": ["G", "C", "P"],
|
| 39 |
-
}
|
| 40 |
-
cat_list = list(AA_categories)
|
| 41 |
-
AA_lut = {aa: category for category in AA_categories for aa in AA_categories[category]}
|
| 42 |
-
AA_lut
|
| 43 |
-
aa_cat_numbers = [cat_list.index(AA_lut[aa]) for aa in df_wt["sequence"]]
|
| 44 |
-
df_wt["aa_cat"] = aa_cat_numbers
|
| 45 |
-
|
| 46 |
-
# %%
|
| 47 |
-
cmap = Colormap("colorbrewer:Accent_6")
|
| 48 |
-
sol = defaultdict(list)
|
| 49 |
-
colors = cmap(df_wt["aa_cat"])
|
| 50 |
-
|
| 51 |
-
nums = range(6)
|
| 52 |
-
colors = cmap(nums)
|
| 53 |
-
|
| 54 |
-
for n, c in zip(nums, colors):
|
| 55 |
-
print(n, c)
|
| 56 |
-
# %%
|
| 57 |
-
len(cmap.color_stops)
|
| 58 |
-
|
| 59 |
-
colors = cmap.to_altair(N=cmap.num_colors)
|
| 60 |
-
domain = range(6)
|
| 61 |
-
altair_scale = alt.Scale(domain=domain, range=colors, clamp=True)
|
| 62 |
-
# %%
|
| 63 |
-
alt.Chart(df_wt).mark_point().encode(
|
| 64 |
-
x="r_number",
|
| 65 |
-
y="aa_cat",
|
| 66 |
-
color=alt.Color("aa_cat:N", scale=altair_scale),
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
# %%
|
| 70 |
-
import pandas as pd
|
| 71 |
-
|
| 72 |
-
df = pd.DataFrame({"a": [1, 2, 3, 4], "b": [7, 6, 5, 4], "c": ["a", "b", "b", "c"]})
|
| 73 |
-
|
| 74 |
-
chart = alt.Chart(df).mark_point().encode(alt.X("a"), alt.Y("b"), alt.Color("c:N"))
|
| 75 |
-
chart
|
| 76 |
-
# %%
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
# %%
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
ddG = df_wt["deltaG"] - df_dimer["deltaG"]
|
| 83 |
-
ddG
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
# %%
|
| 87 |
-
|
| 88 |
-
fig, ax = plt.subplots()
|
| 89 |
-
ax.scatter(df_wt["r_number"], df_wt["deltaG"])
|
| 90 |
-
|
| 91 |
-
# %%
|
| 92 |
-
fig, ax = plt.subplots()
|
| 93 |
-
ax.scatter(df_wt["r_number"], ddG)
|
| 94 |
-
|
| 95 |
-
# %%
|
| 96 |
-
df_wt.columns
|
| 97 |
-
# %%
|
| 98 |
-
|
| 99 |
-
output = pd.DataFrame(
|
| 100 |
-
{
|
| 101 |
-
"r_number": df_wt["r_number"],
|
| 102 |
-
"SecB tetramer ΔG": df_wt["deltaG"],
|
| 103 |
-
"dimer ΔΔG": ddG,
|
| 104 |
-
"aa_category": df_wt["aa_cat"],
|
| 105 |
-
}
|
| 106 |
-
)
|
| 107 |
-
output = output.set_index("r_number")
|
| 108 |
-
|
| 109 |
-
output
|
| 110 |
-
# %%
|
| 111 |
-
import numpy as np
|
| 112 |
-
|
| 113 |
-
N = 150
|
| 114 |
-
fuzzy_sin = 0.5 * (1 + np.sin(np.arange(N) / 10.0)) + np.random.normal(
|
| 115 |
-
loc=0, scale=0.1, size=N
|
| 116 |
-
)
|
| 117 |
-
df = pd.DataFrame({"fuzzy_sin": fuzzy_sin})
|
| 118 |
-
df
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
# add series to output dataframe a a column
|
| 123 |
-
|
| 124 |
-
output["fuzzy_sin"] = series
|
| 125 |
-
output
|
| 126 |
-
# %%
|
| 127 |
-
|
| 128 |
-
output.to_csv("SecB_data.csv")
|
| 129 |
-
# %%
|
| 130 |
-
|
| 131 |
-
dir(cmap)
|
| 132 |
-
cmap.category
|
| 133 |
-
|
| 134 |
-
# %%
|
| 135 |
-
|
| 136 |
-
tol_cmap = Colormap("tol:rainbow_discrete_7")
|
| 137 |
-
tol_cmap.category
|
| 138 |
-
tol_cmap.num_colors
|
| 139 |
-
tol_cmap.interpolation
|
| 140 |
-
|
| 141 |
-
# %%
|
| 142 |
-
|
| 143 |
-
tol_cmap = Colormap("vispy:hsl")
|
| 144 |
-
tol_cmap.category
|
| 145 |
-
tol_cmap.num_colors
|
| 146 |
-
tol_cmap.interpolation
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
# %%
|
| 150 |
-
tol_cmap = Colormap("yorick:stern")
|
| 151 |
-
tol_cmap.category
|
| 152 |
-
tol_cmap.num_colors
|
| 153 |
-
tol_cmap.interpolation
|
| 154 |
-
# %%
|
| 155 |
-
tol_cmap = Colormap("tol:rainbow_whbr")
|
| 156 |
-
tol_cmap.category
|
| 157 |
-
tol_cmap.num_colors
|
| 158 |
-
tol_cmap.interpolation
|
| 159 |
-
# %%
|
| 160 |
-
tol_cmap = Colormap("glasbey:glasbey")
|
| 161 |
-
tol_cmap.category
|
| 162 |
-
tol_cmap.num_colors
|
| 163 |
-
# tol_cmap.interpolation
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
# %%
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|