| 1 | #Merge all gene counts from run 1
|
|---|
| 2 | #Date 06-Nov-2013
|
|---|
| 3 |
|
|---|
| 4 | setwd("/virdir/Backup/run_1_gene_counts")
|
|---|
| 5 | datadir <- "/virdir/Backup/run_1_gene_counts/run_1_gene_counts"
|
|---|
| 6 | filelist <- dir(datadir)
|
|---|
| 7 |
|
|---|
| 8 | length(filelist) #2330
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 | temp <- read.table(paste(datadir,filelist[1], sep="/"), as.is=T, header=T, row.names=1)
|
|---|
| 12 |
|
|---|
| 13 | for(i in 2:length(filelist))
|
|---|
| 14 | {
|
|---|
| 15 | temp2 <-read.table(paste(datadir,filelist[i], sep="/"), as.is=T, header=T, row.names=1)
|
|---|
| 16 | temp <- cbind(temp, temp2[,1])
|
|---|
| 17 | print(i)
|
|---|
| 18 | }
|
|---|
| 19 | dim(temp)
|
|---|
| 20 | #add colnames
|
|---|
| 21 | sample_names <- c()
|
|---|
| 22 | for (i in 1:length(filelist))
|
|---|
| 23 | {
|
|---|
| 24 | sample_names[i] <- strsplit(filelist[i], "\\.")[[1]][1]
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | colnames(temp) <- sample_names
|
|---|
| 28 |
|
|---|
| 29 | write.table(temp, file="combined_gene_count_run_1.txt", sep="\t", quote=F, row.names=T)
|
|---|
| 30 |
|
|---|