From 34bfd0add1adc82e68c51d139d064211e5ca5f11 Mon Sep 17 00:00:00 2001 From: Witold Wolski Date: Thu, 23 May 2024 18:29:58 +0200 Subject: [PATCH] moved ProteinAnnotation to prolfquapp --- NAMESPACE | 1 - R/ProteinAnnotation.R | 125 ------------------ man/LFQData.Rd | 3 +- man/LFQDataAggregator.Rd | 3 +- man/LFQDataPlotter.Rd | 3 +- man/LFQDataStats.Rd | 3 +- man/LFQDataSummariser.Rd | 3 +- man/LFQDataToSummarizedExperiment.Rd | 3 +- man/LFQDataWriter.Rd | 3 +- man/ProteinAnnotation.Rd | 183 --------------------------- 10 files changed, 7 insertions(+), 323 deletions(-) delete mode 100644 R/ProteinAnnotation.R delete mode 100644 man/ProteinAnnotation.Rd diff --git a/NAMESPACE b/NAMESPACE index db39276ae..b25f6c6fc 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 417a54342..000000000 --- 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 22aecc329..743e1e096 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 ffd6c6fd2..c21dbd31c 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 b4a5a98a2..00fe9bdfa 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 7e2ca682b..5ee310c30 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 532853d16..8b596fef8 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 28afe9406..0bbd217f8 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 7744cc1c3..8973614fc 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 5cf592644..000000000 --- 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{
}} -\describe{ -\item{\code{row_annot}}{data.frame containing further information} - -\item{\code{pID}}{column with protein ids} - -\item{\code{description}}{name of column containing descriptions} - -\item{\code{cleaned_ids}}{vector with columns containing addition IDs} - -\item{\code{nr_children}}{name of columns with the number of peptides} -} -\if{html}{\out{
}} -} -\section{Methods}{ -\subsection{Public methods}{ -\itemize{ -\item \href{#method-ProteinAnnotation-new}{\code{ProteinAnnotation$new()}} -\item \href{#method-ProteinAnnotation-annotate_decoys}{\code{ProteinAnnotation$annotate_decoys()}} -\item \href{#method-ProteinAnnotation-annotate_contaminants}{\code{ProteinAnnotation$annotate_contaminants()}} -\item \href{#method-ProteinAnnotation-nr_clean}{\code{ProteinAnnotation$nr_clean()}} -\item \href{#method-ProteinAnnotation-clean}{\code{ProteinAnnotation$clean()}} -\item \href{#method-ProteinAnnotation-clone}{\code{ProteinAnnotation$clone()}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-ProteinAnnotation-new}{}}} -\subsection{Method \code{new()}}{ -initialize -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{ProteinAnnotation$new( - lfqdata, - row_annot = NULL, - description = NULL, - ids = NULL, - nr_children = "nr_peptides" -)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{lfqdata}}{data frame from \code{\link{setup_analysis}}} - -\item{\code{row_annot}}{data frame with row annotation. Must have columns matching \code{config$table$hierarchy_keys_depth()}} - -\item{\code{description}}{name of column with description} - -\item{\code{ids}}{names of columns with cleaned Ids} - -\item{\code{nr_children}}{column with the number of children} - -\item{\code{nr_peptides}}{additional peptides} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-ProteinAnnotation-annotate_decoys}{}}} -\subsection{Method \code{annotate_decoys()}}{ -annotate rev sequences -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{ProteinAnnotation$annotate_decoys(pattern = "REV_")}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{pattern}}{default "REV_"} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-ProteinAnnotation-annotate_contaminants}{}}} -\subsection{Method \code{annotate_contaminants()}}{ -annotate contaminants -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{ProteinAnnotation$annotate_contaminants(pattern = "^zz|^CON")}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{pattern}}{default "^zz|^CON"} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-ProteinAnnotation-nr_clean}{}}} -\subsection{Method \code{nr_clean()}}{ -get number of neither contaminants nor decoys -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{ProteinAnnotation$nr_clean(contaminants = TRUE, decoys = TRUE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{contaminants}}{remove contaminants} - -\item{\code{decoys}}{remove decoys -return number of cleans} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-ProteinAnnotation-clean}{}}} -\subsection{Method \code{clean()}}{ -remove REV and CON sequences -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{ProteinAnnotation$clean(contaminants = TRUE, decoys = TRUE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{contaminants}}{remove contaminants} - -\item{\code{decoys}}{remove decoys} -} -\if{html}{\out{
}} -} -} -\if{html}{\out{
}} -\if{html}{\out{}} -\if{latex}{\out{\hypertarget{method-ProteinAnnotation-clone}{}}} -\subsection{Method \code{clone()}}{ -The objects of this class are cloneable with this method. -\subsection{Usage}{ -\if{html}{\out{
}}\preformatted{ProteinAnnotation$clone(deep = FALSE)}\if{html}{\out{
}} -} - -\subsection{Arguments}{ -\if{html}{\out{
}} -\describe{ -\item{\code{deep}}{Whether to make a deep clone.} -} -\if{html}{\out{
}} -} -} -}