Skip to content

Commit

Permalink
Merge pull request #161 from tcarver/master
Browse files Browse the repository at this point in the history
updates
  • Loading branch information
tcarver authored Feb 19, 2024
2 parents 37c8207 + e860cb6 commit fa0d5d9
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 26 deletions.
19 changes: 11 additions & 8 deletions build/pedigreejs.v3.0.0-rc3.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,6 @@ var pedigreejs = (function (exports) {
}
}
}

recurse(root);
recurse(root);
}
Expand Down Expand Up @@ -1205,7 +1204,6 @@ var pedigreejs = (function (exports) {
};
clear(opts); // clear all storage data
}

delete opts.dataset;
let selected = $("input[name='default_fam']:checked");
if (selected.length > 0 && selected.val() === 'extended2') {
Expand Down Expand Up @@ -1579,6 +1577,11 @@ var pedigreejs = (function (exports) {
ped.unshift(indi);
}
}

// group mztwins
ped.sort(function (a, b) {
return a.mztwin !== undefined ? a.mztwin.localeCompare(b.mztwin) : 0;
});
return [hdr, ped];
}

Expand Down Expand Up @@ -1694,7 +1697,6 @@ var pedigreejs = (function (exports) {
// result, 0=untested, P=positive, N=negative
}
}

