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

TASK-4451 - Variant and Sample Variant Browser discrepancies and other visualisation details to fix #900

Merged
merged 8 commits into from
May 16, 2024
8 changes: 7 additions & 1 deletion src/sites/iva/conf/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const hosts = [
url: "https://ws.opencb.org/opencga-prod"
},
{
id: "test1",
id: "demo",
url: "https://demo.app.zettagenomics.com/opencga"
},
{
Expand Down Expand Up @@ -194,6 +194,12 @@ const SUITE = {
{id: "getting-started", name: "Getting Started", tab: false, url: "#getting-started", icon: "fa fa-book"}
]
},
jobMonitor: {
visibility: "private"
},
fileExplorer: {
visibility: "private"
},
restApi: {
visibility: "private"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class CellbasePopulationFrequencyGrid extends LitElement {
constructor() {
super();

this._init();
this.#init();
}

createRenderRoot() {
Expand All @@ -50,7 +50,7 @@ export default class CellbasePopulationFrequencyGrid extends LitElement {
};
}

_init() {
#init() {
this._prefix = UtilsNew.randomString(8);

this.populationFrequencies = [];
Expand All @@ -76,15 +76,12 @@ export default class CellbasePopulationFrequencyGrid extends LitElement {
}

variantIdObserver() {
console.log("variantIdObserver", this.variantId, this.cellbaseClient);
if (this.cellbaseClient && this.variantId) {
this.cellbaseClient.get("genomic", "variant", this.variantId, "annotation", {assembly: this.assembly}, {})
.then(restResponse => {
this.populationFrequencies = restResponse.getResult(0).populationFrequencies;
this.requestUpdate();
});
} else {
// this.populationFrequencies = null;
}
}

Expand All @@ -94,17 +91,20 @@ export default class CellbasePopulationFrequencyGrid extends LitElement {
return refAllele + "/" + altAllele;
}

freqFormatter(value, row, index) {
return (value !== 0 && value !== 1) ? Number(value).toFixed(4) : value;
freqFormatter(value, count) {
if (typeof value === "undefined") {
return "NA";
}
return (value !== 0 && value !== 1) ? `<span style="margin:0 5px">${Number(value).toPrecision(4)}</span> / <span style="margin:0 5px">${count}</span> (${(value * 100).toPrecision(4)} %)` : value;
}

renderPlot() {
const popArray = [];
const mafArray = [];
if (typeof this.populationFrequencies !== "undefined") {
if (this.populationFrequencies) {
for (let i = 0; i < this.populationFrequencies.length; i++) {
popArray.push(this.populationFrequencies[i].study + "-" + this.populationFrequencies[i].population);
mafArray.push(Math.min(Number(this.populationFrequencies[i].refAlleleFreq).toFixed(4), Number(this.populationFrequencies[i].altAlleleFreq).toFixed(4)));
mafArray.push(Math.min(Number(this.populationFrequencies[i].refAlleleFreq).toPrecision(4), Number(this.populationFrequencies[i].altAlleleFreq).toPrecision(4)));
}
}

Expand Down Expand Up @@ -203,14 +203,28 @@ export default class CellbasePopulationFrequencyGrid extends LitElement {
colspan: 1
},
{
title: "Allele Frequency",
title: "Number of Samples",
rowspan: 2,
colspan: 1,
formatter: (value, row) => {
if (row.refHomGenotypeCount || row.hetGenotypeCount || row.altHomGenotypeCount) {
return row.refHomGenotypeCount + row.hetGenotypeCount + row.altHomGenotypeCount;
} else {
return (row?.refAlleleCount + row?.altAlleleCount) / 2;
}
},
halign: "center",
align: "right"
},
{
title: "Allele Info",
rowspan: 1,
colspan: 2,
formatter: this.alleleFormatter,
halign: "center"
},
{
title: "Genotype Frequency",
title: "Genotype Info",
rowspan: 1,
colspan: 3,
formatter: this.alleleFormatter,
Expand All @@ -219,52 +233,47 @@ export default class CellbasePopulationFrequencyGrid extends LitElement {
],
[
{
title: "Reference",
field: "refAlleleFreq",
title: `Reference Allele<br><span style="font-style: italic">Freq / Count (%)</span>`,
rowspan: 1,
colspan: 1,
sortable: true,
formatter: this.freqFormatter,
formatter: (value, row) => this.freqFormatter(row.refAlleleFreq, row.refAlleleCount),
halign: "center",
align: "right"
},
{
title: "Alternate",
field: "altAlleleFreq",
title: `Alternate Allele<br><span style="font-style: italic">Freq / Count (%)</span>`,
rowspan: 1,
colspan: 1,
sortable: true,
formatter: this.freqFormatter,
formatter: (value, row) => this.freqFormatter(row.altAlleleFreq, row.altAlleleCount),
halign: "center",
align: "right"
},
{
title: "Ref/Ref",
field: "refHomGenotypeFreq",
title: `Ref/Ref Genotype<br><span style="font-style: italic">Freq / Count (%)</span>`,
rowspan: 1,
colspan: 1,
sortable: true,
formatter: this.freqFormatter,
formatter: (value, row) => this.freqFormatter(row.refHomGenotypeFreq, row.refHomGenotypeCount),
halign: "center",
align: "right"
},
{
title: "Ref/Alt",
field: "hetGenotypeFreq",
title: `Ref/Alt Genotype<br><span style="font-style: italic">Freq / Count (%)</span>`,
rowspan: 1,
colspan: 1,
sortable: true,
formatter: this.freqFormatter,
formatter: (value, row) => this.freqFormatter(row.hetGenotypeFreq, row.hetGenotypeCount),
halign: "center",
align: "right"
},
{
title: "Alt/Alt",
field: "altHomGenotypeFreq",
title: `Alt/Alt Genotype<br><span style="font-style: italic">Freq / Count (%)</span>`,
rowspan: 1,
colspan: 1,
sortable: true,
formatter: this.freqFormatter,
formatter: (value, row) => this.freqFormatter(row.altHomGenotypeFreq, row.altHomGenotypeCount),
halign: "center",
align: "right"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,19 @@ export default class VariantInterpreterGridFormatter {
}

static clinicalPopulationFrequenciesFormatter(value, row) {
const popFreqMap = new Map();
// If variant population freqs exist read values
if (row?.annotation?.populationFrequencies?.length > 0) {
const popFreqMap = new Map();
row.annotation.populationFrequencies.forEach(popFreq => {
popFreqMap.set(popFreq.study + ":" + popFreq.population, popFreq);
});
return VariantGridFormatter.renderPopulationFrequencies(
this._config.populationFrequencies,
popFreqMap,
POPULATION_FREQUENCIES.style,
this._config.populationFrequenciesConfig,
);
} else {
return "-";
}
return VariantGridFormatter.renderPopulationFrequencies(
this._config.populationFrequencies,
popFreqMap,
POPULATION_FREQUENCIES.style,
this._config.populationFrequenciesConfig,
);
}

static predictionFormatter(value, row) {
Expand Down
Loading
Loading