Skip to content

Commit

Permalink
Merge pull request #107 from jku-vds-lab/ch/prepDemoVersion
Browse files Browse the repository at this point in the history
add dummy embedding controller in case we are in demo mode
  • Loading branch information
dvmoritzschoefl authored Oct 17, 2023
2 parents 79adde3 + 422d071 commit 7a119fd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# REACT_APP_CIME_BACKEND_URL=https://reaction-optimization.caleydoapp.org/
# REACT_APP_CIME_BACKEND_URL=/api/reaction_cime
# REACT_APP_CIME_BACKEND_URL=/api/reaction_cime
16 changes: 16 additions & 0 deletions src/Overrides/Embeddings/DummyEmbeddingController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { EmbeddingController } from 'projection-space-explorer';

export class DummyEmbeddingController extends EmbeddingController {
init() {
// console.log('init');
}

override terminate() {
// console.log('terminate');
}

override supportsPause() {
// console.log('supportsPause');
return false;
}
}
98 changes: 57 additions & 41 deletions src/ReactionCIMEApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
import { connect, ConnectedProps, useDispatch } from 'react-redux';
import HelpIcon from '@mui/icons-material/Help';
import { IconButton, Tooltip } from '@mui/material';
import { useVisynAppContext } from 'visyn_core/app';
import { useVisynAppContext, VisynApp, VisynHeader } from 'visyn_core/app';
import { Anchor, useMantineTheme } from '@mantine/core';
import { VisynApp, VisynHeader } from 'visyn_core/app';

import { BrowserRouter, useSearchParams } from 'react-router-dom';
import { IClientConfig } from 'visyn_core/base';
import { LineUpContext } from './LineUpContext';
Expand All @@ -41,6 +41,7 @@ import bayerLogo from './assets/bayer_logo.svg';
import { BackendCSVLoader } from './Overrides/Dataset/BackendCSVLoader';
import { TabDocumentation } from './Utility/TabDocumentation';
import { BuildInfoContent, BuildInfoLogos } from './Utility/HeaderCustomization';
import { DummyEmbeddingController } from './Overrides/Embeddings/DummyEmbeddingController';

PluginRegistry.getInstance().registerPlugin(new ReactionsPlugin());

Expand All @@ -63,6 +64,7 @@ type PropsFromRedux = ConnectedProps<typeof connector>;
type Props = PropsFromRedux;

