-
Notifications
You must be signed in to change notification settings - Fork 0
/
process2JSON.R
63 lines (53 loc) · 2.11 KB
/
process2JSON.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
library(RJSONIO)
generateMAPLOTjson_f <- function(ones,twos,inputCONFIG,dat.sel,dat.top) {
MAINLABEL <- paste(unique(gsub("1$|2$|3$", "", c(ones, twos))), collapse = " ")
dir <- gsub(" ", "_", MAINLABEL)
dir.create(dir)
metaList <- list(type='maplot', config=inputCONFIG)
blackX <- dat.sel$A[dat.sel$color == "black"]
blackY <- dat.sel$M[dat.sel$color == "black"]
blackSymbol <- dat.sel$symbol[dat.sel$color == "black"]
blackPtsList <- list(x=blackX, y=blackY, symbol=blackSymbol)
otherX <- dat.sel$A[dat.sel$color != "black"]
otherY <- dat.sel$M[dat.sel$color != "black"]
otherSymbol <- dat.sel$symbol[dat.sel$color != "black"]
otherColor <- dat.sel$color[dat.sel$color != "black"]
otherPtsList <- list(x=otherX, y=otherY, color=otherColor, symbol=otherSymbol)
topX <- dat.top$A
topY <- dat.top$M
topSymbol <- dat.top$symbol
topPtsList <-list(x=topX, y=topY, symbol=topSymbol)
dataList <- list(blackPts=blackPtsList)
if( !is.null(otherX) && length(otherX) != 0) {
dataList$otherPts <- otherPtsList
}
if(!is.null(topX) && length(topX)!=0) {
dataList$topPts <- topPtsList
}
jsonList <- list(meta=metaList, data=dataList)
maplotfn <- paste0(dir, "/", "MAplotData.json")
write(toJSON(jsonList), maplotfn, append=FALSE)
}
generateHEATMAPjson_f <- function(ones,twos,inputCONFIG,dat.top,dat.heat) {
MAINLABEL <- paste(unique(gsub("1$|2$|3$", "", c(ones, twos))), collapse = " ")
dir <- gsub(" ", "_", MAINLABEL)
dir.create(dir)
SYMBOL <- dat.top$symbol
PROBESET <- rownames(dat.heat)
metaList <- list(type='heatmap', config=inputCONFIG)
heatmapList <- list(symbol=SYMBOL, probeset=PROBESET)
sampleList.names <- colnames(dat.heat)
sampleList <- vector("list", length(sampleList.names))
N <- ncol(dat.heat)
for(i in as.numeric(1:N)) {
c <- sampleList.names[[i]]
cc<-dat.heat[,c]
ccc <- as.vector(cc)
l <- list( name=c, data=ccc)
sampleList[[i]] <- l
}
heatmapList$samples <- sampleList
jsonList=list(meta=metaList, data=heatmapList)
heatmapfn <- paste0(dir, "/", "HeatmapData.json")
write(toJSON(jsonList),heatmapfn, append=FALSE)
}