Browse code

changed load matrix files

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

Joseph Paulson authored on 25/06/2013 18:40:43
Showing5 changed files

... ...
@@ -1,6 +1,6 @@
1 1
 Package: metagenomeSeq
2 2
 Title: Statistical analysis for sparse high-throughput sequencing
3
-Version: 1.1.7
3
+Version: 1.1.8
4 4
 Date: 2013-06-11
5 5
 Author: Joseph Nathaniel Paulson, Mihai Pop,  Hector Corrada Bravo
6 6
 Maintainer: Joseph N. Paulson <jpaulson@umiacs.umd.edu>
... ...
@@ -1,14 +1,18 @@
1
-versions 1.1.7 (2013-06-11)
1
+version 1.1.8 (2103-06-25)
2
+	
3
+	Modified load_meta and load_metaQ to be faster/use less memory.
4
+
5
+version 1.1.7 (2013-06-11)
2 6
 
3 7
 	Changed modified date on vignette
4 8
 
5
-versions 1.1.6 (2013-06-11)
9
+version 1.1.6 (2013-06-11)
6 10
 
7 11
 	Re-added plotGenus' jitter
8 12
 	Fixed vignette with the new plotOTU and plotGenus call
9 13
 	Fixed uniqueNames call in the MR tables
10 14
 
11
-versions 1.1.5 (2013-06-11)
15
+version 1.1.5 (2013-06-11)
12 16
 
13 17
 Changed thanks to Kasper Daniel Hansen's suggestions the following:
14 18
 
... ...
@@ -18,7 +22,7 @@ Changed thanks to Kasper Daniel Hansen's suggestions the following:
18 22
 
19 23
 Still need to turn the fitZig output to S3, consider subsetting function address low p-values
20 24
 
21
-versions 1.1.3 (2013-06-01) 
25
+version 1.1.3 (2013-06-01) 
22 26
 
23 27
 Changed thanks to Kasper Daniel Hansen's suggestions the following:
24 28
 
... ...
@@ -33,7 +33,7 @@ function(obj,pFlag = FALSE,rel=.1,qFlag = TRUE, ...){
33 33
             refS[k:length(refS)] - approx(yy[,i],n=lo)$y
34 34
         })
35 35
     }
36
-	diffr2 = matrixStats::rowMedians(abs(diffr))
36
+	diffr2 = matrixStats::rowMedians(abs(diffr),na.rm=TRUE)
37 37
 	if(pFlag ==TRUE){
38 38
         plot(abs(diff(diffr2[diffr2>0]))/diffr2[diffr2>0][-1],type="h",ylab="Relative difference for reference",xaxt="n",...)
39 39
 		abline(h=rel)
... ...
@@ -13,26 +13,11 @@
13 13
 load_meta <-
14 14
 function(file,sep="\t")
15 15
 {
16
-	dat2 <- read.table(file,header=FALSE,sep="\t");
17
-    # load names 
18
-	subjects <- array(0,dim=c(ncol(dat2)-1));
19
-	for(i in 1:length(subjects)) {
20
-		subjects[i] <- as.character(dat2[1,i+1]);
21
-	}
22
-	
16
+	dat2 <- read.table(file,header=FALSE,sep=sep,nrows=1,stringsAsFactors=FALSE);
17
+	subjects <- as.character(dat2[1,-1]);
23 18
 	classes <-c("character",rep("numeric",length(subjects)));
24
-	dat3 <- read.table(file,header=FALSE,skip=1,sep=sep,colClasses=classes);
25
-	
26
-	taxa<- as.matrix(dat3[,1]);
27
-
28
-	matrix <- array(0, dim=c(length(taxa),length(subjects)));
29
-	for(i in (1:length(subjects))){
30
-		matrix[,i] <- as.numeric(dat3[,i+1]);
31
-	}	
32
-	
33
-	colnames(matrix) = subjects;
34
-    rownames(matrix) = taxa;
35
-	obj <- list(counts=as.data.frame(matrix), taxa=as.data.frame(taxa))
36
-	
19
+	dat3 <- read.table(file,header=FALSE,skip=1,sep=sep,colClasses=classes,row.names=1);
20
+	taxa<- rownames(dat3);
21
+	obj <- list(counts=as.data.frame(dat3), taxa=as.data.frame(taxa))
37 22
 	return(obj);
38 23
 }
... ...
@@ -10,28 +10,18 @@
10 10
 #' @seealso \code{\link{load_meta}} \code{\link{load_phenoData}}
11 11
 #' @examples
12 12
 #' obj = load_metaQ("~/Desktop/testFile.tsv")
13
-load_metaQ <-
14
-function(file)
15
-{	
16
-	dat2 <- read.table(file,header=FALSE,sep="\t");
17
-# load names 
18
-	subjects <- array(0,dim=c(ncol(dat2)-1));
19
-	for(i in 1:length(subjects)) {
20
-		subjects[i] <- as.character(dat2[1,i+1]);
21
-	}
22
-    classes <-c("character",rep("numeric",(length(subjects)-1)),"character");
23
-	dat3 <- read.table(file,header=TRUE,sep="\t",colClasses=classes);
24
-	
25
-	taxa<- dat3[,1+length(subjects)];
13
+load_metaQ <- function(file) {	
14
+	dat2 <- read.delim(file,header=FALSE,stringsAsFactors=FALSE,nrows=1,skip=1);
15
+	len = ncol(dat2)
16
+	subjects = as.character(dat2[1,-c(1,len)]);
17
+	classes <-c("character",rep("numeric",(len-2)),"character");
18
+	dat3 <- read.delim(file,header=TRUE,colClasses=classes,skip=1);
19
+	taxa<- dat3[,len];
26 20
 	taxa<-as.matrix(taxa);
27
-	
28
-	matrix <- array(0, dim=c(length(taxa),(length(subjects)-1)));
29
-	for(i in (1:(length(subjects)-1))){
30
-		matrix[,i] <- as.numeric(dat3[,i+1]);
31
-	}	
32
-	
33
-	colnames(matrix) = subjects[-length(subjects)];
34
-	obj <- list(counts=matrix, taxa=as.data.frame(taxa),otus = as.data.frame(dat3[,1]))
35
-	
21
+	matrix <- dat3[,-c(1,len)]
22
+	colnames(matrix) = subjects;
23
+	otus = dat3[,1];
24
+	rownames(matrix) = otus;
25
+	obj <- list(counts=as.data.frame(matrix), taxa=as.data.frame(taxa),otus = as.data.frame(otus))
36 26
 	return(obj);
37 27
 }