CurrentSession<-sessioninfo::package_info()
if(!"Biostrings" %in% CurrentSession$package) library("Biostrings", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"DT" %in% CurrentSession$package) library("DT", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"data.table" %in% CurrentSession$package) library("data.table", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"GenomicFeatures" %in% CurrentSession$package) library("GenomicFeatures", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"ggplot2" %in% CurrentSession$package) library("ggplot2", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"plotly" %in% CurrentSession$package) library("plotly", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"rtracklayer" %in% CurrentSession$package) library("rtracklayer", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"httr" %in% CurrentSession$package) library("httr", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"xml2" %in% CurrentSession$package) library("xml2", character.only = TRUE, quietly = TRUE, verbose = FALSE)
if(!"viridisLite" %in% CurrentSession$package) library("viridisLite", character.only = TRUE, quietly = TRUE, verbose = FALSE)

CurrentList<-ls()
if(!"BANK" %in% CurrentList) BANK<-Biostrings::readAAStringSet(params$ProteinBankFasta)
if(!"PEPTIDES" %in% CurrentList){ PEPTIDES<-data.table::fread(params$PeptideResults,integer64 = "numeric")
if("UpdateProteins" %in% colnames(PEPTIDES)){
  PEPTIDES$Proteins<-PEPTIDES$UpdateProteins
}
if("UpdatedSequence" %in% colnames(PEPTIDES)){
  PEPTIDES$Sequence<-PEPTIDES$UpdatedSequence
}}
CurrentList<-ls()
if(!"SampleDescription" %in% CurrentList) SampleDescription <- data.table::fread(params$SampleDescription, header = TRUE)

#source("./SharedFunctionAcrossRmd.R")
#source(params$Utils)
names(BANK)<-gsub(" .*$","",names(BANK))
LocalProt<-BANK[params$ProteinOfInterest]
if("SplitedUpdateProteins" %in% colnames(PEPTIDES)) {
  LocalPeptides <-
    PEPTIDES[`SplitedUpdateProteins` == params$ProteinOfInterest]
} else{
  LocalPeptides <-
    PEPTIDES[`Leading razor protein` == params$ProteinOfInterest]
}
LightIntensitiesName <- colnames(LocalPeptides)[
  grep(params$IntensityPrefix,
       colnames(LocalPeptides))]
MaxIntensities<-apply(
  LocalPeptides[,..LightIntensitiesName],
  1,max)

LocalPeptides[, (LightIntensitiesName) := lapply(.SD, function(x) x/MaxIntensities), .SDcols = LightIntensitiesName]


#SampleDescription <- read.table(params$SampleDescription, header = TRUE)
if(length(grep(" $",params$IntensityPrefix))>0){
  UsablePrefix<-params$IntensityPrefix
}else{
  UsablePrefix<-paste(params$IntensityPrefix," ",sep="")
}
Groups <- unique(unlist(SampleDescription[,params$SampleGroupName,with=FALSE],use.names=FALSE))
Groups <- Groups[!duplicated(Groups)]
# SamplesByGroup <- lapply(as.vector(Groups),
#                          function(x, SampleDescription) {
#                            paste(UsablePrefix, as.vector(SampleDescription[SampleDescription[,params$SampleGroupName] == x, params$SampleName]),sep="")
#                          }, SampleDescription = SampleDescription)
# names(SamplesByGroup) <- Groups

SamplesByGroup <-
  lapply(Groups,
         function(x, SampleDescription) {
           paste0(UsablePrefix,unlist(SampleDescription[get(params$SampleGroupName) == x, ][, .SD, .SDcols = params$SampleName], use.names = FALSE))
         }, SampleDescription = SampleDescription)
names(SamplesByGroup) <- Groups

for(LocalGroup in Groups) {
  LocalPeptides[, paste(LocalGroup, "Infos") := paste(.SD, collapse = ","), .SDcols =
                  SamplesByGroup[[LocalGroup]], by = Sequence]
}

PeptideColumnOfInterest<-c("Proteins",
                           "Sequence",
                           paste(Groups,"Infos"),
                           "Start position",
                           "End position",
                           #"Score",
                           "PEP"
                           )

if("UpdateProteins" %in% colnames(LocalPeptides)){
  LocalPeptides$Proteins<-LocalPeptides$UpdateProteins
}


#Discard the peptides that came from nowhere 
#Most likely found only on Heavy intensities
#Silac's Burden
LocalPeptides <-
  LocalPeptides[MaxIntensities > 0, ..PeptideColumnOfInterest]
LocalPeptides <- LocalPeptides[,
                               PEP := formatC(PEP,
                                              format = "e",
                                              digits = 2)]
PeptidesCols<-c("Start position","End position","PEP","Proteins","Sequence")
LocalPep <- data.frame(LocalPeptides[, ..PeptidesCols])
colnames(LocalPep)<-c("Start","End","Pep","Proteins","Sequence")
LocalPep$Proteins <-
  unlist(lapply(LocalPep$Proteins, function(x) {
    paste(unlist(lapply(
      unlist(strsplit(split = ';', x)), STRING_ProteinShortName
    )), collapse = " ")
  }))
LocalProteinSequence<-HTML_Pretty_Sequence(
  Sequence=as.vector(LocalProt),
  Peptides=LocalPep,
  LineWidth=60)

Column {data-width=600}

Peptides

Table description

All the peptides that match this protein, each line is a peptide.

  • Proteins: Number of proteins that match this peptide. You can hover over the number to have more informations on the different proteins matched by this peptide.

  • Sequence: Peptide sequence. If the peptide sequence is too long, you can hover over it to see the whole sequence in a popup.

  • Infos: Normalized intensities of the peptides across all the sample of a group. Group are defined by values presents in the sample sheet file. You can hover over the bars to see the sample name.

  • Start position: matching start position of the peptide in the protein sequence

  • End position: matching end position of the peptide in the protein sequence

  • PEP: FDR of the peptide identification

#LocalPeptides$Proteins<-unlist(
#    lapply(LocalPeptides$Proteins,NProteins)
#  )
LocalPeptides <- LocalPeptides[,
                               Sequence := HTML_VECTOR_Peptide2Popover(Sequence, 15)]
LocalDatatable <- DT::datatable(
  LocalPeptides[,..PeptideColumnOfInterest],
  width = "100%",
  #extension =c("Responsive"),
  options = LIST_ComputeDatatableOptions(LIST_SampleNames=SamplesByGroup),
  rownames = FALSE,
  escape = FALSE
)
#LocalDatatable<-formatSignif(LocalDatatable,"PEP",digits=3)
LocalDatatable$dependencies <-
  append(LocalDatatable$dependencies,
         htmlwidgets:::getDependency("sparkline"))
LocalDatatable

Column {data-width=350}

Protein

Protein legend

Protein sequence as provided in the protein bank.

  • Matching peptide is displayed with this FORMALISM

  • Matching proteotypic peptide is displayed with this FORMALISM

  • Variation to the canonical form (splicing variant)is displayed with this FORMALISM

You can hover over each formalism to have more informations. A specific positon on the protein sequence can have several features of interest such as overlapping peptide due to misscleavage or a peptide overlaping a aplicing variant, each of these features will be diplayed in the informations.

cat(LocalProteinSequence)

{js, echo=FALSE} $('[data-toggle="popover"]').popover({container: 'body'});



47Lies/isoformnspectRe documentation built on May 29, 2021, 3 p.m.