Learn R Programming

biofiles (version 1.0.0)

filter: Return a subset of features or annotations from a GenBank Record

Description

filter returns a subset of features from '>gbRecordList, '>gbRecord or '>gbFeatureTable objects, based on filters provided as key, range, or qualifier values.

select returns a specified subset of annotations from GenBank Features as a data.frame.

Usage

filter(x, ...)

select(x, ...)

# S4 method for gbFeatureTable filter(x, ..., .cols = NULL)

# S4 method for gbFeatureTable select(x, ..., .cols = NULL)

# S4 method for gbRecord filter(x, ..., .cols = NULL)

# S4 method for gbRecord select(x, ..., .cols = NULL)

# S4 method for gbRecordList filter(x, ..., .cols = NULL)

# S4 method for gbRecordList select(x, ..., .cols = NULL)

Arguments

x

A ‘gbRecord’ or ‘gbFeatureTable’ instance.

...

For filter: named values that specify the features to select. These are merged with the values of keys to create the actual query. See Details; for select: see .cols.

.cols

A character vector of ‘keys’ that specify annotaions to be returned as a data.frame from the filtered features. If NULL, a ‘gbFeatureTable’ is returned. Supported ‘keys’ are “index” or “idx”, “start”, tag (e.g., “locus_tag”, “product”, “db_xref”). Specific db_xrefs can by queried using, e.g. “db_xref.GI” or “db_xref.GeneID”.

Value

Depending on the value of .col a gbRecordList, gbRecord, orgbFeatureTable or a data.frame.

Details

Filters are provided as named values using keywords and/or “qualifier = value” pairs:

Permissible keywords are:

index/idx

For example: idx = c(3,4,5,6), idx = 100:150, index = c(1,12:20)

range

For example: range = "10000..25000", range = "..10000,20000..25000", range = "30000.."

key

For example: key = "CDS", key = c("CDS", "gene")

arbitrary qualifiers

For example: product = "ribosomal", locus_tag = c("CPSIT_0123", "CPSIT_0124", "CPSIT_0125"), pseudo = TRUE

Examples

Run this code
# NOT RUN {
load(system.file("extdata", "S_cerevisiae_mito.rda", package = "biofiles"))

## filter all hydrophobic tRNAs from the yeast mitochondrion
hydrophobic <- c("Val", "Ile", "Leu", "Met", "Phe", "Trp", "Cys")
trna <- filter(x, key = "tRNA", product = hydrophobic)

## select start, end, orientation, product, and GeneID
df <- select(trna, "start", "end", "strand", "product", "db_xref.GeneID")
df

## combine the above steps into one
cols <- c("start", "end", "strand", "product", "db_xref.GeneID")
filter(x, key = "tRNA", product = hydrophobic, .cols = cols)

## filter all CDS from position 60,000 bp onward
filter(x, key = "CDS", range = "60000..")
# }

Run the code above in your browser using DataLab