Skip to content

Commit

Permalink
implement remove; #35
Browse files Browse the repository at this point in the history
  • Loading branch information
stolarczyk committed Mar 20, 2020
1 parent 2d8299a commit 0e5c7e4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/constants.R
Expand Up @@ -12,4 +12,5 @@ CFG_IMPLY_IF_KEY = "if"
CFG_DERIVE_ATTRS_KEY = "attributes"
CFG_DERIVE_SOURCES_KEY = "sources"
CFG_IMPORTS_KEY = "imports"
CFG_DUPLICATE_KEY = "duplicate"
CFG_DUPLICATE_KEY = "duplicate"
CFG_REMOVE_KEY = "remove"
21 changes: 21 additions & 0 deletions R/project.R
Expand Up @@ -76,6 +76,7 @@ setMethod(
".modifySamples",
signature = "Project",
definition = function(object) {
object = .removeAttrs(object)
object = .appendAttrs(object)
object = .duplicateAttrs(object)
object = .implyAttrs(object)
Expand Down Expand Up @@ -283,6 +284,26 @@ setMethod(

# sample modifiers --------------------------------------------------------

#' Remove attributes across all the samples
#'
#' @param .Object an object of \code{\link{Project-class}}
#'
#' @return an object of \code{\link{Project-class}}
.removeAttrs <- function(.Object) {
if (!CFG_MODIFIERS_KEY %in% names(config(.Object))) return(.Object)
modifiers = config(.Object)[[CFG_MODIFIERS_KEY]]
if (!CFG_REMOVE_KEY %in% names(modifiers)) return(.Object)
toRemove = modifiers[[CFG_REMOVE_KEY]]
if (!is.null(toRemove)) {
# get a copy of samples to get the dimensions
for (rem in toRemove) {
if(rem %in% colnames(sampleTable(.Object))) {
.Object@samples[,rem] = NULL
}
}
}
return(.Object)
}


#' Append constant attributes across all the samples
Expand Down

0 comments on commit 0e5c7e4

Please sign in to comment.