-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathannotateControls.R
31 lines (24 loc) · 995 Bytes
/
annotateControls.R
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
##############################################################################
#
# Annotate control probes based on the Illumina file. Control probes can
# fall in multiple categories
#
##############################################################################
cl <- commandArgs(trailingOnly = TRUE)
library(data.table)
expression_file <- cl[1]
control_annotation_file <- cl[2]
outfile <- cl[3]
expression <- read.csv(expression_file, row.names = 1, check.names = FALSE)
control_annotation <- read.delim(control_annotation_file, stringsAsFactors = FALSE)
control_annotation <- rbindlist(lapply(split(control_annotation, control_annotation$Array_Address_Id), function(x){
if (nrow(x) > 1){
z <- x[1,,drop=F]
z[1,] <- apply(x,2,function(y) paste(unique(y), collapse = ','))
z
}else{
x
}
}))
control_annotation <- control_annotation[match(rownames(expression), control_annotation$Array_Address_Id),]
write.csv(control_annotation, file = outfile, row.names = FALSE)