A genuinely heterozygous site must show BOTH alleles in a BALANCED way once reads are pooled across all of a donor's samples. Two kinds of genotyping error are removed (they generate the homozygous "leak" that 04_asc_benchmarking.R quantifies):

  1. pooled minor-allele count below minMinor (strictly monoallelic);

  2. pooled minor-allele FRACTION below minMinorFrac – a hom-ref (or hom-alt) site whose few minor reads are just sequencing error scattered across many samples. An absolute count alone misses these, because ~0.3% error across ~50 deep samples can sum to >=2 minor reads while the pooled fraction stays near zero; the fraction test catches them.

For each donor, offending sites have their counts ZEROED in that donor's sample columns (ref = alt = 0), giving total coverage 0 so they are dropped by the downstream coverage filters and never tested. Zeroing (rather than NA) keeps plain sum() / rowSums() calls valid. Genuine ASC survives: even strong allele-specific sites pool to a minor fraction well above minMinorFrac across a donor's many samples.

ascDropHomozygous(
  refMat,
  altMat,
  annot,
  minMinor = 2L,
  minMinorFrac = 0.05,
  minTotal = 10L,
  verbose = TRUE
)

Arguments

refMat, altMat

count matrices [snp x sample].

annot

sample annotation with sampleId, donor.

minMinor

minimum donor-pooled minor-allele reads (default 2).

minMinorFrac

minimum donor-pooled minor-allele fraction (default 0.05); below this a covered site is treated as homozygous+error.

minTotal

donor-pooled coverage above which the tests apply rather than treating the site as merely low-coverage (default 10).

verbose

log how many donor x site cells were masked (default TRUE).

Value

list(ref, alt) with donor-specific zeroing applied.

Author

Irem B. GUNDUZ