Browse code

Commit made by the Bioconductor Git-SVN bridge. Consists of 1 commit(s).

Commit information:

Commit id: eb4c389c4d932922d89f34321e58c9aa74f72e14
Commit message:
Updating aggregateByTaxonomy and defaults for the fun.
Committed by nosson <nosson at gmail.com>
Commit date: 2014-03-09T23:17:57-04:00

From: Bioconductor Git-SVN Bridge <bioc-sync@bioconductor.org>

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

Joseph Paulson authored on 10/03/2014 03:18:09
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.44
3
+Version: 1.5.45
4 4
 Date: 2013-03-09
5 5
 Author: Joseph Nathaniel Paulson, Mihai Pop, Hector Corrada Bravo
6 6
 Maintainer: Joseph N. Paulson <jpaulson@umiacs.umd.edu>
... ...
@@ -15,7 +15,7 @@ License: Artistic-2.0
15 15
 Depends: R(>= 3.0), Biobase, limma, matrixStats, methods, RColorBrewer,
16 16
         gplots
17 17
 Suggests: annotate, biom, vegan, knitr
18
-Collate: 'aggregateByTaxonomy.R' 'aggregateM.R' 'allClasses.R'
18
+Collate: 'aggregateByTaxonomy.R' 'allClasses.R'
19 19
         'biom2MRexperiment.R' 'calculateEffectiveSamples.R' 'cumNorm.R'
20 20
         'cumNormStat.R' 'cumNormStatFast.R' 'cumNormMat.R'
21 21
         'doCountMStep.R' 'doZeroMStep.R' 'doEStep.R' 'exportMat.R'
... ...
@@ -10,7 +10,6 @@ exportMethods(
10 10
 )
11 11
 
