annotate SMART/DiffExpAnal/DESeqTools/loadCountData.R @ 34:529e3e6a0954

Deleted selected files
author m-zytnicki
date Tue, 30 Apr 2013 14:35:27 -0400
parents 94ab73e8a190
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 # loadCountData
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2 # loads counts, one file per lane
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 # file names from target file
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5 # input : target
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6 # output : raw count table
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8 # created Feb 6th, 2012
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 # modified May 2nd, 2012 (colnames -> target$label)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 # Marie-Agnes Dillies
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 loadCountData <- function(target, header){
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 require(DESeq)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 fileNames <- target$files
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 if(header!=0){
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 #rawCounts <- read.table(as.character(paste(rawDir,target$files[1],sep="/")), sep="\t", header=TRUE)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 rawCounts <- read.table(as.character(target$files[1],sep="/"), sep="\t", header=TRUE)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 } else if(header==0){
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 rawCounts <- read.table(as.character(target$files[1],sep="/"), sep="\t")}
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 colnames(rawCounts) <- c("Id", as.character(target$label[1]))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26 for (i in 2:length(fileNames)){
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 if(header!=0){
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 tmp <- read.table(as.character(target$files[i],sep="/"), sep="\t", header=TRUE)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 } else if(header==0){
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 tmp <- read.table(as.character(target$files[i],sep="/"), sep="\t")}
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 colnames(tmp) <- c("Id", as.character(target$label[i]))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 rawCounts <- merge(rawCounts, tmp, by="Id", all=T)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 }
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 rawCounts[is.na(rawCounts)] <- 0
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 return(rawCounts)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 }