Skip to content

Commit

Permalink
Merge pull request #947 from opencb/TASK-6535
Browse files Browse the repository at this point in the history
TASK-6535 - Add Haploid call option filter
  • Loading branch information
jmjuanes authored Jul 16, 2024
2 parents 96296df + 738a530 commit 97f8d4f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 38 deletions.
3 changes: 3 additions & 0 deletions src/webcomponents/commons/filters/sample-genotype-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ export default class SampleGenotypeFilter extends LitElement {
{
separator: true
},
{
id: "1", name: "HAPLOID (1)"
},
{
id: "1/2", name: "BIALLELIC (1/2)"
},
Expand Down
15 changes: 12 additions & 3 deletions src/webcomponents/variant/family-genotype-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export default class FamilyGenotypeFilter extends LitElement {

// Return the default genotype values according the role
defaultGenotype(sample) {
return sample.id === this.clinicalAnalysis.proband.samples[0].id ? ["0/1", "1/1", "1/2"] : [...this._config.defaultGenotypes];
return sample.id === this.clinicalAnalysis.proband.samples[0].id ? ["0/1", "1/1", "1", "1/2"] : [...this._config.defaultGenotypes];
}

render() {
Expand Down Expand Up @@ -339,12 +339,13 @@ export default class FamilyGenotypeFilter extends LitElement {
${BioinfoUtils.getIdName(this.clinicalAnalysis.disorder.id, this.clinicalAnalysis.disorder.name)}
</a>
</th>
<th rowspan="1" colspan="4" style="text-align: center">Genotypes</th>
<th rowspan="1" colspan="5" style="text-align: center">Genotypes</th>
</tr>
<tr>
<th scope="col">HOM_REF (0/0)</th>
<th scope="col">HET (0/1)</th>
<th scope="col">HOM_ALT (1/1)</th>
<th scope="col">HAPLOID (1)</th>
<th scope="col">BIALLELIC (1/2)</th>
</tr>
</thead>
Expand Down Expand Up @@ -415,6 +416,14 @@ export default class FamilyGenotypeFilter extends LitElement {
?disabled="${this.mode !== "CUSTOM"}"
@change="${this.onSampleTableChange}">
</td>
<td style="padding-left: 20px">
<input
type="checkbox"
class="sample-checkbox" data-gt="1" data-sample-id="${sample.id}"
.checked="${this.state?.[sample.id]?.genotypes.includes("1")}"
?disabled="${this.mode !== "CUSTOM"}"
@change="${this.onSampleTableChange}">
</td>
<td style="padding-left: 20px">
<input
type="checkbox"
Expand Down Expand Up @@ -453,7 +462,7 @@ export default class FamilyGenotypeFilter extends LitElement {

getDefaultConfig() {
return {
defaultGenotypes: ["0/0", "0/1", "1/1", "1/2"],
defaultGenotypes: ["0/0", "0/1", "1/1", "1", "1/2"],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ class VariantInterpreterBrowserCancer extends LitElement {
{
separator: true
},
{
id: "1", name: "HAPLOID (1)"
},
{
id: "1/2", name: "BIALLELIC (1/2)"
},
{
id: "NA", name: "NA"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ class VariantInterpreterBrowserCNV extends LitElement {
{
separator: true
},
{
id: "1", name: "HAPLOID (1)"
},
{
id: "1/2", name: "BIALLELIC (1/2)"
},
{
id: "NA", name: "NA"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@ class VariantInterpreterBrowserRd extends LitElement {
switch (this.clinicalAnalysis.type.toUpperCase()) {
case "SINGLE":
case "CANCER":
this._sampleQuery = this.sample.id + ":" + ["0/1", "1/1", "1/2"].join(",");
this._sampleQuery = this.sample.id + ":" + ["0/1", "1/1", "1", "1/2"].join(",");
break;
case "FAMILY":
// Add proband genotypes
const sampleIds = [this.sample.id + ":" + ["0/1", "1/1", "1/2"].join(",")];
const sampleIds = [this.sample.id + ":" + ["0/1", "1/1", "1", "1/2"].join(",")];
for (const member of this.clinicalAnalysis.family?.members) {
// Proband is already in the array in the first position, we add other family members
if (member.id !== this.clinicalAnalysis.proband?.id && member.samples?.length > 0) {
sampleIds.push(member.samples[0].id + ":" + ["0/0", "0/1", "1/1", "1/2"].join(","));
sampleIds.push(member.samples[0].id + ":" + ["0/0", "0/1", "1/1", "1", "1/2"].join(","));
}
}
this._sampleQuery = sampleIds.join(";");
Expand Down Expand Up @@ -347,7 +347,7 @@ class VariantInterpreterBrowserRd extends LitElement {
{
id: "sample-genotype",
title: "Sample Genotype",
visible: () => this.clinicalAnalysis.type.toUpperCase() === "SINGLE",
visible: () => this.clinicalAnalysis.type.toUpperCase() === "SINGLE" || this.clinicalAnalysis.type.toUpperCase() === "CANCER",
params: {
genotypes: [
{
Expand All @@ -359,12 +359,12 @@ class VariantInterpreterBrowserRd extends LitElement {
{
separator: true
},
{
id: "1", name: "HAPLOID (1)"
},
{
id: "1/2", name: "BIALLELIC (1/2)"
},
// {
// id: "1", name: "HEMI"
// }
]
},
tooltip: tooltips.sample,
Expand All @@ -389,6 +389,15 @@ class VariantInterpreterBrowserRd extends LitElement {
individual: this.clinicalAnalysis?.proband
}
},
{
id: "variant-file",
title: "VCF File Filter",
visible: () => this.files?.length > 1,
params: {
files: this.files,
},
tooltip: tooltips.vcfFile,
},
{
id: "variant-file-sample-filter",
title: "Variant Caller Sample Filters",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,16 @@ export default class VariantInterpreterGridFormatter {
</a>
</div>` : `
<div style="margin: 5px 0">${panel.id}</div>`
}
}
</div>
${gene.modesOfInheritance ? `
<div class="help-block" style="margin: 5px 0" title="Panel Mode of Inheritance of gene ${gene.name}">${gene.modesOfInheritance.join(", ")}</div>
` : ""
}
}
${gene.confidence ? `
<div style="color: ${confidenceColor}" title="Panel Confidence of gene ${gene.name}">${gene.confidence}</div>
` : ""
}
}
`;
} else {
panelHtml = re.panelId;
Expand Down Expand Up @@ -628,8 +628,12 @@ export default class VariantInterpreterGridFormatter {
allelesHtml.push(`<span style="color: ${color}">${allelesSeq[i]}</span>`);
}

const bar = genotype.includes("/") ? "/" : "|";
res = `<span>${allelesHtml[0]} ${bar} ${allelesHtml[1]}</span>`;
if (allelesHtml.length === 1) {
res = `<span>${allelesHtml[0]}</span>`;
} else {
const bar = genotype.includes("/") ? "/" : "|";
res = `<span>${allelesHtml[0]} ${bar} ${allelesHtml[1]}</span>`;
}
}
return res;
}
Expand Down
41 changes: 18 additions & 23 deletions src/webcomponents/variant/variant-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ export default class VariantSamples extends LitElement {
this.config = this.getDefaultConfig();
this.gridCommons = new GridCommons(this.gridId, this, this.config);

// Select all genotypes by default
// Nacho: to be more consistent with the rest of the application we are NOT selecting all genotypes by default
this.selectedGenotypes = "";
const selectedGenotypesArray = []
for (const genotype of this.config.genotypes) {
if (genotype.fields) {
selectedGenotypesArray.push(genotype.fields.filter(gt => gt.id).map(gt => gt.id).join(","));
}
}
this.selectedGenotypes = selectedGenotypesArray.join(",");
// const selectedGenotypesArray = [];
// for (const genotype of this.config.genotypes) {
// if (genotype.fields) {
// selectedGenotypesArray.push(genotype.fields.filter(gt => gt.id).map(gt => gt.id).join(","));
// }
// }
// this.selectedGenotypes = selectedGenotypesArray.join(",");
}

updated(changedProperties) {
Expand All @@ -87,6 +87,7 @@ export default class VariantSamples extends LitElement {

genotypeFormatter(value) {
if (value?.data?.length > 0) {
// Color schema: 0/1, 0|1, 1|0 == darkorange; 1, 1/1 == red
const gt = value.data[0];
const color = gt === "0/1" || gt === "0|1" || gt === "1|0" ? "darkorange" : "red";
return `<span style="color: ${color}">${value.data[0]}</span>`;
Expand All @@ -95,7 +96,7 @@ export default class VariantSamples extends LitElement {
}
}

variantFormatter(value, row) {
variantFormatter(value) {
if (value && value.file && value.dataKeys && value.data && value.dataKeys.length === value.data.length) {
const fileInfo = `Filter: ${value.file.data["FILTER"]}; Qual: ${value.file.data["QUAL"]}`;
const sampleFormat = [];
Expand All @@ -108,10 +109,6 @@ export default class VariantSamples extends LitElement {
}
}

individualFormatter(value) {
return value || "-";
}

renderTable() {
if (!this.opencgaSession || !this.variantId) {
return;
Expand Down Expand Up @@ -151,10 +148,6 @@ export default class VariantSamples extends LitElement {
total: response.total,
rows: response.rows
}),
// responseHandler: response => {
// const result = this.gridCommons.responseHandler(response, $(this.table).bootstrapTable("getOptions"));
// return result.response;
// },
onClickRow: (row, selectedElement) => this.gridCommons.onClickRow(row.id, row, selectedElement),
onLoadSuccess: data => {
this.gridCommons.onLoadSuccess(data, 2);
Expand Down Expand Up @@ -274,7 +267,6 @@ export default class VariantSamples extends LitElement {
field: "id",
rowspan: 2,
colspan: 1,
// formatter: this.variantFormatter,
halign: "center"
},
{
Expand All @@ -297,7 +289,6 @@ export default class VariantSamples extends LitElement {
title: "Individual",
rowspan: 1,
colspan: 4,
// formatter: this.variantFormatter,
halign: "center"
},
{
Expand All @@ -315,7 +306,7 @@ export default class VariantSamples extends LitElement {
field: "individualId",
colspan: 1,
rowspan: 1,
formatter: this.individualFormatter,
formatter: value => value || "-",
halign: "center"
},
{
Expand Down Expand Up @@ -363,6 +354,7 @@ export default class VariantSamples extends LitElement {
skip: 0,
limit: 5000,
};

// batch size for sample query
const BATCH_SIZE = 100;

Expand Down Expand Up @@ -481,14 +473,17 @@ export default class VariantSamples extends LitElement {
{
id: "1/1", name: "Homozygous Alternate (1/1)"
},
{
id: "1", name: "Haploid (1)"
},
{
id: "1/2", name: "Biallelic (1/2)"
},
]
},
{
separator: true
},
// {
// separator: true
// },
{
id: "Secondary Alternate Genotypes",
fields: [
Expand Down

0 comments on commit 97f8d4f

Please sign in to comment.