Skip to content

Commit

Permalink
add logical option for define_samples
Browse files Browse the repository at this point in the history
optional logical output, with vector sample length as phenoData/MSdata rows.
  • Loading branch information
cbroeckl committed May 8, 2024
1 parent 4c76380 commit e1f932a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion R/rc.feature.filter.cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ check_arguments_filter.cv <- function(ramclustObj, qc.tag) {
#'
#' @param ramclustObj ramclustObj containing MSdata with optional MSMSdata (MSe, DIA, idMSMS)
#' @param tag character vector of length one or two. If length is two, enter search string and factor name in $phenoData slot (i.e. c("QC", "sample.type"). If length one (i.e. "QC"), will search for this string in the 'sample.names' slot by default.
#' @param logical optionally convert numeric vector with length equal to the number of matched samples to a logical vector of length equal to number of samples, with TRUE representing matching samples.
#'
#' @return samples found using the tag
#' @export

define_samples <- function(ramclustObj, tag) {
define_samples <- function(ramclustObj, tag, logical = FALSE) {
## define samples in each set
if(length(tag) == 0) {
stop("no tag provided", "\n")
Expand All @@ -55,6 +57,11 @@ define_samples <- function(ramclustObj, tag) {
if (length(samples) == 0) {
stop("no QC samples found using the tag ", "'", tag, "'", "\n")
}

if(logical) {
1:nrow(ramclustObj$MSdata) %in% samples
}

return(samples)
}

Expand Down
3 changes: 2 additions & 1 deletion R/rc.feature.normalize.qc.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ rc.feature.normalize.qc <- function(ramclustObj = NULL,

## define QC samples in each set
if(!is.null(qc.tag)) {
qc <- grepl(qc.tag[1], ramclustObj$phenoData[,2])
# qc <- grepl(qc.tag[1], ramclustObj$phenoData[,2])
qc <- define_samples(ramclustObj = ramclustObj, tag = qc.tag, logical = TRUE)
}

if (!is.logical(qc)) {
Expand Down

0 comments on commit e1f932a

Please sign in to comment.