From 81b69976a43d7af6cf58dd640e92a248ca8bd321 Mon Sep 17 00:00:00 2001 From: Randy Creasi Date: Thu, 16 Jan 2025 13:49:00 -0500 Subject: [PATCH] Replace Vector Catalog in Cell Line Selector (cherry-picked) (#171) This commit already exists on master. This just cherry-picks it onto the external-24q4 branch. --- .../src/components/DataColumnSelect.tsx | 76 +++++++++++++++++++ .../components/LongTableCellLineSelector.tsx | 62 ++++++--------- .../src/styles/cell_line_selector.scss | 4 + .../utilities/renderCellLineSelectorModal.tsx | 23 ++---- .../packages/@depmap/data-explorer-2/index.ts | 3 + .../@depmap/data-explorer-2/src/api.ts | 6 +- .../CellLineSelectorModal.tsx | 4 +- .../DatasetMetadataSelector/index.tsx | 14 ++-- .../DatasetMetadataSelector/utils.ts | 2 +- .../@depmap/data-explorer-2/src/utils/misc.ts | 32 ++++++++ .../packages/elara-frontend/src/index.tsx | 6 +- .../src/modals/ElaraContextManager.tsx | 6 +- .../ElaraCustomAnalysesPage.tsx | 6 +- .../src/pages/Downloads/ElaraDataSlicer.tsx | 8 +- .../portal-frontend/src/apps/interactive.tsx | 7 +- .../src/apps/interactivev2.tsx | 7 +- .../celligner/components/CellignerPage.tsx | 4 +- .../ConfigurationPanel/ColorByViewOptions.tsx | 2 +- .../ConfigurationPanel/selectors.tsx | 2 - .../components/StandaloneContextEditor.tsx | 9 ++- .../hooks/useContextBuilder.tsx | 9 ++- .../packages/portal-frontend/src/index.tsx | 4 +- portal-backend/depmap/data_explorer_2/plot.py | 7 +- 23 files changed, 188 insertions(+), 115 deletions(-) create mode 100644 frontend/packages/@depmap/cell-line-selector/src/components/DataColumnSelect.tsx rename frontend/packages/{portal-frontend/src/data-explorer-2/components/ConfigurationPanel => @depmap/data-explorer-2/src/components}/DatasetMetadataSelector/index.tsx (85%) rename frontend/packages/{portal-frontend/src/data-explorer-2/components/ConfigurationPanel => @depmap/data-explorer-2/src/components}/DatasetMetadataSelector/utils.ts (96%) diff --git a/frontend/packages/@depmap/cell-line-selector/src/components/DataColumnSelect.tsx b/frontend/packages/@depmap/cell-line-selector/src/components/DataColumnSelect.tsx new file mode 100644 index 00000000..54d6ba7a --- /dev/null +++ b/frontend/packages/@depmap/cell-line-selector/src/components/DataColumnSelect.tsx @@ -0,0 +1,76 @@ +import React, { useState } from "react"; +import { + convertDimensionToSliceId, + DatasetMetadataSelector, + DimensionSelect, + PlotConfigSelect, +} from "@depmap/data-explorer-2"; +import styles from "../styles/cell_line_selector.scss"; + +interface Props { + onChange: ( + sliceId: string | null, + valueType: "continuous" | "categorical" + ) => void; +} + +function DataColumnSelect({ onChange }: Props) { + const [valueType, setValueType] = useState< + "continuous" | "categorical" | null + >(null); + const [value, setValue] = useState(null); + + return ( +
+ { + setValueType(nextValueType as "continuous" | "categorical"); + onChange(null, nextValueType as "continuous" | "categorical"); + setValue(null); + }} + options={{ + categorical: "Model Property", + continuous: "Matrix Data", + }} + /> + {valueType === "continuous" && ( + { + const sliceId = convertDimensionToSliceId(dimension); + onChange(sliceId, valueType); + }} + /> + )} + {valueType === "categorical" && ( + { + setValue(partialOrCompleteSliceId); + + if ( + partialOrCompleteSliceId && + partialOrCompleteSliceId.split("/").length === 4 + ) { + onChange(partialOrCompleteSliceId, valueType); + } else { + onChange(null, valueType); + } + }} + /> + )} +
+ ); +} + +export default DataColumnSelect; diff --git a/frontend/packages/@depmap/cell-line-selector/src/components/LongTableCellLineSelector.tsx b/frontend/packages/@depmap/cell-line-selector/src/components/LongTableCellLineSelector.tsx index a22434b9..8ec8ea7b 100644 --- a/frontend/packages/@depmap/cell-line-selector/src/components/LongTableCellLineSelector.tsx +++ b/frontend/packages/@depmap/cell-line-selector/src/components/LongTableCellLineSelector.tsx @@ -1,6 +1,7 @@ /* eslint-disable */ import * as React from "react"; -import { Link, VectorCatalog } from "@depmap/interactive"; +import { fetchMetadataColumn } from "@depmap/data-explorer-2"; +import { Link } from "@depmap/interactive"; import { Button } from "react-bootstrap"; import { CellData } from "../models/cellLines"; import update from "immutability-helper"; @@ -18,6 +19,7 @@ import { inferColumnType, } from "@depmap/long-table"; import { ApiContext } from "@depmap/api"; +import DataColumnSelect from "./DataColumnSelect"; export interface LongTableCellLineSelectorProps { idCol: string; @@ -203,46 +205,26 @@ export class LongTableCellLineSelector extends React.Component<
Add a data column
- ) => { - let colLabel = ""; - for (let i = 1; i < labels.length; i++) { - colLabel = colLabel.concat(" ").concat(labels[i].label); - } - - this.context - .getApi() - .getVector(id) - .then((response: VectorResponse) => { - let newVector: Vector; - let newColType: "continuous" | "categorical" | null = null; - try { - if (response.values) { - newVector = { - cellLines: response.cellLines, - values: response.values, - }; - newColType = "continuous"; - } else if (response.categoricalValues) { - newVector = { - cellLines: response.cellLines, - values: response.categoricalValues, - }; - newColType = "categorical"; - } else { - throw "ERROR! neither continuous nor categorical values were returned"; - } - this.setState({ - vector: newVector, - vectorId: id, - newColLabel: colLabel, - newColType, - }); - } catch (err) { - console.log(err); - } + { + if (!sliceId) { + this.setState({ + vector: undefined, + vectorId: undefined, }); + } else { + fetchMetadataColumn(sliceId).then((metadataColumn) => { + this.setState({ + vector: { + cellLines: Object.keys(metadataColumn.indexed_values), + values: Object.values(metadataColumn.indexed_values), + }, + vectorId: sliceId, + newColLabel: metadataColumn.label, + newColType: valueType, + }); + }); + } }} />
diff --git a/frontend/packages/@depmap/cell-line-selector/src/styles/cell_line_selector.scss b/frontend/packages/@depmap/cell-line-selector/src/styles/cell_line_selector.scss index 0adf36c7..e87ce99a 100644 --- a/frontend/packages/@depmap/cell-line-selector/src/styles/cell_line_selector.scss +++ b/frontend/packages/@depmap/cell-line-selector/src/styles/cell_line_selector.scss @@ -3,6 +3,10 @@ $link_blue_hover: #23527c; $modal-height: 72vh; $bottom-div-height: 35px; +.DimensionSelect { + margin-top: 12px; +} + // TODO: Get rid of :global and convert the corresponding component to CSS // Module format. :global { diff --git a/frontend/packages/@depmap/cell-line-selector/src/utilities/renderCellLineSelectorModal.tsx b/frontend/packages/@depmap/cell-line-selector/src/utilities/renderCellLineSelectorModal.tsx index 0e6b3c47..43885b19 100644 --- a/frontend/packages/@depmap/cell-line-selector/src/utilities/renderCellLineSelectorModal.tsx +++ b/frontend/packages/@depmap/cell-line-selector/src/utilities/renderCellLineSelectorModal.tsx @@ -10,9 +10,12 @@ const CellLineSelectorModal = React.lazy( ) ); +const getVectorCatalogApi = () => { + throw new Error("Vector Catalog API is no longer supported!"); +}; + export default function renderCellLineSelectorModal( getApi: ApiContextInterface["getApi"], - getVectorCatalogApi: ApiContextInterface["getVectorCatalogApi"], container: HTMLElement | null ) { if (!container) { @@ -23,18 +26,12 @@ export default function renderCellLineSelectorModal( } const dapi = getApi(); - const apiFunctions = { - depmap: { - getApi, - getVectorCatalogApi, - }, - }; // Unmount a previous instance if any (otherwise this is a no-op). ReactDOM.unmountComponentAtNode(container); ReactDOM.render( - + dapi.getCellLineSelectorLines()} @@ -50,7 +47,6 @@ export default function renderCellLineSelectorModal( export function renderCellLineSelectorModalUsingBBApi( getApi: ApiContextInterface["getApi"], - getVectorCatalogApi: ApiContextInterface["getVectorCatalogApi"], container: HTMLElement | null ) { if (!container) { @@ -61,17 +57,12 @@ export function renderCellLineSelectorModalUsingBBApi( } const bbapi = getApi(); - const apiFunctions = { - breadbox: { - getApi, - getVectorCatalogApi, - }, - }; + // Unmount a previous instance if any (otherwise this is a no-op). ReactDOM.unmountComponentAtNode(container); ReactDOM.render( - + bbapi.getCellLineSelectorLines()} diff --git a/frontend/packages/@depmap/data-explorer-2/index.ts b/frontend/packages/@depmap/data-explorer-2/index.ts index 6a330f58..1ed62265 100644 --- a/frontend/packages/@depmap/data-explorer-2/index.ts +++ b/frontend/packages/@depmap/data-explorer-2/index.ts @@ -6,6 +6,7 @@ export { default as DimensionSelect } from "./src/components/DimensionSelect"; export { default as SliceLabelSelect } from "./src/components/DimensionSelect/SliceLabelSelect"; export { default as ContextBuilderModal } from "./src/components/ContextBuilder/ContextBuilderModal"; export { default as ContextManager } from "./src/components/ContextManager"; +export { default as DatasetMetadataSelector } from "./src/components/DatasetMetadataSelector"; export { fetchContextLabels, @@ -18,6 +19,7 @@ export { fetchGeneTeaEnrichment, fetchGeneTeaTermContext, fetchLinearRegression, + fetchMetadataColumn, fetchMetadataSlices, fetchPlotDimensions, fetchWaterfall, @@ -52,6 +54,7 @@ export { export { capitalize, + convertDimensionToSliceId, getDimensionTypeLabel, isCompleteDimension, isCompleteExpression, diff --git a/frontend/packages/@depmap/data-explorer-2/src/api.ts b/frontend/packages/@depmap/data-explorer-2/src/api.ts index 476f3e67..0010eba2 100644 --- a/frontend/packages/@depmap/data-explorer-2/src/api.ts +++ b/frontend/packages/@depmap/data-explorer-2/src/api.ts @@ -271,7 +271,11 @@ export async function fetchContextSummary( export async function fetchMetadataColumn( slice_id: string -): Promise<{ slice_id: string; indexed_values: Record }> { +): Promise<{ + slice_id: string; + label: string; + indexed_values: Record; +}> { return postJson("/get_metadata", { metadata: { slice_id } }); } diff --git a/frontend/packages/@depmap/data-explorer-2/src/components/ContextBuilder/CellLineSelector/CellLineSelectorModal.tsx b/frontend/packages/@depmap/data-explorer-2/src/components/ContextBuilder/CellLineSelector/CellLineSelectorModal.tsx index fa9d96e0..a604b787 100644 --- a/frontend/packages/@depmap/data-explorer-2/src/components/ContextBuilder/CellLineSelector/CellLineSelectorModal.tsx +++ b/frontend/packages/@depmap/data-explorer-2/src/components/ContextBuilder/CellLineSelector/CellLineSelectorModal.tsx @@ -77,7 +77,7 @@ function CellLineSelectorModal({ Set >(new Set()); - const { getApi, getVectorCatalogApi } = useContext(ApiContext); + const { getApi } = useContext(ApiContext); useEffect(() => { getApi() @@ -91,7 +91,7 @@ function CellLineSelectorModal({ setSelection(modelNamesToIDs(initialSelection, td)); } }); - }, [useModelNames, initialSelection, getApi, getVectorCatalogApi]); + }, [useModelNames, initialSelection, getApi]); useEffect(() => { getApi() diff --git a/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/DatasetMetadataSelector/index.tsx b/frontend/packages/@depmap/data-explorer-2/src/components/DatasetMetadataSelector/index.tsx similarity index 85% rename from frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/DatasetMetadataSelector/index.tsx rename to frontend/packages/@depmap/data-explorer-2/src/components/DatasetMetadataSelector/index.tsx index 1f350367..dcf317c6 100644 --- a/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/DatasetMetadataSelector/index.tsx +++ b/frontend/packages/@depmap/data-explorer-2/src/components/DatasetMetadataSelector/index.tsx @@ -1,10 +1,7 @@ import React, { useEffect, useState } from "react"; -import { - fetchMetadataSlices, - MetadataSlices, - PlotConfigSelect, - SliceLabelSelector, -} from "@depmap/data-explorer-2"; +import { fetchMetadataSlices, MetadataSlices } from "../../api"; +import PlotConfigSelect from "../PlotConfigSelect"; +import SliceLabelSelector from "../SliceLabelSelector"; import { containsPartialSlice, getDatasetIdFromSlice, @@ -12,8 +9,7 @@ import { getOptions, sliceLabel, slicePrefix, -} from "src/data-explorer-2/components/ConfigurationPanel/DatasetMetadataSelector/utils"; -import styles from "src/data-explorer-2/styles/ConfigurationPanel.scss"; +} from "./utils"; interface Props { show: boolean; @@ -58,7 +54,7 @@ function DatasetMetadataSelector({ } return ( -
+
{ let out = ""; diff --git a/frontend/packages/@depmap/data-explorer-2/src/utils/misc.ts b/frontend/packages/@depmap/data-explorer-2/src/utils/misc.ts index ce181da3..f5ef4dce 100644 --- a/frontend/packages/@depmap/data-explorer-2/src/utils/misc.ts +++ b/frontend/packages/@depmap/data-explorer-2/src/utils/misc.ts @@ -31,6 +31,10 @@ export const isCompleteExpression = (expr: any) => { return false; } + if (typeof expr === "boolean") { + return true; + } + if (expr.and && expr.and.length === 0) { return false; } @@ -91,6 +95,34 @@ export const isSampleType = (dimensionType: string | null | undefined) => { ); }; +export function convertDimensionToSliceId( + dimension: Partial +) { + if (!isCompleteDimension(dimension)) { + return null; + } + + if (dimension.axis_type !== "raw_slice") { + throw new Error("Cannot convert a context to a slice ID!"); + } + + if (isSampleType(dimension.slice_type)) { + throw new Error( + "Cannot convert a sample to a slice ID! Only features are supported." + ); + } + + const expr = dimension.context.expr as { "==": [object, string] }; + const feature = expr["=="][1]; + + return [ + "slice", + urlLibEncode(dimension.dataset_id), + urlLibEncode(feature), + "label", + ].join("/"); +} + export const capitalize = (str: string) => { return str && str.replace(/\b[a-z]/g, (c: string) => c.toUpperCase()); }; diff --git a/frontend/packages/elara-frontend/src/index.tsx b/frontend/packages/elara-frontend/src/index.tsx index 3e9be4a9..297cc28f 100644 --- a/frontend/packages/elara-frontend/src/index.tsx +++ b/frontend/packages/elara-frontend/src/index.tsx @@ -12,7 +12,6 @@ import "bootstrap/dist/css/bootstrap.css"; // Include this after bootstrap so we can override its styles. import "./index.scss"; import { ApiContext } from "@depmap/api"; -import { VectorCatalogApi } from "@depmap/interactive"; const DataExplorer = React.lazy(() => import("src/pages/DataExplorer")); const Datasets = React.lazy(() => import("@depmap/dataset-manager")); @@ -45,9 +44,10 @@ const App = () => { })(); }, [bbapi]); - const vectorCatalogApi = new VectorCatalogApi(bbapi); const getApi = () => bbapi; - const getVectorCatalogApi = () => vectorCatalogApi; + const getVectorCatalogApi = () => { + throw new Error("Vector Catalog API is no longer supported!"); + }; return ( diff --git a/frontend/packages/elara-frontend/src/modals/ElaraContextManager.tsx b/frontend/packages/elara-frontend/src/modals/ElaraContextManager.tsx index efb1a4e4..a1779e63 100644 --- a/frontend/packages/elara-frontend/src/modals/ElaraContextManager.tsx +++ b/frontend/packages/elara-frontend/src/modals/ElaraContextManager.tsx @@ -4,7 +4,6 @@ import { ContextManager, DataExplorerApiProvider, } from "@depmap/data-explorer-2"; -import { VectorCatalogApi } from "@depmap/interactive"; import { ElaraApi } from "src/api"; import { evaluateContext, @@ -25,9 +24,10 @@ function ElaraContextManager({ onHide }: Props) { () => new ElaraApi(basename === "" ? "/" : basename) ); - const vectorCatalogApi = new VectorCatalogApi(bbapi); const getApi = () => bbapi; - const getVectorCatalogApi = () => vectorCatalogApi; + const getVectorCatalogApi = () => { + throw new Error("Vector Catalog API is no longer supported!"); + }; return ( diff --git a/frontend/packages/elara-frontend/src/pages/CustomAnalyses/ElaraCustomAnalysesPage.tsx b/frontend/packages/elara-frontend/src/pages/CustomAnalyses/ElaraCustomAnalysesPage.tsx index 1ba1a307..554206bf 100644 --- a/frontend/packages/elara-frontend/src/pages/CustomAnalyses/ElaraCustomAnalysesPage.tsx +++ b/frontend/packages/elara-frontend/src/pages/CustomAnalyses/ElaraCustomAnalysesPage.tsx @@ -12,11 +12,7 @@ export default function ElaraCustomAnalysesPage() { const apiContext = useContext(ApiContext); const launchCellLineSelectorModal = () => - renderCellLineSelectorModal( - apiContext.getApi, - apiContext.getVectorCatalogApi, - cellLineSelectorContainer - ); + renderCellLineSelectorModal(apiContext.getApi, cellLineSelectorContainer); return ( { const dapi = new ElaraApi("/"); - const vectorCatalogApi = new VectorCatalogApi(dapi); const getDapi = () => dapi; - const getVectorCatalogApi = () => vectorCatalogApi; const cellLineSelectorContainer = document.getElementById( "cell_line_selector_modal" ); const launchCellLineSelectorModal = () => - renderCellLineSelectorModal( - getDapi, - getVectorCatalogApi, - cellLineSelectorContainer - ); + renderCellLineSelectorModal(getDapi, cellLineSelectorContainer); const onCellLineLinkClick = () => { launchCellLineSelectorModal(); // Need this click so that the tooltip doesn't stay open in front of the cell line modal diff --git a/frontend/packages/portal-frontend/src/apps/interactive.tsx b/frontend/packages/portal-frontend/src/apps/interactive.tsx index 34b5aa4a..2f2d186d 100644 --- a/frontend/packages/portal-frontend/src/apps/interactive.tsx +++ b/frontend/packages/portal-frontend/src/apps/interactive.tsx @@ -6,7 +6,6 @@ import { InteractivePage } from "@depmap/interactive"; import { getQueryParams } from "@depmap/utils"; import { renderCellLineSelectorModal } from "@depmap/cell-line-selector"; import { - getVectorCatalogApi, getDapi, apiFunctions, fetchUrlPrefix, @@ -33,11 +32,7 @@ const { showCustomAnalysis } = data; const App = () => { const launchCellLineSelectorModal = () => - renderCellLineSelectorModal( - getDapi, - getVectorCatalogApi, - cellLineSelectorContainer - ); + renderCellLineSelectorModal(getDapi, cellLineSelectorContainer); const relativeUrlPrefix = fetchUrlPrefix(); diff --git a/frontend/packages/portal-frontend/src/apps/interactivev2.tsx b/frontend/packages/portal-frontend/src/apps/interactivev2.tsx index 10729717..ba631f60 100644 --- a/frontend/packages/portal-frontend/src/apps/interactivev2.tsx +++ b/frontend/packages/portal-frontend/src/apps/interactivev2.tsx @@ -5,11 +5,7 @@ import ErrorBoundary from "src/common/components/ErrorBoundary"; import { InteractivePage } from "@depmap/interactive"; import { getQueryParams } from "@depmap/utils"; import { renderCellLineSelectorModalUsingBBApi } from "@depmap/cell-line-selector"; -import { - getBreadboxApi, - apiFunctions, - bbGetVectorCatalogApi, -} from "src/common/utilities/context"; +import { getBreadboxApi, apiFunctions } from "src/common/utilities/context"; import PlotlyLoader from "src/plot/components/PlotlyLoader"; import { ApiContext } from "@depmap/api"; @@ -31,7 +27,6 @@ const App = () => { const launchCellLineSelectorModal = () => renderCellLineSelectorModalUsingBBApi( getBreadboxApi, - bbGetVectorCatalogApi, cellLineSelectorContainer ); diff --git a/frontend/packages/portal-frontend/src/celligner/components/CellignerPage.tsx b/frontend/packages/portal-frontend/src/celligner/components/CellignerPage.tsx index 613e4e19..6d6b1be8 100644 --- a/frontend/packages/portal-frontend/src/celligner/components/CellignerPage.tsx +++ b/frontend/packages/portal-frontend/src/celligner/components/CellignerPage.tsx @@ -3,7 +3,7 @@ import { Grid, Row, Col, Tabs, Tab, SelectCallback } from "react-bootstrap"; import { enabledFeatures } from "@depmap/globals"; import { DepmapApi } from "src/dAPI"; -import { getDapi, getVectorCatalogApi } from "src/common/utilities/context"; +import { getDapi } from "src/common/utilities/context"; import WideTable, { WideTableColumns } from "@depmap/wide-table"; import { titleCase } from "@depmap/utils"; import CellignerCellLinesForTumorsControlPanel from "./CellignerCellLinesForTumorsControlPanel"; @@ -201,7 +201,7 @@ export default class CellignerPage extends React.Component { launchCellLineSelectorModal() { const container = document.getElementById("cell_line_selector_modal"); // defined in layout.html - renderCellLineSelectorModal(getDapi, getVectorCatalogApi, container); + renderCellLineSelectorModal(getDapi, container); } handleSelectTab(activeTab: ValidTab) { diff --git a/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/ColorByViewOptions.tsx b/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/ColorByViewOptions.tsx index 1058ec83..5a0ba302 100644 --- a/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/ColorByViewOptions.tsx +++ b/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/ColorByViewOptions.tsx @@ -1,6 +1,7 @@ import React from "react"; import { ContextSelector, + DatasetMetadataSelector, DimensionSelect, SliceLabelSelect, useDataExplorerSettings, @@ -9,7 +10,6 @@ import { ContextPath, DataExplorerContext, FilterKey } from "@depmap/types"; import { PlotConfigReducerAction } from "src/data-explorer-2/reducers/plotConfigReducer"; import { ColorByTypeSelector, - DatasetMetadataSelector, SortBySelector, } from "src/data-explorer-2/components/ConfigurationPanel/selectors"; import styles from "src/data-explorer-2/styles/ConfigurationPanel.scss"; diff --git a/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/selectors.tsx b/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/selectors.tsx index d9192a1a..086a5af5 100644 --- a/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/selectors.tsx +++ b/frontend/packages/portal-frontend/src/data-explorer-2/components/ConfigurationPanel/selectors.tsx @@ -18,8 +18,6 @@ import { import HelpTip from "src/data-explorer-2/components/HelpTip"; import styles from "src/data-explorer-2/styles/ConfigurationPanel.scss"; -export { default as DatasetMetadataSelector } from "src/data-explorer-2/components/ConfigurationPanel/DatasetMetadataSelector"; - type DatasetsByIndexType = Record; export function PlotTypeSelector({ diff --git a/frontend/packages/portal-frontend/src/data-explorer-2/components/StandaloneContextEditor.tsx b/frontend/packages/portal-frontend/src/data-explorer-2/components/StandaloneContextEditor.tsx index f1d64dc4..52a6a403 100644 --- a/frontend/packages/portal-frontend/src/data-explorer-2/components/StandaloneContextEditor.tsx +++ b/frontend/packages/portal-frontend/src/data-explorer-2/components/StandaloneContextEditor.tsx @@ -5,10 +5,7 @@ import { saveContextToLocalStorage, } from "@depmap/data-explorer-2"; import { DataExplorerContext } from "@depmap/types"; -import { - getDapi as getApi, - getVectorCatalogApi, -} from "src/common/utilities/context"; +import { getDapi as getApi } from "src/common/utilities/context"; interface Props { /* The context to use as a starting point. This can be as simple as @@ -26,6 +23,10 @@ interface Props { onSave?: (context: DataExplorerContext, hash: string) => void; } +const getVectorCatalogApi = () => { + throw new Error("Vector Catalog API is no longer supported!"); +}; + function StandaloneContextEditor({ context, hash, diff --git a/frontend/packages/portal-frontend/src/data-explorer-2/hooks/useContextBuilder.tsx b/frontend/packages/portal-frontend/src/data-explorer-2/hooks/useContextBuilder.tsx index 11a309a4..14d47d35 100644 --- a/frontend/packages/portal-frontend/src/data-explorer-2/hooks/useContextBuilder.tsx +++ b/frontend/packages/portal-frontend/src/data-explorer-2/hooks/useContextBuilder.tsx @@ -10,10 +10,7 @@ import { DataExplorerPlotConfig, ContextPath, } from "@depmap/types"; -import { - getDapi as getApi, - getVectorCatalogApi, -} from "src/common/utilities/context"; +import { getDapi as getApi } from "src/common/utilities/context"; import { plotToQueryString, plotsAreEquivalentWhenSerialized, @@ -22,6 +19,10 @@ import { type SaveCallback = (context: DataExplorerContext) => void; const noop = () => {}; +const getVectorCatalogApi = () => { + throw new Error("Vector Catalog API is no longer supported!"); +}; + export default function useContextBuilder( plot: DataExplorerPlotConfig, setPlot: (config: DataExplorerPlotConfig) => void diff --git a/frontend/packages/portal-frontend/src/index.tsx b/frontend/packages/portal-frontend/src/index.tsx index 92007a1d..e29e324e 100644 --- a/frontend/packages/portal-frontend/src/index.tsx +++ b/frontend/packages/portal-frontend/src/index.tsx @@ -8,7 +8,7 @@ import { } from "@depmap/cell-line-selector"; import { getQueryParams } from "@depmap/utils"; -import { getDapi, getVectorCatalogApi } from "src/common/utilities/context"; +import { getDapi } from "src/common/utilities/context"; import { DatasetOption } from "src/entity/components/EntitySummary"; @@ -105,7 +105,7 @@ const renderWithErrorBoundary = ( export function launchCellLineSelectorModal() { const container = document.getElementById("cell_line_selector_modal"); // defined in layout.html - renderCellLineSelectorModal(getDapi, getVectorCatalogApi, container); + renderCellLineSelectorModal(getDapi, container); } export function showTermsAndConditionsModal() { diff --git a/portal-backend/depmap/data_explorer_2/plot.py b/portal-backend/depmap/data_explorer_2/plot.py index 68a35c0d..7e63d247 100644 --- a/portal-backend/depmap/data_explorer_2/plot.py +++ b/portal-backend/depmap/data_explorer_2/plot.py @@ -118,7 +118,7 @@ def compute_filter(input_filter): def compute_metadata(metadata): slice_id = metadata["slice_id"] indexed_values = slice_to_dict(slice_id) - label = slice_id + label = None # HACK: Look up a label for the `slice_id` in `hardcoded_metadata_slices`. # When we stop relying on Slice IDs and start using SliceQuery objects, @@ -131,6 +131,11 @@ def compute_metadata(metadata): _, identifier, _ = decode_slice_id(slice_id) label = f"{info['name']} ({info['sliceTypeLabel']} = {identifier})" + if label is None: + dataset_id, identifier, _ = decode_slice_id(slice_id) + dataset = data_access.get_matrix_dataset(dataset_id) + label = f"{identifier} {dataset.label}" + return { "label": label, "slice_id": slice_id,