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)
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)
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)