Skip to content

Commit

Permalink
update log labels for metric table
Browse files Browse the repository at this point in the history
  • Loading branch information
elissa-alarmani committed Sep 9, 2024
1 parent f8785b2 commit 3bf322c
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions browser/src/VariantPage/VariantSiteQualityMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,10 @@ const SiteQualityMetricsHistogram = ({
height,
width,
}: SiteQualityMetricsHistogramProps) => {
const isLogScale = metric === 'SiteQuality' || metric === 'AS_QUALapprox' || metric === 'DP'
const logScaleMetrics = ['SiteQuality', 'AS_QUALapprox', 'QUALapprox', 'DP', 'AS_VarDP']
const isLogScale = logScaleMetrics.includes(metric)

const logLabels = ['AS_VarDP', 'QUALapprox', 'AS_QUALapprox']

const isLogMetrics = logLabels.includes(xLabel)

const xLabelRenamed = isLogMetrics ? `log(${xLabel})` : xLabel
const xLabelRenamed = isLogScale ? `log(${xLabel})` : xLabel

const primaryValues = exomeBinValues || genomeBinValues
const secondaryValues = exomeBinValues ? genomeBinValues : null
Expand All @@ -641,14 +638,14 @@ const SiteQualityMetricsHistogram = ({
exomeMetricValue !== null ? exomeMetricValue : genomeMetricValue

const primaryMetricValue =
isLogMetrics && originalPrimaryMetricValue > 0
isLogScale && originalPrimaryMetricValue > 0
? Math.log10(originalPrimaryMetricValue)
: originalPrimaryMetricValue

const originalSecondaryMetricValue = exomeMetricValue !== null ? genomeMetricValue : null

const secondaryMetricValue =
isLogMetrics && originalSecondaryMetricValue > 0
isLogScale && originalSecondaryMetricValue > 0
? Math.log10(originalSecondaryMetricValue)
: originalSecondaryMetricValue

Expand Down Expand Up @@ -891,7 +888,7 @@ const SiteQualityMetricsHistogram = ({
fontSize={12}
textAnchor={secondaryLabelOnLeft ? 'end' : 'start'}
>
{formatMetricValue(originalSecondaryMetricValue, metric, isLogMetrics)}
{formatMetricValue(originalSecondaryMetricValue, metric, isLogScale)}
</text>
</>
)}
Expand Down Expand Up @@ -920,7 +917,7 @@ const SiteQualityMetricsHistogram = ({
textAnchor={primaryLabelOnLeft ? 'end' : 'start'}
>
{/* {formattedLabel} */}
{formatMetricValue(originalPrimaryMetricValue, metric, logLabels.includes(xLabel))}
{formatMetricValue(originalPrimaryMetricValue, metric, isLogScale)}
</text>
</>
)}
Expand Down Expand Up @@ -1038,32 +1035,31 @@ const VariantSiteQualityMetricsDistribution = ({
const includeExomes = selectedSequencingType.includes('e')
const includeGenomes = selectedSequencingType.includes('g')

const logLabels = ['AS_VarDP', 'QUALapprox', 'AS_QUALapprox']

const isLogMetrics = logLabels.includes(selectedMetric)
const logScaleMetrics = ['SiteQuality', 'AS_QUALapprox', 'QUALapprox', 'DP', 'AS_VarDP']
const isLogScale = logScaleMetrics.includes(selectedMetric)

let values
if (variant.exome && variant.genome) {
values = `${
exomeMetricValue === null
? '–'
: formatMetricValue(exomeMetricValue, selectedMetric, isLogMetrics)
: formatMetricValue(exomeMetricValue, selectedMetric, isLogScale)
} (exome samples), ${
genomeMetricValue === null
? '–'
: formatMetricValue(genomeMetricValue, selectedMetric, isLogMetrics)
: formatMetricValue(genomeMetricValue, selectedMetric, isLogScale)
} (genome samples)`
} else if (variant.exome) {
values = `${
exomeMetricValue === null
? '–'
: formatMetricValue(exomeMetricValue, selectedMetric, isLogMetrics)
: formatMetricValue(exomeMetricValue, selectedMetric, isLogScale)
} (exome samples)`
} else {
values = `${
genomeMetricValue === null
? '–'
: formatMetricValue(genomeMetricValue, selectedMetric, isLogMetrics)
: formatMetricValue(genomeMetricValue, selectedMetric, isLogScale)
} (genome samples)`
}

Expand Down Expand Up @@ -1154,6 +1150,7 @@ const TooltipHint = styled.span`

const renderMetric = (metric: any, datasetId: any) => {
let description
console.log(metric)

Check warning on line 1153 in browser/src/VariantPage/VariantSiteQualityMetrics.tsx

View workflow job for this annotation

GitHub Actions / Checks

Unexpected console statement
if (metric === 'SiteQuality') {
description = getSiteQualityMetricDescription(datasetId)
} else if (metric.startsWith('AS_')) {
Expand Down Expand Up @@ -1208,6 +1205,8 @@ const VariantSiteQualityMetricsTable = ({

const availableMetrics = getAvailableMetrics(datasetId)

const logScaleMetrics = ['SiteQuality', 'AS_QUALapprox', 'QUALapprox', 'DP', 'AS_VarDP']

return (
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
<BaseTable style={{ width: '100%' }}>
Expand All @@ -1226,14 +1225,22 @@ const VariantSiteQualityMetricsTable = ({
{exomeMetricValues && metric in exomeMetricValues && isVariantInExomes && (
<td>
{exomeMetricValues![metric] != null
? formatMetricValue(exomeMetricValues![metric], metric)
? formatMetricValue(
exomeMetricValues![metric],
metric,
logScaleMetrics.includes(metric)
)
: '–'}
</td>
)}
{genomeMetricValues && metric in genomeMetricValues && isVariantInGenomes && (
<td>
{genomeMetricValues && ![metric] != null
? formatMetricValue(genomeMetricValues![metric], metric)
? formatMetricValue(
genomeMetricValues![metric],
metric,
logScaleMetrics.includes(metric)
)
: '–'}
</td>
)}
Expand Down

0 comments on commit 3bf322c

Please sign in to comment.