diff --git a/CHANGELOG.md b/CHANGELOG.md index 72226cd..a3d3fe4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,15 @@ Changelog +version 1.4.3 +--------------------------- ++ Add prior count to CPM calculation ++ Add FDR sort again to markdown files ++ Fix filenames when downloading ++ Add check reload to barcodeplot to update add genes list ++ Change gProfiler correction to gSCS version 1.4.2 --------------------------- + Remove ordering based on FDR in deTab -+ Add Changelog file \ No newline at end of file ++ Add Changelog file diff --git a/DESCRIPTION b/DESCRIPTION index fb4ffb6..34249d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dgeAnalysis Type: Package Title: dgeAnalysis -Version: 1.4.2 +Version: 1.4.3 Author@R: person("Tom", "Kuipers", email = "t.b.kuipers@outlook.com", role = c("aut", "cre")) Description: diff --git a/MANUAL.pdf b/MANUAL.pdf index e522f44..dcdd746 100644 Binary files a/MANUAL.pdf and b/MANUAL.pdf differ diff --git a/README.md b/README.md index d4d44bf..d71c5eb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # dgeAnalysis -This R package contains the R-Shiny application v1.4.2 developed to perform differential gene expression analysis. +This R package contains the R-Shiny application v1.4.3 developed to perform differential gene expression analysis. * dgeAnalysis manual: https://github.com/LUMC/dgeAnalysis/blob/master/MANUAL.pdf ## Installing diff --git a/inst/src/markdown/analysisDESeq2.Rmd b/inst/src/markdown/analysisDESeq2.Rmd index 3531de1..386ea1e 100644 --- a/inst/src/markdown/analysisDESeq2.Rmd +++ b/inst/src/markdown/analysisDESeq2.Rmd @@ -114,7 +114,7 @@ dge <- DGEList(counts = assay(se), dge <- dge[rowSums(abs(dge$counts)) > 1,] tempDge <- dge -tempDge$counts <- cpm(dge, log = TRUE) +tempDge$counts <- cpm(dge, log = TRUE, prior.count = 1) countDistributionLinePlot(tempDge) dge <- DGEList(counts = assay(se), samples = colData(se)) @@ -137,7 +137,7 @@ analysis <- DESeqDataSet(se, design = design) analysis <- analysis[rowSums(abs(assay(analysis))) > 1,] # FILTER IF NESSECARY -counts <- cpm(counts(analysis), log = TRUE) +counts <- cpm(counts(analysis), log = TRUE, prior.count = 1) selectedFeatures <- rownames(analysis)[apply(counts, 1, function(v) sum(v >= cpm_value)) >= 1 / 4 * ncol(counts)] analysis <- analysis[selectedFeatures, ] @@ -161,10 +161,8 @@ Extract the normalized data from the analysis results. # GET NORMALIZED COUNTS getSize <- estimateSizeFactors(analysis) -normCounts <- cpm(data.frame(counts(getSize, normalized = TRUE))) -normDge <- DGEList(counts = normCounts, samples = dge$samples) -normDge$counts <- log2(normDge$counts) -normDge$counts[is.infinite(normDge$counts)] <- 0 +normDge <- DGEList(counts = data.frame(counts(getSize, normalized = TRUE)), samples = dge$samples) +normDge$counts <- cpm(normDge, log = TRUE, prior.count = 1) countDistributionLinePlot(normDge) samplePca2dPlot(normDge, design_base, "PC1", "PC2") @@ -217,10 +215,6 @@ if (!is.null(data_annotation)) { deTab$Row.names <- NULL } -# MAKE BOTH TABLES EQUAL -deTab <- deTab[intersect(rownames(deTab), rownames(normDge$counts)), ] -normDge$counts <- normDge$counts[intersect(rownames(deTab), rownames(normDge$counts)), ] - #ORDER deTab TABLE deTab <- rename(deTab, "FDR" = "adj.P.Val") deOrder <- c("avgLog2CPM", "avgLog2FC", "P.Value", "FDR", "DE") @@ -264,6 +258,7 @@ Results are saved, so they can be retrieved by the application. ```{r save} # SAVE ANALYSIS +deTab <- deTab[order(deTab$FDR),] save(deTab, normDge, file = "analysis.RData") ``` diff --git a/inst/src/markdown/analysisEdgeR.Rmd b/inst/src/markdown/analysisEdgeR.Rmd index b0d8da2..6010bb4 100644 --- a/inst/src/markdown/analysisEdgeR.Rmd +++ b/inst/src/markdown/analysisEdgeR.Rmd @@ -122,7 +122,7 @@ row.names(dge$genes) <- row.names(dge$counts) dge <- dge[rowSums(abs(dge$counts)) > 1,] tempDge <- dge -tempDge$counts <- cpm(dge, log = TRUE) +tempDge$counts <- cpm(dge, log = TRUE, prior.count = 1) countDistributionLinePlot(tempDge) ``` @@ -134,7 +134,7 @@ The raw data is filtered based on the input values provided. # GET SELECTED FEATURES edger <- calcNormFactors(dge, method = "TMM") -counts <- cpm(edger, log = TRUE) +counts <- cpm(edger, log = TRUE, prior.count = 1) selectedFeatures <- rownames(edger)[apply(counts, 1, function(v) sum(v >= cpm_value)) >= 1 / 4 * ncol(counts)] @@ -157,7 +157,7 @@ The filtered data is normalized using TMM. normDge <- calcNormFactors(highExprDge, method = "TMM") tempDge <- normDge -tempDge$counts <- cpm(normDge, log = TRUE) +tempDge$counts <- cpm(normDge, log = TRUE, prior.count = 1) countDistributionLinePlot(tempDge) samplePca2dPlot(tempDge, design_base, "PC1", "PC2") @@ -255,7 +255,8 @@ Results are saved, so they can be retrieved by the application. ```{r save} # SAVE ANALYSIS -normDge$counts <- cpm(normDge, log = TRUE) +deTab <- deTab[order(deTab$FDR),] +normDge$counts <- cpm(normDge, log = TRUE, prior.count = 1) save(deTab, normDge, file = "analysis.RData") ``` diff --git a/inst/src/markdown/analysisLimma.Rmd b/inst/src/markdown/analysisLimma.Rmd index eab660c..1c69adf 100644 --- a/inst/src/markdown/analysisLimma.Rmd +++ b/inst/src/markdown/analysisLimma.Rmd @@ -122,7 +122,7 @@ row.names(dge$genes) <- row.names(dge$counts) dge <- dge[rowSums(abs(dge$counts)) > 1,] tempDge <- dge -tempDge$counts <- cpm(dge, log = TRUE) +tempDge$counts <- cpm(dge, log = TRUE, prior.count = 1) countDistributionLinePlot(tempDge) ``` @@ -134,7 +134,7 @@ The raw data is filtered based on the input values provided. # GET SELECTED FEATURES limmaV <- calcNormFactors(dge, method = "TMM") -counts <- cpm(limmaV, log = TRUE) +counts <- cpm(limmaV, log = TRUE, prior.count = 1) selectedFeatures <- rownames(limmaV)[apply(counts, 1, function(v) sum(v >= cpm_value)) >= 1 / 4 * ncol(counts)] @@ -157,7 +157,7 @@ The filtered data is normalized using TMM. normDge <- calcNormFactors(highExprDge, method = "TMM") tempDge <- normDge -tempDge$counts <- cpm(normDge, log = TRUE) +tempDge$counts <- cpm(normDge, log = TRUE, prior.count = 1) countDistributionLinePlot(tempDge) samplePca2dPlot(tempDge, design_base, "PC1", "PC2") @@ -257,7 +257,8 @@ Results are saved, so they can be retrieved by the application. ```{r save} # SAVE ANALYSIS -normDge$counts <- cpm(normDge, log = TRUE) +deTab <- deTab[order(deTab$FDR),] +normDge$counts <- cpm(normDge, log = TRUE, prior.count = 1) save(deTab, normDge, file = "analysis.RData") ``` diff --git a/inst/src/markdown/enrichmentGProfiler2.Rmd b/inst/src/markdown/enrichmentGProfiler2.Rmd index 49afe3f..52962a3 100644 --- a/inst/src/markdown/enrichmentGProfiler2.Rmd +++ b/inst/src/markdown/enrichmentGProfiler2.Rmd @@ -67,7 +67,7 @@ enrich <- gost( ordered_query = FALSE, significant = significant, user_threshold = alfa, - correction_method = "bonferroni", + correction_method = "gSCS", domain_scope = "annotated", sources = database, evcodes = TRUE diff --git a/inst/src/tabs/analysis/svr_analysis.R b/inst/src/tabs/analysis/svr_analysis.R index e86c0cc..1568b31 100644 --- a/inst/src/tabs/analysis/svr_analysis.R +++ b/inst/src/tabs/analysis/svr_analysis.R @@ -109,6 +109,7 @@ output[["group_analysis_bar"]] <- renderUI({ ## Add specific gene to barplot observe({ tryCatch({ + checkReload() updateSelectizeInput( session = session, inputId = 'selected_analysis_bar', diff --git a/inst/src/tabs/export/svr_export.R b/inst/src/tabs/export/svr_export.R index 3945df4..1a8d85e 100644 --- a/inst/src/tabs/export/svr_export.R +++ b/inst/src/tabs/export/svr_export.R @@ -46,7 +46,7 @@ datasetInput <- reactive({ ## create filename and save data as CSV output$downloadCSV <- downloadHandler( filename = function() { - paste("shiny_analysis_", gsub(" ", "_", tolower(input$dataset_select)), ".csv", sep = "") + paste0("shiny_analysis_", gsub(" ", "_", tolower(input$dataset_select)), ".csv") }, content = function(file) { write.table( @@ -62,7 +62,7 @@ output$downloadCSV <- downloadHandler( ## create filename and save data as TSV output$downloadTSV <- downloadHandler( filename = function() { - paste("shiny_analysis_", gsub(" ", "_", tolower(input$dataset_select)), ".tsv", sep = "") + paste0("shiny_analysis_", gsub(" ", "_", tolower(input$dataset_select)), ".tsv") }, content = function(file) { write.table( @@ -77,11 +77,9 @@ output$downloadTSV <- downloadHandler( ## Download markdown HTML report DGE output[["downloadDGE_HTML"]] <- downloadHandler( - filename = paste(input$analysis_method, - '_', - gsub('-', '', Sys.Date()), - '.html', - sep = ''), + filename = function() { + paste0(input$analysis_method, '_', gsub('-', '', Sys.Date()),'.html') + }, content <- function(file) { file.copy(paste0('markdown/', input$analysis_method, '.html'), file) } @@ -89,10 +87,9 @@ output[["downloadDGE_HTML"]] <- downloadHandler( ## Download markdown HTML report Enrichment output[["downloadENRICH_HTML"]] <- downloadHandler( - filename = paste('gprofiler_', - gsub('-', '', Sys.Date()), - '.html', - sep = ''), + filename = function() { + paste0('gprofiler_', gsub('-', '', Sys.Date()), '.html') + }, content <- function(file) { file.copy(paste0('markdown/enrichmentGProfiler2.html'), file) } diff --git a/inst/src/tabs/upload/svr_upload.R b/inst/src/tabs/upload/svr_upload.R index cb1481b..a703a26 100644 --- a/inst/src/tabs/upload/svr_upload.R +++ b/inst/src/tabs/upload/svr_upload.R @@ -246,7 +246,7 @@ get_raw_dge <- reactive({ samples = colData(se), genes = rowData(se)) dge <- dge[rowSums(abs(dge$counts)) > 1,] - dge$counts <- cpm(dge, log = TRUE) + dge$counts <- cpm(dge, log = TRUE, prior.count = 1) dge })