Skip to content

Commit

Permalink
chore: update for CytAssist (#1162)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloster authored Feb 12, 2025
1 parent 875058c commit d9e63fa
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .infra/rdev/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ stack:
services:
explorer:
image:
tag: sha-ba19fbbe
tag: sha-f848aba8
replicaCount: 1
env:
# env vars common to all deployment stages
Expand Down
11 changes: 9 additions & 2 deletions client/src/components/Graph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import { Dataframe } from "util/dataframe";
import { RootState } from "reducers";
import { Field } from "common/types/schema";
import { Query } from "annoMatrix/query";
import { SLIDE_SIZE, THROTTLE_MS } from "util/constants";
import { getSlideSize, THROTTLE_MS } from "util/constants";
import { isSpatialMode, shouldShowOpenseadragon } from "common/selectors";
import { fetchDeepZoomImageFailed } from "actions/config";
import { track } from "analytics";
import { EVENTS } from "analytics/events";
import { DatasetUnsMetadata } from "common/types/entities";
import { getFeatureFlag } from "util/featureFlags/featureFlags";
import { FEATURES } from "util/featureFlags/features";
import { allSingleValues } from "util/singleValues";
import { LassoFunctionWithAttributes } from "./setupLasso";
import { CentroidLabels } from "./overlays/CentroidLabels/CentroidLabels";
import { GraphOverlayLayer } from "./overlays/GraphOverlayLayer/GraphOverlayLayer";
Expand Down Expand Up @@ -1168,6 +1169,7 @@ class Graph extends React.Component<GraphProps, GraphState> {
imageUnderlay,
imageOpacity,
unsMetadata,
annoMatrix: { schema },
} = this.props;

if (
Expand All @@ -1193,9 +1195,14 @@ class Graph extends React.Component<GraphProps, GraphState> {
opacity: imageOpacity / 100,
});

const assayOntologyTermId = allSingleValues({ schema }).get(
"assay_ontology_term_id"
);

const { imageHeight } = unsMetadata;

const calculatedPixelsPerMeter = imageHeight / SLIDE_SIZE;
const calculatedPixelsPerMeter =
imageHeight / getSlideSize(assayOntologyTermId);

this.openseadragon.scalebar({
type: Openseadragon.ScalebarType.MICROSCOPY,
Expand Down
1 change: 0 additions & 1 deletion client/src/reducers/singleContinuousValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const singleContinuousValue = (
): SingleContinuousValueState => {
switch (action.type) {
case "add single continuous value":

state.singleContinuousValues.set(action.field, action.value);
return state;
default:
Expand Down
8 changes: 8 additions & 0 deletions client/src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export const SCALE_MAX_HIRES = 12.0;
* https://kb.10xgenomics.com/hc/en-us/articles/360035487572-What-is-the-spatial-resolution-and-configuration-of-the-capture-area-of-the-Visium-v1-Gene-Expression-Slide
*/
export const SLIDE_SIZE = 0.008;
export const SLIDE_SIZE_CYT_ASSIST = 0.011;

export function getSlideSize(assayOntologyTermId: string): number {
if (assayOntologyTermId === "EFO:0022860") {
return SLIDE_SIZE_CYT_ASSIST;
}
return SLIDE_SIZE;
}

export const LAYOUT_CHOICE_TEST_ID = "layout-choice";

Expand Down
16 changes: 16 additions & 0 deletions client/src/util/singleValues.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Schema } from "common/types/schema";
import { selectableCategoryNames } from "./stateManager/controlsHelpers";

export function allSingleValues({ schema }: { schema: Schema }) {
const singleValues = new Map();
const allCategoryNames = () => selectableCategoryNames(schema).sort();

allCategoryNames().forEach((catName) => {
const colSchema = schema.annotations.obsByName[catName];
const isUserAnno = colSchema?.writable;
if (!isUserAnno && colSchema.categories?.length === 1) {
singleValues.set(catName, colSchema.categories[0]);
}
});
return singleValues;
}
6 changes: 4 additions & 2 deletions server/dataset/cxg_dataset.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import logging
import os
import pickle
import pickle # TODO: remove this after 5.3.0 migration
import threading

import numpy as np
Expand Down Expand Up @@ -388,7 +388,9 @@ def get_uns(self, metadata_key):
for key in uns.meta:
if key == metadata_key:
try:
return pickle.loads(uns.meta[key])
if type(uns.meta[key]) == bytes: # TODO: remove this after 5.3.0 migration
return pickle.loads(uns.meta[key]) # for backwards compatibility
return json.loads(uns.meta[key])
except Exception as e:
print(f"Error deserializing uns data for key {key}: {e}")
return None
Expand Down

0 comments on commit d9e63fa

Please sign in to comment.