Skip to content

Commit 3ecee9d

Browse files
committed
fix bugs
- anova metabolite boxplot index - heatmap key error
1 parent 0e32db8 commit 3ecee9d

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/clustering.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,17 @@ def get_heatmap(data):
3636
# Create dataframe with sorted features
3737
ord_ft = ord_samp.T.reset_index()
3838
ord_ft = ord_ft.reindex(cluster_ft["leaves"])
39-
ord_ft.rename(columns={"index": "metabolite"}, inplace=True)
4039

41-
# ord_ft.set_index("metabolite", inplace=True)
40+
ord_ft.drop(columns=["row ID"], inplace=True)
41+
# Append string prefix to numeric indeces
42+
ord_ft.index = pd.Index(["m_"+x if x.isnumeric() else x for x in ord_ft.index.astype(str)])
4243

43-
# if we have numerical values convert them to strings to have even spacing
44-
# try:
45-
# float(ord_ft.index[0])
46-
# y_ticks = ["m_"+str(m) for m in ord_ft.index]
47-
# except ValueError:
48-
# y_ticks = list(ord_ft.index)
49-
ord_ft["metabolite"] = ord_ft["metabolite"].astype(str).apply(lambda x: "m_"+x if x.isnumeric() else x)
50-
ord_ft.set_index("metabolite", inplace=True)
51-
52-
y_ticks = ord_ft.index.tolist()
44+
st.dataframe(ord_ft)
45+
5346
# Heatmap
5447
fig = px.imshow(
5548
ord_ft,
56-
y=y_ticks,
49+
y=ord_ft.index.tolist(),
5750
x=list(ord_ft.columns),
5851
text_auto=False,
5952
aspect="auto",

src/fileselection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def load_from_gnps(task_id, cmn=False):
7575
an_url = f"https://proteomics2.ucsd.edu/ProteoSAFe/DownloadResultFile?task={task_id}&file=DB_result/&block=main"
7676
an = pd.read_csv(an_url, sep = "\t")[["#Scan#", "Compound_Name"]].set_index("#Scan#")
7777
if cmn:
78-
ft.index = ft["row ID"]
78+
ft.index = ft["row ID"].astype(str)
7979
ft = ft.drop(columns=["row m/z", "row retention time", "row ID"])
8080
else:
8181
index_with_mz_RT = pd.Index(ft.apply(lambda x: f'{x["row ID"]}_{round(x["row m/z"], 4)}_{round(x["row retention time"], 2)}', axis=1))

0 commit comments

Comments
 (0)