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-1111 - Add Pharmacogenomics view in IVA #770

Draft
wants to merge 41 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
dcf5ba4
wc: added new button for pharmacogenomics in browser-toolbar
jmjuanes May 8, 2023
143d9d9
wc: minor style fixes in interpreter browser toolbar
jmjuanes May 8, 2023
6c0981e
wc: dispatch event when clicking on pharmacogenomics variants button
jmjuanes May 8, 2023
a154b6f
wc: added listener in interpreter browser template for PGx variants f…
jmjuanes May 8, 2023
392b40b
wc: add new step for pharmacogenomics in interpreter
jmjuanes May 8, 2023
cbd2300
wc: initialize pharmacogenomics components
jmjuanes May 9, 2023
73abf91
wc: added pharmacogenomics tab to interpreter browser RD
jmjuanes May 9, 2023
81b1965
wc: using pharmacogenomics-report component in interpreter step
jmjuanes May 9, 2023
73a9e9f
wc: minor fixes in pharmacogenomics report component
jmjuanes May 9, 2023
2ea4321
wc: added listener to filter for pgx variants in browser template
jmjuanes May 10, 2023
c9ae798
wc: fix pgx filter in interpreter browser template
jmjuanes May 10, 2023
c832af8
wc: import pgx variants from cellbase in pgx-report component
jmjuanes May 10, 2023
cc6a8a7
wc: increase chunk size in pgx variants of browser-template
jmjuanes May 10, 2023
31bb203
Merge branch 'develop' into TASK-1111
jmjuanes May 11, 2023
92fb002
iva: remove enabledComponents print in iva-app
jmjuanes May 11, 2023
350c4ef
wc: remove pharmacogenomics step in interpreter
jmjuanes May 11, 2023
1868d3d
wc: add new tab in variant interpreter brwoser for pgx
jmjuanes May 11, 2023
664d760
wc: fix getting pgx drugs info in pharmacogenomics-report component
jmjuanes May 11, 2023
58b0695
wc: work in progress in pharmacogenomics grid
jmjuanes May 11, 2023
55b2c14
wc: keep previous filters when filtering by pharmacogenomics
jmjuanes May 11, 2023
c82d60e
wc: keep previous ids when filtering by pharmacogenomics
jmjuanes May 11, 2023
a2277e5
wc: change endpoint to obtain pgx annotation in pharmacogenomics-report
jmjuanes May 11, 2023
804a20d
wc: display a loading indicator in pharmacogenomics-report
jmjuanes May 11, 2023
7aeb002
wc: minor style fixes in loading view of pharmacogenomics-report
jmjuanes May 11, 2023
b4d2266
wc: initialize pharmacogenomics grid and add basic columns
jmjuanes May 11, 2023
774fcca
wc: include pharmacogenomics grid in pgx-report component
jmjuanes May 11, 2023
0e18641
wc: some improvements in pharmacogenomics-grid
jmjuanes May 11, 2023
6f9d02f
wc: overwrite id field in query after applying pharmacogenomics filter
jmjuanes May 11, 2023
80788e8
wc: fix importing variants and annotation in pharmacogenomics-report …
jmjuanes May 12, 2023
8655438
wc: added initial variant ccolumns in pharmacogenomics-grid
jmjuanes May 12, 2023
71ca5be
wc: added detail table content in pharmacogenomics-grid component
jmjuanes May 12, 2023
1d2b79d
wc: minor fixes in pharmacogenomics report component
jmjuanes May 12, 2023
fe4f5f9
wc: disable pharmacogenomics summary tab in RD browser
jmjuanes May 12, 2023
7cc4614
wc: remove development code in pharmacogenomics-report component
jmjuanes May 15, 2023
3e44ac0
wc: added error notification in pharmacogenomics-report component
jmjuanes May 15, 2023
a67f3a4
Merge branch 'develop' into TASK-1111
jmjuanes May 18, 2023
e38507f
wc: fix queries to CellBase in pharmacogenomics-report #TASK-4362
jmjuanes May 18, 2023
6ea6a74
wc: set pharmacogenomics buggon disabled by default in variant browse…
jmjuanes May 22, 2023
0ea4ff1
wc: hide pharmacogenomics tab by default in variant interpreter brows…
jmjuanes May 22, 2023
0e7867b
wc: fix queries to opencga in pharmacogenomics-report component #TASK…
jmjuanes May 22, 2023
31ebb94
wc: rename options for displaying pharmacogenomics tab #TASK-4362
jmjuanes May 22, 2023
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
1 change: 0 additions & 1 deletion src/sites/iva/iva-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,6 @@ class IvaApp extends LitElement {
}

