Skip to content

Commit

Permalink
Add haploid call 1 to family cases
Browse files Browse the repository at this point in the history
  • Loading branch information
imedina committed Jul 15, 2024
1 parent 9f1179c commit 738a530
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
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 @@ -138,13 +138,12 @@ class VariantInterpreterBrowserRd extends LitElement {
this._sampleQuery = this.sample.id + ":" + ["0/1", "1/1", "1", "1/2"].join(",");
break;
case "FAMILY":
// TODO Nacho, Josemi: add Haploid (1) to family cases
// 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
38 changes: 15 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 @@ -489,9 +481,9 @@ export default class VariantSamples extends LitElement {
},
]
},
{
separator: true
},
// {
// separator: true
// },
{
id: "Secondary Alternate Genotypes",
fields: [
Expand Down

0 comments on commit 738a530

Please sign in to comment.