diff --git a/DESCRIPTION b/DESCRIPTION index 1d335f9..67b8830 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: dsOmics Type: Package Title: DataSHIELD server site Omic functions -Version: 1.0.17.9000 +Version: 1.0.17.9001 Date: 2021-07-08 Authors@R: c(person("Yannick", "Marcon", , "yannick.marcon@obiba.org", role = "aut"), person("Xavier", "Esriba-Montagut", , "xavier.escriba@isglobal.org", role = "aut"), @@ -38,7 +38,7 @@ AggregateMethods: nSamplesDS, nFeaturesDS, tablePhenoDS, - limmaDS, + limmaDS2, getVariable, getChromosomeNamesDS, GWASDS, @@ -65,6 +65,7 @@ AssignMethods: RNAseqPreprocDS, PRSDS, PRSDS_aux, + limmaDS, make_valid_namesDS, fastGWAS_S, fastGWAS_getFitted.values, diff --git a/R/limmaDS.R b/R/limmaDS.R index 94b99bb..e5b57a0 100644 --- a/R/limmaDS.R +++ b/R/limmaDS.R @@ -100,21 +100,22 @@ limmaDS <- function(Set, variable_names, covariable_names, type, contrasts, variable_names = variable_names, covariable_names = covariable_names, sva=sva, method = method, big = big) - temp <- MEAL::getProbeResults(res, fNames=annotCols, coef = coef, - contrast = contrasts, robust = robust, sort.by = sort.by) - if(any(class(temp) == 'simpleError')){stop(paste(temp))} - if(type == 1){ - if(inherits(Set, "ExpressionSet")){ - Set.counts <- Biobase::exprs(Set) - } - else if (inherits(Set, c("SummarizedExperiment","RangedSummarizedExperiment"))){ - Set.counts <- SummarizedExperiment::assay(Set) - } - } - n <- apply(Set.counts, 1, function(x) sum(!is.na(x))) - ans <- tibble::as_tibble(temp) %>% tibble::add_column(.before=1, id=rownames(temp)) %>% - tibble::add_column(.after = 1, n=n) %>% dplyr::rename("beta" = "logFC") %>% - dplyr::select(id, tail(names(.), length(annotCols)), everything()) %>% - dplyr::select(id, n, beta, SE, t, P.Value, adj.P.Val, annotCols) - return(ans) + return(res) + # temp <- MEAL::getProbeResults(res, fNames=annotCols, coef = coef, + # contrast = contrasts, robust = robust, sort.by = sort.by) + # if(any(class(temp) == 'simpleError')){stop(paste(temp))} + # if(type == 1){ + # if(inherits(Set, "ExpressionSet")){ + # Set.counts <- Biobase::exprs(Set) + # } + # else if (inherits(Set, c("SummarizedExperiment","RangedSummarizedExperiment"))){ + # Set.counts <- SummarizedExperiment::assay(Set) + # } + # } + # n <- apply(Set.counts, 1, function(x) sum(!is.na(x))) + # ans <- tibble::as_tibble(temp) %>% tibble::add_column(.before=1, id=rownames(temp)) %>% + # tibble::add_column(.after = 1, n=n) %>% dplyr::rename("beta" = "logFC") %>% + # dplyr::select(id, tail(names(.), length(annotCols)), everything()) %>% + # dplyr::select(id, n, beta, SE, t, P.Value, adj.P.Val, annotCols) + # return(ans) } diff --git a/R/limmaDS2.R b/R/limmaDS2.R new file mode 100644 index 0000000..3cc5ae7 --- /dev/null +++ b/R/limmaDS2.R @@ -0,0 +1,49 @@ +#' +#' @title Differential expression analysis using limma on the server-side +#' @description Performs differential expression analysis using LIMMA +#' @param Set either a \code{ExpressionSet} or a \code{RangedSummarizedExperiment} +#' @param variable_names grouping variable used to perform differential expression analysis +#' @param covariable_names name of variables used in the adjusted models +#' @param type ... +#' @param contrasts ... +#' @param levels ... +#' @param coef ... +#' @param sva should differential expression analysis be adjusted by SVA? +#' @param annotCols variables from the annotation data used in the output +#' @param method String indicating the method used in the regression (e.g. lmFit function of limma: "ls" or +#' "robust". (Default: "ls") +#' @param robust Logical value indicating whether robust method is applied in the eBayes function of limma. Default is FALSE. +#' @param normalization String indicating the normalize method used when using voom for RNAseq data (see normalized.method argument in limma::vomm) +#' @param voomQualityWeights Logical value indicating whether limma::voomWithQualityWeights should be used instead of +#' limma::voom. +#' @param big Logical value indicating whether SmartSVA should be used instead of SVA +#' (TRUE recommended for methylation or when having large number of samples). +#' +#' +#' @return a matrix with genes ordered by p-value +#' @author Gonzalez, JR. +#' +#' @import dplyr +#' @export +#' +limmaDS2 <- function(Set, res, type, contrasts, + coef, annotCols, robust, sort.by){ + + temp <- MEAL::getProbeResults(res, fNames=annotCols, coef = coef, + contrast = contrasts, robust = robust, sort.by = sort.by) + if(any(class(temp) == 'simpleError')){stop(paste(temp))} + if(type == 1){ + if(inherits(Set, "ExpressionSet")){ + Set.counts <- Biobase::exprs(Set) + } + else if (inherits(Set, c("SummarizedExperiment","RangedSummarizedExperiment"))){ + Set.counts <- SummarizedExperiment::assay(Set) + } + } + n <- apply(Set.counts, 1, function(x) sum(!is.na(x))) + ans <- tibble::as_tibble(temp) %>% tibble::add_column(.before=1, id=rownames(temp)) %>% + tibble::add_column(.after = 1, n=n) %>% dplyr::rename("beta" = "logFC") %>% + dplyr::select(id, tail(names(.), length(annotCols)), everything()) %>% + dplyr::select(id, n, beta, SE, t, P.Value, adj.P.Val, annotCols) + return(ans) +}