comparison additional_functions_block_splsda.R @ 1:e93350dc99f1 draft

"planemo upload for repository https://gitlab.com/bilille/galaxy-viscorvar commit 1eda261d4fe137d6e8806b0c6af7eaf12d11ac95"
author ppericard
date Thu, 15 Oct 2020 12:22:25 +0000
parents d0b77b926863
children
comparison
equal deleted inserted replaced
0:d0b77b926863 1:e93350dc99f1
1 #' @title Check if a block contains missing values
2 #' @description Check if a block contains missing values
3 #' @param list_X type : list of matrix. This list is used to perform the data integration.
4 #' @details This function checks if a block contains missing values.
5 #' @return type : boolean. If at least one block contains missing values,
6 #' this function returns TRUE, otherwise this function returns FALSE.
7 #' @examples
8 #' X1 = matrix(1:9, nrow = 3, ncol = 3)
9 #' X2 = matrix(10:18, nrow = 3, ncol = 3)
10 #' list_X = list()
11 #' list_X[[1]] = X1
12 #' list_X[[2]] = X2
13 #' names(list_X) = c("X1", "X2")
14 #' boolean_block_missing_values = blockMissingValues(list_X)
15 #' @export
16 blockMissingValues <-function(list_X)
17 {
18 name_blocks = names(list_X)
19 name_blocks_missing_values = c()
20 boolean_block_missing_values = FALSE
21
22 for(i in 1:length(list_X))
23 {
24 X_i = list_X[[i]]
25 name_block_i = name_blocks[i]
26
27 vec = sapply(1:dim(X_i)[2], FUN = function(j){
28 res = any(is.na(X_i[, j]))
29
30 return(res)
31 })
32
33 if(any(vec))
34 {
35 name_blocks_missing_values = c(name_blocks_missing_values, name_block_i)
36
37 }
38
39 } # End for(i in 1:length(list_X)).
40
41 if(length(name_blocks_missing_values) != 0)
42 {
43 stop(paste("The data integration can not be performed if a block contains missing values : ", paste(name_blocks_missing_values, collapse = ", "), " contains missing values. "))
44 boolean_block_missing_values = TRUE
45
46 }
47
48 return(boolean_block_missing_values)
49
50 }
51
52
53 #' @title Determination of selected variables for all components 1 #' @title Determination of selected variables for all components
54 #' @description The function unionSelectBlockVariables determines, for each block, the selected block variables 2 #' @description The function unionSelectBlockVariables determines, for each block, the selected block variables
55 #' for all components. 3 #' for all components.
56 #' @param res_block_splsda type : sgccda. This parameter is the output of block.splsda function 4 #' @param res_block_splsda type : sgccda. This parameter is the output of block.splsda function
57 #' mixOmics. 5 #' mixOmics.