for (let j = 0; j < pathology_tests.length; j++) {
// status, 0 = unspecified, N = negative, P = positive
if (pathology_tests[j] + '_bc_pathology' in p) {
Expand Down Expand Up @@ -2522,9 +2524,9 @@ var pedigreejs = (function (exports) {
// update status field and age label - 0 = alive, 1 = dead
function updateStatus(status) {
$('#age_yob_lock').removeClass('fa-lock fa-unlock-alt');
status === 1 ? $('#age_yob_lock').addClass('fa-unlock-alt') : $('#age_yob_lock').addClass('fa-lock');
status === "1" ? $('#age_yob_lock').addClass('fa-unlock-alt') : $('#age_yob_lock').addClass('fa-lock');
$('#id_age_' + status).removeClass("hidden");
$('#id_age_' + (status === 1 ? '0' : '1')).addClass("hidden");
$('#id_age_' + (status === "1" ? '0' : '1')).addClass("hidden");
}
function nodeclick(node) {
$('form > fieldset').prop('disabled', false);
Expand Down Expand Up @@ -2767,6 +2769,7 @@ var pedigreejs = (function (exports) {
nodeclick: nodeclick,
save: save,
save_ashkn: save_ashkn,
updateStatus: updateStatus,
update_diagnosis_age_widget: update_diagnosis_age_widget
});

Expand Down Expand Up @@ -3575,7 +3578,7 @@ var pedigreejs = (function (exports) {
'colour': 'pink'
}, {
'type': 'ovarian_cancer',
'colour': '#4DAA4D'
'colour': '#306430'
}, {
'type': 'pancreatic_cancer',
'colour': '#4289BA'
Expand All @@ -3588,7 +3591,7 @@ var pedigreejs = (function (exports) {
font_size: '.75em',
font_family: 'Helvetica',
font_weight: 700,
background: "#EEE",
background: "#FAFAFA",
node_background: '#fdfdfd',
validate: true,
DEBUG: false
Expand Down Expand Up @@ -3741,7 +3744,7 @@ var pedigreejs = (function (exports) {

// alive status = 0; dead status = 1
node.filter(function (d) {
return d.data.status === "1";
return d.data.status === "1" || d.data.status === 1;
}).append('line').style("stroke", "black").attr("x1", function (_d, _i) {
return -0.6 * opts.symbol_size;
}).attr("y1", function (_d, _i) {
Expand Down
2 changes: 1 addition & 1 deletion build/pedigreejs.v3.0.0-rc3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/pedigreejs.v3.0.0-rc3.min.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions es/canrisk_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ export function readCanRisk(boadicea_lines) {
ped.unshift(indi);
}
}

// group mztwins
ped.sort(function(a, b) {
return a.mztwin !== undefined ? a.mztwin.localeCompare(b.mztwin) : 0;
});

return [hdr, ped];
}

Expand Down
7 changes: 3 additions & 4 deletions es/pedigree.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function build(options) {
zoomOut: 1.0,
diseases: [ {'type': 'breast_cancer', 'colour': '#F68F35'},
{'type': 'breast_cancer2', 'colour': 'pink'},
{'type': 'ovarian_cancer', 'colour': '#4DAA4D'},
{'type': 'ovarian_cancer', 'colour': '#306430'},
{'type': 'pancreatic_cancer', 'colour': '#4289BA'},
{'type': 'prostate_cancer', 'colour': '#D5494A'}],
labels: ['stillbirth', ['age', 'yob'], 'alleles',
Expand All @@ -39,7 +39,7 @@ export function build(options) {
font_size: '.75em',
font_family: 'Helvetica',
font_weight: 700,
background: "#EEE",
background: "#FAFAFA",
node_background: '#fdfdfd',
validate: true,
DEBUG: false}, options );
Expand Down Expand Up @@ -213,11 +213,10 @@ export function build(options) {


// alive status = 0; dead status = 1
node.filter(function (d) {return d.data.status === "1";})
node.filter(function (d) {return d.data.status === "1" || d.data.status === 1;})
.append('line')
.style("stroke", "black")
.attr("x1", function(_d, _i) {return -0.6*opts.symbol_size;})
.attr("y1", function(_d, _i) {return 0.6*opts.symbol_size;})
.attr("x2", function(_d, _i) {return 0.6*opts.symbol_size;})
.attr("y2", function(_d, _i) {return -0.6*opts.symbol_size;});

Expand Down
6 changes: 3 additions & 3 deletions es/popup_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ $(document).on('fhChange', function(e, opts){
})

// update status field and age label - 0 = alive, 1 = dead
function updateStatus(status) {
export function updateStatus(status) {
$('#age_yob_lock').removeClass('fa-lock fa-unlock-alt');
(status === 1 ? $('#age_yob_lock').addClass('fa-unlock-alt') : $('#age_yob_lock').addClass('fa-lock'));
(status === "1" ? $('#age_yob_lock').addClass('fa-unlock-alt') : $('#age_yob_lock').addClass('fa-lock'));
$('#id_age_'+status).removeClass("hidden");
$('#id_age_'+(status === 1 ? '0' : '1')).addClass("hidden");
$('#id_age_'+(status === "1" ? '0' : '1')).addClass("hidden");
}

export function nodeclick(node) {
Expand Down
115 changes: 113 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@
'targetDiv': 'pedigree',
'btn_target': 'pedigree_history',
// 'nodeclick': pedigree_form.nodeclick,
'width': ($(window).width() > 450 ? 390 : $(window).width()- 30),
'height': 280,
'width': ($(window).width() > 540 ? 500 : $(window).width()- 30),
'height': 350,
'symbol_size': 30,
'edit': true,
'zoomIn': .5,
Expand All @@ -186,6 +186,108 @@
opts.dataset = dataset;
}
opts = pedigreejs.pedigreejs.build(opts);

/**
* Funtion to get the pedigree data in BOADICEA v4 format
*/
function get_pedigree_bwa4(dataset) {
let msg = "BOADICEA import pedigree file format 4.0 ";
let famid = opts.dataset[0].famid;

// female risk factors
let probandIdx = pedigreejs.pedigreejs_utils.getProbandIndex(dataset);
let sex = 'F';
if(probandIdx) {
sex = dataset[probandIdx].sex;
}

msg += "\nFamID\tName\tTarget\tIndivID\tFathID\tMothID\tSex\tMZtwin\tDead\tAge\tYob";
msg += "\t1stBrCa\t2ndBrCa\tOvCa\tProCa\tPanCa\tAshkn";
msg += "\tBRCA1t\tBRCA1r\tBRCA2t\tBRCA2r\tPALB2t\tPALB2r\tATMt\tATMr\tCHEK2t\tCHEK2r\tER\tPR\tHER2\tCK14\tCK56";

for(let i=0; i<dataset.length; i++) {
let p = dataset[i];

msg += '\n'+famid+'\t'; // max 13 chars
msg += (p.display_name ? p.display_name : "NA")+'\t'; // display_name
msg += ('proband' in p ? '1' : 0)+'\t';
msg += p.name+'\t'; // max 7 chars
msg += ('father' in p && !('noparents' in p)? p.father : 0)+'\t'; // max 7 chars
msg += ('mother' in p && !('noparents' in p)? p.mother : 0)+'\t'; // max 7 chars
msg += p.sex+'\t';
msg += ('mztwin' in p ? p.mztwin : 0)+'\t'; // MZtwin
msg += ('status' in p ? p.status : 0)+'\t'; // current status: 0 = alive, 1 = dead
msg += ('age' in p ? p.age : 0)+'\t'; // Age at last follow up or 0 = unspecified
msg += ('yob' in p ? p.yob : 0)+'\t'; // YOB or 0 = unspecified

let cmsg = "";
$.each(pedigreejs.pedigreejs_canrisk_file.cancers, function(cancer, diagnosis_age) {
// Age at 1st cancer or 0 = unaffected, AU = unknown age at diagnosis (affected unknown)
if(diagnosis_age in p)
cmsg += (diagnosis_age in p ? p[diagnosis_age] : 'AU')+'\t';
else
cmsg += '0\t';
});
msg+=cmsg;

// Ashkenazi status, 0 = not Ashkenazi, 1 = Ashkenazi
msg += ('ashkenazi' in p ? p.ashkenazi : 0)+'\t';

let gt = ['brca1', 'brca2', 'palb2', 'atm', 'chek2'];
for(let j=0; j<gt.length; j++) {
if(gt[j]+'_gene_test' in p &&
p[gt[j]+'_gene_test']['type'] !== '-' &&
p[gt[j]+'_gene_test']['result'] !== '-') {
msg += p[gt[j]+'_gene_test']['type'] + '\t';
msg += p[gt[j]+'_gene_test']['result'] + '\t';
} else {
msg += '0\t0\t'; // type, 0=untested, S=mutation search, T=direct gene test
// result, 0=untested, P=positive, N=negative
}
}

let ptests = pedigreejs.pedigreejs_canrisk_file.pathology_tests;
for(let j=0; j<ptests.length; j++) {
// status, 0 = unspecified, N = negative, P = positive
if(ptests[j]+'_bc_pathology' in p) {
msg += p[ptests[j]+'_bc_pathology'];
} else {
msg += '0';
}
if(j<(ptests.length-1))
msg += "\t";
}
}
return msg;
}

function save(asCanRisk) {
let curr = pedigreejs.pedigreejs_pedcache.current(opts);
var content;
var fileName;
if (asCanRisk){
content = pedigreejs.pedigreejs_canrisk_file.get_non_anon_pedigree(opts.dataset);
filename = "ped.canrisk";
} else {
content = get_pedigree_bwa4(opts.dataset);
filename = "ped.boadicea";
}

let file = new Blob([content], {type: "text/plain"});
let a = document.createElement("a");
let url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}

$('#save-boadicea').click(function(_e) { save(false); });
$('#save-canrisk').click(function(_e) { save(true); });
});
</script>
</head>
Expand All @@ -212,6 +314,7 @@ <h2>A web tool for building and displaying pedigrees.</h2>
<label class="btn">
<input id="save" type="button" style="display: none;"/>Save
</label>

<label class="btn">
<input id="print" type="button" style="display: none;"/>Print
</label>
Expand All @@ -224,6 +327,14 @@ <h2>A web tool for building and displaying pedigrees.</h2>

<div id="pedigrees"></div>
<div id="node_properties"></div>

<br/>
<label class="btn">
<input id="save-boadicea" type="button" style="display: none;"/>Save (BOADICEA v4 format)
</label>
<label class="btn">
<input id="save-canrisk" type="button" style="display: none;"/>Save (CanRisk format)
</label>
</div>
</div>
<div>
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@
},
"homepage": "https://ccge-boadicea.github.io/pedigreejs/",
"devDependencies": {
"@babel/core": "^7.22.9",
"@babel/eslint-parser": "^7.22.9",
"@babel/preset-env": "^7.22.9",
"@rollup/plugin-babel": "^6.0.3",
"npm-check-updates": "^16.10.17",
"rollup": "^3.27.0",
"@babel/core": "^7.23.9",
"@babel/eslint-parser": "^7.23.10",
"@babel/preset-env": "^7.23.9",
"@rollup/plugin-babel": "^6.0.4",
"npm-check-updates": "^16.14.15",
"rollup": "^4.12.0",
"rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2"
},
"dependencies": {
"postcss": "^8.4.27"
"caniuse-lite": "^1.0.30001588",
"postcss": "^8.4.35"
}
}

0 comments on commit fa0d5d9

Please sign in to comment.