Skip to content

Commit 46c510e

Browse files
authored
Merge pull request #15 from mpc-bioinformatics/testing
Testing
2 parents d234133 + 9eb9fe4 commit 46c510e

24 files changed

+755
-178
lines changed

R/helpers-get_protein_origin.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
#' For each protein node, get information about protein origin (contaminant, spike-in
44
#' or a specific species).
55
#'
6-
#' @param accessions character vector with protein accessions (inside a protein node), separated by ";"
7-
#' @param contaminants character vector of contaminant protein accessions
8-
#' @param spike_ins character vector of spike-in protein accessions
9-
#' @param organisms names list with character vectors of protein accessions for each organism
6+
#' @param accessions \strong{character vectors} \cr
7+
#' The protein accessions (inside a protein node), separated by ";".
8+
#' @param contaminants \strong{character vectors} \cr
9+
#' The contaminant protein accessions.
10+
#' @param spike_ins \strong{character vectors} \cr
11+
#' The spike-in protein accessions.
12+
#' @param organisms \strong{named list of character vectors} \cr
13+
#' Each organism with the corresponding protein accessions.
1014
#'
11-
#' @return character vector with protein origin for each protein accession
15+
#' @return A character vector with protein origin for each protein accession
1216
#' @export
1317
#'
1418
#' @examples # TODO
19+
1520
get_protein_origin <- function(accessions,
1621
contaminants = NULL,
1722
spike_ins = NULL,

R/helpers-isomorphisms.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ direct_bipartite_graph <- function(bip_graph, from_type = FALSE){
4848

4949

5050
# turn undirected into directed edges
51-
bip_graph <- igraph::as.directed(bip_graph, mode = "arbitrary")
51+
bip_graph <- igraph::as_directed(bip_graph, mode = "arbitrary")
5252

5353
from_vertices <- igraph::V(bip_graph)[igraph::V(bip_graph)$type == from_type]
5454
to_vertices <- igraph::V(bip_graph)[igraph::V(bip_graph)$type == !from_type]

R/plot_top10_iso_classes.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22

33
#' Plots the 10 most common isomorphism classes from a prototypelist
44
#'
5-
#' @param prototypelist prototype list, result of generatePrototypeList()
6-
#' @param out_file output file
7-
#' @param plot_height heigh of plot (in inches)
8-
#' @param plot_width width of plot (in inches)
5+
#' @param prototypelist \strong{bppg prototype list} \cr
6+
#' A prototype list, result of [bppg::generatePrototypeList()].
7+
#' @param out_file \strong{character} \cr
8+
#' The output file.
9+
#' @param plot_height \strong{numeric} \cr
10+
#' The heigh of plot (in inches).
11+
#' @param plot_width \strong{numeric} \cr
12+
#' The width of plot (in inches).
913
#'
10-
#' @return nothing, save plot as pdf
14+
#' @return Nothing, saves plot as pdf.
1115
#' @export
1216
#'
1317
#' @examples # TODO
18+
1419
plot_top10_iso_classes <- function(prototypelist, out_file, plot_height = 10, plot_width = 4) {
1520

1621
### sort prototypelist decreasing by counter

R/quant-iterated_Ci.R

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,37 @@
55

66
#' Iterate over possible Ci values
77
#'
8-
#' @param S list of biadjacency matrix (M) and
9-
#' @param grid.size number of grid points for the Cis
10-
#' @param omit_grid_borders if TRUE, omit exact value of 1 and 0 from the grid (recommended, as they may cause numerical issues)
11-
#' @param grid.start start of the grid (default is 0)
12-
#' @param grid.stop end of the grid (default is 1)
13-
#' @param verbose if TRUE, print additional information (see solnp function)
14-
#' @param verbose_opt verbose argument of the minimize_squared_error function
15-
#' @param control control object to be passed to minimize_squared_error
16-
#' @param extend_grid_at_borders extend the grid close to the borders (0 and 1). While exact values of 0 and 1 may cause numerical problems, values close to those may be valuable to get a better estimate of the protein ratios
17-
#' @param log_level passed to minimize_squared_error
8+
#' @param S \strong{list} \cr
9+
#' A list of biadjacency matrix of the bipartite peptide-protein graph (named "X")
10+
#' and measured peptide ratios (named "fc").
11+
#' @param grid.size \strong{integer} \cr
12+
#' The number of grid points for the Cis.
13+
#' @param omit_grid_borders \strong{logical} \cr
14+
#' If \code{TRUE}, omit exact value of 1 and 0 from the grid (recommended, as they may cause numerical issues).
15+
#' @param grid.start \strong{integer} \cr
16+
#' The start of the grid (default is 0).
17+
#' @param grid.stop \strong{integer} \cr
18+
#' The end of the grid (default is 1).
19+
#' @param verbose \strong{logical} \cr
20+
#' If \code{TRUE}, print additional information (see solnp function).
21+
#' @param verbose_opt \strong{logical} \cr
22+
#' The \code{verbose} argument of the [bppg::minimize_squared_error()] function.
23+
#' @param control \strong{list} \cr
24+
#' The \code{control} object to be passed to the [bppg::minimize_squared_error()] function.
25+
#' @param extend_grid_at_borders \strong{logical} \cr
26+
#' If \code{TRUE}, the grid will be extend close to the borders (0 and 1).
27+
#' While exact values of 0 and 1 may cause numerical problems,
28+
#' values close to those may be valuable to get a better estimate of the protein ratios.
29+
#' @param log_level \strong{logical} \cr
30+
#' The \code{log_level} argument will passed to the [bppg::minimize_squared_error()] function.
1831
#'
1932
#' @return
2033
#' A dataframe containing the optimal Ci and Ri values together with the reached minimal error term.
2134
#'
2235
#' @export
2336
#'
37+
#' @seealso [bppg::minimize_squared_error()], [bppg::automated_analysis_iterated_Ci()]
38+
#'
2439
#' @details
2540
#' With minimize_squared_error() each protein node receives one estimate for the protein ratio. However, in some cases, there are multiple possible values for the protein ratios that lead to the same, minimal error term.
2641
#' To get a better coverage of the optimal solutions, this function iterates over a grid of possible weights Ci for each protein node.
@@ -115,17 +130,32 @@ iterate_over_Ci <- function(S,
115130

116131
#' Extract protein ratio solutions from the result of iterate_over_Ci()
117132
#'
118-
#' @param S igraph object or list of biadjacency matrix (M) and fold changes (fc)
119-
#' @param res result of iterate_over_Ci()
120-
#' @param use_results_from_other_proteins if TRUE, use the results from other proteins within the same graph to calculate the optimal solution for each protein node
121-
#' @param verbose if TRUE, print additional information
122-
#' @param job job object from the BatchExperiment. Used to print the job id and parameters in the output
123-
#' @param S_is_graph set to TRUE,if S is an igraph object and FALSE if S is a list with the biadjacency matrix and fold changes
133+
#' @param S \strong{igraph graph object OR list} \cr
134+
#' An igraph graph of the bipartite peptide-protein graph with peptide ratios
135+
#' OR
136+
#' a list of the biadjacency matrix of the bipartite peptide-protein graph (named "X")
137+
#' and the measured peptide ratios (named "fc"). \cr
138+
#' Set \code{S_is_graph} depending on the input type.
139+
#' @param res \strong{list} \cr
140+
#' The list resulting from the [bppg::iterate_over_Ci()] function.
141+
#' @param use_results_from_other_proteins \strong{logical} \cr
142+
#' If \code{TRUE}, the results from other proteins within the same graph will be used
143+
#' to calculate the optimal solution for each protein node.
144+
#' @param verbose \strong{logical} \cr
145+
#' If \code{TRUE}, additional information will be printed.
146+
#' @param job \strong{BatchExperiment job object} \cr
147+
#' Is used to print the job id and parameters in the output
148+
#' @param S_is_graph \strong{logical} \cr
149+
#' If \code{TRUE}, S is an igraph object and
150+
#' if \code{FALSE} S is a list with the biadjacency matrix and fold changes.
124151
#'
125-
#' @return data frame
152+
#' @return A data frame
126153
#' @export
127154
#'
155+
#' @seealso [bppg::iterate_over_Ci()], [bppg::minimize_squared_error()]
156+
#'
128157
#' @examples # TODO
158+
129159
automated_analysis_iterated_Ci <- function(S,
130160
res,
131161
use_results_from_other_proteins = FALSE,

R/quant-minimize_squared_error.R

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11

22
#' Function to set up the equations for the optimization problem
33
#'
4-
#' @param Ri vector containing protein ratios (estimated)
5-
#' @param Ci vector contraining protein weights (estimated, sum up to 1)
6-
#' @param M biadjaceny matrix of the corresponding graphs
7-
#' @param rj vector containing the measured peptide ratios
8-
#' @param log_level if TRUE, the Ri are given on log2-level and need to be back-transformed here (this may allow a symmetric behaviour during optimization)
4+
#' @param Ri \strong{numeric vector} \cr
5+
#' Contains the (estimated) protein ratios.
6+
#' @param Ci \strong{numeric vector} \cr
7+
#' Contains the protein weights (estimated, sum up to 1)
8+
#' @param M \strong{matrix} \cr
9+
#' The biadjaceny matrix of the corresponding graphs.
10+
#' @param rj \strong{numeric vector} \cr
11+
#' Contains the measured peptide ratios.
12+
#' @param log_level \strong{logical} \cr
13+
#' If \code{TRUE}, the Ri are given on log2-level and need to be back-transformed here (this may allow a symmetric behaviour during optimization)
914
#'
1015
#' @return list containing the following elements:
1116
#' \item{res_Mat}{matrix containing the estimated peptide ratios using Ri and Ci}
@@ -53,13 +58,21 @@ equation <- function(Ri,
5358

5459
#' Function to set up the optimization problem and minimize the sum of squared error terms
5560
#'
56-
#' @param S list of biadjacency matrix of the bipartite peptide-protein graph (X) and measured peptide ratios (fc)
57-
#' @param fixed.Ci vector of fixed protein weights, variable weights set as NA. Sum of fixed weights must not exceed 1. If NULL, all Cis will be considered as variable. This argument is needed to fix Ci on a grid point in the iterated_Ci function.
58-
#' @param verbose if TRUE, additional information on each iteration of the optimization is printed (see also rsolnp function in package Rsolnp)
59-
#' @param reciprocal if TRUE, the reciprocal of the peptide ratios is used for the optimization
60-
#' @param log_level if TRUE, the Ri are log2-transformed before optimization, allowing a symmetric consideration of Ri < 0 and > 0.
61-
#' @param control control parameters for solnp
62-
#' @param ... additional parameters to solnp
61+
#' @param S \strong{list} \cr
62+
#' A list of biadjacency matrix of the bipartite peptide-protein graph (X) and measured peptide ratios (fc).
63+
#' @param fixed.Ci \strong{numeric vector} \cr
64+
#' The fixed protein weights, variable weights set as NA. Sum of fixed weights must not exceed 1.
65+
#' If NULL, all Cis will be considered as variable.
66+
#' This argument is needed to fix Ci on a grid point in the iterated_Ci function.
67+
#' @param verbose \strong{logical} \cr
68+
#' If \code{TRUE}, additional information on each iteration of the optimization is printed (see also rsolnp function in package Rsolnp).
69+
#' @param reciprocal \strong{logical} \cr
70+
#' If \code{TRUE}, the reciprocal of the peptide ratios is used for the optimization.
71+
#' @param log_level \strong{logical} \cr
72+
#' If \code{TRUE}, the Ri are log2-transformed before optimization, allowing a symmetric consideration of Ri < 0 and > 0.
73+
#' @param control \strong{list} \cr
74+
#' The control parameters for solnp.
75+
#' @param ... Additional parameters to solnp.
6376
#'
6477
#' @return list containing the following elements:
6578
#' \item{Ri}{estimated protein ratios}

R/quant-protein_elimination.R

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
11

22
#' Tries to recursively remove protein nodes from graph while keeping the error term in the optimization step low
33
#'
4-
#' @param G igraph object
5-
#' @param threshold threshold for increase of error term, default 1.05 refers to 5% increase
6-
#' @param iter iteration (this is a recursive function)
7-
#' @param min_error_ref minimal error term with all available protein nodes
8-
#' @param min_error_current current minimal error term
9-
#' @param protein_nodes_list current list of protein nodes
10-
#' @param combination_list list of node combinations
11-
#' @param error_list list of error terms
12-
#' @param comb_current current combination of protein nodes
13-
#' @param G_current current graph (with removed protein nodes)
14-
#' @param n_comb_current current number of protein nodes
4+
#' @param G \strong{igraph graph object} \cr
5+
#' The graph to eliminate the proteins in.
6+
#' @param threshold \strong{numeric} \cr
7+
#' The threshold for increase of error term.
8+
#' The default 1.05 refers to 5% increase.
9+
#' @param iter \strong{numeric} \cr
10+
#' The iteration (this is a recursive function).
11+
#' @param min_error_ref \strong{numeric} \cr
12+
#' The minimal error term with all available protein nodes.
13+
#' \code{min_error_ref} is assigned automatically.
14+
#' @param min_error_current \strong{numeric} \cr
15+
#' The current minimal error term.
16+
#' \code{min_error_current} is assigned automatically.
17+
#' @param protein_nodes_list \strong{igraph node list} \cr
18+
#' A current list of protein nodes.
19+
#' @param combination_list \strong{character vector} \cr
20+
#' A list of node combinations.
21+
#' For \code{iter == 0}, \code{combination_list} is assigned automatically.
22+
#' @param error_list \strong{numeric vector} \cr
23+
#' A list of error terms.
24+
#' @param comb_current \strong{?} \cr
25+
#' The current combination of protein nodes.
26+
#' \code{comb_current} is assigned automatically.
27+
#' @param G_current \strong{igraph graph object} \cr
28+
#' The current graph (with removed protein nodes).
29+
#' \code{G_current} is assigned automatically.
30+
#' @param n_comb_current \strong{integer} \cr
31+
#' The current number of protein nodes.
32+
#' For \code{iter == 0}, \code{n_comb_current} is assigned automatically.
1533
#'
1634
#' @return list
1735
#' @export
1836
#'
37+
#' @seealso [bppg::minimize_squared_error()]
38+
#'
1939
#' @examples # TODO
40+
2041
protein_elimination <- function(G,
2142
threshold = 1.05,
2243
iter = 0,

R/tables-proteinnode_info.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11

22
#' Table with information on each protein node
33
#'
4-
#' @param G list of list of igraph objects: graphs with collapsed protein and peptide nodes
4+
#' @param G \strong{list of list of igraph objects} \cr
5+
#' The graphs with collapsed protein and peptide nodes.
56
#'
6-
#' @return data frame with information on
7+
#' @return A data frame with information on number of unique/shared peptides.
78
#' @export
89
#'
10+
#' @seealso For the generation of the list of lists of igraphs: [generate_graphs_from_quant_data()]
11+
#'
912
#' @examples # TODO
13+
1014
calculate_proteinnode_info <- function(G) {
1115

1216
G2 <- lapply(G, function(x) {

man/automated_analysis_iterated_Ci.Rd

Lines changed: 22 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/calculate_proteinnode_info.Rd

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/equation.Rd

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)