const ApplicationWrapper = connector(({ setMouseMoveFn, setMouseClickFn, resetViews }: Props) => {
const { clientConfig } = useVisynAppContext();
const loadedDataset = usePSESelector((state) => state.dataset);
const [searchParams, setSearchParams] = useSearchParams();
const dispatch = useDispatch();
Expand All @@ -76,6 +78,46 @@ const ApplicationWrapper = connector(({ setMouseMoveFn, setMouseClickFn, resetVi
}
};

const embeddings = [
{
id: 'umapRemote',
name: 'UMAP',
settings: { nneighbors: true },
embController: new RemoteEmbeddingController('umap', startProjection),
description:
'Performs Uniform Manifold Approximation (UMAP) on the whole dataset using the chosen feature columns. This projects the high-dimensional dataset to a two-dimensional space that will then be shown as a scatterplot.',
tooltip:
'Performs Uniform Manifold Approximation (UMAP) on the whole dataset using the chosen feature columns. This method scales better than t-SNE with an increasing number of points.',
},
{
id: 'tsneRemote',
name: 't-SNE',
settings: { perplexity: true },
embController: new RemoteEmbeddingController('tsne', startProjection),
description:
'Performs t-distributed stochastic neighbor embedding (t-SNE) on the whole dataset using the chosen feature columns. This projects the high-dimensional dataset to a two-dimensional space that will then be shown as a scatterplot.',
tooltip: 'Performs t-distributed stochastic neighbor embedding (t-SNE) on the whole dataset using the chosen feature columns.',
},
{
id: 'pcaRemote',
name: 'PCA',
settings: {},
embController: new RemoteEmbeddingController('pca', startProjection),
description:
'Performs principal component analysis (PCA) on the whole dataset using the chosen feature columns. This linearly projects the high-dimensional dataset to a two-dimensional space that will then be shown as a scatterplot.',
tooltip: 'Performs principal component analysis (PCA) on the whole dataset using the chosen feature columns.',
},
{
id: 'rmOverlap',
name: 'Overlap removal',
settings: { hideSettings: true },
embController: new RemoteEmbeddingController('rmOverlap', startProjection),
tooltip: 'Removes overlapping points by moving them to the nearest non-overlapping position. This helps to reduce visual clutter.',
description:
'Removes overlapping points of the current projection by moving them to the nearest non-overlapping position. This is particularly useful for large datasets after a projection like t-SNE or UMAP has been triggered to reduce visual clutter.',
},
];

const onLoadProject = React.useCallback(
(tableId: string) => {
new BackendCSVLoader().resolvePath(
Expand Down Expand Up @@ -132,45 +174,19 @@ const ApplicationWrapper = connector(({ setMouseMoveFn, setMouseClickFn, resetVi
baseUrl: ReactionCIMEBackendFromEnv.baseUrl,
}}
features={{
embeddings: [
{
id: 'umapRemote',
name: 'UMAP',
settings: { nneighbors: true },
embController: new RemoteEmbeddingController('umap', startProjection),
description:
'Performs Uniform Manifold Approximation (UMAP) on the whole dataset using the chosen feature columns. This projects the high-dimensional dataset to a two-dimensional space that will then be shown as a scatterplot.',
tooltip:
'Performs Uniform Manifold Approximation (UMAP) on the whole dataset using the chosen feature columns. This method scales better than t-SNE with an increasing number of points.',
},
{
id: 'tsneRemote',
name: 't-SNE',
settings: { perplexity: true },
embController: new RemoteEmbeddingController('tsne', startProjection),
description:
'Performs t-distributed stochastic neighbor embedding (t-SNE) on the whole dataset using the chosen feature columns. This projects the high-dimensional dataset to a two-dimensional space that will then be shown as a scatterplot.',
tooltip: 'Performs t-distributed stochastic neighbor embedding (t-SNE) on the whole dataset using the chosen feature columns.',
},
{
id: 'pcaRemote',
name: 'PCA',
settings: {},
embController: new RemoteEmbeddingController('pca', startProjection),
description:
'Performs principal component analysis (PCA) on the whole dataset using the chosen feature columns. This linearly projects the high-dimensional dataset to a two-dimensional space that will then be shown as a scatterplot.',
tooltip: 'Performs principal component analysis (PCA) on the whole dataset using the chosen feature columns.',
},
{
id: 'rmOverlap',
name: 'Overlap removal',
settings: { hideSettings: true },
embController: new RemoteEmbeddingController('rmOverlap', startProjection),
tooltip: 'Removes overlapping points by moving them to the nearest non-overlapping position. This helps to reduce visual clutter.',
description:
'Removes overlapping points of the current projection by moving them to the nearest non-overlapping position. This is particularly useful for large datasets after a projection like t-SNE or UMAP has been triggered to reduce visual clutter.',
},
],
embeddings: clientConfig.publicVersion
? [
{
id: 'noProjection',
name: 'Dummy Projection',
settings: { hideSettings: true },
embController: new DummyEmbeddingController(),
description:
'Performs a projection on the whole dataset using the chosen feature columns. This projects the high-dimensional dataset to a two-dimensional space that will then be shown as a scatterplot. Projections are disabled in the Demo version.',
tooltip: 'Performs a Projection on the whole dataset using the chosen feature columns.',
},
]
: embeddings,
showVisibleProjections: false,
showTrailSettings: false,
enableFeatureWeighing: true,
Expand Down

0 comments on commit 7a119fd

Please sign in to comment.