Spaces:
Sleeping
Sleeping
File size: 2,976 Bytes
692d068 |
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# %%
from collections import defaultdict
import altair as alt
import matplotlib.pyplot as plt
import pandas as pd
from cmap import Colormap
import polars as pl
#%%
df = pl.read_csv("example_data_bk.csv")
df.columns
df_crop = df[:, :3]
df_crop
df_crop.write_csv("example_data.csv")
#%%
# %%
kwargs = {"comment": "#", "header": [0, 1], "index_col": 0}
df = pd.read_csv("fit_result_batch.csv", **kwargs)
# %%
df
# %%
df_wt = df["SecB WT apo"].reset_index()
df_dimer = df["SecB his dimer apo"].reset_index()
AA_categories = {
"pos": ["R", "H", "K"],
"neg": ["D", "E"],
"aromatic": ["F", "W", "Y"],
"polar": ["S", "T", "N", "Q"],
"nonpolar": ["A", "V", "I", "L", "M"],
"other": ["G", "C", "P"],
}
cat_list = list(AA_categories)
AA_lut = {aa: category for category in AA_categories for aa in AA_categories[category]}
AA_lut
aa_cat_numbers = [cat_list.index(AA_lut[aa]) for aa in df_wt["sequence"]]
df_wt["aa_cat"] = aa_cat_numbers
# %%
cmap = Colormap("colorbrewer:Accent_6")
sol = defaultdict(list)
colors = cmap(df_wt["aa_cat"])
nums = range(6)
colors = cmap(nums)
for n, c in zip(nums, colors):
print(n, c)
# %%
len(cmap.color_stops)
colors = cmap.to_altair(N=cmap.num_colors)
domain = range(6)
altair_scale = alt.Scale(domain=domain, range=colors, clamp=True)
# %%
alt.Chart(df_wt).mark_point().encode(
x="r_number",
y="aa_cat",
color=alt.Color("aa_cat:N", scale=altair_scale),
)
# %%
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3, 4], "b": [7, 6, 5, 4], "c": ["a", "b", "b", "c"]})
chart = alt.Chart(df).mark_point().encode(alt.X("a"), alt.Y("b"), alt.Color("c:N"))
chart
# %%
# %%
ddG = df_wt["deltaG"] - df_dimer["deltaG"]
ddG
# %%
fig, ax = plt.subplots()
ax.scatter(df_wt["r_number"], df_wt["deltaG"])
# %%
fig, ax = plt.subplots()
ax.scatter(df_wt["r_number"], ddG)
# %%
df_wt.columns
# %%
output = pd.DataFrame(
{
"r_number": df_wt["r_number"],
"SecB tetramer ΔG": df_wt["deltaG"],
"dimer ΔΔG": ddG,
"aa_category": df_wt["aa_cat"],
}
)
output = output.set_index("r_number")
output
# %%
import numpy as np
N = 150
fuzzy_sin = 0.5 * (1 + np.sin(np.arange(N) / 10.0)) + np.random.normal(
loc=0, scale=0.1, size=N
)
df = pd.DataFrame({"fuzzy_sin": fuzzy_sin})
df
# add series to output dataframe a a column
output["fuzzy_sin"] = series
output
# %%
output.to_csv("SecB_data.csv")
# %%
dir(cmap)
cmap.category
# %%
tol_cmap = Colormap("tol:rainbow_discrete_7")
tol_cmap.category
tol_cmap.num_colors
tol_cmap.interpolation
# %%
tol_cmap = Colormap("vispy:hsl")
tol_cmap.category
tol_cmap.num_colors
tol_cmap.interpolation
# %%
tol_cmap = Colormap("yorick:stern")
tol_cmap.category
tol_cmap.num_colors
tol_cmap.interpolation
# %%
tol_cmap = Colormap("tol:rainbow_whbr")
tol_cmap.category
tol_cmap.num_colors
tol_cmap.interpolation
# %%
tol_cmap = Colormap("glasbey:glasbey")
tol_cmap.category
tol_cmap.num_colors
# tol_cmap.interpolation
# %%
|