diff --git a/R/config.R b/R/config.R index 12d1823..bc26438 100644 --- a/R/config.R +++ b/R/config.R @@ -57,6 +57,7 @@ setMethod( #' x = list(a=list(b=list(c="~/test.txt"))) #' .expandList(x) #' @export +#' @keywords internal .expandList <- function(x) { if (is.list(x)) return(lapply(x, .expandList)) @@ -79,6 +80,7 @@ setMethod( #' l = list(a="a", b="b") #' .getSubscript(l, 1) == .getSubscript(l, "a") #' @export +#' @keywords internal .getSubscript <- function(lst, i) { if (is.character(i)) return(grep(paste0("^", i, "$"), names(lst))) @@ -183,6 +185,7 @@ setMethod( #' @param object an object of \code{"\linkS4class{Config}"} #' #' @return an object of \code{"\linkS4class{Config}"} +#' @keywords internal setGeneric(".reformat", function(object) standardGeneric(".reformat")) @@ -264,6 +267,7 @@ setMethod( #' @param filename file path to config file #' #' @seealso \url{https://pep.databio.org/} +#' @keywords internal .loadConfig = function(filename = NULL, amendments = NULL) { if (!file.exists(filename)) { @@ -320,6 +324,7 @@ setMethod( #' @return possibly updated config #' #' @return config +#' @keywords internal .applyAmendments = function(cfg, amendments = NULL) { if (!is.null(amendments)) { for (amendment in amendments) { @@ -344,6 +349,7 @@ setMethod( #' #' @return config data enriched in imported sections, if imports existed in the #' input +#' @keywords internal .applyImports = function(cfg_data, filename) { if (!CFG_P_MODIFIERS_KEY %in% names(cfg_data) || !CFG_IMPORT_KEY %in% names(cfg_data[[CFG_P_MODIFIERS_KEY]])) @@ -365,6 +371,7 @@ setMethod( #' @param filename path to the config file #' #' @return string project name +#' @keywords internal .inferProjectName = function(cfg, filename) { if (!is.null(cfg$name)) return(cfg$name) diff --git a/R/project.R b/R/project.R index 13d572c..85296fe 100644 --- a/R/project.R +++ b/R/project.R @@ -145,6 +145,7 @@ setMethod( #' @param object an object of \code{"\linkS4class{Project}"} #' #' @return modified Project object +#' @keywords internal setGeneric(".modifySamples", function(object) standardGeneric(".modifySamples")) @@ -375,6 +376,7 @@ setMethod( #' @param .Object an object of \code{"\linkS4class{Project}"} #' #' @return an object of \code{"\linkS4class{Project}"} +#' @keywords internal .removeAttrs <- function(.Object) { if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object))) return(.Object) @@ -399,6 +401,7 @@ setMethod( #' @param .Object an object of \code{\link{Project-class}} #' #' @return an object of \code{\link{Project-class}} +#' @keywords internal .appendAttrs <- function(.Object) { if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object))) return(.Object) @@ -432,6 +435,7 @@ setMethod( #' @param .Object an object of \code{"\linkS4class{Project}"} #' #' @return an object of \code{"\linkS4class{Project}"} +#' @keywords internal .duplicateAttrs <- function(.Object) { if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object))) return(.Object) @@ -450,6 +454,7 @@ setMethod( #' @param .Object an object of \code{"\linkS4class{Project}"} #' #' @return an object of \code{"\linkS4class{Project}"} +#' @keywords internal .implyAttrs = function(.Object) { if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object))) return(.Object) @@ -499,6 +504,7 @@ setMethod( #' @param .Object an object of \code{"\linkS4class{Project}"} #' #' @return an object of \code{"\linkS4class{Project}"} +#' @keywords internal .deriveAttrs = function(.Object) { if (!CFG_S_MODIFIERS_KEY %in% names(config(.Object))) return(.Object) @@ -539,6 +545,7 @@ setMethod( #' @param sampleTablePath a character string indicating a path to the sample table #' #' @return an data.frame with samples; one sample per row +#' @keywords internal .loadSampleAnnotation = function(sampleTablePath) { if (.safeFileExists(sampleTablePath)) { samples = data.table::fread(sampleTablePath) @@ -555,6 +562,7 @@ setMethod( #' @param path string, a path to the subsample table to read and incorporate #' #' @return an object of \code{"\linkS4class{Project}"} +#' @keywords internal .loadSubsampleAnnotation = function(.Object, path) { if (.safeFileExists(path)) { subsamplesTable = data.table::fread(path) @@ -608,6 +616,7 @@ setMethod( #' @param subsampleAannotationPaths a vector of strings specifying the paths to sample #' #' @return an object of \code{"\linkS4class{Project}"} +#' @keywords internal .mergeAttrs = function(.Object, subsampleAannotationPaths) { if (is.null(subsampleAannotationPaths)) return(.Object) @@ -625,6 +634,7 @@ setMethod( #' @param .Object an object of \code{"\linkS4class{Project}"} #' #' @return an object of \code{"\linkS4class{Project}"} +#' @keywords internal .autoMergeDuplicatedNames = function(.Object) { s = sampleTable(.Object) sampleNames = s[[.Object@sampleNameAttr]] @@ -675,6 +685,7 @@ setMethod( #' @param .Object an object of \code{"\linkS4class{Project}"} #' @param stIndex character string indicating a constructor-specified sample table index #' @param sstIndex character string indicating a constructor-specified subsample table index +#' @keywords internal .getTableIndexes <- function(.Object, stIndex, sstIndex) { .getIndexVal <- function(spec, config, default, key) { if (!is.null(spec)) diff --git a/R/utils.R b/R/utils.R index c252e99..677611f 100644 --- a/R/utils.R +++ b/R/utils.R @@ -16,6 +16,7 @@ #' path = "$HOME/my/path/string.txt" #' .expandPath(path) #' @export +#' @keywords internal .expandPath = function(path) { # helper function removeNonWords = function(str) { @@ -90,6 +91,7 @@ #' @examples #' .strformat("~/{VAR1}{VAR2}_file", list(VAR1="hi", VAR2="hello")) #' .strformat("$HOME/{VAR1}{VAR2}_file", list(VAR1="hi", VAR2="hello")) +#' @keywords internal .strformat = function(string, args, parent = NULL) { result = c() # if parent provided, make the path absolute and expand it. @@ -130,6 +132,7 @@ #' #' @export #' @return Target itself if already absolute, else target nested within parent. +#' @keywords internal .makeAbsPath = function(perhapsRelative, parent) { res = c() for (pR in perhapsRelative) { @@ -155,6 +158,7 @@ # Must test for is.null first, since is.na(NULL) returns a logical(0) which is # not a boolean +#' @keywords internal .isDefined = function(var) { !(is.null(var) || is.na(var)) } @@ -163,6 +167,7 @@ #' #' @param path The path to check for seeming absolute-ness. #' @return Flag indicating whether the \code{path} appears to be absolute. +#' @keywords internal .isAbsolute = function(path) { if (!is.character(path)) stop("The path must be character") @@ -176,6 +181,7 @@ #' @import RCurl #' #' @return logical indicating whether a string is a valid URL +#' @keywords internal .isValidUrl = function(str) { ans = FALSE if (grepl("www.|http:|https:", str)) { @@ -189,6 +195,7 @@ #' @param path string to be checked #' #' @return a logical indicating whether it's an existing path or valid URL +#' @keywords internal .safeFileExists = function(path) { (.isValidUrl(path) || (!is.null(path) && file.exists(path))) } @@ -205,6 +212,7 @@ #' dataFrame=mtcars #' listifiedDataFrame=.listifyDF(dataFrame) #' @export +#' @keywords internal .listifyDF = function(DF) { if (!is.data.frame(DF)) stop("The input object must be a data.frame.") @@ -296,6 +304,7 @@ fetchSamples = function(samples, #' @param rgx string to expand in the system #' #' @return a list of all the elements after possible expansion +#' @keywords internal .matchesAndRegexes = function(rgx) { res = c() for (i in rgx) { @@ -327,6 +336,7 @@ fetchSamples = function(samples, #' p = Project(file = projectConfig) #' .printNestedList(config(p),level=2) #' @export +#' @keywords internal .printNestedList = function(lst, level = 0) { if (!is.list(lst)) stop("The input is not a list, cannot be displayed.") @@ -358,6 +368,7 @@ fetchSamples = function(samples, #' l = list(a=list(b="test")) #' .checkSection(l,c("a","b")) #' .checkSection(l,c("c","b")) +#' @keywords internal .checkSection = function(object, sectionNames) { tryToNum = function(x) { convertedX = suppressWarnings(as.numeric(x)) @@ -382,6 +393,7 @@ fetchSamples = function(samples, #' @param config an object of \code{"\linkS4class{Config}"} #' #' @return a string which specifies a path to the sample table file +#' @keywords internal .getSampleTablePathFromConfig = function(config) { if (!CFG_SAMPLE_TABLE_KEY %in% names(config)) stop("Sample table not defined in config") @@ -393,6 +405,7 @@ fetchSamples = function(samples, #' @param config an object of \code{"\linkS4class{Config}"} #' #' @return string/vector of strings/NULL depending on the configuration +#' @keywords internal .getSubSampleTablePathFromConfig = function(config) { if (!CFG_SUBSAMPLE_TABLE_KEY %in% names(config)) return(NULL) @@ -408,6 +421,7 @@ fetchSamples = function(samples, #' #' @return a boolean, TRUE if indicating the path seems to be pointing to a config, #' or FALSE if the path seems to be pointing to an annotation file. +#' @keywords internal .isCfg = function(filePath) { if (endsWith(tolower(filePath), ".yaml") || endsWith(tolower(filePath), ".yml")) diff --git a/_pkgdown.yaml b/_pkgdown.yaml index b221217..5afa853 100644 --- a/_pkgdown.yaml +++ b/_pkgdown.yaml @@ -31,16 +31,5 @@ articles: contents: - starts_with("feature") -reference: - - title: "pepr API" - desc: "Exported functions of `pepr`." - contents: - - -matches("\\.") - - title: "utilities" - desc: "Extra non-exported utility functions." - contents: - - .strformat - - .expandPath - - .printNestedList news: - one_page: true diff --git a/man/dot-appendAttrs.Rd b/man/dot-appendAttrs.Rd index 5ed660c..db13290 100644 --- a/man/dot-appendAttrs.Rd +++ b/man/dot-appendAttrs.Rd @@ -15,3 +15,4 @@ an object of \code{\link{Project-class}} \description{ Append constant attributes across all the samples } +\keyword{internal} diff --git a/man/dot-applyAmendments.Rd b/man/dot-applyAmendments.Rd index b4f0146..8fd8ad7 100644 --- a/man/dot-applyAmendments.Rd +++ b/man/dot-applyAmendments.Rd @@ -19,3 +19,4 @@ config \description{ Overwrite and/or add Project attributes from the amendments section } +\keyword{internal} diff --git a/man/dot-applyImports.Rd b/man/dot-applyImports.Rd index 126ceaf..421b069 100644 --- a/man/dot-applyImports.Rd +++ b/man/dot-applyImports.Rd @@ -18,3 +18,4 @@ config data enriched in imported sections, if imports existed in the \description{ Function for recursive config data imports } +\keyword{internal} diff --git a/man/dot-autoMergeDuplicatedNames.Rd b/man/dot-autoMergeDuplicatedNames.Rd index d84ea30..1d6c108 100644 --- a/man/dot-autoMergeDuplicatedNames.Rd +++ b/man/dot-autoMergeDuplicatedNames.Rd @@ -15,3 +15,4 @@ an object of \code{"\linkS4class{Project}"} \description{ If sample table specifies samples with non-unique names, try to merge these samples } +\keyword{internal} diff --git a/man/dot-checkSection.Rd b/man/dot-checkSection.Rd index c3b95dc..5455522 100644 --- a/man/dot-checkSection.Rd +++ b/man/dot-checkSection.Rd @@ -22,3 +22,4 @@ l = list(a=list(b="test")) .checkSection(l,c("a","b")) .checkSection(l,c("c","b")) } +\keyword{internal} diff --git a/man/dot-deriveAttrs.Rd b/man/dot-deriveAttrs.Rd index c34de25..0350948 100644 --- a/man/dot-deriveAttrs.Rd +++ b/man/dot-deriveAttrs.Rd @@ -15,3 +15,4 @@ an object of \code{"\linkS4class{Project}"} \description{ Derive attributes } +\keyword{internal} diff --git a/man/dot-duplicateAttrs.Rd b/man/dot-duplicateAttrs.Rd index fe8f9e1..7a650ea 100644 --- a/man/dot-duplicateAttrs.Rd +++ b/man/dot-duplicateAttrs.Rd @@ -15,3 +15,4 @@ an object of \code{"\linkS4class{Project}"} \description{ Duplicate a selected attribute across all the samples } +\keyword{internal} diff --git a/man/dot-expandList.Rd b/man/dot-expandList.Rd index 8a39763..15124fd 100644 --- a/man/dot-expandList.Rd +++ b/man/dot-expandList.Rd @@ -19,3 +19,4 @@ Recursively try to expand list of strings x = list(a=list(b=list(c="~/test.txt"))) .expandList(x) } +\keyword{internal} diff --git a/man/dot-expandPath.Rd b/man/dot-expandPath.Rd index 0a5dfb8..73bb822 100644 --- a/man/dot-expandPath.Rd +++ b/man/dot-expandPath.Rd @@ -27,3 +27,4 @@ string = "https://www.r-project.org/" path = "$HOME/my/path/string.txt" .expandPath(path) } +\keyword{internal} diff --git a/man/dot-getSampleTablePathFromConfig.Rd b/man/dot-getSampleTablePathFromConfig.Rd index f0e78eb..d680945 100644 --- a/man/dot-getSampleTablePathFromConfig.Rd +++ b/man/dot-getSampleTablePathFromConfig.Rd @@ -15,3 +15,4 @@ a string which specifies a path to the sample table file \description{ Get the sample table from config } +\keyword{internal} diff --git a/man/dot-getSubSampleTablePathFromConfig.Rd b/man/dot-getSubSampleTablePathFromConfig.Rd index b4aa1da..b93ef5b 100644 --- a/man/dot-getSubSampleTablePathFromConfig.Rd +++ b/man/dot-getSubSampleTablePathFromConfig.Rd @@ -15,3 +15,4 @@ string/vector of strings/NULL depending on the configuration \description{ Get the subsample tables from config } +\keyword{internal} diff --git a/man/dot-getSubscript.Rd b/man/dot-getSubscript.Rd index 31d5e5a..c080c81 100644 --- a/man/dot-getSubscript.Rd +++ b/man/dot-getSubscript.Rd @@ -22,3 +22,4 @@ index of the element requested l = list(a="a", b="b") .getSubscript(l, 1) == .getSubscript(l, "a") } +\keyword{internal} diff --git a/man/dot-getTableIndexes.Rd b/man/dot-getTableIndexes.Rd index 1328c35..3e49c15 100644 --- a/man/dot-getTableIndexes.Rd +++ b/man/dot-getTableIndexes.Rd @@ -24,3 +24,4 @@ This is the (sub)sample table index selection priority order: \item Deafult value } } +\keyword{internal} diff --git a/man/dot-implyAttrs.Rd b/man/dot-implyAttrs.Rd index e434ca7..adc129a 100644 --- a/man/dot-implyAttrs.Rd +++ b/man/dot-implyAttrs.Rd @@ -15,3 +15,4 @@ an object of \code{"\linkS4class{Project}"} \description{ Imply attributes } +\keyword{internal} diff --git a/man/dot-inferProjectName.Rd b/man/dot-inferProjectName.Rd index 948e223..d10997a 100644 --- a/man/dot-inferProjectName.Rd +++ b/man/dot-inferProjectName.Rd @@ -17,3 +17,4 @@ string project name \description{ Based on dedicated config section or PEP enclosing dir } +\keyword{internal} diff --git a/man/dot-isAbsolute.Rd b/man/dot-isAbsolute.Rd index 9a91ca1..15d8aaa 100644 --- a/man/dot-isAbsolute.Rd +++ b/man/dot-isAbsolute.Rd @@ -15,3 +15,4 @@ Flag indicating whether the \code{path} appears to be absolute. \description{ Determine whether a path is absolute. } +\keyword{internal} diff --git a/man/dot-isCfg.Rd b/man/dot-isCfg.Rd index a01ce34..067b321 100644 --- a/man/dot-isCfg.Rd +++ b/man/dot-isCfg.Rd @@ -17,3 +17,4 @@ a boolean, TRUE if indicating the path seems to be pointing to a config, Determine if the input file seems to be a project config file (based on the file extension). } +\keyword{internal} diff --git a/man/dot-isValidUrl.Rd b/man/dot-isValidUrl.Rd index 5416df9..4052d42 100644 --- a/man/dot-isValidUrl.Rd +++ b/man/dot-isValidUrl.Rd @@ -15,3 +15,4 @@ logical indicating whether a string is a valid URL \description{ Determine whether the string is a valid URL } +\keyword{internal} diff --git a/man/dot-listifyDF.Rd b/man/dot-listifyDF.Rd index e196aa1..e8951c1 100644 --- a/man/dot-listifyDF.Rd +++ b/man/dot-listifyDF.Rd @@ -20,3 +20,4 @@ so that its cells can contain multiple elements dataFrame=mtcars listifiedDataFrame=.listifyDF(dataFrame) } +\keyword{internal} diff --git a/man/dot-loadConfig.Rd b/man/dot-loadConfig.Rd index 0114b4c..e3ef667 100644 --- a/man/dot-loadConfig.Rd +++ b/man/dot-loadConfig.Rd @@ -17,3 +17,4 @@ Loads a PEP config file \seealso{ \url{https://pep.databio.org/} } +\keyword{internal} diff --git a/man/dot-loadSampleAnnotation.Rd b/man/dot-loadSampleAnnotation.Rd index e3d5989..8b5036c 100644 --- a/man/dot-loadSampleAnnotation.Rd +++ b/man/dot-loadSampleAnnotation.Rd @@ -15,3 +15,4 @@ an data.frame with samples; one sample per row \description{ Read sample table from disk } +\keyword{internal} diff --git a/man/dot-loadSubsampleAnnotation.Rd b/man/dot-loadSubsampleAnnotation.Rd index 013ec35..47f80da 100644 --- a/man/dot-loadSubsampleAnnotation.Rd +++ b/man/dot-loadSubsampleAnnotation.Rd @@ -17,3 +17,4 @@ an object of \code{"\linkS4class{Project}"} \description{ Load single subsample annotation } +\keyword{internal} diff --git a/man/dot-makeAbsPath.Rd b/man/dot-makeAbsPath.Rd index 51c1f1e..d5ff77e 100644 --- a/man/dot-makeAbsPath.Rd +++ b/man/dot-makeAbsPath.Rd @@ -17,3 +17,4 @@ Target itself if already absolute, else target nested within parent. \description{ Create an absolute path from a primary target and a parent candidate. } +\keyword{internal} diff --git a/man/dot-matchesAndRegexes.Rd b/man/dot-matchesAndRegexes.Rd index e6a985f..5a367a1 100644 --- a/man/dot-matchesAndRegexes.Rd +++ b/man/dot-matchesAndRegexes.Rd @@ -15,3 +15,4 @@ a list of all the elements after possible expansion \description{ Create a list of matched files in the system and unmatched regular expessions } +\keyword{internal} diff --git a/man/dot-mergeAttrs.Rd b/man/dot-mergeAttrs.Rd index 22f11c0..3410abf 100644 --- a/man/dot-mergeAttrs.Rd +++ b/man/dot-mergeAttrs.Rd @@ -17,3 +17,4 @@ an object of \code{"\linkS4class{Project}"} \description{ Merge samples defined in sample table with ones in subsample table(s) } +\keyword{internal} diff --git a/man/dot-modifySamples.Rd b/man/dot-modifySamples.Rd index 319e24c..d275877 100644 --- a/man/dot-modifySamples.Rd +++ b/man/dot-modifySamples.Rd @@ -15,3 +15,4 @@ modified Project object \description{ Perform all the sample attribute modifications } +\keyword{internal} diff --git a/man/dot-printNestedList.Rd b/man/dot-printNestedList.Rd index 688496b..5cbcfb7 100644 --- a/man/dot-printNestedList.Rd +++ b/man/dot-printNestedList.Rd @@ -26,3 +26,4 @@ package = "pepr") p = Project(file = projectConfig) .printNestedList(config(p),level=2) } +\keyword{internal} diff --git a/man/dot-reformat.Rd b/man/dot-reformat.Rd index d75fe71..a83c298 100644 --- a/man/dot-reformat.Rd +++ b/man/dot-reformat.Rd @@ -15,3 +15,4 @@ an object of \code{"\linkS4class{Config}"} \description{ Check config spec version and reformat if needed } +\keyword{internal} diff --git a/man/dot-removeAttrs.Rd b/man/dot-removeAttrs.Rd index dd6849a..a1c6121 100644 --- a/man/dot-removeAttrs.Rd +++ b/man/dot-removeAttrs.Rd @@ -15,3 +15,4 @@ an object of \code{"\linkS4class{Project}"} \description{ Remove attributes across all the samples } +\keyword{internal} diff --git a/man/dot-safeFileExists.Rd b/man/dot-safeFileExists.Rd index 7c0d6dc..54a05aa 100644 --- a/man/dot-safeFileExists.Rd +++ b/man/dot-safeFileExists.Rd @@ -15,3 +15,4 @@ a logical indicating whether it's an existing path or valid URL \description{ Check whether the string is a valid URL or an existing local path } +\keyword{internal} diff --git a/man/dot-strformat.Rd b/man/dot-strformat.Rd index b51c8c9..c83e762 100644 --- a/man/dot-strformat.Rd +++ b/man/dot-strformat.Rd @@ -24,3 +24,4 @@ Additionally, if the string is a non-absolute path, it will be expanded. .strformat("~/{VAR1}{VAR2}_file", list(VAR1="hi", VAR2="hello")) .strformat("$HOME/{VAR1}{VAR2}_file", list(VAR1="hi", VAR2="hello")) } +\keyword{internal} diff --git a/tests/testthat/test_config.R b/tests/testthat/test_config.R index e3fc816..27f9c1d 100644 --- a/tests/testthat/test_config.R +++ b/tests/testthat/test_config.R @@ -51,6 +51,7 @@ configConst = system.file( package = "pepr" ) +#' @keywords internal .isAbsolute = function(path) { if (!is.character(path)) stop("The path must be character") return(grepl("^(/|[A-Za-z]:|\\\\|~)", path))