|
| 1 | +#' |
| 2 | +#' @title ds.acme function template |
| 3 | +#' @description example aggregate function template |
| 4 | +#' @details Client-side acme example aggregate function template |
| 5 | +#' This file is to be placed in server-sides R directory. |
| 6 | +#' @param name a character vector containing "a name" |
| 7 | +#' @param datasources specifies the particular 'connection object(s)' to use. |
| 8 | +#' @return character vector containing "a message" |
| 9 | +#' @author Ever, Who. |
| 10 | +#' @export |
| 11 | +#' |
| 12 | + |
| 13 | +ds.acme <- function(model, Set, type.data = "SummarizedExperiment", threshold = NULL, |
| 14 | + reference = NULL, annotCols=NULL, datasources=NULL) |
| 15 | +{ |
| 16 | + # if no opal login details are provided look for 'opal' objects in the environment |
| 17 | + if (is.null(datasources)) |
| 18 | + { |
| 19 | + datasources <- DSI::datashield.connections_find() |
| 20 | + } |
| 21 | + type <- charmatch(type.data, c("SummarizedExperiment", "matrix", "htseq")) |
| 22 | + |
| 23 | + if(is.na(type)) |
| 24 | + { |
| 25 | + stop("type.data must be 'SummarizedExperiment', 'matrix', 'htseq'") |
| 26 | + } |
| 27 | + |
| 28 | + mt <- all.vars(model) |
| 29 | + variable_names <- mt[1] |
| 30 | + |
| 31 | + if (length(mt)>1) |
| 32 | + { |
| 33 | + covariable_names <- paste(mt[-1], collapse=",") |
| 34 | + } |
| 35 | + |
| 36 | + else |
| 37 | + { |
| 38 | + covariable_names <- NULL |
| 39 | + } |
| 40 | + |
| 41 | + if (!is.null(annotCols)) |
| 42 | + { |
| 43 | + annotCols <- paste(annotCols, collapse=",") |
| 44 | + } |
| 45 | + |
| 46 | + # call the server side function |
| 47 | + calltext <- call("acmeDS",Set, type,variable_names, covariable_names, annotCols, threshold, reference) |
| 48 | + |
| 49 | + output <- datashield.aggregate(datasources, calltext) |
| 50 | + |
| 51 | + return(output) |
| 52 | +} |
| 53 | +#ds.acme |
0 commit comments