From 624fa5fed675078a018d90e8154dde633ec6a266 Mon Sep 17 00:00:00 2001 From: Witold Wolski Date: Tue, 13 Aug 2019 16:01:00 +0200 Subject: [PATCH] cleanup --- DESCRIPTION | 2 +- R/Grp2Analysis.R | 6 +- .../RunScripts/Run_MQ_QuantTwoGroupAnalysis.R | 3 + inst/samples/plotlyExample.Rmd | 32 ------- .../plotlyViewer/ProteinPeptideViewer.Rmd | 87 ------------------- .../plotlyViewer/RenderPepideProteinViewer.R | 28 ------ vignettes/Grp2PullDownExample.Rmd | 2 +- 7 files changed, 9 insertions(+), 151 deletions(-) delete mode 100644 inst/samples/plotlyExample.Rmd delete mode 100644 inst/samples/plotlyViewer/ProteinPeptideViewer.Rmd delete mode 100644 inst/samples/plotlyViewer/RenderPepideProteinViewer.R diff --git a/DESCRIPTION b/DESCRIPTION index 07c1571..522dbb0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,11 +11,11 @@ Author: Witold Wolski Description: Analysing and LFQ and SRM experiments in service mode. Data preprocessing and visualization. Imports: - bibliospec, bookdown, conflicted, corrplot, dplyr, + forcats, glue, gridExtra, heatmap3, diff --git a/R/Grp2Analysis.R b/R/Grp2Analysis.R index 50a0fd6..1621c87 100644 --- a/R/Grp2Analysis.R +++ b/R/Grp2Analysis.R @@ -168,14 +168,16 @@ Grp2Analysis <- setRefClass("Grp2Analysis", fileID <- as.character(subset(.self$annotation_, Condition == condition)$Raw.file) normalized[, fileID] }, + resetModelMatrix = function(){ + .self$modelMatrix <- matrix(ncol=0, nrow=0) + }, setModelMatrix = function(modelMatrix){ .self$modelMatrix <- modelMatrix }, getDesignMatrix = function(){ if(isTRUE(all.equal(dim(.self$modelMatrix), c(0,0)))){ # hack for putting reference into denomintor. - design <- gsub(reference, paste("A_", reference, sep=""), - .self$annotation_$Condition) + design <- forcats::fct_relevel(.self$annotation_$Condition, .self$reference) .self$modelMatrix <- model.matrix(~design) } return(.self$modelMatrix) diff --git a/inst/RunScripts/Run_MQ_QuantTwoGroupAnalysis.R b/inst/RunScripts/Run_MQ_QuantTwoGroupAnalysis.R index 6f52d3a..34ed3b4 100644 --- a/inst/RunScripts/Run_MQ_QuantTwoGroupAnalysis.R +++ b/inst/RunScripts/Run_MQ_QuantTwoGroupAnalysis.R @@ -60,11 +60,14 @@ grp2 <- Grp2Analysis(annotation, "Experimentname", numberOfProteinClusters = 20 ) +grp2$getDesignMatrix() + grp2$setMQProteinGroups(protein) grp2$setQValueThresholds(qvalue = qvalueThreshold,qfoldchange = qfoldchange) mqQuantMatrixGRP2 <- grp2 head(mqQuantMatrixGRP2$getModPValuesCI()) + usethis::use_data(mqQuantMatrixGRP2, overwrite = TRUE) #readr::write_tsv(grp2$getResultTable(), path=file.path(resultdir,"pValues.csv")) diff --git a/inst/samples/plotlyExample.Rmd b/inst/samples/plotlyExample.Rmd deleted file mode 100644 index b454f9c..0000000 --- a/inst/samples/plotlyExample.Rmd +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: "test" -author: "Witold Wolski" -date: "13 September 2018" -output: html_document ---- - -```{r} -# These examples demonstrate ways to display binned/aggregated selections -library(plotly) -tx <- highlight_key(txhousing, ~city) - -p1 <- ggplot(tx, aes(date, median, group = city)) + geom_line() + xlab(NULL) - -gg1 <- ggplotly(p1, tooltip = c("city", "date", "median")) - -p2 <- plot_ly(tx, x = ~median, color = I("black")) %>% - add_histogram(histnorm = "probability density") - -subplot(gg1, p2, titleX = TRUE, titleY = TRUE) %>% - layout(barmode = "overlay") %>% - highlight(dynamic = TRUE, selected = attrs_selected(opacity = 0.3)) - -xxx<- data.frame(a = 1:4, b=3:6) -x<- data.frame(a = 1:4, b=letters[1:4], stringsAsFactors = TRUE) - -plot_ly(xxx, type="table") - -add_trace(plot_ly(x, type="table"), type="table") - -plot_ly(type="table",header=list(values=names(x)), cells=list(values=unname(x))) -``` diff --git a/inst/samples/plotlyViewer/ProteinPeptideViewer.Rmd b/inst/samples/plotlyViewer/ProteinPeptideViewer.Rmd deleted file mode 100644 index 05f9528..0000000 --- a/inst/samples/plotlyViewer/ProteinPeptideViewer.Rmd +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: "Protein - Peptide - Volcano Browser - V0.1" -author: wew@fgcz.ethz.ch -params: - par : Europe -output: - flexdashboard::flex_dashboard: - orientation: rows - social: menu - source_code: embed - theme: cerulean ---- - -```{r} -library(plotly) -library(crosstalk) -library(tidyverse) -library(readr) -dataX <- params$dataX - -``` - -```{r} -protTable <- params$par$prot -peptideTable <- params$par$pep -``` - - -```{r Make dataset, eval=FALSE} -protTable <- data.frame(protein_Id = c("A","B","C"), fc = c(2,3,-1), p.value = c(0.1,0.01,0.4), mean = c(3,10,20)) -peptideTable <- data.frame(protein_Id = c("A","A","B","B","B","C"), - peptide_Id = c("ax","bx","cd","ad","bd","ca"), - fc = c(2,3,1,2.2,1.3,-1), - p.value = c(0.1,0.01,0.01,0.4,0.1,0.4)) -peptideTable <- peptideTable %>% tidyr::unite("prot_pep", protein_Id, peptide_Id, remove=FALSE ) - -``` - - - -```{r} -library(crosstalk) -# Notice the 'group = ' argument - this does the trick! -shared_prot <- SharedData$new(protTable, ~protein_Id, group = "Choose protein") -shared_pep <- SharedData$new(peptideTable, ~protein_Id, group = "Choose protein") -# You don't need this second filter now -#filter_select("owner", "Car owner:", shared_pep, ~ owner) -``` - -# Volcano Plots - -## - - -### Protein Volcano - -```{r} - -#filter_select("prot", "Protein :", shared_prot, ~prot) -plot_ly(shared_prot, x = ~fc, y = ~ I(-log10(p.value)) , type="scatter" , mode="markers", text=~protein_Id) %>% highlight("plotly_click") - -``` - -### Peptide Volcano - -```{r} -plot_ly(data=shared_pep, x = ~fc, y = ~ I(-log10(p.value)), mode="markers", type="scatter", text=~prot_pep) - -``` - -## - -### Proteins - -```{r} -DT::datatable(shared_prot) -``` - -### Peptides - -```{r} -DT::datatable(shared_pep) -``` - - - - diff --git a/inst/samples/plotlyViewer/RenderPepideProteinViewer.R b/inst/samples/plotlyViewer/RenderPepideProteinViewer.R deleted file mode 100644 index e095a12..0000000 --- a/inst/samples/plotlyViewer/RenderPepideProteinViewer.R +++ /dev/null @@ -1,28 +0,0 @@ -library(readr) -library(tidyverse) - -outdir <- "tmp" -prot <- read_csv("LinearModelP_Values.txt") -pep <- readr::read_csv("PEPTIDE_P_VALUES.txt") - - -prot <- prot %>% dplyr::rename(fc = estimate) %>% select(-rhs) -pep <- pep %>% dplyr::rename(fc = estimate) %>% select(-rhs) - -#peptide <- pep %>%filter(lhs == "NR - c") %>% select(-rhs) -pep <- pep %>% tidyr::unite("prot_pep", protein_Id, peptide_Id, remove=FALSE ) - -file.copy("C:/Users/wolski/prog/LFQService/inst/plotly_reports/ProteinPeptideViewer.Rmd","ProteinPeptideViewer.Rmd") - -for(i in unique(pep$lhs)){ - print(i) - proti <- prot %>%filter(lhs == i) - pepi <- pep %>% filter(lhs == i) - name <- make.names(i) - par <- list(prot = proti, pep=pepi) - - destname<-paste0("ProteinPeptideViewer", name, ".html" ) - rmarkdown::render("ProteinPeptideViewer.Rmd", - params=list(par=par), - output_file = file.path(outdir, destname)) -} diff --git a/vignettes/Grp2PullDownExample.Rmd b/vignettes/Grp2PullDownExample.Rmd index c461228..75088c7 100644 --- a/vignettes/Grp2PullDownExample.Rmd +++ b/vignettes/Grp2PullDownExample.Rmd @@ -16,7 +16,7 @@ header-includes: params: grp: !r quote(SRMService::grp2PullDownExample) vignette: > - %\VignetteIndexEntry{FGCZ Two-Group Analysis} + %\VignetteIndexEntry{FGCZ Two-Group Analysis - pull down example} %\VignetteEncoding{UTF-8} %\VignetteEngine{knitr::rmarkdown} bibliography: bibliography.bib