Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/protViz/SRMService
Browse files Browse the repository at this point in the history
  • Loading branch information
wolski committed Oct 27, 2020
2 parents 1f9ba2e + d179740 commit dfd4ca7
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 140 deletions.
Binary file modified .DS_Store
Binary file not shown.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ For more information about this project please visit the wproject wiki


## Install
For Debian 10
You will need to have installed:

```
sudo apt-get install libssl-dev
sudo apt-get install pandoc
sudo apt-get isntall pandoc-citeproc
```


```{r}
install.packages(c("bookdown", "conflicted", "corrplot", "dplyr", "forcats", "gridExtra", "heatmap3", "limma", "missForest", "pander", "plyr", "purrr", "quantable", "R6", "reshape2", "rlang", "rmarkdown", "scales", "shiny", "tibble", "tidyr", "tidyverse", "usethis"))
install.packages(c("tidyverse","usethis"))
install.packages("BiocManager")
BiocManager::install("limma")
```


```{r}
library(devtools)
Expand All @@ -13,7 +31,9 @@ install_github(c('protViz/SRMService'))
```


## Deployment on server
## Deployment on shiny-server




```{r}
Expand Down
20 changes: 12 additions & 8 deletions inst/RunScripts/RUN_VarSelection_Multinomial.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
rm(list=ls())

library(SRMService)
library(reshape2)

packagedir <- path.package("SRMService")
longm <- read.csv(file.path(packagedir, "samples/immunoLongFormat.txt"),row.names = 1,stringsAsFactors = F)
longm$Intensity <- log2(longm$Intensity+1)
longm <-
read.csv(
file.path(packagedir, "samples/immunoLongFormat.txt"),
row.names = 1,
stringsAsFactors = F
)
longm$Intensity <- log2(longm$Intensity + 1)



#head(datam)
longm$Protein <- longm$Variable
protData <- ProteinVariableSelect$new(longm)

rmarkdown::render("VariableSelection_MultinomialLasso.Rmd",output_format = "pdf_document", clean=FALSE)



rmarkdown::render(
"VariableSelection_MultinomialLasso.Rmd",
output_format = "pdf_document",
clean = FALSE
)
62 changes: 38 additions & 24 deletions inst/RunScripts/Run_Generic_QuantTwoGroupAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
# www.github.com/protViz/SRMService
# by W.E. Wolski, J. Grossmann, C. Panse
#
rm(list=ls())
library(limma)
library(SRMService)

### Protein groups file
packagePath <- path.package("SRMService")
packagePath <- "."
proteinGroupsFile <- file.path(packagePath,"/inst/samples/genericQuantMatrix","Generic_QuantMatrix.txt")
proteinGroupsFile <-
file.path(packagePath,
"/inst/samples/genericQuantMatrix",
"Generic_QuantMatrix.txt")

# read in protein groups file
protein <- readr::read_tsv(proteinGroupsFile)
Expand All @@ -29,35 +31,46 @@ colnames(protein) <- make.names(colnames(protein))
originalHeaders <- colnames(protein)
fakeNrPeptides <- rep(3, nrow(protein))
fakeFastaHeader <- rep("No_Description", nrow(protein))
protein <- cbind(protein,fakeNrPeptides, fakeFastaHeader)
protein <- cbind(protein, fakeNrPeptides, fakeFastaHeader)


# for project p2482 put the sample annotations from metainfo
newHeaders <- c("Majority.protein.IDs", paste("Intensity.",originalHeaders[2:length(originalHeaders)], sep=""), "Peptides","Fasta.headers")
newHeaders <-
c(
"Majority.protein.IDs",
paste("Intensity.", originalHeaders[2:length(originalHeaders)], sep = ""),
"Peptides",
"Fasta.headers"
)
colnames(protein) <- newHeaders




# all raw files in protein groups (select here for proper 2grp)
rawF <- gsub("Intensity\\.", "", grep("Intensity\\.",colnames(protein),value=T) )
rawF <-
gsub("Intensity\\.", "", grep("Intensity\\.", colnames(protein), value =
T))

# how to parse condition from the filenames (separator in fn _ )
condition <- quantable::split2table(rawF)[,3]
condition <- quantable::split2table(rawF)[, 3]
#
annotation <- data.frame(Raw.file = rawF,
Condition = condition,
BioReplicate = paste("X",1:length(condition),sep=""),
Run = 1:length(condition),
IsotopeLabelType = rep("L",length(condition)),
stringsAsFactors = F)
annotation <- data.frame(
Raw.file = rawF,
Condition = condition,
BioReplicate = paste("X", 1:length(condition), sep =
""),
Run = 1:length(condition),
IsotopeLabelType = rep("L", length(condition)),
stringsAsFactors = F
)


###################################
### Configuration section

tmpdir <- tempdir()
resultdir <- file.path(tmpdir,"GenericTwoGroup")
resultdir <- file.path(tmpdir, "GenericTwoGroup")
dir.create(resultdir)

# calls up data editor
Expand All @@ -68,28 +81,29 @@ Experimentname = "pXXX_compareDifferentTissues"
nrNas = sum(!is.na(annotation$Condition)) - 3

nrPeptides = 2
reference=unique(annotation$Condition)[1]
reference = unique(annotation$Condition)[1]
qvalueThreshold = 0.01
qfoldchange =1
qfoldchange = 1

write.table(annotation, file=file.path(resultdir, "annotationused.txt"))
write.table(annotation, file = file.path(resultdir, "annotationused.txt"))

####### END of user configuration ##


# important structure for protein matrix

# Do the analysis
grp2 <- Grp2Analysis(annotation,
Experimentname,
maxNA=nrNas,
nrPeptides=nrPeptides,
reference=reference,
numberOfProteinClusters = 20
)
grp2 <- Grp2Analysis(
annotation,
Experimentname,
maxNA = nrNas,
nrPeptides = nrPeptides,
reference = reference,
numberOfProteinClusters = 20
)
grp2$setMQProteinGroups(protein)

grp2$setQValueThresholds(qvalue = qvalueThreshold,qfoldchange = qfoldchange)
grp2$setQValueThresholds(qvalue = qvalueThreshold, qfoldchange = qfoldchange)

#write out results and render pdf
#readr::write_tsv(x = grp2$getResultTable(), path = file.path(resultdir,"pValues.csv"))
Expand Down
59 changes: 36 additions & 23 deletions inst/RunScripts/Run_MQ_QuantTwoGroupAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,44 @@
# www.github.com/protViz/SRMService
# by W.E. Wolski, J. Grossmann, C. Panse
#
rm(list=ls())
library(limma)
library(SRMService)

### Protein groups file
packagedir <- path.package("SRMService")

proteinGroupsFile <- file.path(packagedir, "samples/proteinGroups/proteinGroups.txt")
####! set the path to the proteinGroups.txt file.
proteinGroupsFile <-
file.path(packagedir, "samples/proteinGroups/proteinGroups.txt")

###


protein <- readr::read_tsv(proteinGroupsFile)
colnames(protein) <- make.names(colnames(protein))
tmp <- cumsum(rev(table(protein$Peptides)))
barplot(tmp[(length(tmp)-5):length(tmp)],ylim=c(0, length(protein$Peptides)),xlab='nr of proteins with at least # peptides')
barplot(tmp[(length(tmp) - 5):length(tmp)], ylim = c(0, length(protein$Peptides)), xlab =
'nr of proteins with at least # peptides')

##
rawF <-
gsub("Intensity\\.", "", grep("Intensity\\.", colnames(protein), value =
T))

rawF <- gsub("Intensity\\.", "", grep("Intensity\\.",colnames(protein),value=T) )
condition <- quantable::split2table(rawF)[,3]
annotation <- data.frame(Raw.file = rawF,
Condition = condition,
BioReplicate = paste("X",1:length(condition),sep=""),
Run = 1:length(condition),
IsotopeLabelType = rep("L",length(condition)),
stringsAsFactors = F)
condition <- quantable::split2table(rawF)[, 3]

# Raw.file <- c("23bb","23bcd","23ddd","","","")
# condition <- c("baseline","baseline","w1","w1")

annotation <- data.frame(
Raw.file = rawF,
Condition = condition,
BioReplicate = paste("X", 1:length(condition), sep =
""),
Run = 1:length(condition),
IsotopeLabelType = rep("L", length(condition)),
stringsAsFactors = F
)



Expand All @@ -44,26 +56,28 @@ Experimentname = ""
nrNas = sum(!is.na(annotation$Condition)) - 1
nrNas = 5
nrPeptides = 2
reference=unique(annotation$Condition)[1]
reference="WT"
reference = unique(annotation$Condition)[1]
reference = "WT"
qvalueThreshold = 0.05
qfoldchange =1
write.table(annotation, file=file.path(resultdir, "annotationused.txt"))
qfoldchange = 1
write.table(annotation, file = file.path(resultdir, "annotationused.txt"))

####### END of user configuration ##

# source("R/Grp2Analysis.R")
grp2 <- Grp2Analysis(annotation, "Experimentname",
maxNA=nrNas,
nrPeptides=nrPeptides,
reference=reference,
numberOfProteinClusters = 20
)
grp2 <- Grp2Analysis(
annotation,
"Experimentname",
maxNA = nrNas,
nrPeptides = nrPeptides,
reference = reference,
numberOfProteinClusters = 20
)

grp2$getDesignMatrix()

grp2$setMQProteinGroups(protein)
grp2$setQValueThresholds(qvalue = qvalueThreshold,qfoldchange = qfoldchange)
grp2$setQValueThresholds(qvalue = qvalueThreshold, qfoldchange = qfoldchange)
mqQuantMatrixGRP2 <- grp2

head(mqQuantMatrixGRP2$getModPValuesCI())
Expand All @@ -74,4 +88,3 @@ usethis::use_data(mqQuantMatrixGRP2, overwrite = TRUE)
## REMOVE TO RENDER
# rmarkdown::render("vignettes/Grp2AnalysisHeatmap3.Rmd",bookdown::pdf_document2(), params=list(grp = grp2))
# rmarkdown::render("vignettes/Grp2Analysis.Rmd",bookdown::pdf_document2(), params=list(grp = grp2))

48 changes: 27 additions & 21 deletions inst/RunScripts/Run_PD_QuantTwoGroupAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,65 @@ library(quantable)
library(SRMService)

## specify file names

inputFilesFile <- "20161115_02_G3_InputFiles.txt"
proteinsFile <- "20161115_02_G3_Proteins.txt"
##


rm(list=ls())
inputFiles <- read_tsv( inputFilesFile )
inputFiles <- read_tsv(inputFilesFile)
inputFileFix <- fix_PD_inputFiles(inputFiles)

annotation <- data.frame(Raw.file = inputFileFix$Raw.File,
Condition = gsub("[0-9]","",quantable::split2table(inputFileFix$Raw.File)[,3]),
BioReplicate = paste("X",1:nrow(inputFileFix),sep=""),
Run = 1:nrow(inputFileFix),
IsotopeLabelType = rep("L",nrow(inputFileFix)),
stringsAsFactors = F)
annotation <- data.frame(
Raw.file = inputFileFix$Raw.File,
Condition = gsub("[0-9]", "", quantable::split2table(inputFileFix$Raw.File)[, 3]),
BioReplicate = paste("X", 1:nrow(inputFileFix), sep =
""),
Run = 1:nrow(inputFileFix),
IsotopeLabelType = rep("L", nrow(inputFileFix)),
stringsAsFactors = F
)



proteins <- read_tsv( proteinsFile )
proteinsFIX <- remap_PD_ProteinTable(proteins,inputFiles)
proteins <- read_tsv(proteinsFile)
proteinsFIX <- remap_PD_ProteinTable(proteins, inputFiles)




###################################
### Configuration section
fix(annotation)
resultdir="output"
resultdir = "output"
dir.create(resultdir)


Experimentname = ""
nrNas = sum(!is.na(annotation$Condition)) - 1
nrPeptides = 2
reference=unique(annotation$Condition)[1]
reference = unique(annotation$Condition)[1]
qvalueThreshold = 0.01
qfoldchange =2
qfoldchange = 2

write.table(annotation, file=file.path(resultdir, "annotationused.txt"))
write.table(annotation, file = file.path(resultdir, "annotationused.txt"))

####### END of user configuration ##



library(SRMService)
grp2 <- Grp2Analysis(annotation, "test pd import", maxNA=nrNas , nrPeptides=nrPeptides, reference=reference)
grp2 <-
Grp2Analysis(
annotation,
"test pd import",
maxNA = nrNas ,
nrPeptides = nrPeptides,
reference = reference
)
grp2$setProteins(proteinsFIX)
grp2$setQValueThresholds(qvalue = qvalueThreshold,qfoldchange = qfoldchange)
grp2$setQValueThresholds(qvalue = qvalueThreshold, qfoldchange = qfoldchange)

results <- grp2$getResultTableWithPseudo()
write_tsv(results,path= file.path(resultdir,"pValues.tsv"))
write_tsv(results, path = file.path(resultdir, "pValues.tsv"))
rmarkdown::render("Grp2Analysis.Rmd", output_format = bookdown::pdf_document2())




Loading

0 comments on commit dfd4ca7

Please sign in to comment.