From 262f1f4490054159246edecf1dedafd4556377a9 Mon Sep 17 00:00:00 2001 From: Airen Zaldivar Date: Mon, 11 Nov 2024 15:15:31 -0600 Subject: [PATCH 1/5] Show term2 value in list samples if there is overlay --- client/plots/barchart.events.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/plots/barchart.events.js b/client/plots/barchart.events.js index 5a7bc249d9..b4b32a88fb 100644 --- a/client/plots/barchart.events.js +++ b/client/plots/barchart.events.js @@ -497,10 +497,16 @@ async function listSamples(event, self, seriesId, dataId, chartId) { const data = await self.app.vocabApi.getAnnotatedSampleData(opts) const rows = [] for (const sample of data.lst) { - const value = data.refs.bySampleId[Number(sample.sample)].label - rows.push([{ value }]) + const sampleName = data.refs.bySampleId[Number(sample.sample)].label + const row = [{ value: sampleName }] + if (self.config.term2) { + const value = sample[self.config.term2.$id]?.value + row.push({ value }) + } + rows.push(row) } const columns = [{ label: 'Sample' }] + if (self.config.term2) columns.push({ label: self.config.term2.term.name }) const menu = new Menu({ padding: '5px' }) const div = menu.d.append('div') renderTable({ @@ -508,7 +514,6 @@ async function listSamples(event, self, seriesId, dataId, chartId) { columns, div, showLines: true, - maxWidth: '27vw', maxHeight: '40vh', resize: true }) From 52f7e60d648e08827ecb6d7a27c35c2bfab65e78 Mon Sep 17 00:00:00 2001 From: Airen Zaldivar Date: Tue, 12 Nov 2024 10:07:10 -0600 Subject: [PATCH 2/5] When listing samples, Added column with numeric values if the term is numeric --- client/plots/barchart.events.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/client/plots/barchart.events.js b/client/plots/barchart.events.js index b4b32a88fb..de89e1ced4 100644 --- a/client/plots/barchart.events.js +++ b/client/plots/barchart.events.js @@ -4,7 +4,7 @@ import { newpane, export_data } from '../src/client' import { filterJoin, getFilterItemByTag, getNormalRoot, findItemByTermId, normalizeProps } from '#filter' import { rgb } from 'd3-color' import { roundValueAuto } from '#shared/roundValue.js' - +import { isNumericTerm } from '#shared/terms.js' export default function getHandlers(self) { const tip = new Menu({ padding: '5px' }) self.dom.tip = tip @@ -74,7 +74,7 @@ export default function getHandlers(self) { //mouse-over p-value and 2x2 table if (t2) { - const pvalue = d.groupPvalues.term2tests.find(x => x.term2id === d.dataId).pvalue + const pvalue = d.groupPvalues?.term2tests?.find(x => x.term2id === d.dataId).pvalue const term1Label = d.groupPvalues.term1Label const term2Label = d.groupPvalues.term2tests.find(x => x.term2id === d.dataId).term2Label const tableValues = d.groupPvalues.term2tests.find(x => x.term2id === d.dataId).tableValues @@ -496,16 +496,26 @@ async function listSamples(event, self, seriesId, dataId, chartId) { } const data = await self.app.vocabApi.getAnnotatedSampleData(opts) const rows = [] + const termIsNumeric = isNumericTerm(self.config.term.term) + const term2isNumeric = self.config.term2 ? isNumericTerm(self.config.term2.term) : false + for (const sample of data.lst) { const sampleName = data.refs.bySampleId[Number(sample.sample)].label const row = [{ value: sampleName }] + if (termIsNumeric) { + const value = sample[self.config.term.$id]?.value + row.push({ value: roundValueAuto(value) }) + } if (self.config.term2) { - const value = sample[self.config.term2.$id]?.value + let value = sample[self.config.term2.$id] + const label = self.config.term2.term.values?.[value.key]?.label + value = term2isNumeric || !label ? value.value : label row.push({ value }) } rows.push(row) } const columns = [{ label: 'Sample' }] + if (termIsNumeric) columns.push({ label: self.config.term.term.name }) if (self.config.term2) columns.push({ label: self.config.term2.term.name }) const menu = new Menu({ padding: '5px' }) const div = menu.d.append('div') @@ -528,7 +538,7 @@ async function listSamples(event, self, seriesId, dataId, chartId) { values: [{ key: value }] } } - if (term.term.type == 'integer' || term.term.type == 'float') { + if (isNumericTerm(term.term)) { const bins = self.bins[termIndex] tvs.tvs.ranges = [bins.find(bin => bin.label == value)] } From 487c9c769ddaa6089e196c000b6625de516ea5a3 Mon Sep 17 00:00:00 2001 From: Airen Zaldivar Date: Tue, 12 Nov 2024 10:15:17 -0600 Subject: [PATCH 3/5] Rounded term2 value --- client/plots/barchart.events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/plots/barchart.events.js b/client/plots/barchart.events.js index de89e1ced4..96c454e654 100644 --- a/client/plots/barchart.events.js +++ b/client/plots/barchart.events.js @@ -509,7 +509,7 @@ async function listSamples(event, self, seriesId, dataId, chartId) { if (self.config.term2) { let value = sample[self.config.term2.$id] const label = self.config.term2.term.values?.[value.key]?.label - value = term2isNumeric || !label ? value.value : label + value = term2isNumeric ? roundValueAuto(value.value) : label || value.value row.push({ value }) } rows.push(row) From c749c86e51ebe157bd427af4c1d3042b67642b93 Mon Sep 17 00:00:00 2001 From: Airen Zaldivar Date: Tue, 12 Nov 2024 14:33:10 -0600 Subject: [PATCH 4/5] Fixed bug when checking sample type for non dict terms --- server/src/termdb.filter.js | 2 +- shared/utils/src/terms.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/termdb.filter.js b/server/src/termdb.filter.js index fe619258ba..97f7bad0c8 100644 --- a/server/src/termdb.filter.js +++ b/server/src/termdb.filter.js @@ -467,7 +467,7 @@ function getFilterSampleTypes(filter, ds, sampleTypes) { const term_id = item.tvs.term const sample_type = getSampleType(term_id, ds) - sampleTypes.add(sample_type) + if (sample_type != null) sampleTypes.add(sample_type) } return sampleTypes } diff --git a/shared/utils/src/terms.js b/shared/utils/src/terms.js index 14458c3c1b..c145b951a0 100644 --- a/shared/utils/src/terms.js +++ b/shared/utils/src/terms.js @@ -153,6 +153,7 @@ export function getBin(lst, value) { export function getSampleType(term, ds) { if (!term) return null + if (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE if (term.id) return ds.cohort.termdb.term2SampleType.get(term.id) if (term.type == 'samplelst') { const key = Object.keys(term.values)[0] From 5b8d9f633be42a470dbd0617a7f7374f17d41d95 Mon Sep 17 00:00:00 2001 From: Airen Zaldivar Date: Wed, 13 Nov 2024 09:53:50 -0600 Subject: [PATCH 5/5] Validated empty value --- client/plots/barchart.events.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/plots/barchart.events.js b/client/plots/barchart.events.js index 96c454e654..fb40195a95 100644 --- a/client/plots/barchart.events.js +++ b/client/plots/barchart.events.js @@ -508,9 +508,12 @@ async function listSamples(event, self, seriesId, dataId, chartId) { } if (self.config.term2) { let value = sample[self.config.term2.$id] - const label = self.config.term2.term.values?.[value.key]?.label - value = term2isNumeric ? roundValueAuto(value.value) : label || value.value - row.push({ value }) + if (!value) row.push({ value: '' }) + else { + const label = self.config.term2.term.values?.[value.key]?.label + value = term2isNumeric ? roundValueAuto(value.value) : label || value.value + row.push({ value }) + } } rows.push(row) }