Linear classifier for removing low frequency false positives.

    Uses a logistic classifier based on 0.5% tumor only variants from the smcounter2 paper:

    https://github.com/bcbio/bcbio_validations/tree/master/somatic-lowfreq

    The classifier uses strand bias (SBF) and read mismatches (NM) and
    applies only for low frequency (<2%) and low depth (<30) variants.

def _lowfreq_linear_filter(tumor_index, is_paired):
    """Linear classifier for removing low frequency false positives.

    Uses a logistic classifier based on 0.5% tumor only variants from the smcounter2 paper:

    https://github.com/bcbio/bcbio_validations/tree/master/somatic-lowfreq

    The classifier uses strand bias (SBF) and read mismatches (NM) and
    applies only for low frequency (<2%) and low depth (<30) variants.
    """
    if is_paired:
        sbf = "FORMAT/SBF[%s]" % tumor_index
        nm = "FORMAT/NM[%s]" % tumor_index
    else:
        sbf = "INFO/SBF"
        nm = "INFO/NM"
    cmd = ("""bcftools filter --soft-filter 'LowFreqBias' --mode '+' """
           """-e  'FORMAT/AF[{tumor_index}] < 0.02 && FORMAT/VD[{tumor_index}] < 30 """
           """&& {sbf} < 0.1 && {nm} >= 2.0'""")
    return cmd.format(**locals())