18
|
1 # loadCountData
|
|
2 # loads counts, one file per lane
|
|
3 # file names from target file
|
|
4
|
|
5 # input : target
|
|
6 # output : raw count table
|
|
7
|
|
8 # created Feb 6th, 2012
|
|
9 # modified May 2nd, 2012 (colnames -> target$label)
|
|
10 # Marie-Agnes Dillies
|
|
11
|
|
12
|
|
13 loadCountData <- function(target, header){
|
|
14
|
|
15 require(DESeq)
|
|
16 fileNames <- target$files
|
|
17
|
|
18 if(header!=0){
|
|
19 #rawCounts <- read.table(as.character(paste(rawDir,target$files[1],sep="/")), sep="\t", header=TRUE)
|
|
20 rawCounts <- read.table(as.character(target$files[1],sep="/"), sep="\t", header=TRUE)
|
|
21 } else if(header==0){
|
|
22 rawCounts <- read.table(as.character(target$files[1],sep="/"), sep="\t")}
|
|
23
|
|
24 colnames(rawCounts) <- c("Id", as.character(target$label[1]))
|
|
25
|
|
26 for (i in 2:length(fileNames)){
|
|
27 if(header!=0){
|
|
28 tmp <- read.table(as.character(target$files[i],sep="/"), sep="\t", header=TRUE)
|
|
29 } else if(header==0){
|
|
30 tmp <- read.table(as.character(target$files[i],sep="/"), sep="\t")}
|
|
31 colnames(tmp) <- c("Id", as.character(target$label[i]))
|
|
32 rawCounts <- merge(rawCounts, tmp, by="Id", all=T)
|
|
33 }
|
|
34 rawCounts[is.na(rawCounts)] <- 0
|
|
35 return(rawCounts)
|
|
36 }
|