12 12
 export(
13
-aggregateM,
14 13
 aggregateByTaxonomy,
15 14
 aggTax,
16 15
 biom2MRexperiment,
... ...
@@ -1,5 +1,5 @@
1 1
 #' @name aggregateByTaxonomy
2
-#' @title Aggregates a MRexperiment object by a particular taxonomic level.
2
+#' @title Aggregates a MRexperiment object or counts matrix to a particular level.
3 3
 #' 
4 4
 #' Using the featureData information in the MRexperiment, calling aggregateByTaxonomy on a
5 5
 #' MRexperiment and a particular featureData column (i.e. 'genus') will aggregate counts
... ...
@@ -22,8 +22,9 @@
22 22
 #' 
23 23
 #' # not run
24 24
 #' # aggregateByTaxonomy(mouseData,lvl="genus",norm=TRUE,aggfun=colMedians)
25
+#' # aggTax(mouseData,lvl='phylum',norm=FALSE,aggfun=colSums)
25 26
 #' 
26
-aggregateByTaxonomy<-function(obj,lvl,alternate=FALSE,norm=TRUE,log=FALSE,aggfun = colSums,sl=1000,out="MRexperiment"){
27
+aggregateByTaxonomy<-function(obj,lvl,alternate=FALSE,norm=FALSE,log=FALSE,aggfun = colSums,sl=1000,out="MRexperiment"){
27 28
 	if(class(obj)=="MRexperiment"){
28 29
 		mat = MRcounts(obj,norm=norm,log=log,sl=sl)
29 30
 		levels = as.character(fData(obj)[,lvl])
... ...
@@ -64,13 +65,13 @@ aggregateByTaxonomy<-function(obj,lvl,alternate=FALSE,norm=TRUE,log=FALSE,aggfun
64 65
 		} else {
65 66
 			newObj = newMRexperiment(newMat,featureData=taxa)
66 67
 		}
67
-		warning("\n\nThe output here are aggregated (normalized?) counts.\n
68
-			Check default parameters for all metagenomeSeq functions so as not to renormalize.")
68
+		warning("\n\nThe output here are aggregated counts.\n
69
+			Check default parameters for all metagenomeSeq functions and consider normalization.")
69 70
 		return(newObj)
70 71
 	}
71 72
 }
72 73
 #' @rdname aggregateByTaxonomy
73 74
 #' @export
74
-aggTax<-function(obj,lvl,alternate=FALSE,norm=TRUE,log=FALSE,aggfun = colSums,sl=1000,out='MRexperiment'){
75
+aggTax<-function(obj,lvl,alternate=FALSE,norm=FALSE,log=FALSE,aggfun = colSums,sl=1000,out='MRexperiment'){
75 76
 	aggregateByTaxonomy(obj,lvl,alternate=alternate,norm=norm,log=log,aggfun = aggfun,sl=sl,out=out)
76 77
 }
77 78
\ No newline at end of file
78 79
deleted file mode 100644
... ...
@@ -1,58 +0,0 @@
1
-#' Aggregates counts by a particular classification.
2
-#' 
3
-#' This function takes a MRexperiment object of data at a particular level with
4
-#' feature information allowing for aggregation of counts to a particular
5
-#' level. This method assumes taxa begin at the highest level and continue to
6
-#' the current level, reverse assumes taxa begin at the lowest level.
7
-#' 
8
-#' 
9
-#' @param obj A MRexperiment object.
10
-#' @param lvl The level to go up (numeric, 1,2,3).
11
-#' @param taxa A vector of taxa annotations with splits
12
-#' @param split The way character strings in taxa in the obj are split.
13
-#' @return Updated object with counts aggregated to the various taxanomic
14
-#' levels.
15
-aggregateM <-
16
-function(obj,taxa,lvl,split=";"){
17
-
18
-	tmp<-strsplit(taxa,split=split);
19
-	nrows = length(taxa);
20
-    cnts  = MRcounts(obj)
21
-	
22
-	maxName=max(sapply(tmp,length))
23
-	
24
-	featureMat<-array("NA",dim=c(nrows,maxName));
25
-	
26
-	for(i in 1:nrows){
27
-		for(j in 1:length(tmp[[i]])){
28
-			featureMat[i,j]=tmp[[i]][j]
29
-			}
30
-	}
31
-	
32
-	tt = sapply(1:nrows,function(i){
33
-		   t = featureMat[i,1]
34
-		   for(j in 2:lvl){
35
-				t = paste(t,featureMat[i,j],sep=";")
36
-		   }
37
-		   t})
38
-	
39
-	newTaxa<-unique(tt);
40
-    newCountMat<-array(0,dim=c(length(newTaxa),ncol(cnts)));
41
-
42
-    colnames(newCountMat)<-sampleNames(obj)
43
-	rownames(newCountMat)<-newTaxa;	
44
-	
45
-	for(i in 1:length(newTaxa)){
46
-		if(length(which(tt==newTaxa[i]))<2){
47
-			newCountMat[rownames(newCountMat)==newTaxa[i],]=as.matrix(cnts[which(tt==newTaxa[i]),],nr=1)
48
-		}else{
49
-			newCountMat[rownames(newCountMat)==newTaxa[i],]=colSums(cnts[which(tt==newTaxa[i]),])
50
-		}
51
-	}
52
-	
53
-	taxa<-newTaxa;
54
-	assayData(obj)<-newCountMat;
55
-	validObject(obj)
56
-
57
-	return(obj)
58
-}
... ...
@@ -1,17 +1,17 @@
1 1
 \name{aggregateByTaxonomy}
2 2
 \alias{aggTax}
3 3
 \alias{aggregateByTaxonomy}
4
-\title{Aggregates a MRexperiment object by a particular taxonomic level.
4
+\title{Aggregates a MRexperiment object or counts matrix to a particular level.
5 5
 
6 6
 Using the featureData information in the MRexperiment, calling aggregateByTaxonomy on a
7 7
 MRexperiment and a particular featureData column (i.e. 'genus') will aggregate counts
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, log = FALSE,
12
-  aggfun = colSums, sl = 1000, out = "MRexperiment")
11
+aggregateByTaxonomy(obj, lvl, alternate = FALSE, norm = FALSE,
12
+  log = FALSE, aggfun = colSums, sl = 1000, out = "MRexperiment")
13 13
 
14
-aggTax(obj, lvl, alternate = FALSE, norm = TRUE, log = FALSE,
14
+aggTax(obj, lvl, alternate = FALSE, norm = FALSE, log = FALSE,
15 15
   aggfun = colSums, sl = 1000, out = "MRexperiment")
16 16
 }
17 17
 \arguments{
... ...
@@ -39,8 +39,8 @@ aggTax(obj, lvl, alternate = FALSE, norm = TRUE, log = FALSE,
39 39
 An aggregated count matrix.
40 40
 }
41 41
 \description{
42
-Aggregates a MRexperiment object by a particular taxonomic
43
-level.
42
+Aggregates a MRexperiment object or counts matrix to a
43
+particular level.
44 44
 
45 45
 Using the featureData information in the MRexperiment,
46 46
 calling aggregateByTaxonomy on a MRexperiment and a
... ...
@@ -52,5 +52,6 @@ colMeans and colMedians.
52 52
 \examples{
53 53
 # not run
54 54
 # aggregateByTaxonomy(mouseData,lvl="genus",norm=TRUE,aggfun=colMedians)
55
+# aggTax(mouseData,lvl='phylum',norm=FALSE,aggfun=colSums)
55 56
 }
56 57
 
57 58
deleted file mode 100644
... ...
@@ -1,29 +0,0 @@
1
-\name{aggregateM}
2
-\alias{aggregateM}
3
-\title{Aggregates counts by a particular classification.}
4
-\usage{
5
-aggregateM(obj, taxa, lvl, split = ";")
6
-}
7
-\arguments{
8
-  \item{obj}{A MRexperiment object.}
9
-
10
-  \item{lvl}{The level to go up (numeric, 1,2,3).}
11
-
12
-  \item{taxa}{A vector of taxa annotations with splits}
13
-
14
-  \item{split}{The way character strings in taxa in the obj
15
-  are split.}
16
-}
17
-\value{
18
-Updated object with counts aggregated to the various
19
-taxanomic levels.
20
-}
21
-\description{
22
-This function takes a MRexperiment object of data at a
23
-particular level with feature information allowing for
24
-aggregation of counts to a particular level. This method
25
-assumes taxa begin at the highest level and continue to the
26
-current level, reverse assumes taxa begin at the lowest
27
-level.
28
-}
29
-