diff --git a/NAMESPACE b/NAMESPACE index db39276a..b25f6c6f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -26,7 +26,6 @@ export(MissingHelpers) export(Model) export(ModelInterface) export(ProjectStructure) -export(ProteinAnnotation) export(R6_extract_values) export(UpSet_interaction_missing_stats) export(UpSet_missing_stats) diff --git a/R/ProteinAnnotation.R b/R/ProteinAnnotation.R deleted file mode 100644 index 417a5434..00000000 --- a/R/ProteinAnnotation.R +++ /dev/null @@ -1,125 +0,0 @@ -# ProteinAnnotation ---- -#' Decorates LFQData with a row annotation and some protein specific functions. -#' -#' @export -#' @family LFQData -#' @examples -#' -#' istar <-prolfqua::sim_lfq_data_peptide_config() -#' lfqdata <- LFQData$new(istar$data, istar$config) -#' pannot <- ProteinAnnotation$new( lfqdata ) -#' pannot$annotate_decoys() -#' pannot$annotate_contaminants() -#' dd <- pannot$clean() -#' tmp <- lfqdata$get_subset(dd) -#' pannot$row_annot -#' -ProteinAnnotation <- - R6::R6Class("ProteinAnnotation", - public = list( - #' @field row_annot data.frame containing further information - row_annot = NULL, - #' @field pID column with protein ids - pID = character(), - #' @field description name of column containing descriptions - description = "description", - #' @field cleaned_ids vector with columns containing addition IDs - cleaned_ids = character(), - #' @field nr_children name of columns with the number of peptides - nr_children = character(), - #' @description initialize - #' @param lfqdata data frame from \code{\link{setup_analysis}} - #' @param row_annot data frame with row annotation. Must have columns matching \code{config$table$hierarchy_keys_depth()} - #' @param description name of column with description - #' @param ids names of columns with cleaned Ids - #' @param nr_peptides additional peptides - #' @param nr_children column with the number of children - initialize = function(lfqdata, - row_annot = NULL, - description = NULL, - ids = NULL, - nr_children = "nr_peptides"){ - self$pID = lfqdata$config$table$hierarchy_keys_depth()[1] - self$nr_children = nr_children - if ( !is.null(ids)) {self$cleaned_ids = ids} else {self$cleaned_ids = self$pID} - if ( !is.null(description)) {self$description = description} else {self$description = self$pID} - if ( !is.null(row_annot)) { - stopifnot(self$pID %in% colnames(row_annot)) - row_annot <- dplyr::filter(row_annot, !!sym(self$pID) %in% lfqdata$data[[self$pID]] ) - self$row_annot <- row_annot - } else { - self$row_annot <- distinct(select(lfqdata$data, self$pID)) - } - - stopifnot(self$cleaned_ids %in% colnames(self$row_annot)) - stopifnot(self$description %in% colnames(self$row_annot)) - - if (!self$nr_children %in% colnames(row_annot) ) { - warning("no nr_children column specified, computing using nr_obs_experiment function") - self$row_annot <- inner_join( - self$row_annot, - nr_obs_experiment(lfqdata$data, lfqdata$config, name_nr_child = self$nr_children), - by = self$pID) - } - }, - #' @description - #' annotate rev sequences - #' @param pattern default "REV_" - annotate_decoys = function(pattern = "REV_") { - self$row_annot <- self$row_annot |> mutate( - REV = case_when(grepl(pattern, !!sym(self$pID), ignore.case = TRUE) ~ TRUE, - TRUE ~ FALSE)) - - return(sum(self$row_annot$REV)) - }, - #' @description - #' annotate contaminants - #' @param pattern default "^zz|^CON" - annotate_contaminants = function(pattern = "^zz|^CON") { - self$row_annot <- self$row_annot |> mutate( - CON = case_when(grepl(pattern, !!sym(self$pID), ignore.case = TRUE) ~ TRUE, - TRUE ~ FALSE)) - return(sum(self$row_annot$CON)) - }, - #' @description get number of neither contaminants nor decoys - #' @param contaminants remove contaminants - #' @param decoys remove decoys - #' return number of cleans - nr_clean = function(contaminants = TRUE, decoys = TRUE){ - - if (decoys && !("REV" %in% colnames(self$row_annot)) ) { stop("annotate REV") } - if (contaminants & !("CON" %in% colnames(self$row_annot)) ) { stop("annotate CON") } - - res <- if (decoys && contaminants) { - sum(!self$row_annot$REV & !self$row_annot$CON) - } else if (contaminants) { - sum(!self$row_annot$CON) - } else if (decoys) { - sum(!self$row_annot$REV) - } else { - nrow(self$row_annot) - } - return(res) - }, - #' @description remove REV and CON sequences - #' @param contaminants remove contaminants - #' @param decoys remove decoys - #' - clean = function(contaminants = TRUE, decoys = TRUE){ - if (contaminants && !("REV" %in% colnames(self$row_annot)) ) { stop("annotate REV") } - if (decoys && !("CON" %in% colnames(self$row_annot)) ) { stop("annotate CON") } - res <- if (decoys && contaminants) { - filter(self$row_annot , !self$row_annot$REV & !self$row_annot$CON ) - } else if (contaminants) { - filter(self$row_annot , !self$row_annot$CON) - } else if (decoys) { - filter(self$row_annot , !self$row_annot$REV ) - } else { - self$row_annot - } - return(res) - } - - ) - ) - diff --git a/man/LFQData.Rd b/man/LFQData.Rd index 22aecc32..743e1e09 100644 --- a/man/LFQData.Rd +++ b/man/LFQData.Rd @@ -64,8 +64,7 @@ Other LFQData: \code{\link{LFQDataStats}}, \code{\link{LFQDataSummariser}}, \code{\link{LFQDataToSummarizedExperiment}()}, -\code{\link{LFQDataWriter}}, -\code{\link{ProteinAnnotation}} +\code{\link{LFQDataWriter}} } \concept{LFQData} \section{Public fields}{ diff --git a/man/LFQDataAggregator.Rd b/man/LFQDataAggregator.Rd index ffd6c6fd..c21dbd31 100644 --- a/man/LFQDataAggregator.Rd +++ b/man/LFQDataAggregator.Rd @@ -53,8 +53,7 @@ Other LFQData: \code{\link{LFQDataStats}}, \code{\link{LFQDataSummariser}}, \code{\link{LFQDataToSummarizedExperiment}()}, -\code{\link{LFQDataWriter}}, -\code{\link{ProteinAnnotation}} +\code{\link{LFQDataWriter}} } \concept{LFQData} \section{Public fields}{ diff --git a/man/LFQDataPlotter.Rd b/man/LFQDataPlotter.Rd index b4a5a98a..00fe9bdf 100644 --- a/man/LFQDataPlotter.Rd +++ b/man/LFQDataPlotter.Rd @@ -54,8 +54,7 @@ Other LFQData: \code{\link{LFQDataStats}}, \code{\link{LFQDataSummariser}}, \code{\link{LFQDataToSummarizedExperiment}()}, -\code{\link{LFQDataWriter}}, -\code{\link{ProteinAnnotation}} +\code{\link{LFQDataWriter}} } \concept{LFQData} \keyword{static} diff --git a/man/LFQDataStats.Rd b/man/LFQDataStats.Rd index 7e2ca682..5ee310c3 100644 --- a/man/LFQDataStats.Rd +++ b/man/LFQDataStats.Rd @@ -71,8 +71,7 @@ Other LFQData: \code{\link{LFQDataPlotter}}, \code{\link{LFQDataSummariser}}, \code{\link{LFQDataToSummarizedExperiment}()}, -\code{\link{LFQDataWriter}}, -\code{\link{ProteinAnnotation}} +\code{\link{LFQDataWriter}} } \concept{LFQData} \section{Public fields}{ diff --git a/man/LFQDataSummariser.Rd b/man/LFQDataSummariser.Rd index 532853d1..8b596fef 100644 --- a/man/LFQDataSummariser.Rd +++ b/man/LFQDataSummariser.Rd @@ -36,8 +36,7 @@ Other LFQData: \code{\link{LFQDataPlotter}}, \code{\link{LFQDataStats}}, \code{\link{LFQDataToSummarizedExperiment}()}, -\code{\link{LFQDataWriter}}, -\code{\link{ProteinAnnotation}} +\code{\link{LFQDataWriter}} } \concept{LFQData} \section{Public fields}{ diff --git a/man/LFQDataToSummarizedExperiment.Rd b/man/LFQDataToSummarizedExperiment.Rd index 28afe940..0bbd217f 100644 --- a/man/LFQDataToSummarizedExperiment.Rd +++ b/man/LFQDataToSummarizedExperiment.Rd @@ -34,7 +34,6 @@ Other LFQData: \code{\link{LFQDataPlotter}}, \code{\link{LFQDataStats}}, \code{\link{LFQDataSummariser}}, -\code{\link{LFQDataWriter}}, -\code{\link{ProteinAnnotation}} +\code{\link{LFQDataWriter}} } \concept{LFQData} diff --git a/man/LFQDataWriter.Rd b/man/LFQDataWriter.Rd index 7744cc1c..8973614f 100644 --- a/man/LFQDataWriter.Rd +++ b/man/LFQDataWriter.Rd @@ -17,8 +17,7 @@ Other LFQData: \code{\link{LFQDataPlotter}}, \code{\link{LFQDataStats}}, \code{\link{LFQDataSummariser}}, -\code{\link{LFQDataToSummarizedExperiment}()}, -\code{\link{ProteinAnnotation}} +\code{\link{LFQDataToSummarizedExperiment}()} } \concept{LFQData} \section{Public fields}{ diff --git a/man/ProteinAnnotation.Rd b/man/ProteinAnnotation.Rd deleted file mode 100644 index 5cf59264..00000000 --- a/man/ProteinAnnotation.Rd +++ /dev/null @@ -1,183 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/ProteinAnnotation.R -\name{ProteinAnnotation} -\alias{ProteinAnnotation} -\title{Decorates LFQData with a row annotation and some protein specific functions.} -\description{ -Decorates LFQData with a row annotation and some protein specific functions. - -Decorates LFQData with a row annotation and some protein specific functions. -} -\examples{ - -istar <-prolfqua::sim_lfq_data_peptide_config() -lfqdata <- LFQData$new(istar$data, istar$config) -pannot <- ProteinAnnotation$new( lfqdata ) -pannot$annotate_decoys() -pannot$annotate_contaminants() -dd <- pannot$clean() -tmp <- lfqdata$get_subset(dd) -pannot$row_annot - -} -\seealso{ -Other LFQData: -\code{\link{LFQData}}, -\code{\link{LFQDataAggregator}}, -\code{\link{LFQDataPlotter}}, -\code{\link{LFQDataStats}}, -\code{\link{LFQDataSummariser}}, -\code{\link{LFQDataToSummarizedExperiment}()}, -\code{\link{LFQDataWriter}} -} -\concept{LFQData} -\section{Public fields}{ -\if{html}{\out{