diff --git a/.DS_Store b/.DS_Store index 314e1ce..54f013b 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.Rbuildignore b/.Rbuildignore index a9a4129..96f3663 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^\.Rproj\.user$ ^cran-comments\.md$ ^revdep$ +^CRAN-SUBMISSION$ diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..eaaf403 --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 1.0.0 +Date: 2023-05-03 18:27:23 UTC +SHA: 5e8241576dcf70e63d13d9c1004c7643edecef95 diff --git a/DESCRIPTION b/DESCRIPTION index 1491047..77a3551 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,6 +26,7 @@ Imports: ggplot2, partition, doParallel, + parallel, utils, stats, tidyr diff --git a/R/ACDC.R b/R/ACDC.R index d880b60..b0dec0e 100755 --- a/R/ACDC.R +++ b/R/ACDC.R @@ -54,6 +54,10 @@ #' @import CCP #' @import utils #' @import stats +#' @import tidyr +#' @import foreach +#' @import doParallel +#' @import parallel ACDC <- function(fullData, ILC = 0.50, externalVar, identifierList = colnames(fullData), numNodes = 1) { # to remove "no visible binding" note @@ -62,7 +66,7 @@ ACDC <- function(fullData, ILC = 0.50, externalVar, identifierList = colnames(fu ## function to suppress output # use for p.asym hush = function(code){ - sink("/dev/null") + sink(nullfile()) tmp = code sink() return(tmp) @@ -78,6 +82,9 @@ ACDC <- function(fullData, ILC = 0.50, externalVar, identifierList = colnames(fu if(ncol(fullData) != length(identifierList)) stop("identifierList must be the same length as the number of columns in fullData.") if(0 > ILC | 1 < ILC) stop("ILC must be between 0 and 1.") + # iteration counter + i = 0 + # partition and find modules part <- partition(fullData, threshold = ILC) modules <- part$mapping_key[which(grepl("reduced_var_", part$mapping_key$variable)), ]$indices @@ -86,13 +93,8 @@ ACDC <- function(fullData, ILC = 0.50, externalVar, identifierList = colnames(fu if(length(modules) == 0) stop("No modules identified. Try a smaller ILC.") # parallel set up - my.cluster <- parallel::makeCluster( - numNodes, - type = "PSOCK") - doParallel::registerDoParallel(cl = my.cluster) - - # iteration counter - i = 0 + my.cluster <- parallel::makeCluster(numNodes) + doParallel::registerDoParallel(my.cluster) # for each module... results <- foreach (i = 1:length(modules), diff --git a/R/ACDChighdim.R b/R/ACDChighdim.R index f21608d..57dcb40 100644 --- a/R/ACDChighdim.R +++ b/R/ACDChighdim.R @@ -26,16 +26,7 @@ #' # load dataset #' data("nutrimouse") #' -#' # generate random phenotype -#' r.pheno <- rnorm(nrow(nutrimouse$lipid)) -#' -#' # run function for random phenotype -#' ACDChighdim(moduleIdentifier = 1, -#' moduleCols = list(1:ncol(nutrimouse$lipid)), -#' fullData = nutrimouse$lipid, -#' externalVar = r.pheno) -#' -#' # run function for diet and genotype (non-random) +#' # run function for diet and genotype #' ACDChighdim(moduleIdentifier = 1, #' moduleCols = list(1:ncol(nutrimouse$lipid)), #' fullData = nutrimouse$lipid, @@ -73,7 +64,7 @@ ACDChighdim <- function(moduleIdentifier = 1, moduleCols, fullData, externalVar, ## function to suppress output # use for p.asym hush = function(code){ - sink("/dev/null") + sink(nullfile()) tmp = code sink() return(tmp) diff --git a/R/ACDCmod.R b/R/ACDCmod.R index 369e36f..5325e1a 100755 --- a/R/ACDCmod.R +++ b/R/ACDCmod.R @@ -25,20 +25,12 @@ #' # load dataset #' data("nutrimouse") #' -#' # generate random phenotype -#' r.pheno <- rnorm(nrow(nutrimouse$lipid)) -#' #' # partition dataset and save modules #' library(partition) #' part <- partition(nutrimouse$lipid, threshold = 0.50) #' mods <- part$mapping_key[which(grepl("reduced_var_", part$mapping_key$variable)), ]$mapping #' -#' # run function for random phenotype -#' ACDCmod(fullData = nutrimouse$lipid, -#' modules=mods, -#' externalVar = r.pheno) -#' -#' # run function for diet and genotype (non-random) +#' # run function for diet and genotype #' ACDCmod(fullData = nutrimouse$lipid, #' modules = mods, #' externalVar = data.frame(diet=as.numeric(nutrimouse$diet), @@ -66,10 +58,10 @@ #' @import CCP #' @import utils #' @import stats -#' @import parallel +#' @import tidyr #' @import foreach #' @import doParallel -#' @import tidyr +#' @import parallel ACDCmod <- function(fullData, modules, externalVar, identifierList=colnames(fullData), numNodes = 1) { # to remove "no visible binding" note @@ -78,7 +70,7 @@ ACDCmod <- function(fullData, modules, externalVar, identifierList=colnames(full ## function to suppress output # use for p.asym hush = function(code){ - sink("/dev/null") + sink(nullfile()) tmp = code sink() return(tmp) @@ -94,15 +86,13 @@ ACDCmod <- function(fullData, modules, externalVar, identifierList=colnames(full if(ncol(fullData) != length(identifierList)) stop("identifierList must be the same length as the number of columns in fullData.") if(length(modules) == 0) stop("No modules input.") - # parallel set up - my.cluster <- parallel::makeCluster( - numNodes, - type = "PSOCK") - doParallel::registerDoParallel(cl = my.cluster) - # iteration counter i = 0 + # parallel set up + my.cluster <- parallel::makeCluster(numNodes) + doParallel::registerDoParallel(my.cluster) + # for each module... results <- foreach (i = 1:length(modules), .combine = rbind, diff --git a/R/OSCA_par.R b/R/OSCA_par.R index 19125a8..97ce1e0 100755 --- a/R/OSCA_par.R +++ b/R/OSCA_par.R @@ -33,19 +33,6 @@ #' # load dataset #' data("nutrimouse") #' -#' # generate random phenotype -#' r.pheno <- rnorm(nrow(nutrimouse$gene)) -#' -#' ## random phenotype -#' # run function; input path to OSCA software -#' # OSCA_par(df = nutrimouse$gene, -#' # externalVar = r.pheno, -#' # ILCincrement = 0.25, -#' # oscaPath = "pathHere", -#' # numNodes = detectCores()-1, -#' # permute = T) -#' -#' ## observed external variable #' # run function; input path to OSCA software #' # OSCA_par(df = nutrimouse$gene, #' # externalVar = as.numeric(nutrimouse$diet), @@ -70,9 +57,9 @@ #' @export #' @import data.table #' @import partition -#' @import parallel #' @import foreach #' @import doParallel +#' @import parallel OSCA_par <- function(df, externalVar, ILCincrement = 0.05, oscaPath, numNodes = 1, permute = T) { # check correct dimensions of input @@ -94,10 +81,8 @@ OSCA_par <- function(df, externalVar, ILCincrement = 0.05, oscaPath, numNodes = externalVar_permute <- sample(externalVar) # parallel set up - my.cluster <- parallel::makeCluster( - numNodes, - type = "PSOCK") - doParallel::registerDoParallel(cl = my.cluster) + my.cluster <- parallel::makeCluster(numNodes) + doParallel::registerDoParallel(my.cluster) # PVE for each value with permutations or PVE for each value without permutations if (permute == T) { diff --git a/R/OSCA_parPlot.R b/R/OSCA_parPlot.R index d94384b..fec569d 100755 --- a/R/OSCA_parPlot.R +++ b/R/OSCA_parPlot.R @@ -18,22 +18,6 @@ #' # load dataset #' data("nutrimouse") #' -#' # generate random phenotype -#' r.pheno <- rnorm(nrow(nutrimouse$gene)) -#' -#' ## random phenotype -#' # run OSCA_par and save output; input path to OSCA software -#' # r.par <- OSCA_par(df = nutrimouse$gene, -#' # externalVar = r.pheno, -#' # ILCincrement = 0.25, -#' # oscaPath = "pathHere", -#' # numNodes = detectCores()-1, -#' # permute = T) -#' -#' # run function -#' #OSCA_parPlot(df=r.par, externalVarName = "Random Phenotype", dataName = "Nutritional Issue Genes") -#' -#' ## observed external variables #' # run OSCA_par and save output; input path to OSCA software #' # par <- OSCA_par(df = nutrimouse$gene, #' # externalVar = as.numeric(nutrimouse$diet), diff --git a/R/OSCA_singleValue.R b/R/OSCA_singleValue.R index 6e4e9b6..eb33058 100755 --- a/R/OSCA_singleValue.R +++ b/R/OSCA_singleValue.R @@ -17,17 +17,7 @@ #' #' # load dataset #' data("nutrimouse") -#' -#' # generate random phenotype -#' r.pheno <- rnorm(nrow(nutrimouse$gene)) -#' -#' ## random phenotype -#' # run function; input path to OSCA software -#' # OSCA_singleValue(df = nutrimouse$gene, -#' # externalVar= r.pheno, -#' # oscaPath = "pathHere") #' -#' ## observed external variable #' # run function; input path to OSCA software #' # OSCA_singleValue(df = nutrimouse$gene, #' # externalVar = as.numeric(nutrimouse$diet), diff --git a/man/ACDChighdim.Rd b/man/ACDChighdim.Rd index b49adaf..9d91552 100644 --- a/man/ACDChighdim.Rd +++ b/man/ACDChighdim.Rd @@ -55,16 +55,7 @@ library(CCA) # load dataset data("nutrimouse") -# generate random phenotype -r.pheno <- rnorm(nrow(nutrimouse$lipid)) - -# run function for random phenotype -ACDChighdim(moduleIdentifier = 1, - moduleCols = list(1:ncol(nutrimouse$lipid)), - fullData = nutrimouse$lipid, - externalVar = r.pheno) - -# run function for diet and genotype (non-random) +# run function for diet and genotype ACDChighdim(moduleIdentifier = 1, moduleCols = list(1:ncol(nutrimouse$lipid)), fullData = nutrimouse$lipid, diff --git a/man/ACDCmod.Rd b/man/ACDCmod.Rd index 3cd9fa8..643c9bf 100755 --- a/man/ACDCmod.Rd +++ b/man/ACDCmod.Rd @@ -50,20 +50,12 @@ library(CCA) # load dataset data("nutrimouse") -# generate random phenotype -r.pheno <- rnorm(nrow(nutrimouse$lipid)) - # partition dataset and save modules library(partition) part <- partition(nutrimouse$lipid, threshold = 0.50) mods <- part$mapping_key[which(grepl("reduced_var_", part$mapping_key$variable)), ]$mapping -# run function for random phenotype -ACDCmod(fullData = nutrimouse$lipid, - modules=mods, - externalVar = r.pheno) - -# run function for diet and genotype (non-random) +# run function for diet and genotype ACDCmod(fullData = nutrimouse$lipid, modules = mods, externalVar = data.frame(diet=as.numeric(nutrimouse$diet), diff --git a/man/OSCA_par.Rd b/man/OSCA_par.Rd index 19df543..1fa57c6 100755 --- a/man/OSCA_par.Rd +++ b/man/OSCA_par.Rd @@ -56,19 +56,6 @@ library(CCA) # load dataset data("nutrimouse") -# generate random phenotype -r.pheno <- rnorm(nrow(nutrimouse$gene)) - -## random phenotype -# run function; input path to OSCA software -# OSCA_par(df = nutrimouse$gene, -# externalVar = r.pheno, -# ILCincrement = 0.25, -# oscaPath = "pathHere", -# numNodes = detectCores()-1, -# permute = T) - -## observed external variable # run function; input path to OSCA software # OSCA_par(df = nutrimouse$gene, # externalVar = as.numeric(nutrimouse$diet), diff --git a/man/OSCA_parPlot.Rd b/man/OSCA_parPlot.Rd index 7d9ac73..e8b48a3 100755 --- a/man/OSCA_parPlot.Rd +++ b/man/OSCA_parPlot.Rd @@ -31,22 +31,6 @@ library(CCA) # load dataset data("nutrimouse") -# generate random phenotype -r.pheno <- rnorm(nrow(nutrimouse$gene)) - -## random phenotype -# run OSCA_par and save output; input path to OSCA software -# r.par <- OSCA_par(df = nutrimouse$gene, -# externalVar = r.pheno, -# ILCincrement = 0.25, -# oscaPath = "pathHere", -# numNodes = detectCores()-1, -# permute = T) - -# run function -#OSCA_parPlot(df=r.par, externalVarName = "Random Phenotype", dataName = "Nutritional Issue Genes") - -## observed external variables # run OSCA_par and save output; input path to OSCA software # par <- OSCA_par(df = nutrimouse$gene, # externalVar = as.numeric(nutrimouse$diet), diff --git a/man/OSCA_singleValue.Rd b/man/OSCA_singleValue.Rd index ceffdae..16d37bb 100755 --- a/man/OSCA_singleValue.Rd +++ b/man/OSCA_singleValue.Rd @@ -31,16 +31,6 @@ library(CCA) # load dataset data("nutrimouse") -# generate random phenotype -r.pheno <- rnorm(nrow(nutrimouse$gene)) - -## random phenotype -# run function; input path to OSCA software -# OSCA_singleValue(df = nutrimouse$gene, -# externalVar= r.pheno, -# oscaPath = "pathHere") - -## observed external variable # run function; input path to OSCA software # OSCA_singleValue(df = nutrimouse$gene, # externalVar = as.numeric(nutrimouse$diet),