blob: e7021ef295543a94288ad68bad09c9249c44c896 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#library(rjson)
library(jsonlite)
dir.name <- '../Data/history/expr/json'
tpm.file <- '../Data/history/expr/assemble/TPM.6604.txt'
take.log <- 'YES'
X <- read.table(tpm.file, header=T, check.names=FALSE, sep="\t")
gene.id <- as.vector(X[,1])
X[,1] <- NULL # remove first column
if (take.log == 'YES') {
X <- log(X+1)
}
if (!dir.exists(dir.name)) {
dir.create(dir.name)
}
for (i in 1:dim(X)[1]) {
y <- toJSON(X[i,], digits=I(3))
file.name = paste(dir.name, paste(gene.id[i], 'json', sep='.'), sep='/')
cat(y, file=file.name)
}
|