Skip to content

Commit 645e1cd

Browse files
committed
clean up
1 parent 6137685 commit 645e1cd

File tree

4 files changed

+35
-36
lines changed

4 files changed

+35
-36
lines changed

R/PCA_helper.R

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' A method for filtering the data for PCA.
2-
#'
3-
#'
2+
#'
3+
#'
44
#' @param D \strong{data.frame} \cr
55
#' The data set containing intensities of the sample.
66
#' @param impute \strong{logical} \cr
@@ -9,23 +9,26 @@
99
#' The imputation method. Options are "mean" or "median".
1010
#' @param propNA \strong{numeric} \cr
1111
#' The proportion of allowed missing NAs for a protein, before it is discarded.
12-
#'
13-
#'
12+
#'
13+
#'
1414
#' @return The filtered data.
15-
#'
15+
#' @examples
16+
#'
17+
#'
18+
#'
1619

1720
filter_PCA_data <- function(D, impute = FALSE, impute_method = "mean", propNA = 0){
18-
21+
1922
# proportion if missing values per protein
2023
mean_NA <- apply(D, 1, function(x) mean(is.na(x)))
2124

2225
### remove rows with too many missing values
2326
D <- D[mean_NA <= propNA, ]
24-
27+
2528
if (nrow(D) == 0){
2629
return(NULL)
2730
}
28-
31+
2932
## perform imputation
3033
if (impute) {
3134
D <- as.data.frame(t(apply(D, 1, function(x) {
@@ -35,20 +38,20 @@ filter_PCA_data <- function(D, impute = FALSE, impute_method = "mean", propNA =
3538
}
3639
return(x)
3740
})))
38-
39-
41+
42+
4043
} else {
4144
D <- stats::na.omit(D)
4245
if (nrow(D) == 0){
4346
return(NULL)
4447
}
4548
}
46-
49+
4750
### remove proteins/peptides with an (almost) constant value (variance near zero)
4851
v <- matrixStats::rowVars(as.matrix(D))
4952
ind_zeroVar <- which(v < 1e-25)
5053
if (length(ind_zeroVar) > 0) D <- D[-ind_zeroVar,]
51-
54+
5255
return(D)
5356
}
5457

R/WIP_Clustering_Heatmap_Lineplots.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' @param dist_method distance method for clustering, default is "correlation"
1111
#'
1212
#' @return save heatmap and data frame with cluster information, as well as line plots
13-
#' @export
13+
#'
1414
#'
1515
#' @examples # TODO
1616
Clustering_heatmap_lineplots2 <- function(D, id, output_path, suffix = "", nr_clusters = NULL, row_split = TRUE, dist_method = "correlation") {

R/automatedNormalization.R

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,57 @@
1313
#'
1414
#' @return The normalized data as well as a message.
1515
#' @export
16+
#' @examples
1617
#'
1718

18-
automatedNormalization <- function(DATA,
19-
method = "median",
19+
automatedNormalization <- function(DATA,
20+
method = "median",
2021
is_log_transformed = TRUE,
2122
log_base = 2,
2223
lts.quantile = 0.8){
23-
24+
2425
mess <- ""
25-
26+
2627
if(method == "loess" | method == "quantile" | method == "median"){
27-
28+
2829
#### choose normalization function
2930
fun <- switch(method,
3031
"loess" = limma::normalizeBetweenArrays,
3132
"quantile" = limma::normalizeBetweenArrays,
3233
"median" = limma::normalizeBetweenArrays)
33-
34+
3435
### choose arguments for normalization function
3536
args <- switch(method,
3637
"loess" = list(object = DATA, method = "cyclicloess"),
3738
"quantile" = list(object = DATA, method = "quantile"),
3839
"median" = list(object = DATA, method = "scale"))
39-
40-
40+
41+
4142
DATA_norm <- do.call(fun, args)
4243
DATA_norm <- as.data.frame(DATA_norm)
43-
44+
4445
mess <- paste0(mess, "Data successfully ", method ," normalized. \n")
45-
46+
4647
}
47-
48+
4849
if (method == "lts") {
49-
50+
5051
### reverse log-transformation, if data is log-transformed
51-
if(is_log_transformed){
52+
if(is_log_transformed){
5253
DATA <- log_base^DATA
5354
}
54-
55+
5556
DATA_norm <- vsn::vsn2(as.matrix(DATA), lts.quantile = lts.quantile)
5657
DATA_norm <- DATA_norm@hx
5758
DATA_norm <- as.data.frame(DATA_norm)
5859
mess <- paste0(mess, "Data successfully lts normalized. \n")
5960
}
60-
61+
6162
if (method == "nonorm") {
6263
DATA_norm <- DATA
6364
mess <- paste0(mess, "Data successfully not normalized. \n")
6465
}
65-
66+
6667
return(list("data" = DATA_norm, "message" = mess))
67-
68-
}
68+
69+
}

R/workflow_ANOVA.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
3-
4-
5-
61
#' The workflow for ANOVA of quantitative proteomics data
72
#'
83
#' @param data_path \strong{character} \cr

0 commit comments

Comments
 (0)