Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Eplant/views/eFP/Viewer/EFPTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ function SVGTooltip(props: {
<KeyValueRow
label='Log2 fold change vs control'
value={Math.log2(
props.tissue.mean / (props.data.control ?? 1)
props.tissue.mean /
(props.group.control ?? props.data.control ?? 1)
).toFixed(2)}
/>
</TableBody>
Expand Down
7 changes: 6 additions & 1 deletion Eplant/views/eFP/Viewer/legend.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, styled, useTheme } from '@mui/material'

import { getColor } from '../svg'
import { ColorMode, EFPData, EFPState } from '../types'
import { ColorMode, EFPData } from '../types'

interface ILegendProps {
data: EFPData
Expand All @@ -18,6 +18,11 @@ export default styled(function Legend({
...rest
}: ILegendProps) {
const theme = useTheme()
// TODO: legend uses data.control (cross-group average) and data.min/max as a
// global approximation. This can diverge from per-group colours when groups
// have different controls. A per-group legend is out of scope for this fix.
// I.e. The colours may not line up in this commit/PR due to group colours being different
// than the global legend
const control = data.control ?? 1
const values = Array(GRADIENT_STEPS)
.fill(0)
Expand Down
12 changes: 7 additions & 5 deletions Eplant/views/eFP/svg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ export function getColor(
colorMode: ColorMode,
tissueStd?: number,
maskThreshold?: number,
maskingEnabled?: boolean
maskingEnabled?: boolean,
absoluteMax?: number
): string {
const extremum = Math.max(
Math.abs(Math.log2(group.min / control)),
Expand All @@ -118,7 +119,7 @@ export function getColor(
return mix(
theme.palette.neutral.main,
theme.palette.hot.main,
value / group.max
value / (absoluteMax ?? group.max)
)
}

Expand All @@ -139,13 +140,14 @@ export function useStyles(
tissue.id
} { fill: ${getColor(
tissue.mean,
data,
control ?? 1,
group,
group.control ?? control ?? 1,
theme,
colorMode,
tissue.std,
maskThreshold,
maskingEnabled
maskingEnabled,
data.max
)} !important; }`
)
)
Expand Down
Loading