facets-suite icon indicating copy to clipboard operation
facets-suite copied to clipboard

Bug in HRD-LOH calculation (copy-number-scores.R) causing loss of HRD-LOH information

Open danielmuldoon opened this issue 1 year ago • 0 comments

calculate_hrdloh function bug

To reproduce the bug: find a tumor-normal sample with only one complete chromosome deletion. This deletion must be homozygous. Slack me for specific tumor-normal examples from IMPACT.

Situation: when there are no *“existing” chromosomes in chr_del, the calculation sets segs_loh to NA/NULL and we lose all HRDLOH information for that sample. For example, a sample segs dataframe has chrom=19, but entire chromosome 19 is 0:0 (mcn:lcn), so chromosome 19 gets filtered out at initial step, and no longer exists in segs_loh to be filtered out by chr_del list. Since chrom 19 is the only deleted chromosome and happens to be a homozygous deletion, the calculation is trying to pass something that exists in chr_del but doesn't exist in segs_loh when trying to filter out that chromosome in the final step. If chromosome 19 was a heterozygous deletion 1:0 (mcn:lcn), this error would not occur. If chromosome 20 was deleted as well (1:0), this error would not occur.

“Initial” step of HRDLOH calculation: segs_loh = segs_loh[which(segs_loh$lcn == 0 & segs_loh$mcn != 0), ]

once filtered out, then chrom 19 no longer exists in segs_loh (but still exists in chr_del)

“Final” step of HRDLOH calculation after filtering out 0:0 segments: segs_loh = segs_loh[-which(segs_loh$chrom %in% chr_del)

Potential solutions:

  1. Move the “final” step chronologically above the "initial" step? May cause yet foreseen bugs
  2. Change base R final step solution to a dplyr method that can better handle the NA/Null that is created when there are “existing” chromosomes in chr_del but not segs_loh i.e.:
if (length(chr_del) > 0) {
        segs_loh = segs_loh %>% filter(!(chrom %in% chr_del))
    }

*“exisiting”: chromosomes that are in the chr_del list but not in segs_loh dataframe

danielmuldoon avatar Nov 09 '23 19:11 danielmuldoon