filtering: Manipulating GDCQuery filters

filteringR Documentation

Manipulating GDCQuery filters

Description

Manipulating GDCQuery filters

The filter is simply a safe accessor for the filter element in GDCQuery objects.

The get_filter is simply a safe accessor for the filter element in GDCQuery objects.

Usage

filter(x, expr)

## S3 method for class 'GDCQuery'
filter(x, expr)

get_filter(x)

## S3 method for class 'GDCQuery'
get_filter(x)

Arguments

x

the object on which to set the filter list member

expr

a filter expression in the form of the right hand side of a formula, where bare names (without quotes) are allowed if they are available fields associated with the GDCQuery object, x

Value

A GDCQuery object with the filter field replaced by specified filter expression

Examples

# make a GDCQuery object to start
#
# Projects
#
pQuery = projects()

# check for the default fields
# so that we can use one of them to build a filter
default_fields(pQuery)
pQuery = filter(pQuery,~ project_id == 'TCGA-LUAC')
get_filter(pQuery)

#
# Files
#
fQuery = files()
default_fields(fQuery)

fQuery = filter(fQuery,~ data_format == 'VCF')
# OR
# with recent GenomicDataCommons versions:
#   no "~" needed
fQuery = filter(fQuery, data_format == 'VCF')

get_filter(fQuery)

fQuery = filter(fQuery,~ data_format == 'VCF'
                & experimental_strategy == 'WXS'
                & type == 'simple_somatic_mutation')

files() %>% filter(~ data_format == 'VCF'
                   & experimental_strategy=='WXS'
                   & type == 'simple_somatic_mutation') %>% count()
                   
                   
files() %>% filter( data_format == 'VCF'
                   & experimental_strategy=='WXS'
                   & type == 'simple_somatic_mutation') %>% count()

# Filters may be chained for the 
# equivalent query
# 
# When chained, filters are combined with logical AND

files() %>%
  filter(~ data_format == 'VCF') %>%
  filter(~ experimental_strategy == 'WXS') %>%
  filter(~ type == 'simple_somatic_mutation') %>%
  count()

# OR

files() %>%
  filter( data_format == 'VCF') %>%
  filter( experimental_strategy == 'WXS') %>%
  filter( type == 'simple_somatic_mutation') %>%
  count()

# Use str() to get a cleaner picture
str(get_filter(fQuery))

Bioconductor/GenomicDataCommons documentation built on Jan. 30, 2024, 11:59 p.m.