<!-- This is where main IVA application is rendered -->
${console.log("Enabled components", Object.keys(this.config.enabledComponents).filter(key => this.config.enabledComponents[key])) }
<div class="container-fluid" style="min-height:calc(100vh - 100px);">
${this.config.enabledComponents.home ? html`
<div class="content" id="home">
Expand Down
293 changes: 293 additions & 0 deletions src/webcomponents/clinical/pharmacogenomics/pharmacogenomics-grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
import {LitElement, html} from "lit";
import UtilsNew from "../../../core/utils-new.js";
import GridCommons from "../../commons/grid-commons.js";
import VariantGridFormatter from "../../variant/variant-grid-formatter.js";
import VariantInterpreterGridFormatter from "../../variant/interpretation/variant-interpreter-grid-formatter.js";
import "../../commons/opencb-grid-toolbar.js";
import "../../loading-spinner.js";

export default class PharmacogenomicsGrid extends LitElement {

constructor() {
super();
this.#init();
}

createRenderRoot() {
return this;
}

static get properties() {
return {
opencgaSession: {
type: Object,
},
sampleId: {
type: String,
},
variants: {
type: Array,
},
config: {
type: Object,
},
};
}

#init() {
this._prefix = UtilsNew.randomString(8);
this._config = this.getDefaultConfig();
}

update(changedProperties) {
if (changedProperties.has("opencgaSession") || changedProperties.has("config")) {
this._config = {
...this.getDefaultConfig(),
...this.config,
};
this.gridCommons = new GridCommons(this._prefix + "PgxTable", this, this._config);
}

super.update(changedProperties);
}

updated(changedProperties) {
if (changedProperties.has("variants") || changedProperties.has("config") || changedProperties.has("opencgaSession")) {
this.renderTable();
}
}

renderTable() {
return this.renderLocalTable();
}

renderLocalTable() {
this.table = $(`#${this._prefix}PgxTable`);
this.table.bootstrapTable("destroy");
this.table.bootstrapTable({
data: this.variants,
columns: this.getDefaultColumns(),
sidePagination: "local",
iconsPrefix: GridCommons.GRID_ICONS_PREFIX,
icons: GridCommons.GRID_ICONS,
uniqueId: "id",
pagination: this._config.pagination,
pageSize: this._config.pageSize,
pageList: this._config.pageList,
detailView: this._config.detailView,
detailFormatter: (value, row) => this.detailFormatter(value, row),

// This has been added to make the grid properties in all bootstrap table formatters, as some grid formattes needs them
variantGrid: this,

// onClickRow: (row, selectedElement) => this.gridCommons.onClickRow(row.id, row, selectedElement),
onDblClickRow: (row, element) => {
if (this._config.detailView) {
if (element[0].innerHTML.includes("fa-plus")) {
$("#" + this.gridId).bootstrapTable("expandRow", element[0].dataset.index);
} else {
$("#" + this.gridId).bootstrapTable("collapseRow", element[0].dataset.index);
}
}
},
// onExpandRow: (index, row) => {
// this.gridCommons.onClickRow(row.id, row, this.querySelector(`tr[data-index="${index}"]`));
// },
onPostBody: data => {
this.gridCommons.onLoadSuccess({rows: data, total: data.length}, 2);
},
});
}

detailFormatter(value, row) {
let result = "<div style='padding-bottom:24px'>";
let detailHtml = "";
if (row?.annotation?.pharmacogenomics) {
detailHtml += "<div style='padding: 10px 0px 5px 25px'><h4>Drugs</h4></div>";
detailHtml += "<div style='padding: 5px 40px'>";
detailHtml += this.drugsTableFormatter(row);
detailHtml += "</div>";
}
result += detailHtml + "</div>";
return result;
}

