Exemple #1
0
def pwmoccsmethod(seqsdata, pwm, lambda_, Widx, numsamples, args):
    logger.debug('Importance sampling using PWM importance weights')
    calculateZn = jem.createZncalculatorFn(pwm, lambda_)
    numpositive = numsamples / 2  # Sample half in each orientation
    W = args.Ws[Widx]
    childoccfreqs = jis.DistForFreqs(seqsdata.childoccfreqs[:, Widx])
    cb = jis.importancesample(
        seqsdata.index, W,
        jis.WeightedSamplingDist(childoccfreqs, jis.PWMImportanceWeight(pwm)),
        numpositive, jis.ISMemoCbAdaptor(W, jis.ZnSumCb(W), calculateZn))
    return seqsdata.numoccs[Widx], jis.importancesample(
        seqsdata.index, W,
        jis.WeightedSamplingDist(childoccfreqs,
                                 jis.PWMImportanceWeight(jem.pwmrevcomp(pwm))),
        numsamples - numpositive, cb)
Exemple #2
0
def pwmuniquemethod(seqsdata, pwm, lambda_, Widx, numsamples, args):
    logger.debug('Importance sampling using PWM weights over unique W-mers')
    calculateZn = jem.createZncalculatorFn(pwm, lambda_)
    W = args.Ws[Widx]
    childuniquefreqs = jis.DistForFreqs(seqsdata.childuniquefreqs[:, Widx])
    childoccfreqs = jis.DistForFreqs(seqsdata.childoccfreqs[:, Widx])
    numpositive = numsamples / 2  # Sample half in each orientation
    cb = jis.importancesample(
        seqsdata.index, W,
        jis.WeightedSamplingDist(
            childuniquefreqs,
            jis.PWMImportanceWeightUnique(pwm, childoccfreqs)), numpositive,
        jis.ISMemoCbAdaptor(W, jis.ZnSumCb(W), calculateZn, unique=True))
    return seqsdata.numunique[Widx], jis.importancesample(
        seqsdata.index, W,
        jis.WeightedSamplingDist(
            childuniquefreqs,
            jis.PWMImportanceWeightUnique(jem.pwmrevcomp(pwm), childoccfreqs)),
        numsamples - numpositive, cb)
Exemple #3
0
def pwmoccsmethod(seqsdata, pwm, lambda_, Widx, numsamples, args):
    logger.debug('Importance sampling using PWM importance weights')
    calculateZn = jem.createZncalculatorFn(pwm, lambda_)
    numpositive = numsamples / 2  # Sample half in each orientation
    W = args.Ws[Widx]
    childoccfreqs = jis.DistForFreqs(seqsdata.childoccfreqs[:, Widx])
    cb = jis.importancesample(
        seqsdata.index,
        W,
        jis.WeightedSamplingDist(
            childoccfreqs,
            jis.PWMImportanceWeight(pwm)),
        numpositive,
        jis.ISMemoCbAdaptor(W, jis.ZnSumCb(W), calculateZn))
    return seqsdata.numoccs[Widx], jis.importancesample(
        seqsdata.index,
        W,
        jis.WeightedSamplingDist(
            childoccfreqs,
            jis.PWMImportanceWeight(jem.pwmrevcomp(pwm))),
        numsamples - numpositive,
        cb)
Exemple #4
0
def pwmuniquemethod(seqsdata, pwm, lambda_, Widx, numsamples, args):
    logger.debug('Importance sampling using PWM weights over unique W-mers')
    calculateZn = jem.createZncalculatorFn(pwm, lambda_)
    W = args.Ws[Widx]
    childuniquefreqs = jis.DistForFreqs(seqsdata.childuniquefreqs[:, Widx])
    childoccfreqs = jis.DistForFreqs(seqsdata.childoccfreqs[:, Widx])
    numpositive = numsamples / 2  # Sample half in each orientation
    cb = jis.importancesample(
        seqsdata.index,
        W,
        jis.WeightedSamplingDist(
            childuniquefreqs,
            jis.PWMImportanceWeightUnique(pwm, childoccfreqs)),
        numpositive,
        jis.ISMemoCbAdaptor(W, jis.ZnSumCb(W), calculateZn, unique=True))
    return seqsdata.numunique[Widx], jis.importancesample(
        seqsdata.index,
        W,
        jis.WeightedSamplingDist(
            childuniquefreqs,
            jis.PWMImportanceWeightUnique(jem.pwmrevcomp(pwm), childoccfreqs)),
        numsamples - numpositive,
        cb)