readAnnotation: Reads and parses GFF/GTF files

View source: R/readAnnot.R

readAnnotationR Documentation

Reads and parses GFF/GTF files

Description

readAnnotation reads and parses content of GFF/GTF files and stores annotated genomic features (regions) in a GRanges object.

Usage

readAnnotation(fileName, feature = NULL, source = NULL, tagName = NULL)

Arguments

fileName

A path, URL or connection to the GFF/GTF annotation file. Compressed files ("gz", "bz2" and "xz") are handled transparently.

feature

NULL (the default) or a character vector of valid feature types. If not NULL, then only the features of the specified type(s) are imported.

source

NULL (the default) or a character vector of valid source types. If not NULL, then only the sources of the specified type(s) are imported.

tagName

NULL (the default). If not NULL, use this tag as systematic name for the elements of the GRanges object.

Details

feature and source can be NULL. In this case, no selection is performed and all content into the file is imported. If tagName is NULL, then a systematic name (annot.N) is given to elements of the GRanges object.

Value

A GRanges object with annotated regions information.

See Also

GFFFile-class

Examples

##-----------------------------------------------------------------------
## Extraction of miRNAs using an GTF annotation file
##-----------------------------------------------------------------------
basedir  <- system.file("extdata", package="srnadiff", mustWork = TRUE)
gtfFile  <- file.path(basedir, "Homo_sapiens.GRCh38.76.gtf.gz")
annotReg <- readAnnotation(gtfFile, feature="gene", source="miRNA")
annotReg

##-----------------------------------------------------------------------
## Extraction of mature miRNAs using a miRBase-formatted file
##-----------------------------------------------------------------------
basedir  <- system.file("extdata", package="srnadiff", mustWork = TRUE)
gffFile  <- file.path(basedir, "mirbase21_GRCh38.gff3")
annotReg <- readAnnotation(gffFile, feature="miRNA", tagName="miRNA")
annotReg

##-----------------------------------------------------------------------
## Extraction of precursor miRNAs using a miRBase-formatted file
##-----------------------------------------------------------------------
basedir  <- system.file("extdata", package="srnadiff", mustWork = TRUE)
gffFile  <- file.path(basedir, "mirbase21_GRCh38.gff3")
annotReg <- readAnnotation(gffFile, feature="miRNA_primary_transcript")
annotReg


mzytnicki/srnadiff documentation built on March 7, 2023, 2:18 a.m.