Extends dplyr::filter() to subset samples in a qseaSet based on
predicates applied to its sampleTable.
# S3 method for class 'qseaSet'
filter(.data, ..., .preserve = FALSE)qseaSet
A qseaSet object whose samples are to be filtered.
Predicate expressions passed to dplyr::filter(), evaluated on the
sampleTable. For example, age > 65, tissue == "Colon".
Default: none (no filtering).
logical(1)
Placeholder argument for compatibility with dplyr::filter(). Ignored
here since grouping is not implemented.
Default: FALSE.
A qseaSet object containing only the samples whose
sampleTable rows satisfied the filter expressions. If no samples
remain, an empty qseaSet is returned (with a message but not an error).
Filtering is performed on the result of qsea::getSampleTable(.data).
Matching rows determine the sample_names retained in the qseaSet.
Grouped filtering (group_by) is not supported for qseaSet.
qsea::getSampleTable() to inspect metadata,
subsetQset() for explicit sample subsetting,
selectQset() for column selection in the sampleTable.
data(exampleTumourNormal, package = "mesa")
# Keep only older patients
exampleTumourNormal %>% filter(age >= 70)
#> qseaSet
#> =======================================
#> 6 Samples:
#> Colon1_N, Colon1_T, Lung2_N, Lung2_T, Lung3_N, Lung3_T
#> 819 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38
# Restrict to colon tissue
exampleTumourNormal %>% filter(tissue == "Colon")
#> qseaSet
#> =======================================
#> 4 Samples:
#> Colon1_N, Colon1_T, Colon2_N, Colon2_T
#> 819 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38
# Select only tumour samples
exampleTumourNormal %>% filter(tumour != "Normal")
#> qseaSet
#> =======================================
#> 5 Samples:
#> Colon1_T, Colon2_T, Lung1_T, Lung2_T, Lung3_T
#> 819 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38
# Combine predicates: lung tumours only
exampleTumourNormal %>%
filter(stringr::str_detect(sample_name, "Lung"), tumour != "Normal")
#> qseaSet
#> =======================================
#> 3 Samples:
#> Lung1_T, Lung2_T, Lung3_T
#> 819 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38
# If no rows match, returns empty qseaSet (with a message)
exampleTumourNormal %>% filter(tissue == "Liver")
#> No samples remaining, returning an empty qseaSet.
#> qseaSet
#> =======================================
#> 0 Samples:
#>
#> 819 Regions in 22 chromosomes of BSgenome.Hsapiens.NCBI.GRCh38