Author: Michael R. Crusoe <michael.crusoe@gmail.com>
Description: r-cran-locfit is non-free and not yet packaged for Debian
--- a/R/core.R
+++ b/R/core.R
@@ -149,7 +149,7 @@
 #' Wald significance tests (defined by \code{\link{nbinomWaldTest}}),
 #' or the likelihood ratio test on the difference in deviance between a
 #' full and reduced model formula (defined by \code{\link{nbinomLRT}})
-#' @param fitType either "parametric", "local", or "mean"
+#' @param fitType either "parametric", or "mean"
 #' for the type of fitting of dispersions to the mean intensity.
 #' See \code{\link{estimateDispersions}} for description.
 #' @param sfType either "ratio", "poscounts", or "iterate"
@@ -207,7 +207,6 @@
 #' 
 #' @import BiocGenerics BiocParallel S4Vectors IRanges GenomicRanges SummarizedExperiment Biobase Rcpp methods
 #'
-#' @importFrom locfit locfit
 #' @importFrom genefilter rowVars filtered_p
 #' @importFrom Hmisc wtd.quantile
 #' 
@@ -244,7 +243,7 @@
 #'
 #' @export
 DESeq <- function(object, test=c("Wald","LRT"),
-                  fitType=c("parametric","local","mean"),
+                  fitType=c("parametric","mean"),
                   sfType=c("ratio","poscounts","iterate"),
                   betaPrior,
                   full=design(object), reduced, quiet=FALSE,
@@ -254,7 +253,7 @@
   # check arguments
   stopifnot(is(object, "DESeqDataSet"))
   test <- match.arg(test, choices=c("Wald","LRT"))
-  fitType <- match.arg(fitType, choices=c("parametric","local","mean"))
+  fitType <- match.arg(fitType, choices=c("parametric","mean"))
   sfType <- match.arg(sfType, choices=c("ratio","poscounts","iterate"))
   # more check arguments
   stopifnot(is.logical(quiet))
@@ -523,7 +522,7 @@
 #' examples below.
 #'
 #' @param object a DESeqDataSet
-#' @param fitType either "parametric", "local", or "mean"
+#' @param fitType either "parametric", or "mean"
 #' for the type of fitting of dispersions to the mean intensity.
 #' See \code{\link{estimateDispersions}} for description.
 #' @param outlierSD the number of standard deviations of log
@@ -744,7 +743,7 @@
 
 #' @rdname estimateDispersionsGeneEst
 #' @export
-estimateDispersionsFit <- function(object,fitType=c("parametric","local","mean"),
+estimateDispersionsFit <- function(object,fitType=c("parametric","mean"),
                                    minDisp=1e-8, quiet=FALSE) {
 
   if (is.null(mcols(object)$allZero)) {
@@ -761,7 +760,7 @@
   ...then continue with testing using nbinomWaldTest or nbinomLRT")
   }
   
-  fitType <- match.arg(fitType, choices=c("parametric","local","mean"))
+  fitType <- match.arg(fitType, choices=c("parametric","mean"))
   stopifnot(length(fitType)==1)
   stopifnot(length(minDisp)==1)
   if (fitType == "parametric") {
@@ -775,18 +774,18 @@
       fitType <- "local"
     }
   }
-  if (fitType == "local") {
-    dispFunction <- localDispersionFit(means = mcols(objectNZ)$baseMean[useForFit],
-                                       disps = mcols(objectNZ)$dispGeneEst[useForFit],
-                                       minDisp = minDisp)
-  }
+  #if (fitType == "local") {
+  #  dispFunction <- localDispersionFit(means = mcols(objectNZ)$baseMean[useForFit],
+  #                                     disps = mcols(objectNZ)$dispGeneEst[useForFit],
+  #                                     minDisp = minDisp)
+  #}
   if (fitType == "mean") {
     useForMean <- mcols(objectNZ)$dispGeneEst > 10*minDisp
     meanDisp <- mean(mcols(objectNZ)$dispGeneEst[useForMean],na.rm=TRUE,trim=0.001)
     dispFunction <- function(means) meanDisp
     attr( dispFunction, "mean" ) <- meanDisp
   }
-  if (!(fitType %in% c("parametric","local","mean"))) {
+  if (!(fitType %in% c("parametric","mean"))) {
     stop("unknown fitType")
   }
  
@@ -1926,16 +1925,17 @@
 
 # Local fit of dispersion to the mean intensity
 # fitting is done on log dispersion, log mean scale
-localDispersionFit <- function( means, disps, minDisp ) {
-  if (all(disps < minDisp*10)) {
-    return(rep(minDisp,length(disps)))
-  }
-  d <- data.frame(logDisps = log(disps), logMeans = log(means))
-  fit <- locfit(logDisps ~ logMeans, data=d[disps >= minDisp*10,,drop=FALSE],
-                weights = means[disps >= minDisp*10])
-  dispFunction <- function(means) exp(predict(fit, data.frame(logMeans=log(means))))
-  return(dispFunction)
-}
+# locfit is non-free and not packaged at this time for Debian
+#localDispersionFit <- function( means, disps, minDisp ) {
+#  if (all(disps < minDisp*10)) {
+#    return(rep(minDisp,length(disps)))
+#  }
+#  d <- data.frame(logDisps = log(disps), logMeans = log(means))
+#  fit <- locfit(logDisps ~ logMeans, data=d[disps >= minDisp*10,,drop=FALSE],
+#                weights = means[disps >= minDisp*10])
+#  dispFunction <- function(means) exp(predict(fit, data.frame(logMeans=log(means))))
+#  return(dispFunction)
+#}
 
 
 # convenience function for testing the log likelihood
--- a/R/methods.R
+++ b/R/methods.R
@@ -521,7 +521,7 @@
 setMethod("estimateSizeFactors", signature(object="DESeqDataSet"),
           estimateSizeFactors.DESeqDataSet)
 
-estimateDispersions.DESeqDataSet <- function(object, fitType=c("parametric","local","mean"),
+estimateDispersions.DESeqDataSet <- function(object, fitType=c("parametric","mean"),
                                              maxit=100, quiet=FALSE, modelMatrix=NULL, minmu=0.5) {
   # Temporary hack for backward compatibility with "old" DESeqDataSet
   # objects. Remove once all serialized DESeqDataSet objects around have
@@ -550,7 +550,7 @@
     mcols(object) <- mcols(object)[,!(mcols(mcols(object))$type %in% c("intermediate","results")),drop=FALSE]
   }
   stopifnot(length(maxit)==1)
-  fitType <- match.arg(fitType, choices=c("parametric","local","mean"))
+  fitType <- match.arg(fitType, choices=c("parametric","mean"))
   
   checkForExperimentalReplicates(object, modelMatrix)
   
@@ -641,7 +641,7 @@
 #' @rdname estimateDispersions
 #' @aliases estimateDispersions estimateDispersions,DESeqDataSet-method
 #' @param object a DESeqDataSet
-#' @param fitType either "parametric", "local", or "mean"
+#' @param fitType either "parametric", or "mean"
 #' for the type of fitting of dispersions to the mean intensity.
 #' \itemize{
 #'   \item parametric - fit a dispersion-mean relation of the form:
@@ -649,10 +649,6 @@
 #'     via a robust gamma-family GLM. The coefficients \code{asymptDisp} and \code{extraPois}
 #'     are given in the attribute \code{coefficients} of the \code{\link{dispersionFunction}}
 #'     of the object.
-#'   \item local - use the locfit package to fit a local regression
-#'     of log dispersions over log base mean (normal scale means and dispersions
-#'     are input and output for \code{\link{dispersionFunction}}). The points
-#'     are weighted by normalized mean count in the local regression.
 #'   \item mean - use the mean of gene-wise dispersion estimates.
 #' }
 #' @param maxit control parameter: maximum number of iterations to allow for convergence
--- a/R/vst.R
+++ b/R/vst.R
@@ -53,12 +53,6 @@
 #' count data. The expression can be found in the file \file{vst.pdf}
 #' which is distributed with the vignette.
 #'
-#' \code{fitType="local"},
-#' the reciprocal of the square root of the variance of the normalized counts, as derived
-#' from the dispersion fit, is then numerically
-#' integrated, and the integral (approximated by a spline function) is evaluated for each
-#' count value in the column, yielding a transformed value. 
-#'
 #' \code{fitType="mean"}, a VST is applied for Negative Binomial distributed counts, 'k',
 #' with a fixed dispersion, 'a': ( 2 asinh(sqrt(a k)) - log(a) - log(4) )/log(2).
 #' 
@@ -191,7 +185,7 @@
     vst.fn <- function(q) ( 2 * asinh(sqrt(alpha * q)) - log(alpha) - log(4) ) / log(2)
     return(vst.fn(ncounts))
   } else {
-    stop( "fitType is not parametric, local or mean" )
+    stop( "fitType is not parametric, or mean" )
   }
 }
 
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -16,7 +16,7 @@
 License: LGPL (>= 3)
 VignetteBuilder: knitr, rmarkdown
 Imports: BiocGenerics (>= 0.7.5), Biobase, BiocParallel, genefilter,
-        methods, stats4, locfit, geneplotter, ggplot2, Hmisc, Rcpp (>=
+        methods, stats4, geneplotter, ggplot2, Hmisc, Rcpp (>=
         0.11.0)
 Depends: S4Vectors (>= 0.23.18), IRanges, GenomicRanges,
         SummarizedExperiment (>= 1.1.6)
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -92,7 +92,6 @@
 importFrom(graphics,hist)
 importFrom(graphics,plot)
 importFrom(graphics,points)
-importFrom(locfit,locfit)
 importFrom(stats,Gamma)
 importFrom(stats,as.formula)
 importFrom(stats,coef)
--- a/tests/testthat/test_dispersions.R
+++ b/tests/testthat/test_dispersions.R
@@ -111,7 +111,7 @@
   # test fit alternative
   dds <- makeExampleDESeqDataSet()
   dds <- estimateSizeFactors(dds)
-  ddsLocal <- estimateDispersions(dds, fitType="local")
+#  ddsLocal <- estimateDispersions(dds, fitType="local")
   ddsMean <- estimateDispersions(dds, fitType="mean")
   ddsMed <- estimateDispersionsGeneEst(dds)
   useForMedian <- mcols(ddsMed)$dispGeneEst > 1e-7
