diff --git a/DESCRIPTION b/DESCRIPTION index 57d73520..30dca63f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mixOmics Type: Package Title: Omics Data Integration Project -Version: 6.17.17 +Version: 6.17.18 Depends: R (>= 3.5.0), MASS, lattice, diff --git a/R/helpers-plot.R b/R/helpers-plot.R index 5cc2db4a..3692f432 100644 --- a/R/helpers-plot.R +++ b/R/helpers-plot.R @@ -149,10 +149,12 @@ if (nlevels(group) == 1) { col.per.group <- ifelse(is.null(col), color.mixo(1), .are.colors(col)) - } - else - { ## group is of length >= 2 + } else if (nlevels(group) < 10) + { col.per.group <- color.mixo(seq_len(nlevels(group))) + } else if (nlevels(group) >= 10) + { + col.per.group <- color.jet(nlevels(group)) } names(col.per.group) <- levels(group) diff --git a/R/plotIndiv.R b/R/plotIndiv.R index 731f8a7c..d021e6a0 100644 --- a/R/plotIndiv.R +++ b/R/plotIndiv.R @@ -70,8 +70,7 @@ #' for ellipse plots. Coded as default for the supervised methods \code{PLS-DA, #' SPLS-DA,sGCCDA}, but needs to be input for the unsupervised methods #' \code{PCA, sPCA, IPCA, sIPCA, PLS, sPLS, rCC, rGCCA, sGCCA} -#' @param col.per.group character (or symbol) color to be used when 'group' is -#' defined. Vector of the same length as the number of groups. +#' @template arg/col.per.group #' @param style argument to be set to either \code{'graphics'}, #' \code{'lattice'}, \code{'ggplot2'} or \code{'3d'} for a style of plotting. #' Default set to 'ggplot2'. See details. \code{3d} is not available for MINT diff --git a/R/selectVar.R b/R/selectVar.R index 366faf3a..a39516b4 100644 --- a/R/selectVar.R +++ b/R/selectVar.R @@ -133,15 +133,13 @@ selectVar.sgcca <- selectVar.mixo_pls selectVar.rgcca <- selectVar.mixo_pls ## -------------------------------- helper -------------------------------- ## -get.name.and.value=function(x,comp) +get.name.and.value <- function(x,comp) { - if(length(x[,comp,drop=FALSE]) > 1) - { - name.var = names(sort(abs(x[,comp]), decreasing = TRUE)[1:sum(x[,comp]!=0)]) - } else { - name.var = rownames(x) # when only one number, sort loses the name of the variable - } - value.var=x[name.var,comp] - return(list(name = name.var, value = data.frame(value.var))) + value <- data.frame(value.var = x[,comp]) + value <- value[abs(value$value.var) > .Machine$double.eps,,drop=FALSE] + value <- value[order(-abs(value$value.var)),,drop=FALSE] + + name.var <- rownames(value) + return(list(name = name.var, value = value)) }