-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MenuBar Update and Configuration Updates
- Loading branch information
1 parent
fe7e010
commit 7282e40
Showing
65 changed files
with
26,123 additions
and
5,357 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules | ||
.next | ||
out | ||
|
||
*storybook.log |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { StorybookConfig } from "@storybook/nextjs"; | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
"../stories/**/*.mdx", | ||
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)", | ||
], | ||
addons: [ | ||
"@storybook/addon-onboarding", | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@chromatic-com/storybook", | ||
"@storybook/addon-interactions", | ||
], | ||
framework: { | ||
name: "@storybook/nextjs", | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: "tag", | ||
}, | ||
staticDirs: ["../public"], | ||
}; | ||
export default config; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Preview } from "@storybook/react"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"use client" | ||
|
||
import { useContext, useEffect, useRef, useState } from "react"; | ||
import LigandContext from "../../../../context/LigandContext"; | ||
import PyodideContext from "../../../../context/PyodideContext"; | ||
import Scatterplot from "../../../../components/tools/toolViz/ScatterPlot"; | ||
import Loader from "../../../../components/ui-comps/Loader"; | ||
|
||
export default function PCA() { | ||
const { ligand, setLigand } = useContext(LigandContext); | ||
const { pyodide } = useContext(PyodideContext); | ||
const [pca, setPCA] = useState<any[]>([]); | ||
const containerRef = useRef(null); | ||
const [loaded, setLoaded] = useState(false); | ||
|
||
useEffect(() => { | ||
setLoaded(false); | ||
if (ligand.some(obj => obj.pca)) { | ||
setPCA(ligand.map(obj => obj.pca)); | ||
setLoaded(true); | ||
} else { | ||
runDimRed(); | ||
} | ||
}, []); | ||
|
||
globalThis.fp = ligand.map((obj) => obj.fingerprint); | ||
|
||
async function runDimRed() { | ||
setLoaded(false); | ||
await pyodide.runPython(` | ||
from sklearn.decomposition import PCA | ||
import js | ||
pca = PCA(n_components=2) | ||
result = pca.fit_transform(js.fp) | ||
js.pca = result | ||
`); | ||
const pca_result = globalThis.pca.toJs(); | ||
const pca_data_in = pca_result.map(([x, y]) => ({ x, y })); | ||
let new_ligand = ligand.map((obj, index) => ({ | ||
...obj, | ||
pca: pca_data_in[index], | ||
})); | ||
setLigand(new_ligand); | ||
setPCA(pca_data_in); | ||
setLoaded(true); | ||
} | ||
|
||
return ( | ||
<div className="tools-container" ref={containerRef}> | ||
<h1>Principal Component Analysis</h1> | ||
{pca.length > 0 && ( | ||
<Scatterplot | ||
data={pca} | ||
colorProperty={ligand.map((obj) => obj.neg_log_activity_column)} | ||
hoverProp={ligand.map((obj) => obj.canonical_smiles)} | ||
xAxisTitle={"Principal Component 1"} | ||
yAxisTitle={"Principal Component 2"} | ||
id={ligand.map((obj) => obj.id)} | ||
/> | ||
)} | ||
{!loaded && <Loader loadingText="Doing PCA Magic" />} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.