From b0f31671e197bf7af60e20dbaa7fa0abd2b3883d Mon Sep 17 00:00:00 2001 From: David Jenkins Date: Fri, 10 Feb 2017 15:01:54 -0500 Subject: [PATCH 1/5] Added version number to the main title of the toolkit. Added warnings if hitting any button before uploading any data --- inst/shiny/server.R | 136 +++++++++++++++++++++++++++----------------- inst/shiny/ui.R | 2 +- 2 files changed, 84 insertions(+), 54 deletions(-) diff --git a/inst/shiny/server.R b/inst/shiny/server.R index 77b23e83c..21e1132f8 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -60,44 +60,59 @@ shinyServer(function(input, output, session) { }) observeEvent(input$filterData, { - vals$counts <- vals$original - vals$counts <- vals$counts[, !(colnames(vals$counts) %in% input$deletesamplelist)] - if (input$removeNoexpress){ - vals$counts <- vals$counts[rowSums(counts(vals$counts)) != 0,] - } - nkeeprows <- ceiling((1-(0.01 * input$LowExpression)) * as.numeric(nrow(vals$counts))) - tokeeprow <- order(rowSums(counts(vals$counts)), decreasing = TRUE)[1:nkeeprows] - tokeepcol <- apply(counts(vals$counts), 2, function(x) sum(as.numeric(x)==0)) >= input$minDetectGenect - vals$counts <- vals$counts[tokeeprow,tokeepcol] + if(is.null(vals$original)){ + alert("Warning: Upload data first!") + } + else{ + vals$counts <- vals$original + vals$counts <- vals$counts[, !(colnames(vals$counts) %in% input$deletesamplelist)] + if (input$removeNoexpress){ + vals$counts <- vals$counts[rowSums(counts(vals$counts)) != 0,] + } + nkeeprows <- ceiling((1-(0.01 * input$LowExpression)) * as.numeric(nrow(vals$counts))) + tokeeprow <- order(rowSums(counts(vals$counts)), decreasing = TRUE)[1:nkeeprows] + tokeepcol <- apply(counts(vals$counts), 2, function(x) sum(as.numeric(x)==0)) >= input$minDetectGenect + vals$counts <- vals$counts[tokeeprow,tokeepcol] + } }) observeEvent(input$resetData, { - vals$counts <- vals$original - updateSelectInput(session, "deletesamplelist", - choices = rownames(pData(vals$counts))) + if(is.null(vals$original)){ + alert("Warning: Upload data first!") + } + else{ + vals$counts <- vals$original + updateSelectInput(session, "deletesamplelist", + choices = rownames(pData(vals$counts))) + } }) clusterDataframe <- observeEvent(input$clusterData, { - if(input$selectCustering == "PCA"){ - pca <- scater::plotPCA(vals$counts, return_SCESet=TRUE) - g <- reducedDimension(pca) - l <- data.frame(g) - w <- input$colorClusters - l$Treatment <- eval(parse(text = paste("pData(vals$counts)$",w,sep=""))) - l$Sample <- rownames(pData(vals$counts)) - g <- ggplot(l, aes(PC1, PC2, label=Sample, color=Treatment))+geom_point() - } else if(input$selectCustering == "tSNE"){ - tsne <- scater::plotTSNE(vals$counts, return_SCESet=TRUE) - g <- reducedDimension(tsne) - l <- data.frame(g) - w <- input$colorClusters - l$Treatment <- eval(parse(text = paste("pData(vals$counts)$",w,sep=""))) - l$Sample <- rownames(pData(vals$counts)) - g <- ggplot(l, aes(X1, X2, label=Sample, color=Treatment))+geom_point() - } - output$clusterPlot <- renderPlotly({ - ggplotly(g) - }) + if(is.null(vals$counts)){ + alert("Warning: Upload data first!") + } + else{ + if(input$selectCustering == "PCA"){ + pca <- scater::plotPCA(vals$counts, return_SCESet=TRUE) + g <- reducedDimension(pca) + l <- data.frame(g) + w <- input$colorClusters + l$Treatment <- eval(parse(text = paste("pData(vals$counts)$",w,sep=""))) + l$Sample <- rownames(pData(vals$counts)) + g <- ggplot(l, aes(PC1, PC2, label=Sample, color=Treatment))+geom_point() + } else if(input$selectCustering == "tSNE"){ + tsne <- scater::plotTSNE(vals$counts, return_SCESet=TRUE) + g <- reducedDimension(tsne) + l <- data.frame(g) + w <- input$colorClusters + l$Treatment <- eval(parse(text = paste("pData(vals$counts)$",w,sep=""))) + l$Sample <- rownames(pData(vals$counts)) + g <- ggplot(l, aes(X1, X2, label=Sample, color=Treatment))+geom_point() + } + output$clusterPlot <- renderPlotly({ + ggplotly(g) + }) + } }) deHeatmapDataframe <- observeEvent(input$makeHeatmap, { @@ -113,14 +128,19 @@ shinyServer(function(input, output, session) { }) diffexDataframe <- observeEvent(input$runDiffex, { - withBusyIndicatorServer("runDiffex", { - #run diffex to get gene list and pvalues - vals$diffexgenelist <- scDiffEx(vals$counts, input$selectDiffex_condition, - input$selectPval, input$selectNGenes, input$applyCutoff, - diffexmethod=input$selectDiffex, - clusterRow=input$clusterRows, - clusterCol=input$clusterColumns) - }) + if(is.null(vals$counts)){ + alert("Warning: Upload data first!") + } + else{ + withBusyIndicatorServer("runDiffex", { + #run diffex to get gene list and pvalues + vals$diffexgenelist <- scDiffEx(vals$counts, input$selectDiffex_condition, + input$selectPval, input$selectNGenes, input$applyCutoff, + diffexmethod=input$selectDiffex, + clusterRow=input$clusterRows, + clusterCol=input$clusterColumns) + }) + } }) output$diffPlot <- renderPlot({ @@ -159,26 +179,36 @@ shinyServer(function(input, output, session) { ) runDownsampler <- observeEvent(input$runSubsample, { - subData <- reactiveValues( - counts=Downsample(counts(vals$counts), newcounts=floor(2^seq.int(from=log2(input$minSim), to=log2(input$maxSim), length.out=10)), iterations=input$iterations) - ) - output$downDone <- renderPlot({ - heatmap(as.matrix(subData$counts[order(apply(subData$counts[,,10,1],1,sum),decreasing=TRUE)[1:20],,10,1])) - }) + if(is.null(vals$counts)){ + alert("Warning: Upload data first!") + } + else{ + subData <- reactiveValues( + counts=Downsample(counts(vals$counts), newcounts=floor(2^seq.int(from=log2(input$minSim), to=log2(input$maxSim), length.out=10)), iterations=input$iterations) + ) + output$downDone <- renderPlot({ + heatmap(as.matrix(subData$counts[order(apply(subData$counts[,,10,1],1,sum),decreasing=TRUE)[1:20],,10,1])) + }) + } }) runDiffPower <- observeEvent(input$runDifferentialPower, { -# if(exists('subData$counts')){ + if(is.null(vals$counts)){ + alert("Warning: Upload data first!") + } + else{ + # if(exists('subData$counts')){ output$powerBoxPlot <- renderPlot({ subData <- Downsample(counts(vals$counts), newcounts=floor(2^seq.int(from=log2(input$minSim), to=log2(input$maxSim), length.out=10)), iterations=input$iterations) diffPower <- differentialPower(datamatrix=counts(vals$counts), downmatrix=subData, conditions=phenoData(vals$counts)[[input$subCovariate]], method=input$selectDiffMethod) boxplot(diffPower)#,names=floor(2^seq.int(from=log2(input$minSim), to=log2(input$maxSim), length.out=10))) }) -# } -# else{ -# output$powerBoxPlot <- renderPlot({ -# plot(c(0,1),c(0,1),main="You need to run the subsampler first.") -# }) -# } + # } + # else{ + # output$powerBoxPlot <- renderPlot({ + # plot(c(0,1),c(0,1),main="You need to run the subsampler first.") + # }) + # } + } }) }) diff --git a/inst/shiny/ui.R b/inst/shiny/ui.R index 8eece22ce..57d4e1e1c 100644 --- a/inst/shiny/ui.R +++ b/inst/shiny/ui.R @@ -21,7 +21,7 @@ if(!is.null(getShinyOption("inputSCEset"))){ # Define UI for application that draws a histogram shinyUI( navbarPage( - "Single Cell Toolkit", + paste("Single Cell Toolkit v.",packageVersion("singleCellTK"), sep=""), #bootstrap theme theme = "bootstrap.min.css", #Upload Tab From bcb17340b4a48c640f3f1f5a007f4758b6689e5e Mon Sep 17 00:00:00 2001 From: David Jenkins Date: Fri, 10 Feb 2017 15:21:34 -0500 Subject: [PATCH 2/5] Added skeleton documentation to some functions. Added explicit :: function calls. Added missing packages to Imports --- DESCRIPTION | 6 ++++-- R/Downsample.Matrix.R | 14 +++++++------- R/misc_functions.R | 16 ++++++++-------- R/scDiffEx.R | 24 ++++++++++++++---------- inst/shiny/ui.R | 2 +- man/Downsample.Rd | 10 +++++----- man/plot_DiffEx.Rd | 11 ++++++----- man/plot_d3DiffEx.Rd | 11 ++++++----- man/scDiffEx.Rd | 4 ++++ 9 files changed, 55 insertions(+), 43 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 71fd76a32..9666bc272 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: singleCellTK Type: Package Title: Interactive Analysis of Single Cell RNA-Seq Data -Version: 0.1.0 +Version: 0.1.2 Author: David Jenkins Maintainer: David Jenkins Description: Run common single cell analysis directly through your browser @@ -22,5 +22,7 @@ Imports: plotly, ggplot2, Rtsne, - shinyjs + shinyjs, + RColorBrewer, + methods RoxygenNote: 5.0.1 diff --git a/R/Downsample.Matrix.R b/R/Downsample.Matrix.R index 96f0ce863..7e58734fe 100644 --- a/R/Downsample.Matrix.R +++ b/R/Downsample.Matrix.R @@ -1,10 +1,10 @@ #' Downsample Data #' -#' @param datamatrix -#' @param newcounts -#' @param byBatch -#' @param batch -#' @param iterations +#' @param datamatrix TODO:document +#' @param newcounts TODO:document +#' @param byBatch TODO:document +#' @param batch TODO:document +#' @param iterations TODO:document #' #' @return Downsampled matrix #' @export Downsample @@ -15,7 +15,7 @@ Downsample <- function(datamatrix, newcounts = c(4, 16, 64, 256, 1024, 4096, 163 for (j in 1:dim(datamatrix)[2]) { probs <- datamatrix[, j] / sum(datamatrix[, j]) for (k in 1:length(newcounts)) { - samps <- rmultinom(iterations, newcounts[k], probs) + samps <- stats::rmultinom(iterations, newcounts[k], probs) for (l in 1:iterations) { outmat[,j,k,l] <- samps[,l] } @@ -27,7 +27,7 @@ Downsample <- function(datamatrix, newcounts = c(4, 16, 64, 256, 1024, 4096, 163 for (j in 1:nlevels(batch)) { probs <- datamatrix[,which(batch == levels(batch)[j])] / sum(datamatrix[,which(batch == levels(batch)[j])]) for (k in 1:length(newcounts)) { - samps <- rmultinom(iterations, newcounts[k], as.vector(probs)) + samps <- stats::rmultinom(iterations, newcounts[k], as.vector(probs)) for (l in 1:iterations) { outmat[,which(batch == levels(batch)[j]),k,l] <- as.matrix(samps[,l], nrow = dim(datamatrix)[1]) } diff --git a/R/misc_functions.R b/R/misc_functions.R index 952ff6f2a..5805f17ef 100644 --- a/R/misc_functions.R +++ b/R/misc_functions.R @@ -13,8 +13,8 @@ summarizeTable <- function(indata){ "Genes with no expression across all samples"), "Value"=c(ncol(indata), nrow(indata), - sum(apply(counts(indata), 2, function(x) sum(as.numeric(x)==0)) < 1700), - sum(rowSums(counts(indata)) == 0)))) + sum(apply(scater::counts(indata), 2, function(x) sum(as.numeric(x)==0)) < 1700), + sum(rowSums(scater::counts(indata)) == 0)))) } #' Create a SCESet object @@ -31,13 +31,13 @@ summarizeTable <- function(indata){ #' @return a SCESet object #' @export createSCESet createSCESet <- function(countfile, annotfile){ - countsin <- read.table(countfile, sep="\t", header=T, row.names=1) - annotin <- read.table(annotfile, sep="\t", header=T, row.names=1) - pd <- new("AnnotatedDataFrame", data = annotin) + countsin <- utils::read.table(countfile, sep="\t", header=T, row.names=1) + annotin <- utils::read.table(annotfile, sep="\t", header=T, row.names=1) + pd <- methods::new("AnnotatedDataFrame", data = annotin) gene_df <- data.frame(Gene = rownames(countsin)) rownames(gene_df) <- gene_df$Gene - fd <- new("AnnotatedDataFrame", data = gene_df) - return(newSCESet(countData = countsin, phenoData = pd, - featureData = fd)) + fd <- methods::new("AnnotatedDataFrame", data = gene_df) + return(scater::newSCESet(countData = countsin, phenoData = pd, + featureData = fd)) } diff --git a/R/scDiffEx.R b/R/scDiffEx.R index 742afdd81..271d307c7 100644 --- a/R/scDiffEx.R +++ b/R/scDiffEx.R @@ -12,6 +12,8 @@ #' up to ntop genes. Required #' @param diffexmethod The method for performing differential expression #' analyis. Available options are DESeq, DESeq2, and limma. Required +#' @param clusterRow Cluster the rows. The default is TRUE +#' @param clusterCol Cluster the columns. The default is TRUE #' #' @return A list of differentially expressed genes. #' @export scDiffEx @@ -58,11 +60,12 @@ scDiffEx <- function(inSCESet, condition, significance=0.05, ntop=500, #' Plot Differential Expression #' -#' @param inSCESet -#' @param condition -#' @param geneList -#' @param clusterRow -#' @param clusterCol +#' @param inSCESet Input data object that contains the data to be plotted. +#' Required +#' @param condition The condition used for plotting the heatmap. Required +#' @param geneList The list of genes to put in the heatmap. Required +#' @param clusterRow Cluster the rows. The default is TRUE +#' @param clusterCol Cluster the columns. The default is TRUE #' #' @return #' @export plot_DiffEx @@ -85,11 +88,12 @@ plot_DiffEx <- function(inSCESet, condition, geneList, clusterRow=TRUE, #' Plot Interactive Differential Expression #' -#' @param inSCESet -#' @param condition -#' @param geneList -#' @param clusterRow -#' @param clusterCol +#' @param inSCESet Input data object that contains the data to be plotted. +#' Required +#' @param condition The condition used for plotting the heatmap. Required +#' @param geneList The list of genes to put in the heatmap. Required +#' @param clusterRow Cluster the rows. The default is TRUE +#' @param clusterCol Cluster the columns. The default is TRUE #' #' @return #' @export plot_d3DiffEx diff --git a/inst/shiny/ui.R b/inst/shiny/ui.R index 57d4e1e1c..3b5af9a03 100644 --- a/inst/shiny/ui.R +++ b/inst/shiny/ui.R @@ -21,7 +21,7 @@ if(!is.null(getShinyOption("inputSCEset"))){ # Define UI for application that draws a histogram shinyUI( navbarPage( - paste("Single Cell Toolkit v.",packageVersion("singleCellTK"), sep=""), + paste("Single Cell Toolkit v",packageVersion("singleCellTK"), sep=""), #bootstrap theme theme = "bootstrap.min.css", #Upload Tab diff --git a/man/Downsample.Rd b/man/Downsample.Rd index 3adf344da..a3bf2a145 100644 --- a/man/Downsample.Rd +++ b/man/Downsample.Rd @@ -8,15 +8,15 @@ Downsample(datamatrix, newcounts = c(4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144), byBatch = FALSE, batch = NULL, iterations = 10) } \arguments{ -\item{datamatrix}{} +\item{datamatrix}{TODO:document} -\item{newcounts}{} +\item{newcounts}{TODO:document} -\item{byBatch}{} +\item{byBatch}{TODO:document} -\item{batch}{} +\item{batch}{TODO:document} -\item{iterations}{} +\item{iterations}{TODO:document} } \value{ Downsampled matrix diff --git a/man/plot_DiffEx.Rd b/man/plot_DiffEx.Rd index 40be4564f..6d5aa2552 100644 --- a/man/plot_DiffEx.Rd +++ b/man/plot_DiffEx.Rd @@ -8,15 +8,16 @@ plot_DiffEx(inSCESet, condition, geneList, clusterRow = TRUE, clusterCol = TRUE) } \arguments{ -\item{inSCESet}{} +\item{inSCESet}{Input data object that contains the data to be plotted. +Required} -\item{condition}{} +\item{condition}{The condition used for plotting the heatmap. Required} -\item{geneList}{} +\item{geneList}{The list of genes to put in the heatmap. Required} -\item{clusterRow}{} +\item{clusterRow}{Cluster the rows. The default is TRUE} -\item{clusterCol}{} +\item{clusterCol}{Cluster the columns. The default is TRUE} } \description{ Plot Differential Expression diff --git a/man/plot_d3DiffEx.Rd b/man/plot_d3DiffEx.Rd index bac04cd9f..e9d2af40d 100644 --- a/man/plot_d3DiffEx.Rd +++ b/man/plot_d3DiffEx.Rd @@ -8,15 +8,16 @@ plot_d3DiffEx(inSCESet, condition, geneList, clusterRow = TRUE, clusterCol = TRUE) } \arguments{ -\item{inSCESet}{} +\item{inSCESet}{Input data object that contains the data to be plotted. +Required} -\item{condition}{} +\item{condition}{The condition used for plotting the heatmap. Required} -\item{geneList}{} +\item{geneList}{The list of genes to put in the heatmap. Required} -\item{clusterRow}{} +\item{clusterRow}{Cluster the rows. The default is TRUE} -\item{clusterCol}{} +\item{clusterCol}{Cluster the columns. The default is TRUE} } \description{ Plot Interactive Differential Expression diff --git a/man/scDiffEx.Rd b/man/scDiffEx.Rd index 92c35d919..0085dab66 100644 --- a/man/scDiffEx.Rd +++ b/man/scDiffEx.Rd @@ -25,6 +25,10 @@ up to ntop genes. Required} \item{diffexmethod}{The method for performing differential expression analyis. Available options are DESeq, DESeq2, and limma. Required} + +\item{clusterRow}{Cluster the rows. The default is TRUE} + +\item{clusterCol}{Cluster the columns. The default is TRUE} } \value{ A list of differentially expressed genes. From e7ceba60dec3c8d2fbf721425b7d81b21ee6d816 Mon Sep 17 00:00:00 2001 From: David Jenkins Date: Sun, 12 Feb 2017 18:15:19 -0500 Subject: [PATCH 3/5] Squash some notes about imports --- DESCRIPTION | 3 ++- R/scDiffEx.R | 29 +++++++++++++++-------------- man/plot_DiffEx.Rd | 4 ++++ man/plot_d3DiffEx.Rd | 3 +++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9666bc272..e9c18ab40 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,5 +24,6 @@ Imports: Rtsne, shinyjs, RColorBrewer, - methods + methods, + Biobase RoxygenNote: 5.0.1 diff --git a/R/scDiffEx.R b/R/scDiffEx.R index 271d307c7..4ead750fd 100644 --- a/R/scDiffEx.R +++ b/R/scDiffEx.R @@ -26,7 +26,7 @@ scDiffEx <- function(inSCESet, condition, significance=0.05, ntop=500, usesig=TRUE, diffexmethod, clusterRow=TRUE, clusterCol=TRUE){ - in.condition <- droplevels(as.factor(pData(inSCESet)[,condition])) + in.condition <- droplevels(as.factor(scater::pData(inSCESet)[,condition])) if (length(levels(in.condition)) != 2) stop("only two labels supported, ", condition, " has ", length(levels(in.condition)), " labels") @@ -67,17 +67,18 @@ scDiffEx <- function(inSCESet, condition, significance=0.05, ntop=500, #' @param clusterRow Cluster the rows. The default is TRUE #' @param clusterCol Cluster the columns. The default is TRUE #' -#' @return +#' @return ComplexHeatmap object for the provided geneList annotated with the +#' condition. #' @export plot_DiffEx #' plot_DiffEx <- function(inSCESet, condition, geneList, clusterRow=TRUE, clusterCol=TRUE){ - diffex.annotation <- data.frame(pData(inSCESet)[,condition]) + diffex.annotation <- data.frame(scater::pData(inSCESet)[,condition]) colnames(diffex.annotation) <- condition topha <- ComplexHeatmap::HeatmapAnnotation(df = diffex.annotation, height = unit(0.333, "cm")) - heatmap <- ComplexHeatmap::Heatmap(t(scale(t(exprs(inSCESet)[geneList,]))), + heatmap <- ComplexHeatmap::Heatmap(t(scale(t(Biobase::exprs(inSCESet)[geneList,]))), name="Expression", column_title = "Differential Expression", cluster_rows = clusterRow, @@ -95,17 +96,17 @@ plot_DiffEx <- function(inSCESet, condition, geneList, clusterRow=TRUE, #' @param clusterRow Cluster the rows. The default is TRUE #' @param clusterCol Cluster the columns. The default is TRUE #' -#' @return +#' @return A d3heatmap object is plotted #' @export plot_d3DiffEx #' plot_d3DiffEx <- function(inSCESet, condition, geneList, clusterRow=TRUE, clusterCol=TRUE){ - diffex.annotation <- data.frame(pData(inSCESet)[,condition]) + diffex.annotation <- data.frame(scater::pData(inSCESet)[,condition]) colnames(diffex.annotation) <- condition topha <- ComplexHeatmap::HeatmapAnnotation(df = diffex.annotation, height = unit(0.333, "cm")) - d3heatmap::d3heatmap(t(scale(t(exprs(inSCESet)[geneList,]))), + d3heatmap::d3heatmap(t(scale(t(Biobase::exprs(inSCESet)[geneList,]))), Rowv=clusterRow, Colv=clusterCol, ColSideColors=RColorBrewer::brewer.pal(8, "Set1")[as.numeric(factor(diffex.annotation[,1]))]) @@ -124,8 +125,8 @@ plot_d3DiffEx <- function(inSCESet, condition, geneList, clusterRow=TRUE, #' @export scDiffEx_deseq2 #' scDiffEx_deseq2 <- function(inSCESet, condition){ - cnts <- counts(inSCESet) - annot_data <- pData(inSCESet)[,condition,drop=F] + cnts <- scater::counts(inSCESet) + annot_data <- scater::pData(inSCESet)[,condition,drop=F] colnames(annot_data) <- "condition" dds <- DESeq2::DESeqDataSetFromMatrix(countData = cnts, colData = annot_data, @@ -147,7 +148,7 @@ scDiffEx_deseq2 <- function(inSCESet, condition){ #' @export scDiffEx_deseq #' scDiffEx_deseq <- function(inSCESet, condition){ - countData <- DESeq::newCountDataSet(counts(inSCESet), condition) + countData <- DESeq::newCountDataSet(scater::counts(inSCESet), condition) countData <- DESeq::estimateSizeFactors(countData) countData <- DESeq::estimateDispersions(countData, method="pooled", fitType="local") @@ -173,10 +174,10 @@ scDiffEx_deseq <- function(inSCESet, condition){ #' @export scDiffEx_limma #' scDiffEx_limma <- function(inSCESet, condition){ - design <- model.matrix(~factor(pData(inSCESet)[,condition])) - fit <- lmFit(exprs(inSCESet), design) - ebayes <- eBayes(fit) - topGenes <- topTable(ebayes, coef=2, adjust="fdr", number=nrow(inSCESet)) + design <- stats::model.matrix(~factor(scater::pData(inSCESet)[,condition])) + fit <- limma::lmFit(Biobase::exprs(inSCESet), design) + ebayes <- limma::eBayes(fit) + topGenes <- limma::topTable(ebayes, coef=2, adjust="fdr", number=nrow(inSCESet)) colnames(topGenes)[5] <- "padj" return(topGenes) } diff --git a/man/plot_DiffEx.Rd b/man/plot_DiffEx.Rd index 6d5aa2552..72dbf4853 100644 --- a/man/plot_DiffEx.Rd +++ b/man/plot_DiffEx.Rd @@ -19,6 +19,10 @@ Required} \item{clusterCol}{Cluster the columns. The default is TRUE} } +\value{ +ComplexHeatmap object for the provided geneList annotated with the +condition. +} \description{ Plot Differential Expression } diff --git a/man/plot_d3DiffEx.Rd b/man/plot_d3DiffEx.Rd index e9d2af40d..858d5d15a 100644 --- a/man/plot_d3DiffEx.Rd +++ b/man/plot_d3DiffEx.Rd @@ -19,6 +19,9 @@ Required} \item{clusterCol}{Cluster the columns. The default is TRUE} } +\value{ +A d3heatmap object is plotted +} \description{ Plot Interactive Differential Expression } From 69e57759c384d933a47580d5c0c0a1f729de2982 Mon Sep 17 00:00:00 2001 From: David Jenkins Date: Sun, 12 Feb 2017 22:56:56 -0500 Subject: [PATCH 4/5] Support for only uploading count matrix, or uploading pheno or feature data. The createsceset object can also work on data frames now. --- R/misc_functions.R | 42 ++++++++++++++++++++++++++++++++++-------- inst/shiny/server.R | 5 +++-- inst/shiny/ui.R | 13 +++++++++++-- man/createSCESet.Rd | 13 +++++++++++-- 4 files changed, 59 insertions(+), 14 deletions(-) diff --git a/R/misc_functions.R b/R/misc_functions.R index 5805f17ef..b1ba5a837 100644 --- a/R/misc_functions.R +++ b/R/misc_functions.R @@ -23,21 +23,47 @@ summarizeTable <- function(indata){ #' object. #' #' @param countfile The path to a text file that contains a header row of sample -#' names, and rows of raw counts per gene for those samples +#' names, and rows of raw counts per gene for those samples. #' @param annotfile The path to a text file that contains columns of annotation #' information for each sample in the countfile. This file should have the same #' number of rows as there are columns in the countfile. +#' @param featurefile The path to a text file that contains columns of +#' annotation information for each gene in the count matrix. This file should +#' have the same genes in the same order as countfile. This is optional. +#' @param inputdataframes If TRUE, countfile and annotfile are read as data +#' frames instead of file paths. The default is FALSE. +#' instead of #' #' @return a SCESet object #' @export createSCESet -createSCESet <- function(countfile, annotfile){ - countsin <- utils::read.table(countfile, sep="\t", header=T, row.names=1) - annotin <- utils::read.table(annotfile, sep="\t", header=T, row.names=1) +createSCESet <- function(countfile=NULL, annotfile=NULL, featurefile=NULL, + inputdataframes=FALSE){ + if(is.null(countfile)){ + stop("You must supply a count file.") + } + if(inputdataframes){ + countsin <- countfile + annotin <- annotfile + featurein <- featurefile + } else{ + countsin <- utils::read.table(countfile, sep="\t", header=T, row.names=1) + if(!is.null(annotfile)){ + annotin <- utils::read.table(annotfile, sep="\t", header=T, row.names=1) + } + if(!is.null(featurefile)){ + featurein <- utils::read.table(featurefile, sep="\t", header=T, row.names=1) + } + } + if(is.null(annotfile)){ + annotin <- data.frame(row.names=colnames(countsin)) + annotin$Sample <- rownames(annotin) + } + if(is.null(featurefile)){ + featurein <- data.frame(Gene = rownames(countsin)) + rownames(featurein) <- featurein$Gene + } pd <- methods::new("AnnotatedDataFrame", data = annotin) - - gene_df <- data.frame(Gene = rownames(countsin)) - rownames(gene_df) <- gene_df$Gene - fd <- methods::new("AnnotatedDataFrame", data = gene_df) + fd <- methods::new("AnnotatedDataFrame", data = featurein) return(scater::newSCESet(countData = countsin, phenoData = pd, featureData = fd)) } diff --git a/inst/shiny/server.R b/inst/shiny/server.R index 21e1132f8..130b90775 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -23,8 +23,9 @@ shinyServer(function(input, output, session) { observeEvent(input$uploadData, { withBusyIndicatorServer("uploadData", { - vals$counts <- createSCESet(input$countsfile$datapath, - input$annotfile$datapath) + vals$counts <- createSCESet(countfile = input$countsfile$datapath, + annotfile = input$annotfile$datapath, + featurefile = input$featurefile$datapath) updateSelectInput(session, "colorClusters", choices = colnames(pData(vals$counts))) updateSelectInput(session, "deletesamplelist", diff --git a/inst/shiny/ui.R b/inst/shiny/ui.R index 3b5af9a03..e546e6b7d 100644 --- a/inst/shiny/ui.R +++ b/inst/shiny/ui.R @@ -39,7 +39,6 @@ shinyUI( ), tags$div( class="container", - #http://shiny.rstudio.com/articles/html-tags.html tags$div(id="uploadAlert", alertText), fileInput('countsfile', 'Upload a matrix of counts here', accept = c( @@ -51,7 +50,17 @@ shinyUI( '.tsv' ) ), - fileInput('annotfile', 'Upload a matrix of annotations here', + fileInput('annotfile', 'Optional: Upload a matrix of annotations here', + accept = c( + 'text/csv', + 'text/comma-separated-values', + 'text/tab-separated-values', + 'text/plain', + '.csv', + '.tsv' + ) + ), + fileInput('featurefile', 'Optional: Upload a matrix of feature annotations here', accept = c( 'text/csv', 'text/comma-separated-values', diff --git a/man/createSCESet.Rd b/man/createSCESet.Rd index ab24ec971..0603c6075 100644 --- a/man/createSCESet.Rd +++ b/man/createSCESet.Rd @@ -4,15 +4,24 @@ \alias{createSCESet} \title{Create a SCESet object} \usage{ -createSCESet(countfile, annotfile) +createSCESet(countfile = NULL, annotfile = NULL, featurefile = NULL, + inputdataframes = FALSE) } \arguments{ \item{countfile}{The path to a text file that contains a header row of sample -names, and rows of raw counts per gene for those samples} +names, and rows of raw counts per gene for those samples.} \item{annotfile}{The path to a text file that contains columns of annotation information for each sample in the countfile. This file should have the same number of rows as there are columns in the countfile.} + +\item{featurefile}{The path to a text file that contains columns of +annotation information for each gene in the count matrix. This file should +have the same genes in the same order as countfile. This is optional.} + +\item{inputdataframes}{If TRUE, countfile and annotfile are read as data +frames instead of file paths. The default is FALSE. +instead of} } \value{ a SCESet object From 0aaeebe3b15a9f7f101eebe42c28fd82b2201433 Mon Sep 17 00:00:00 2001 From: David Jenkins Date: Sun, 12 Feb 2017 23:03:58 -0500 Subject: [PATCH 5/5] added intial travis integration --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..3a8d0542c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: r + +sudo: required + +warnings_are_errors: true + +bioc_required: true