Filter a QFeatures assay to samples with complete group annotations
filter_complete_groups.RdSubsets a QFeatures object to the samples belonging to a specified assay, then removes any samples that have NA in one or more of the given colData columns. Both the assay matrix and colData are filtered consistently.
Value
A list with the following elements:
- mat
Numeric matrix (features x samples) with NA-group samples removed.
- cd_assay
Data frame of colData rows corresponding to the retained samples, in the same column order as
mat.- removed
Character vector of sample IDs that were removed due to NA in a group column. Zero-length if none were removed.
Details
This is a utility used internally by mnar_score() and
mnar_global_score(), but is exported for use in any context where
you need a clean sample set with complete group annotations — for example,
before building a design matrix or running differential abundance testing.
Examples
if (FALSE) { # \dontrun{
# Remove the internal standard sample (NA condition) before modelling
filtered <- filter_complete_groups(obj, "psms_norm", c("Condition", "timepoint"))
mat <- filtered$mat # 16 samples, IS removed
cd <- filtered$cd_assay # matching colData
# Check which samples were dropped
filtered$removed
} # }