Closed elifirem closed 6 years ago
Hi @elifirem,
Witness just computes CCF from the cellular prevalence (CP) by dividing every CP value by the CP of the clonal population (aka the purity or cellularity). Here is the Javascript in WItness that does the computation:
TreePlotter.prototype._calc_ccf = function(structure, populations, pop_id, root_id) {
var pop_ids = Util.sort_ints(Object.keys(populations));
var num_samples = populations[pop_ids[0]].cellular_prevalence.length;
// CCF of non-cancerous population should be zero.
if(parseInt(pop_id, 10) === 0)
return (new Array(num_samples)).fill(0);
var clonal_pidxs = structure[root_id];
var purities = [];
// Don't assume that populations[1] will have the maximum cellular
// prevalence, as this may not be true for polyclonal tumors.
for(var sampidx = 0; sampidx < num_samples; sampidx++) {
var purity = 0;
clonal_pidxs.forEach(function(pidx) {
purity += populations[pidx].cellular_prevalence[sampidx];
});
purities.push(purity);
}
var cps = populations[pop_id].cellular_prevalence;
var ccf = [];
for(var sampidx = 0; sampidx < num_samples; sampidx++) {
ccf.push(cps[sampidx] / purities[sampidx]);
}
return ccf;
}
The only complication arises if you have multiple clonal populations forming a polyclonal tumour. In that case, we take the sum of the purities of the clonal nodes as the overall purity. This should be an extremely rare case, though.
Thanks a lot @jwintersinger !
Hi, Even though witness shows CCF values in populations, it looks like JSON files does not contain that information, there is only cellular prevalence. Is there any way to extract CCF information from the results? Thanks, Irem