comparison SMART/DiffExpAnal/DESeqTools/loadCountData.R @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
children
comparison
equal deleted inserted replaced
30:5677346472b5 31:0ab839023fe4
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 }