Skip to content

Commit 9931542

Browse files
committed
Lot's of small changes to satisfy BiocCheck
1 parent cf380d3 commit 9931542

27 files changed

+281
-14
lines changed

DESCRIPTION

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: proDA
22
Type: Package
33
Title: Differential Abundance Analysis of Label-Free Mass Spectrometry Data
4-
Version: 0.0.0.9000
4+
Version: 0.99.0
55
Authors@R: c(person("Constantin", "Ahlmann-Eltze", email = "[email protected]", role = c("aut", "cre")),
66
person("Simon", "Anders", email="[email protected]", role="ths"))
77
Description: Account for missing values in label-free mass spectrometry data
@@ -37,4 +37,6 @@ Imports:
3737
extraDistr
3838
URL: https://github.com/const-ae/proDA
3939
BugReports: https://github.com/const-ae/proDA/issues
40+
biocViews: Proteomics, MassSpectrometry, DifferentialExpression,
41+
Bayesian, Regression, Software, Normalization, QualityControl
4042
VignetteBuilder: knitr

R/AllGenerics.R

+66
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
#' @param object the object to get from
77
#' @param ... additional arguments used by the concrete implementation
88
#'
9+
#' @examples
10+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
11+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
12+
#' abundances(fit)
13+
#'
14+
#' @return the original matrix that was fitted
15+
#'
916
#' @seealso \link{accessor_methods} for the implementation for a 'proDAFit' object
1017
#' @export
1118
setGeneric("abundances", function(object, ...) standardGeneric("abundances"))
@@ -15,6 +22,13 @@ setGeneric("abundances", function(object, ...) standardGeneric("abundances"))
1522
#' @param object the object to get from
1623
#' @param ... additional arguments used by the concrete implementation
1724
#'
25+
#' @return a list with the values for each fitted hyper-parameter
26+
#'
27+
#' @examples
28+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
29+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
30+
#' hyper_parameters(fit)
31+
#'
1832
#' @seealso \link{accessor_methods} for the implementation for a 'proDAFit' object
1933
#' @export
2034
setGeneric("hyper_parameters", function(object, ...) standardGeneric("hyper_parameters"))
@@ -24,6 +38,13 @@ setGeneric("hyper_parameters", function(object, ...) standardGeneric("hyper_para
2438
#' @param object the object to get from
2539
#' @param ... additional arguments used by the concrete implementation
2640
#'
41+
#' @return a data.frame with information on each fit
42+
#'
43+
#' @examples
44+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
45+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
46+
#' feature_parameters(fit)
47+
#'
2748
#' @seealso \link{accessor_methods} for the implementation for a 'proDAFit' object
2849
#' @export
2950
setGeneric("feature_parameters", function(object, ...) standardGeneric("feature_parameters"))
@@ -33,6 +54,13 @@ setGeneric("feature_parameters", function(object, ...) standardGeneric("feature_
3354
#' @param object the object to get from
3455
#' @param ... additional arguments used by the concrete implementation
3556
#'
57+
#' @return a numeric matrix of size `nrow(fit) * p`
58+
#'
59+
#' @examples
60+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
61+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
62+
#' coefficients(fit)
63+
#'
3664
#' @seealso \link{accessor_methods} for the implementation for a 'proDAFit' object
3765
#' @export
3866
setGeneric("coefficients", function(object, ...) standardGeneric("coefficients"))
@@ -42,6 +70,14 @@ setGeneric("coefficients", function(object, ...) standardGeneric("coefficients")
4270
#' @param object the object to get from
4371
#' @param ... additional arguments used by the concrete implementation
4472
#'
73+
#' @return a list with as many entries as rows in the data. Each element is
74+
#' a p*p matrix
75+
#'
76+
#' @examples
77+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
78+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
79+
#' coefficient_variance_matrices(fit)
80+
#'
4581
#' @seealso \link{accessor_methods} for the implementation for a 'proDAFit' object
4682
#' @export
4783
setGeneric("coefficient_variance_matrices", function(object, ...) standardGeneric("coefficient_variance_matrices"))
@@ -51,6 +87,14 @@ setGeneric("coefficient_variance_matrices", function(object, ...) standardGeneri
5187
#'
5288
#' @param object the object to get from
5389
#' @param ... additional arguments used by the concrete implementation
90+
#'
91+
#' @return a string
92+
#'
93+
#' @examples
94+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
95+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
96+
#' reference_level(fit)
97+
#'
5498
#' @seealso \link{accessor_methods} for the implementation for a 'proDAFit' object
5599
#' @export
56100
setGeneric("reference_level", function(object, ...) standardGeneric("reference_level"))
@@ -61,6 +105,13 @@ setGeneric("reference_level", function(object, ...) standardGeneric("reference_l
61105
#' @param object the object to get from
62106
#' @param ... additional arguments used by the concrete implementation
63107
#'
108+
#' @return a list with information on the convergence
109+
#'
110+
#' @examples
111+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
112+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
113+
#' convergence(fit)
114+
#'
64115
#' @seealso \link{accessor_methods} for the implementation for a 'proDAFit' object
65116
#' @export
66117
setGeneric("convergence", function(object, ...) standardGeneric("convergence"))
@@ -71,6 +122,14 @@ setGeneric("convergence", function(object, ...) standardGeneric("convergence"))
71122
#' @param object the object for which the distance is approximated
72123
#' @param ... additional arguments used by the concrete implementation
73124
#'
125+
#' @return a list with two elements: `mean` and `sd` both are formally
126+
#' of class "dist"
127+
#'
128+
#' @examples
129+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
130+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
131+
#' dist_approx(fit)
132+
#'
74133
#' @seealso \code{\link[stats]{dist}} for the base R function and
75134
#' \code{\link[proDA:dist_approx,proDAFit-method]{dist_approx()}} concrete implementation
76135
#' for 'proDAFit' objects
@@ -83,6 +142,13 @@ setGeneric("dist_approx", function(object, ...) standardGeneric("dist_approx"))
83142
#' @param fit the fit to get the result_names from
84143
#' @param ... additional arguments used by the concrete implementation
85144
#'
145+
#' @return a character vector
146+
#'
147+
#' @examples
148+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
149+
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
150+
#' result_names(fit)
151+
#'
86152
#' @export
87153
setGeneric("result_names", function(fit, ...) standardGeneric("result_names"))
88154

R/calculate_distance.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ dist_approx_mean_var <- function(Y, Pred, X, coef_var, by_sample = FALSE){
7676
Pred)
7777

7878
Pred_var <- mply_dbl(seq_len(nrow(Y)), function(i){
79-
sapply(seq_len(nrow(X)), function(j) t(X[j,]) %zero_dom_mat_mult% coef_var[[i]] %zero_dom_mat_mult% X[j,])
79+
vapply(seq_len(nrow(X)), function(j) t(X[j,]) %zero_dom_mat_mult% coef_var[[i]] %zero_dom_mat_mult% X[j,],
80+
FUN.VALUE = 0.0)
8081
}, ncol=ncol(Y))
8182
Mu_var <- ifelse(! is.na(Y),
8283
0,

R/generate_synthetic_data.R

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
#' if \code{return_summarized_experiment} is \code{FALSE}. Otherwise
5050
#' returns a \code{SummarizedExperiment} with the same information.
5151
#'
52+
#' @examples
53+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
54+
#' names(syn_data)
55+
#' se <- generate_synthetic_data(n_proteins = 10, return_summarized_experiment = TRUE)
56+
#' se
57+
#'
5258
#' @export
5359
generate_synthetic_data <- function(n_proteins, n_conditions = 2,
5460
n_replicates = 3,

R/methods.R

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#' to get the formula that was used to create the linear model.
1313
#' If no formula was used \code{NULL} is returned.
1414
#'
15+
#' @return See the documentation of the generics to find out what each method returns
16+
#'
1517
#' @name accessor_methods
1618
NULL
1719

R/normalization.R

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
#'
1414
#' @param X a matrix of proteins and samples
1515
#' @return the normalized matrix
16+
#'
17+
#' @examples
18+
#' syn_data <- generate_synthetic_data(n_proteins = 10)
19+
#' normalized_data <- median_normalization(syn_data$Y)
20+
#' normalized_data
21+
#'
1622
#' @export
1723
median_normalization <- function(X){
1824
stopifnot(length(dim(X)) == 2)
1925
Xnorm <- X
20-
for(idx in 1:ncol(X)){
26+
for(idx in seq_len(ncol(X))){
2127
Xnorm[, idx] <- X[, idx, drop=FALSE] -
2228
median(X[, idx, drop=FALSE] - rowMeans(X, na.rm=TRUE), na.rm=TRUE )
2329
}

R/proDA.R

+12-4
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ if(getRversion() >= "2.15.1") utils::globalVariables(c("Condition1", "Condition
108108
#' @examples
109109
#'
110110
#' # Quick start
111+
#'
112+
#' # Import the proDA package if you haven't already done so
113+
#' # library(proDA)
111114
#' set.seed(1)
112-
#' library(proDA)
113115
#' syn_data <- generate_synthetic_data(n_proteins = 10)
114116
#' fit <- proDA(syn_data$Y, design = syn_data$groups)
115117
#' fit
@@ -295,7 +297,9 @@ fit_parameters_loop <- function(Y, model_matrix, location_prior_df,
295297
})
296298
Pred_init <- msply_dbl(res_init, function(x) x$coefficients) %*% t(model_matrix)
297299
Pred_init_var <- mply_dbl(seq_len(nrow(Y)), function(i){
298-
sapply(seq_len(nrow(model_matrix)), function(j) t(model_matrix[j,]) %*% res_init[[i]]$coef_variance_matrix %*% model_matrix[j,])
300+
vapply(seq_len(nrow(model_matrix)), function(j)
301+
t(model_matrix[j,]) %*% res_init[[i]]$coef_variance_matrix %*% model_matrix[j,],
302+
FUN.VALUE = 0.0)
299303
}, ncol=ncol(Y))
300304
s2_init <- vapply(res_init, function(x) x[["s2"]], 0.0)
301305
df_init <- vapply(res_init, function(x) x[["df"]], 0.0)
@@ -355,10 +359,14 @@ fit_parameters_loop <- function(Y, model_matrix, location_prior_df,
355359
Pred_unreg <- msply_dbl(res_unreg, function(x) x$coefficients) %zero_dom_mat_mult% t(model_matrix)
356360
Pred_reg <- msply_dbl(res_reg, function(x) x$coefficients) %zero_dom_mat_mult% t(model_matrix)
357361
Pred_var_unreg <- mply_dbl(seq_len(nrow(Y)), function(i){
358-
sapply(seq_len(nrow(model_matrix)), function(j) t(model_matrix[j,]) %zero_dom_mat_mult% res_unreg[[i]]$coef_variance_matrix %zero_dom_mat_mult% model_matrix[j,])
362+
vapply(seq_len(nrow(model_matrix)), function(j)
363+
t(model_matrix[j,]) %zero_dom_mat_mult% res_unreg[[i]]$coef_variance_matrix %zero_dom_mat_mult% model_matrix[j,],
364+
FUN.VALUE = 0.0)
359365
}, ncol=ncol(Y))
360366
Pred_var_reg <- mply_dbl(seq_len(nrow(Y)), function(i){
361-
sapply(seq_len(nrow(model_matrix)), function(j) t(model_matrix[j,]) %zero_dom_mat_mult% res_reg[[i]]$coef_variance_matrix %zero_dom_mat_mult% model_matrix[j,])
367+
vapply(seq_len(nrow(model_matrix)), function(j)
368+
t(model_matrix[j,]) %zero_dom_mat_mult% res_reg[[i]]$coef_variance_matrix %zero_dom_mat_mult% model_matrix[j,],
369+
FUN.VALUE = 0.0)
362370
}, ncol=ncol(Y))
363371
s2_unreg <- vapply(res_unreg, function(x) x[["s2"]], 0.0)
364372
df_unreg <-vapply(res_unreg, function(x) x[["df"]], 0.0)

R/stats_functions.R

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ invprobit <- function(x, rho, zeta, log=FALSE, oneminus=FALSE){
5454
}
5555

5656
#' Same thing as invprobit, but without the parameter validation
57+
#'
58+
#' @return a numeric vector of \code{length(x)}
59+
#'
5760
#' @keywords internal
5861
invprobit_fast <- function(x, rho, zeta, log=FALSE, oneminus=FALSE){
5962
sign_sum <- sum(sign(zeta), na.rm=TRUE)

R/util.R

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ msply_dbl <- function(x, FUN, ...){
7979

8080
#' Helper function that makes sure that NA * 0 = 0 in matrix multiply
8181
#'
82+
#' @param X a matrix of size `n*m`
83+
#' @param Y a matrix of size `m*p`
84+
#'
85+
#' @return a matrix of size `n*p`
86+
#'
8287
#' @keywords internal
8388
`%zero_dom_mat_mult%` <- function(X, Y){
8489
X[is.infinite(X)] <- NA

README.Rmd

+8-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,14 @@ test_res
339339
This walkthrough ends with the identification which proteins are differentially abundant. But for
340340
a real dataset, now the actual analysis only just begins. A list of significant proteins is hardly
341341
ever a publishable result, we need to make sense what the underlying biological mechanisms are. The
342-
precise question that should be asked very much dependent on the biological problem, but some
343-
helpful tool are gene ontology (GO) term analysis, set enrichment tests, and
342+
precise question that should be asked very much dependent on the biological problem.
343+
344+
345+
# Session Info
346+
347+
```{r}
348+
sessionInfo()
349+
```
344350

345351

346352

README.md

+45-2
Original file line numberDiff line numberDiff line change
@@ -433,5 +433,48 @@ differentially abundant. But for a real dataset, now the actual analysis
433433
only just begins. A list of significant proteins is hardly ever a
434434
publishable result, we need to make sense what the underlying biological
435435
mechanisms are. The precise question that should be asked very much
436-
dependent on the biological problem, but some helpful tool are gene
437-
ontology (GO) term analysis, set enrichment tests, and
436+
dependent on the biological problem.
437+
438+
# Session Info
439+
440+
``` r
441+
sessionInfo()
442+
#> R version 3.6.0 (2019-04-26)
443+
#> Platform: x86_64-pc-linux-gnu (64-bit)
444+
#> Running under: Ubuntu 18.04.2 LTS
445+
#>
446+
#> Matrix products: default
447+
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
448+
#> LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
449+
#>
450+
#> locale:
451+
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=de_DE.UTF-8
452+
#> [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8
453+
#> [7] LC_PAPER=de_DE.UTF-8 LC_NAME=C LC_ADDRESS=C
454+
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
455+
#>
456+
#> attached base packages:
457+
#> [1] stats graphics grDevices utils datasets methods base
458+
#>
459+
#> other attached packages:
460+
#> [1] proDA_0.0.0.9000
461+
#>
462+
#> loaded via a namespace (and not attached):
463+
#> [1] Rcpp_1.0.1 RColorBrewer_1.1-2 pillar_1.3.1
464+
#> [4] compiler_3.6.0 GenomeInfoDb_1.20.0 XVector_0.24.0
465+
#> [7] bitops_1.0-6 tools_3.6.0 zlibbioc_1.30.0
466+
#> [10] digest_0.6.18 gtable_0.3.0 evaluate_0.13
467+
#> [13] tibble_2.1.1 lattice_0.20-38 pkgconfig_2.0.2
468+
#> [16] rlang_0.3.4 Matrix_1.2-17 cli_1.1.0
469+
#> [19] DelayedArray_0.10.0 rstudioapi_0.10 yaml_2.2.0
470+
#> [22] parallel_3.6.0 xfun_0.6 GenomeInfoDbData_1.2.1
471+
#> [25] stringr_1.4.0 extraDistr_1.8.10 knitr_1.22
472+
#> [28] S4Vectors_0.22.0 IRanges_2.18.0 stats4_3.6.0
473+
#> [31] grid_3.6.0 Biobase_2.44.0 fansi_0.4.0
474+
#> [34] BiocParallel_1.18.0 rmarkdown_1.12 pheatmap_1.0.12
475+
#> [37] magrittr_1.5 scales_1.0.0 htmltools_0.3.6
476+
#> [40] matrixStats_0.54.0 BiocGenerics_0.30.0 GenomicRanges_1.36.0
477+
#> [43] assertthat_0.2.1 SummarizedExperiment_1.14.0 colorspace_1.4-1
478+
#> [46] utf8_1.1.4 stringi_1.4.3 munsell_0.5.0
479+
#> [49] RCurl_1.95-4.12 crayon_1.3.4
480+
```

man/abundances.Rd

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/accessor_methods.Rd

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/coefficient_variance_matrices.Rd

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/coefficients.Rd

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)