From 4bc7319ea59ce7851b81f253f14c5537dccb97fe Mon Sep 17 00:00:00 2001 From: Dong Date: Fri, 9 Apr 2021 17:51:34 +0300 Subject: [PATCH] rm getOPLSDA() function --- NAMESPACE | 2 -- R/doStat.R | 3 +-- R/getOPLSDA.R | 44 -------------------------------------------- man/getOPLSDA.Rd | 24 ------------------------ 4 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 R/getOPLSDA.R delete mode 100644 man/getOPLSDA.Rd diff --git a/NAMESPACE b/NAMESPACE index 9cdf479..d3e1592 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,7 +11,6 @@ export(doStat) export(getCV) export(getFC) export(getMax) -export(getOPLSDA) export(getP) export(mass) export(mz) @@ -38,7 +37,6 @@ importFrom(plotly,ggplotly) importFrom(plotly,layout) importFrom(plotly,plot_ly) importFrom(reshape2,melt) -importFrom(ropls,opls) importFrom(stats,TukeyHSD) importFrom(stats,aggregate) importFrom(stats,as.formula) diff --git a/R/doStat.R b/R/doStat.R index a9a730b..69ccc4d 100644 --- a/R/doStat.R +++ b/R/doStat.R @@ -16,8 +16,7 @@ doStat <- function(x, Group = NULL){ myCV <- getCV(x, Group = Group) myFC <- getFC(x, Group = Group) myP <- getP(x, Group = Group) - myOPLSDA <- getOPLSDA(x, Group = Group) - myStat <- cbind(maxSample, myCV, myFC, myP, myOPLSDA) + myStat <- cbind(maxSample, myCV, myFC, myP) cat("\nStatistical analysis done. \n") rownames(myStat) <- colnames(x) return(myStat) diff --git a/R/getOPLSDA.R b/R/getOPLSDA.R deleted file mode 100644 index f4a9a0d..0000000 --- a/R/getOPLSDA.R +++ /dev/null @@ -1,44 +0,0 @@ -#' @title calculate VIP values -#' @description calculate VIP values using among different samples groups using OPLSDA. -#' @param x sample ion intensity matrix, row sample, column feature. -#' @param Group sample group information -#' @importFrom utils combn -#' @importFrom ropls opls -#' @return a dataframe with vip values -#' @export -#' @examples -#' dat <- matrix(runif(2*300), ncol = 2, nrow = 300) -#' myGroup <- rep_len(LETTERS[1:3], 300) -#' out <- getOPLSDA(dat, Group = myGroup) - -getOPLSDA <- function(x, Group = NULL){ - cat("\n- Calculating VIP values...\n") - #(1) check input - Group <- as.factor(Group) - if(is.null(Group)){stop("Please include group information")} - if(length(levels(Group)) <= 1){stop("At least two sample groups should be included")} - if(length(Group) != nrow(x)){stop("Missing group informaiton detected")} - - #(2) perform OPLS - n <- levels(Group) - dat2 <- cbind.data.frame(x, Group = Group) - mylist <- combn(n, 2, FUN = function(x) subset(dat2, Group %in% x), simplify = FALSE) - ## change mylist names - listnames <- combn(n, 2, simplify = FALSE) - names(mylist) <- lapply(listnames, function(x) paste("OPLSDA", paste(x, collapse="_vs_"), sep = "_")) - ## perform OPLS-DA using opls package - oplsdafun <- function(i) { - myVIP <- opls(x = subset(i, select = -Group), - y = as.character(i$Group), - predI = 1, - orthoI = 1, - permI = 10, - crossvalI = min(nrow(i), 7), - fig.pdfC = "none", - info.txtC = "none") - round(myVIP@vipVn, 2) - } - list_VIP <- lapply(mylist, oplsdafun) - ## convert result to dataframe and keep the name - return(data.frame(list_VIP)) -} diff --git a/man/getOPLSDA.Rd b/man/getOPLSDA.Rd deleted file mode 100644 index fe5d0fc..0000000 --- a/man/getOPLSDA.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/getOPLSDA.R -\name{getOPLSDA} -\alias{getOPLSDA} -\title{calculate VIP values} -\usage{ -getOPLSDA(x, Group = NULL) -} -\arguments{ -\item{x}{sample ion intensity matrix, row sample, column feature.} - -\item{Group}{sample group information} -} -\value{ -a dataframe with vip values -} -\description{ -calculate VIP values using among different samples groups using OPLSDA. -} -\examples{ -dat <- matrix(runif(2*300), ncol = 2, nrow = 300) -myGroup <- rep_len(LETTERS[1:3], 300) -out <- getOPLSDA(dat, Group = myGroup) -}