## ------------------------------------------------------------------------ source("https://raw.githubusercontent.com/hyounesy/visr-apps/master/visrutils.R") ## ----eval=FALSE---------------------------------------------------------- # visr.app.start(name, info = "", debugdata = NULL) # visr.category(label, info = "") # visr.app.end(printjson = FALSE, writefile = FALSE, filename = NULL) # visr.param (name, label = NULL, info = NULL, # default = NULL, min = NULL, max = NULL, # items = NULL, item.labels = NULL, # type = c("string", "character", "int", "integer", # "double", "boolean", "logical", "multi-string", # "column", "multi-column", # "column-numerical", "multi-column-numerical", # "color", "multi-color", "filename", # "output-column", "output-multi-column", "output-table"), # filename.mode = c("load", "save", "dir"), debugvalue = NULL) ## ------------------------------------------------------------------------ boxplot(mtcars[["mpg"]]~mtcars[["cyl"]], xlab = "cyl", ylab = "mpg") ## ------------------------------------------------------------------------ visr.app.start("Simple Boxplot", debugdata=mtcars) ## ------------------------------------------------------------------------ visr.param("y", type="column-numerical", debugvalue="mpg") visr.param("group", type="column", debugvalue="cyl") ## ------------------------------------------------------------------------ visr.app.end(printjson=TRUE, writefile = FALSE, filename = NULL) ## ----eval=FALSE---------------------------------------------------------- # visr.applyParameters() # # boxplot(visr.input[[visr.param.y]]~visr.input[[visr.param.group]], # xlab = visr.param.group, ylab = visr.param.y) ## ----eval=FALSE---------------------------------------------------------- # source("visrutils.R") # # parameters # visr.app.start("Simple Boxplot", debugdata=mtcars) # visr.param("y", type="column-numerical", debugvalue="mpg") # visr.param("group", type="column", debugvalue="cyl") # visr.app.end(printjson=TRUE, writefile = FALSE, filename = NULL) # visr.applyParameters() # # # code # boxplot(visr.input[[visr.param.y]]~visr.input[[visr.param.group]], # xlab = visr.param.group, # ylab = visr.param.y) ## ------------------------------------------------------------------------ input <- iris columns <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width") cluster_data<-subset(input, select = columns) clusterid <- kmeans(cluster_data, centers = 3)$cluster plot(cluster_data, col = as.integer(clusterid)) ## ------------------------------------------------------------------------ # start parameter definition visr.app.start("Simple Kmeans", debugdata = iris) visr.category("clustering parameters") visr.param("columns", type = "multi-column-numerical", debugvalue = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")) visr.param("k", default = 3) visr.param("algorithm", items = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen")) visr.category("output") visr.param("plot.title", default = "kmeans results") visr.param("output.clusterid", type = "output-column") visr.app.end(printjson=TRUE) ## ----eval=FALSE---------------------------------------------------------- # visr.applyParameters() # # cluster_data<-subset(visr.input, select = visr.param.columns) # visr.param.output.clusterid <- kmeans(cluster_data, # centers = visr.param.k, # algorithm = visr.param.algorithm)$cluster # plot(cluster_data, main = visr.param.plot.title, # col = as.integer(visr.param.output.clusterid)) ## ----eval=FALSE---------------------------------------------------------- # source("visrutils.R") # # # parameters # visr.app.start("Simple Kmeans", debugdata = iris) # visr.category("clustering parameters") # visr.param("columns", type = "multi-column-numerical", # debugvalue = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")) # visr.param("k", default = 3) # visr.param("algorithm", items = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen")) # visr.category("output") # visr.param("plot.title", default = "kmeans results") # visr.param("output.clusterid", type = "output-column") # visr.app.end(printjson=TRUE) # visr.applyParameters() # # # kmeans code # cluster_data<-subset(visr.input, select = visr.param.columns) # visr.param.output.clusterid <- kmeans(cluster_data, # centers = visr.param.k, # algorithm = visr.param.algorithm)$cluster # plot(cluster_data, main = visr.param.plot.title, # col = as.integer(visr.param.output.clusterid)) ## ------------------------------------------------------------------------ library("edgeR", quietly=T) countdata = read.table( "https://raw.githubusercontent.com/hyounesy/bioc2016.visrseq/master/data/counts.txt", header=T, row.names = 1) x <- countdata head(x) group1 <- c("CT.PA.1", "CT.PA.2") group2 <- c("KD.PA.3", "KD.PA.4") groups <- factor(c(rep(1, length(group1)), rep(2, length(group2)))) # c(1, 1, 2, 2) # create edgeR's container for RNA-seq count data y <- DGEList(counts=x[, c(group1, group2)], group = groups) # estimate normalization factors y <- calcNormFactors(y) # estimate tagwise dispersion (simple design) y <- estimateCommonDisp(y) y <- estimateTagwiseDisp(y) # test for differential expression using classic edgeR approach et <- exactTest(y) # total number of DE genes in each direction is.de <- decideTestsDGE(et, adjust.method = "BH", p.value = 0.05, lfc = 0) # The log-fold change for each gene is plotted against the average abundance plotSmear(y, de.tags=rownames(y)[is.de!=0]) ## ------------------------------------------------------------------------ ## edgeR parameters visr.app.start("edgeR", debugdata = countdata) visr.param("group1", type = "multi-column-numerical", debugvalue = c("CT.PA.1", "CT.PA.2")) visr.param("group2", type = "multi-column-numerical", debugvalue = c("KD.PA.3", "KD.PA.4")) visr.param("output.de", label = "DE clusters", type = "output-column") visr.app.end(printjson=TRUE, writefile=T) visr.applyParameters() ## ----eval=FALSE---------------------------------------------------------- # ## edgeR code # library("edgeR") # x <- visr.input # groups <- factor(c(rep(1, length(visr.param.group1)), # e.g. 1,1 # rep(2, length(visr.param.group2)))) # e.g. 2,2 # # create edgeR's container for RNA-seq count data # y <- DGEList(counts=x[, c(visr.param.group1, visr.param.group2)], group = groups) # # estimate normalization factors # y <- calcNormFactors(y) # # estimate tagwise dispersion (simple design) # y <- estimateCommonDisp(y) # y <- estimateTagwiseDisp(y) # # test for differential expression using classic edgeR approach # et <- exactTest(y) # # total number of DE genes in each direction # is.de <- decideTestsDGE(et, adjust.method = "BH", p.value = 0.05, lfc = 0) # # export the results to VisRseq # visr.param.output.de <- as.factor(is.de) # # The log-fold change for each gene is plotted against the average abundance # plotSmear(y, de.tags = rownames(y)[is.de != 0]) ## ----eval=FALSE---------------------------------------------------------- # source("visrutils.R") # # ## edgeR parameters # visr.app.start("edgeR", debugdata = countdata) # visr.param("group1", type = "multi-column-numerical", debugvalue = c("CT.PA.1", "CT.PA.2")) # visr.param("group2", type = "multi-column-numerical", debugvalue = c("KD.PA.3", "KD.PA.4")) # visr.param("output.de", label = "DE clusters", type = "output-column") # visr.app.end(printjson=TRUE, writefile=T) # visr.applyParameters() # # # ## edgeR code # library("edgeR") # x <- visr.input # groups <- factor(c(rep(1, length(visr.param.group1)), # e.g. 1,1 # rep(2, length(visr.param.group2)))) # e.g. 2,2 # # create edgeR's container for RNA-seq count data # y <- DGEList(counts=x[, c(visr.param.group1, visr.param.group2)], group = groups) # # estimate normalization factors # y <- calcNormFactors(y) # # estimate tagwise dispersion (simple design) # y <- estimateCommonDisp(y) # y <- estimateTagwiseDisp(y) # # test for differential expression using classic edgeR approach # et <- exactTest(y) # # total number of DE genes in each direction # is.de <- decideTestsDGE(et, adjust.method = "BH", p.value = 0.05, lfc = 0) # # export the results to VisRseq # visr.param.output.de <- as.factor(is.de) # # The log-fold change for each gene is plotted against the average abundance # plotSmear(y, de.tags = rownames(y)[is.de != 0])