-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwriteEset.R
More file actions
26 lines (23 loc) · 764 Bytes
/
writeEset.R
File metadata and controls
26 lines (23 loc) · 764 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
writeEset <- function(eset, file, creator) {
td <- function(tab) {
ic <- which(sapply(tab, is.list))
if (length(ic) > 0) {
for (ii in ic) {
tab[, ii] <- sapply(tab[, ii], paste, collapse = ";")
}
}
tab
}
expr <- exprs(eset)
pd <- pData(eset)
fd <- fData(eset)
wb <- createWorkbook(creator = creator)
addWorksheet(wb, sheetName = "Phenotype info")
addWorksheet(wb, sheetName = "Feature info")
addWorksheet(wb, sheetName = "Expression")
id <- paste0("ID", 1:nrow(expr))
writeData(wb, sheet = "Expression", data.frame(ID = id, expr))
writeData(wb, sheet = "Feature info", td(cbind(ID = id, fd)))
writeData(wb, sheet = "Phenotype info", td(pd))
saveWorkbook(wb, file = file, overwrite = TRUE)
}