Learn R Programming

rphast (version 1.6.9)

tagval.feat: Extract value from tag-value formatted attribute in features object

Description

Extract value from tag-value formatted attribute in features object

Usage

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).

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab