Skip to content

Calcul des scores

input.sequence.score <- sapply(matrix,
                                 function(x) max(PWMscoreStartingAt(pwm, DNAString(as.character(x))),
                                                 PWMscoreStartingAt(pwm, DNAString(as.character(reverseComplement(x))))))
  input.sequence.pos   <- matchPDict(matrix, dna.seq)
  cutoff.trms <- min(input.sequence.score)
  cutoff.tr50 <- cutoff.trms # par défaut tous sont initialisés sur le
  cutoff.trmc <- cutoff.trms # seul qu'on est sûr de pouvoir
  cutoff.trrl <- cutoff.trms # calculer
  
  if(nrow(resultTable) > 3 && length(which(resultTable$frac <= 0)) == 0) { # seulement si on peut calculer la courbe de régression (min 4 valeurs)
    courbe.regression <- smooth.spline(x=resultTable$midrange, y=resultTable$frac, spar=0.5)
    points.regression <- as.data.frame(predict(courbe.regression, seq(min(resultTable$lower), max(resultTable$upper), 0.001)))
    if(!is.na(t <- points.regression[max(which(points.regression$y <= 0.5)), ]$x)){
      cutoff.tr50 <- t

      derivee <- predict(smooth.spline(x=resultTable$midrange, y=log(resultTable$frac), spar=0.5), resultTable$midrange, deriv=1)
      # derivee.2 <- as.data.frame(predict(courbe.regression, seq(min(resultTable$lower), cutoff.tr50, 0.001), deriv=2))
      # cutoff.trmc <- derivee.2[derivee.2$y == max(derivee.2$y), 1]
      cutoff.trmc <- derivee$x[derivee$y == max(derivee$y)]
      if(length(cutoff.trmc) > 1) cutoff.trmc <- cutoff.trmc[1]
      
      # dd <- as.data.frame(predict(smooth.spline(derivee.2, spar=1.25), deriv=2))
      # cutoff.trrl <- dd[which(dd$y == min(dd$y)), ]$x
      y.subrange <- derivee$y[derivee$x <= cutoff.trmc]
      min <- min(y.subrange)
      x.subrange <- derivee$x[derivee$x <= cutoff.trmc]
      cutoff.trrl <- x.subrange[y.subrange == min]
      if(length(cutoff.trrl) > 1) cutoff.trrl <- cutoff.trrl[1]
      
    }
  }
  
  cutoffs <- list(TRMC=cutoff.trmc,
                  TRMS=cutoff.trms,
                  TRRL=cutoff.trrl,
                  TR50=cutoff.tr50)
Edited by Pierre Tocquin