drugsTableFormatter(variant) {
const drugsRows = variant.annotation.pharmacogenomics
// .filter(item => item.types.includes("Drug"))
.map(item => {
const phenotypes = item.annotations.map(annotation => `<div>${annotation.phenotypes.join(", ")}</div>`);
const phenotypeTypes = item.annotations.map(annotation => `<div>${annotation.phenotypeType}</div>`);
return `
<tr>
<td>${item.id}</td>
<td>${item.name || "-"}</td>
<td>${item.source || "-"}</td>
<td>${phenotypes.join("")}</td>
<td>${phenotypeTypes.join("")}</td>
</tr>
`;
});

return `
<table id="DrugsTable" class="table table-hover table-no-bordered">
<thead>
<tr>
<th style="padding:8px;">ID</th>
<th style="padding:8px;">Name</th>
<th style="padding:8px;">Source</th>
<th style="padding:8px;">Phenotypes</th>
<th style="padding:8px;">Phenotype Types</th>
</tr>
</thead>
<tbody>
${drugsRows.join("")}
</tbody>
</table>
`;
}

render() {
return html`
<div class="force-overflow">
<table id="${this._prefix}PgxTable"></table>
</div>
`;
}

getDefaultColumns() {
return [
[
{
id: "id",
title: "Variant",
field: "id",
rowspan: 2,
colspan: 1,
formatter: (value, row, index) => {
return VariantGridFormatter.variantFormatter(value, row, index, this.opencgaSession.project.organism.assembly, this._config);
},
},
{
id: "genotype",
title: "Genotype",
rowspan: 2,
colspan: 1,
field: {
sampleId: this.sampleId,
quality: this._config.quality,
config: this._config,
},
formatter: VariantInterpreterGridFormatter.sampleGenotypeFormatter,
align: "center",
nucleotideGenotype: true,
visible: !!this.sampleId,
},
{
id: "gene",
title: "Gene",
field: "gene",
rowspan: 2,
colspan: 1,
formatter: (value, row, index) => VariantGridFormatter.geneFormatter(row, index, {}, this.opencgaSession, this._config),
},
{
id: "consequenceType",
title: "Consequence Type",
field: "consequenceType",
rowspan: 2,
colspan: 1,
formatter: (value, row) => VariantGridFormatter.consequenceTypeFormatter(value, row, null, this._config),
},
{
id: "populationFrequencies",
title: "Reference Population Frequencies",
field: "populationFrequencies",
rowspan: 2,
colspan: 1,
formatter: VariantInterpreterGridFormatter.clinicalPopulationFrequenciesFormatter.bind(this),
},
{
id: "clinicalInfo",
title: "Clinical Info",
rowspan: 1,
colspan: 3,
align: "center"
},
],
[
{
id: "clinvar",
title: "ClinVar",
field: "clinvar",
colspan: 1,
rowspan: 1,
formatter: VariantGridFormatter.clinicalTraitAssociationFormatter,
align: "center",
},
{
id: "cosmic",
title: "Cosmic",
field: "cosmic",
colspan: 1,
rowspan: 1,
formatter: VariantGridFormatter.clinicalTraitAssociationFormatter,
align: "center",
},
{
id: "hotspots",
title: "Cancer <br> Hotspots",
field: "hotspots",
colspan: 1,
rowspan: 1,
formatter: VariantGridFormatter.clinicalCancerHotspotsFormatter,
align: "center",
},
],
];
}

getDefaultConfig() {
return {
pagination: true,
pageSize: 10,
pageList: [5, 10, 25],
detailView: true,
quality: {
qual: 30,
dp: 20
},
populationFrequencies: [
"1000G:ALL",
"GNOMAD_GENOMES:ALL",
"GNOMAD_EXOMES:ALL",
],
populationFrequenciesConfig: {
displayMode: "FREQUENCY_BOX"
},
genotype: {
type: "ALLELES"
},
geneSet: {
ensembl: true,
refseq: true,
},
consequenceType: {
// all: false,
maneTranscript: true,
gencodeBasicTranscript: false,
ensemblCanonicalTranscript: true,
refseqTranscript: true,
ccdsTranscript: false,
ensemblTslTranscript: false,
proteinCodingTranscript: false,
highImpactConsequenceTypeTranscript: false,

showNegativeConsequenceTypes: true
},
};
}

}

customElements.define("pharmacogenomics-grid", PharmacogenomicsGrid);
Loading