diff --git a/NAMESPACE b/NAMESPACE index 45ef657..43220b8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,13 +1,16 @@ # Generated by roxygen2: do not edit by hand +export(Grp2Analysis) export(MQtoMSstatsFormat) export(SRMService) export(getIntensities) export(getRequiredColumns) export(piwotPiw) export(plotNicely) +exportClasses(Grp2Analysis) exportClasses(SRMService) import(DBI) import(methods) import(parallel) import(quantable) +import(reshape2) diff --git a/R/Grp2Analysis.R b/R/Grp2Analysis.R index c5e9623..b73954c 100644 --- a/R/Grp2Analysis.R +++ b/R/Grp2Analysis.R @@ -1,12 +1,10 @@ annotationColumns <- c("Raw.file","Condition", "BioReplicate", "Run","IsotopeLabelType") proteinColumns <- c("ProteinName","TopProteinName","nrPeptides") -#' +#' Perform 2 group analysis with visualization #' @export Grp2Analysis #' @exportClass Grp2Analysis #' -#' @examples -#' Grp2Analysis() Grp2Analysis <- setRefClass("Grp2Analysis", fields = list( proteinIntensity = "data.frame", annotation = "data.frame", diff --git a/R/SRMService.R b/R/SRMService.R index 6e29339..f4e5064 100644 --- a/R/SRMService.R +++ b/R/SRMService.R @@ -195,13 +195,19 @@ SRMService <- setRefClass("SRMService", ) return(int_) }, + stripLabel=function(int_,light=FALSE){ + label<-if(light){.self$lightLabel}else{.self$heavyLabel} + rownames(int_) <- gsub(paste("_",label,"$",sep=""),"",rownames(int_)) + invisible(int_) + } + , getMatchingIntensities = function(){ "get matrix with intensities, where nr of NAs in row < maxNA" intLight_ <- .self$getTransitionIntensities(light=TRUE) intHeavy_ <- .self$getTransitionIntensities() - rownames(intLight_) <- gsub("_light$","",rownames(intLight_)) - rownames(intHeavy_) <- gsub("_heavy$","",rownames(intHeavy_)) + intLight_ <- stripLabel(intLight_, light=TRUE) + intHeavy_ <- stripLabel(intHeavy_) idx <-intersect(rownames(intLight_),rownames(intHeavy_)) diff --git a/inst/samples/grp2analysisTest.R b/inst/samples/grp2analysisTest.R index 37045a2..2ee898c 100644 --- a/inst/samples/grp2analysisTest.R +++ b/inst/samples/grp2analysisTest.R @@ -2,6 +2,7 @@ rm(list=ls()) protein <- read.csv("d:/googledrive/DataAnalysis/p2084/215579/proteinGroups.txt",sep="\t",stringsAsFactors = F) +colnames(protein) rawF <-gsub("Intensity\\.", "", grep("Intensity\\.",colnames(protein),value=T) ) @@ -13,24 +14,11 @@ annotation <-data.frame(Raw.file = rawF, IsotopeLabelType = rep("L",length(condition)), stringsAsFactors = F) +library(SRMService) -source("R/Grp2Analysis.R") - - -grp2 <- Grp2Analysis(annotation, "p2084BlaBla", maxNA=8 , nrPeptides=3) -grp2$setHeatmap("red") - +grp2 <- Grp2Analysis(annotation, "p2084BlaBla", maxNA=8 , nrPeptides=2) grp2$setMQProteinGroups(protein) -grp2$getDesignMatrix() - - library(dScipa) -idx <-grep("SL9B2_MOUSE",rownames(grp2$proteinIntensity)) -grp2$proteinIntensity[idx,] -res.eb <- grp2$getPValues() -head(res.eb) -grep("SL9B2_MOUSE",rownames(res.eb)) - rmarkdown::render("inst/reports/Grp2Analysis.Rmd",output_format = "pdf_document", output_file = "Grp2Analysis.pdf") diff --git a/man/Grp2Analysis-class.Rd b/man/Grp2Analysis-class.Rd new file mode 100644 index 0000000..bee0cca --- /dev/null +++ b/man/Grp2Analysis-class.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Grp2Analysis.R +\docType{class} +\name{Grp2Analysis-class} +\alias{Grp2Analysis} +\alias{Grp2Analysis-class} +\title{Perform 2 group analysis with visualization} +\description{ +Perform 2 group analysis with visualization +} +\section{Methods}{ + +\describe{ +\item{\code{getConditionData(condition)}}{get intensities as matrix for single condition} + +\item{\code{getNrNAs()}}{return number of NAs per protein} + +\item{\code{setMQProteinGroups(MQProteinGroups)}}{set MQ protein groups table} + +\item{\code{setProteins(protein)}}{used to verify proteingroups structure and set members} +}} + diff --git a/man/SRMService-class.Rd b/man/SRMService-class.Rd index e86d358..6d63390 100644 --- a/man/SRMService-class.Rd +++ b/man/SRMService-class.Rd @@ -25,52 +25,56 @@ The function performs a SQL query on the SQLite \item{\code{getNrNAs(light = FALSE)}}{show nr of NA's for heavy (defalt) or light transitions} -\item{\code{getTransitionIntensities(light = FALSE)}}{get matrix with intensities, where nr of NAs in row < maxNA} +\item{\code{getTransitionIntensities(maxNA, light = FALSE)}}{get matrix with intensities, where nr of NAs in row < maxNA} -\item{\code{plotCommonTransitions(light = FALSE)}}{Shows transitions which occure in heavy and light} +\item{\code{maxNAHeavy(max)}}{set maximum of na's heavy row} -\item{\code{plotQValues()}}{show q value distribution for peak groups} +\item{\code{maxNALight(max)}}{set maximum of na's in light row} -\item{\code{setMaxNAHeavy(max = 0)}}{set maximum of na's heavy row} +\item{\code{plotCommonTransitions(light = FALSE)}}{Shows transitions which occure in heavy and light} -\item{\code{setMaxNALight(max = 0)}}{set maximum of na's in light row} +\item{\code{plotQValues()}}{show q value distribution for peak groups} }} \examples{ + library(SRMService) tmp <- "D:/googledrive/DataAnalysis/p1930" allData <- read.csv( file=file.path(tmp,"data/longFormat.txt"),row.names = 1) +head(allData) data <-allData pool=2 data <-allData[allData$pool==pool,] head(data) -srms <- SRMService(data,qvalue=0.25) - +srms <- SRMService(data,qvalue=0.05) +SRMService$methods() +srms$maxNAHeavy() +SRMService$fields() +head(srms$piw) srms$plotQValues() srms$plotTransition() srms$plotTransition(light=TRUE) + srms$getNrNAs() srms$getNrNAs(light=TRUE) -srms$maxNAHeavy -srms$maxNALight - -srms$setMaxNAHeavy(30) -srms$setMaxNALight(40) +srms$maxNAHeavy() +srms$maxNALight() +srms$maxNAHeavy(80) +srms$maxNALight(80) +srms$plotCommonTransitions() +srms$plotCommonTransitions(light=TRUE) +tmp <-srms$getLHLog2FoldChange(maxNA = 20) +srms$maxNAFC() +resH <- srms$plotCommonTransitions() +dim(resH) +resL <-srms$plotCommonTransitions(light=TRUE) +dim(resL) +resAll <- srms$getMatchingIntensities() +dim(resAll$light) -colnames(srms$piw) -head(srms$piw) tmpH <- srms$getTransitionIntensities() -dim(tmpH) -stopifnot(max(apply(tmpH, 1, function(x){sum(is.na(x))}))<=30) tmpL <- srms$getTransitionIntensities(light=TRUE) dim(tmpL) -stopifnot(max(apply(tmpL, 1, function(x){sum(is.na(x))}))<=40) -x<-srms$getMatchingIntensities() -rownames(x$light)[1:10] - - -tmp<-srms$getLHLog2FoldChange() -head(tmp) }