Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/aggregate ffpe tissue in catalogue and chart #68

Merged
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
34 changes: 33 additions & 1 deletion packages/demo/public/catalogues/catalogue-dktk.json
Original file line number Diff line number Diff line change
Expand Up @@ -20181,14 +20181,46 @@
{
"value": "histology",
"name": "tumor-tissue-ffpe"
},
{
"value": "sample_kind",
"name": "tissue-ffpe"
},
{
"value": "sample_kind",
"name": "normal-tissue-ffpe"
},
{
"value": "sample_kind",
"name": "other-tissue-ffpe"
}
]
]
},
{
"key": "tumor-tissue-frozen",
"name": "Gewebe schockgefroren",
"description": "Tumorgewebe (Kryo/Frisch)"
"description": "Tumorgewebe (Kryo/Frisch)",
"aggregatedValue": [
[
{
"value": "sample_kind",
"name": "tissue-frozen"
},
{
"value": "sample_kind",
"name": "tumor-tissue-frozen"
},
{
"value": "sample_kind",
"name": "normal-tissue-frozen"
},
{
"value": "sample_kind",
"name": "other-tissue-frozen"
}
]
]
},
{
"key": "tissue-other",
Expand Down
28 changes: 24 additions & 4 deletions packages/demo/public/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,29 @@
"hintText": [
"Verteilung der Probentypen die mit den identifizierten Patienten verbunden sind."
],
"accumulatedValues": [
{
"name": "ffpe-tissue",
"values": [
"tissue-ffpe",
patrickskowronekdkfz marked this conversation as resolved.
Show resolved Hide resolved
"tumor-tissue-ffpe",
"normal-tissue-ffpe",
"other-tissue-ffpe"
]
},
{
"name": "frozen-tissue",
"values": [
"tissue-frozen",
"tumor-tissue-frozen",
"normal-tissue-frozen",
"other-tissue-frozen"
]
}
],
"tooltips": {
"tissue-ffpe": "Gewebe FFPE",
"tissue-frozen": "Gewebe schockgefroren",
"ffpe-tissue": "Gewebe FFPE",
"frozen-tissue": "Gewebe schockgefroren",
"tissue-other": "Gewebe, Andere Konservierungsart",
"whole-blood": "Vollblut",
"blood-serum": "Serum",
Expand All @@ -106,8 +126,8 @@
"derivative-other": "Derivat, Andere"
},
"legendMapping":{
"tissue-ffpe": "Gewebe FFPE",
"tissue-frozen": "Gewebe schockgefroren",
"ffpe-tissue": "Gewebe FFPE",
"frozen-tissue": "Gewebe schockgefroren",
"tissue-other": "Gewebe, Andere Konservierungsart",
"whole-blood": "Vollblut",
"blood-serum": "Serum",
Expand Down
54 changes: 52 additions & 2 deletions packages/lib/src/components/results/ChartComponent.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
export let filterRegex: string = "";
export let groupingLabel: string = "";
export let viewScales: boolean = chartType !== "pie" ? true : false;

let options: ChartOption;
$: options =
($lensOptions?.chartOptions &&
Expand Down Expand Up @@ -171,6 +170,23 @@
},
};

const accumulateValues = (
responseStore: ResponseStore,
valuesToAccumulate: string[],
catalogueGroupCode: string,
): number => {
let aggregatedData = 0;

valuesToAccumulate.forEach((value: string) => {
aggregatedData += getAggregatedPopulationForStratumCode(
responseStore,
value,
catalogueGroupCode,
);
});
return aggregatedData;
};

/**
* gets the aggregated population for a given stratum code
* @param responseStore - the response store
Expand Down Expand Up @@ -242,6 +258,36 @@
});
}

/**
* if accumulated values are set, accumulate the values of the given stratum codes and adds them to the chart
* e.g. {name: "frozen-tissue", values: ["tissue-frozen","tissue-ffpe"]}
* will remove the values from the chart and add their accumulated value to "frozen-tissue"
*/
if (
options.accumulatedValues !== undefined &&
options.accumulatedValues.length > 0
) {
options.accumulatedValues.forEach((valueToAccumulate) => {
const aggregationCount: number = accumulateValues(
responseStore,
valueToAccumulate.values,
catalogueGroupCode,
);

combinedSubGroupData.data.push(aggregationCount);
combinedSubGroupData.labels.push(valueToAccumulate.name);

for (let i = 0; i < combinedSubGroupData.labels.length; i++) {
const element: string = combinedSubGroupData.labels[i];
if (valueToAccumulate.values.includes(element)) {
combinedSubGroupData.labels.splice(i, 1);
combinedSubGroupData.data.splice(i, 1);
i--;
}
}
});
}

return {
labels: combinedSubGroupData.labels,
data: [
Expand Down Expand Up @@ -384,7 +430,11 @@
* will be aggregated in groups if a divider is set
* eg. 'C30', 'C31.1', 'C31.2' -> 'C31' when divider is '.'
*/
let chartData = getChartDataSets(responseStore, chartLabels);
let chartData: ChartDataSets = getChartDataSets(
responseStore,
chartLabels,
);

chart.data.datasets = chartData.data;
chartLabels = chartData.labels;

Expand Down
1 change: 0 additions & 1 deletion packages/lib/src/stores/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ export const addStratifier = ({
groupRange,
}): void => {
let queryItem: QueryItem;
console.log(catalogue);
catalogue.forEach((parentCategory: Category) => {
if ("childCategories" in parentCategory) {
parentCategory.childCategories.forEach(
Expand Down
Loading