-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBEDcounter_collapsed.R
More file actions
39 lines (30 loc) · 902 Bytes
/
BEDcounter_collapsed.R
File metadata and controls
39 lines (30 loc) · 902 Bytes
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
31
32
33
34
35
36
37
38
39
#Read Copy Counter and Aggregator for the Collapsed UMI-Tagged Reads in BED files
#Taihsien Ouyang
#2015 Dec. 10
fileNames=dir()
## Create the annotation vector ##
annot=NULL
for(i in 1:length(fileNames)){
cat("Scanning file", i,"...\n" )
bed<-read.table(fileNames[i])
annot<-unique(c( annot, as.character(bed$V1) ))
}
## Read the UMI-collapsed BED files ##
geList<-list()
for(j in 1:length(fileNames)){ #
cat("Processing",fileNames[j],"\n")
bed<-read.table(fileNames[j])
geList[[j]]<-table( as.character(bed$V1) )
}
## Aggregate the profiles ##
ge<-matrix(0,length(annot),length(fileNames))
rownames(ge)<-annot
colnames(ge)<-fileNames
for(i in 1:length(geList)){
cat(i,"\n")
geneList<-intersect(rownames(ge), names(geList[[i]]))
ge[geneList,i]<-geList[[i]][geneList]
}
cat("Writing outputs\n")
save(ge, file="count_matrix.rda")
write.table(ge, file="count_matrix.csv",sep=",")