Filters-class: Filter objects to retrieve specific data from the database

Description Value Objects of the class Extends Methods Author(s) See Also Examples

Description

The filter objects described on this page allow to filter the results returned from a SimpleCompoundDb database. They inherit from the BasicFilter class defined in the ensembldb database hence providing the same filtering framework. All filter objects provide the same methods.

The individual filters are listed below:

CompoundidFilter

Enables filtering by the compound id (or compound accession). These are provided in the "accession" column of the "compound_basic" database table.

MassrangeFilter

Search for compounds with a mass (either "monoisotopic_molecular_weight" or "avg_molecular_weight", which can be specified with the column parameter of the construction function) within the specified massrange. As a condition only values "()", "[)", "[]" and "(]" are allowed. For "()" the mass of the compound has to be bigger than the lower boundary (value(object)[1]) and smaller than the upper boundary (value(object)[2]). For "(]" the mass of the compound has to be larger than the lower boundary and smaller or equal than the upper boundary. "[]" would match all compounds with a mass larger than or equal to the lower boundary and smaller than or equal to the upper boundary.

Value

Refer to the method and function description above for detailed information on the returned result object.

Objects of the class

Filter objects should always be created by the respective constructor function, always named as the filter class (e.g. CompoundidFilter).

Extends

Class BasicFilter defined in the ensembldb package, directly.

Methods

(in alphabetic order)

column

signature(object="CompoundidFilter", db="SimpleCompoundDb", with.tables="character"): returns the column (attribute name in the SimpleCompoundDb database) that is used by the filter. The method can be applied to any filter class defined in the xcmsExtensions packages. Argument with.tables allows to restrict the filter to certain database tables (by default all database tables are considered).

The method returns a character string with the name of the column.

condition, condition<-

Get and set the condition of the filter (i.e. how values should be compared).

The condition method returns a character string representing the condition.

For MassrangeFilter objects only "()", "(]", "[]" and "[)" are allowed. See the filter description above for more details.

value, value<-

Get and set the value of the filter.

The value method returns a character vector of the value(s).

For MassrangeFilter: argument value has to be a numeric vector of length two specifying the lower and upper boundary of the mass range. The value method for MassrangeFilter returns a numeric vector of length two.

where

signature(object="CompoundidFilter", db="SimpleCompoundDb", with.tables="character"): returns the where clause for the SQL query to retrieve the data. Argument with.tables allows to restrict the filter to certain database tables (by default all database tables are considered).

The method returns a character string with the name of the column.

Author(s)

Johannes Rainer.

See Also

SimpleCompoundDb

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
## With the package a SimpleCompoundDb object is provided which is bound
## to the variable name scDb.
scDb

## List all tables from the database along with the respective columns
listTables(scDb)

## List all column names
columns(scDb)

## Define a CompoundidFilter specifying some ids (accession ids).
cf <- CompoundidFilter(c("HMDB00010", "HMDB00002", "HMDB00011"))

## The default condition is an equality comparison, i.e. "=" for a single value
## and "in" for multiple values.
condition(cf)

## Use the filter to retrieve just data for these compounds from the database.
res <- compounds(scDb, filter=cf, columns=c("name", "inchikey"))
res

## Change the filter to "!="
condition(cf) <- "!="
condition(cf)

## The query will now return all entries except the data for the 3 compounds.
res <- compounds(scDb, filter=cf, columns=c("name", "inchikey"))
nrow(res)

####
## MassrangeFilter
## Define a MassrangeFilter matching compounds with a mass >= 300 and < 310
mrf <- MassrangeFilter(c(300, 310), condition="[)")

## Just print the default where
where(mrf)

## For a SimpleCompoundDb the where clause would be:
where(mrf, scDb)

## So, by default, the column monoisotopic_molecular_weight is searched. To change
## that to avg_molecular_weight:
mrf <- MassrangeFilter(c(300, 310), column="avg_molecular_weight")
where(mrf, scDb)

jotsetung/xcmsExtensions documentation built on May 19, 2019, 9:42 p.m.