Browse code

Updated fitPA,aggTax and added fitMeta and fitDO

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/metagenomeSeq@85736 bc3139a8-67e5-0310-9ffc-ced21a209358

Joseph Paulson authored on 23/01/2014 04:33:54
Showing 6 changed files

... ...
@@ -1,6 +1,6 @@
1 1
 Package: metagenomeSeq
2 2
 Title: Statistical analysis for sparse high-throughput sequencing
3
-Version: 1.5.29
3
+Version: 1.5.30
4 4
 Date: 2013-12-13
5 5
 Author: Joseph Nathaniel Paulson, Mihai Pop,  Hector Corrada Bravo
6 6
 Maintainer: Joseph N. Paulson <jpaulson@umiacs.umd.edu>
... ...
@@ -41,8 +41,10 @@ Collate:
41 41
     'doEStep.R'
42 42
     'exportMat.R'
43 43
     'exportStats.R'
44
-    'fitZig.R'
44
+    'fitDO.R'
45
+    'fitMeta.R'
45 46
     'fitPA.R'
47
+    'fitZig.R'
46 48
     'filterData.R'
47 49
     'getEpsilon.R'
48 50
     'getCountDensity.R'
... ...
@@ -22,6 +22,8 @@ cumNormStatFast,
22 22
 expSummary,
23 23
 exportMat,
24 24
 exportStats,
25
+fitDO,
26
+fitMeta,
25 27
 fitPA,
26 28
 fitZig,
27 29
 filterData,
... ...
@@ -2,6 +2,7 @@ version 1.5.xx (2013-11-12)
2 2
 	+ Incorporating biome format support with the biom2MRexperiment and load_biome function.
3 3
 	+ Added filterData, aggregateByTaxonomy(aggTax), calculateEffectiveSamples, functions.
4 4
 	+ Renamed MRfisher to fitPA (presence-absence fisher test).
5
+	+ Added fitDO (Discovery odds ratio test) and fitMeta (original metastats).
5 6
 	+ Added match.call() info to fitZig output
6 7
 version 1.2.xx (2013-08-20)
7 8
 	+ Our paper got accepted and is available!
... ...
@@ -10,6 +10,7 @@
10 10
 #' @param lvl featureData column name from the MRexperiment object.
11 11
 #' @param alternate Use the rowname for undefined OTUs instead of aggregating to "no_match".
12 12
 #' @param norm Whether to aggregate normalized counts or not.
13
+#' @param log Whether or not to log2 transform the counts - if MRexperiment object.
13 14
 #' @param aggfun Aggregation function.
14 15
 #' @return An aggregated count matrix.
15 16
 #' @aliases aggTax
... ...
@@ -20,9 +21,9 @@
20 21
 #' # not run
21 22
 #' # aggregateByTaxonomy(mouseData,lvl="genus",norm=TRUE,aggfun=colMedians)
22 23
 #' 
23
-aggregateByTaxonomy<-function(obj,lvl,alternate=FALSE,norm=TRUE,aggfun = colSums){
24
+aggregateByTaxonomy<-function(obj,lvl,alternate=FALSE,norm=TRUE,log=FALSE,aggfun = colSums){
24 25
 	if(class(obj)=="MRexperiment"){
25
-		mat = MRcounts(obj,norm=norm,log=FALSE)
26
+		mat = MRcounts(obj,norm=norm,log=log)
26 27
     } else {
27 28
 		stop("Object needs to be a MRexperiment object. If it's a matrix, see aggregateM.")
28 29
     }
... ...
@@ -48,6 +49,6 @@ aggregateByTaxonomy<-function(obj,lvl,alternate=FALSE,norm=TRUE,aggfun = colSums
48 49
 }
49 50
 #' @rdname aggregateByTaxonomy
50 51
 #' @export
51
-aggTax<-function(obj,lvl,alternate=FALSE,norm=TRUE,aggfun = colSums){
52
-    aggregateByTaxonomy(obj,lvl,alternate=alternate,norm=norm,aggfun = aggfun)
52
+aggTax<-function(obj,lvl,alternate=FALSE,norm=TRUE,log=FALSE,aggfun = colSums){
53
+    aggregateByTaxonomy(obj,lvl,alternate=alternate,norm=norm,log=log,aggfun = aggfun)
53 54
 }
54 55
\ No newline at end of file
... ...
@@ -29,15 +29,18 @@ fitPA<-function(obj,cl,thres=0){
29 29
     }
30 30
     nrows= nrow(x);
31 31
 	if(is.null(rownames(x))){rownames(x)=1:nrows}
32
-    
32
+
33
+    nClass1 = sum(cl==unique(cl)[1])
34
+    nClass2 = sum(cl==unique(cl)[2])
35
+
33 36
     res = sapply(1:nrows,function(i){
34 37
         tbl = table(1-x[i,],cl)
35 38
         if(sum(dim(tbl))!=4){
36 39
             tbl = array(0,dim=c(2,2));
37 40
             tbl[1,1] = sum(x[i,cl==unique(cl)[1]])
38 41
             tbl[1,2] = sum(x[i,cl==unique(cl)[2]])
39
-            tbl[2,1] = sum(cl==unique(cl)[1])-tbl[1,1]
40
-            tbl[2,2] = sum(cl==unique(cl)[2])-tbl[1,2]
42
+            tbl[2,1] = nClass1-tbl[1,1]
43
+            tbl[2,2] = nClass2-tbl[1,2]
41 44
         }
42 45
         ft <- fisher.test(tbl, workspace = 8e6, alternative = "two.sided", conf.int = T)
43 46
         list(p=ft$p.value,o=ft$estimate,cl=ft$conf.int[1],cu=ft$conf.int[2])
... ...
@@ -8,10 +8,11 @@ MRexperiment and a particular featureData column (i.e. 'genus') will aggregate c
8 8
 to the desired level using the aggfun function (default colSums). Possible aggfun alternatives
9 9
 include colMeans and colMedians.}
10 10
 \usage{
11
-aggregateByTaxonomy(obj, lvl, alternate = FALSE, norm = TRUE,
11
+aggregateByTaxonomy(obj, lvl, alternate = FALSE, norm = TRUE, log = FALSE,
12 12
   aggfun = colSums)
13 13
 
14
-aggTax(obj, lvl, alternate = FALSE, norm = TRUE, aggfun = colSums)
14
+aggTax(obj, lvl, alternate = FALSE, norm = TRUE, log = FALSE,
15
+  aggfun = colSums)
15 16
 }
16 17
 \arguments{
17 18
   \item{obj}{A MRexperiment object.}
... ...
@@ -25,6 +26,9 @@ aggTax(obj, lvl, alternate = FALSE, norm = TRUE, aggfun = colSums)
25 26
   \item{norm}{Whether to aggregate normalized counts or
26 27
   not.}
27 28
 
29
+  \item{log}{Whether or not to log2 transform the counts -
30
+  if MRexperiment object.}
31
+
28 32
   \item{aggfun}{Aggregation function.}
29 33
 }
30 34
 \value{