[Seqinr-commits] r1659 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 12 10:33:55 CEST 2009


Author: lobry
Date: 2009-10-12 10:33:55 +0200 (Mon, 12 Oct 2009)
New Revision: 1659

Added:
   pkg/R/baselineabif.R
Log:
new utility

Added: pkg/R/baselineabif.R
===================================================================
--- pkg/R/baselineabif.R	                        (rev 0)
+++ pkg/R/baselineabif.R	2009-10-12 08:33:55 UTC (rev 1659)
@@ -0,0 +1,19 @@
+baselineabif <- function(rfu, maxrfu = 1000){
+  #
+  # Check argument:
+  #
+  if(!is.numeric(rfu)) stop("numerical vector expected for rfu")
+  #
+  # Do not consider data above threshold maxrfu:
+  #
+  rfu[rfu >= maxrfu] <- NA
+  #
+  # Compute a kernel density estimate of data:
+  #
+  dst <- density(rfu, na.rm = TRUE)
+  #
+  # Choose as baseline the most common value:
+  #
+  baseline <- dst$x[which.max(dst$y)]
+  return(baseline)
+}



More information about the Seqinr-commits mailing list