Extract value from tag-value formatted attribute in features object

Share:

Description

Extract value from tag-value formatted attribute in features object

Usage

1
tagval.feat(x, tag)

Arguments

x

A features object of type feat. The attribute field should be in tag-value format (either GFF 2 standard; ie, "tag1 val1a val1b; tag2 val2 ; ...", or, GFF 3 standard; ie, "tag1=val1a,val1b;tag2=val2; ...". where vals are in quotes if they are strings.

tag

The tag whose values are to be extracted.

Value

If there is at most one relevant value for each feature, a character vector of the same length as x will be returned, containing the value for each feature, or NA where the tag does not exist for that feature. If some elements have multiple values, then the return value will be a list with the same length as x, each element being a character vector containing the values for the corresponding element of x (or NA for no value).

Author(s)

Melissa J. Hubisz

Examples

1
2
3
4
5
6
7
8
9
exampleArchive <- system.file("extdata", "examples.zip", package="rphast")
featFile <- "sol1.gp"
unzip(exampleArchive, featFile)
f <- read.feat(featFile)
geneName <- tagval.feat(f, "transcript_id")
geneName[1:10]
length(unique(geneName)) # number of unique genes
unlink(featFile)
rm(f, geneName)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.