Skip to content

Commit c9d992c

Browse files
authored
fix: No duplicate cell types tracks (#1225)
1 parent 8d9d858 commit c9d992c

3 files changed

Lines changed: 51 additions & 6 deletions

File tree

client/src/components/BottomPanel/BottomPanel.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
BottomPanelHeaderActions,
1717
InfoIcon,
1818
ChromosomeMapWrapper,
19+
TooltipContent,
1920
} from "./style";
2021

2122
const MAX_CELL_TYPES = 2;
@@ -59,9 +60,17 @@ const BottomSideBar = ({
5960
>
6061
<BottomPanelHeader isMinimized={bottomPanelMinimized}>
6162
<BottomPanelHeaderTitle>
62-
Chromatin Accessibility
63+
Chromatin Accessibility {!bottomPanelMinimized && `(scATAC-seq)`}
6364
<Tooltip
64-
content="Put some text here to explain the feature."
65+
content={
66+
<TooltipContent>
67+
Coverage tracks show normalized chromatin accessibility for each
68+
cell type. scATAC-seq signals were aggregated across cells
69+
within each type in 100bp genomic bins, divided by the cell
70+
type`&apos;`s total fragment count, and multiplied by 10^6 for
71+
visualization.
72+
</TooltipContent>
73+
}
6574
position="bottom"
6675
>
6776
<InfoIcon sdsIcon="InfoCircle" sdsSize="xs" sdsType="interactive" />

client/src/components/BottomPanel/components/CoveragePlot/components/CellTypeDropdown/CellTypeDropdown.tsx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import React, { useMemo, useState, useRef } from "react";
22
import { useCellTypesQuery } from "common/queries/cellType";
3-
import { DefaultAutocompleteOption, DropdownMenu } from "@czi-sds/components";
3+
import {
4+
DefaultAutocompleteOption,
5+
DropdownMenu,
6+
MenuItem,
7+
} from "@czi-sds/components";
48
import { AutocompleteValue } from "@mui/material";
5-
import { useDispatch } from "react-redux";
9+
import { useDispatch, useSelector } from "react-redux";
10+
import { RootState } from "reducers";
611
import { CellTypeInputDropdown } from "./style";
712

813
export function CellTypeDropdown({ cellType }: { cellType: string }) {
14+
const { selectedCellTypes } = useSelector((state: RootState) => ({
15+
selectedCellTypes: state.controls.chromatinSelectedCellTypes,
16+
}));
17+
918
const cellTypesQuery = useCellTypesQuery();
1019
const cellTypes = useMemo(
1120
() => cellTypesQuery.data ?? [],
@@ -19,10 +28,25 @@ export function CellTypeDropdown({ cellType }: { cellType: string }) {
1928
type Multiple = false;
2029
type DisableClearable = false;
2130
type FreeSolo = false;
31+
const otherSelectedCellTypes = useMemo(
32+
() => new Set(selectedCellTypes.filter((type) => type !== cellType)),
33+
[cellType, selectedCellTypes]
34+
);
2235

2336
const cellTypeOptions = useMemo(
24-
() => cellTypes.map<Option>((name) => ({ name })),
25-
[cellTypes]
37+
() =>
38+
cellTypes.map<Option>((name) => ({
39+
name,
40+
component: (
41+
<MenuItem
42+
selected={cellType === name}
43+
disabled={otherSelectedCellTypes.has(name)}
44+
>
45+
{name}
46+
</MenuItem>
47+
),
48+
})),
49+
[cellType, cellTypes, otherSelectedCellTypes]
2650
);
2751

2852
const activeOption = useMemo(
@@ -67,6 +91,14 @@ export function CellTypeDropdown({ cellType }: { cellType: string }) {
6791
setOpen(false);
6892
anchorElRef.current = null;
6993

94+
if (
95+
!value ||
96+
value.name === cellType ||
97+
otherSelectedCellTypes.has(value.name)
98+
) {
99+
return;
100+
}
101+
70102
if (value) {
71103
dispatch({
72104
type: "toggle chromatin cell types",

client/src/components/BottomPanel/style.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,7 @@ export const ChromosomeMapWrapper = styled.div`
8484
min-height: 218px;
8585
transition: "min-height 0.5s ease-in";
8686
`;
87+
88+
export const TooltipContent = styled.div`
89+
max-width: 425px;
90+
`;

0 commit comments

Comments
 (0)