-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_MergeTables
30 lines (24 loc) · 884 Bytes
/
01_MergeTables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
setwd("~/AlgaeProject/Nannochloropsis/outputs/")
# extract the files containing "renamed"
DIR=dir(path = ".",pattern = "renamed", full.names = T)
# generate starting point for the collector table
abundPath=dir(DIR[1] ,"tsv", full.names = T)
temp=read.table(abundPath, header = T)
collector=temp[,c(1,4)]
head(collector)
# generate collector table
for(i in DIR[-1] ){
print(i)
abundPath=dir(i,"tsv", full.names = T)
temp=read.table(abundPath, header =T )
print(all(temp[,1] == collector[,1] ))
collector=cbind(collector,temp[,4] )
}
head(collector)
#rename to sample names
colnames(collector) =c("feat",basename(DIR))
head(collector)
# round off reads to integers
collector[,2:ncol(collector)] <- round(collector[,2:ncol(collector)], digits=0)
head(collector)
write.csv(collector,"~/AlgaeProject/Nannochloropsis/Scripts/MergeTables_collector_cds.csv", row.names = F)