Load genomic feature annotations from a GFF3 or BED file
Source:R/load_annotation.R
loadAnnotation.RdReads a GFF3 or BED annotation file and returns a
GRanges object with standardized metadata
columns. The result can be passed directly to the annotation argument
of commaData.
Arguments
- file
Character string. Path to a GFF3 (
.gff,.gff3,.gff.gz,.gff3.gz) or BED (.bed) file.- feature_types
Character vector or
NULL. If provided, only features with a matchingtype(GFF3) orname(BED) are retained. Common GFF3 types include"gene","CDS","rRNA","tRNA".NULLretains all features.- ...
Additional arguments passed to
rtracklayer::import().
Value
A GRanges object. The mcols
always include:
feature_typeCharacter. The feature type (from GFF3
typecolumn, or"region"for BED).nameCharacter. Feature name or identifier (from GFF3
NameorIDattribute, or BEDnamecolumn).
Additional metadata columns from the source file are preserved.
Details
This function requires the rtracklayer package (Bioconductor):
BiocManager::install("rtracklayer")Both NCBI-style GFF3 (with gene_biotype, product attributes)
and Ensembl-style GFF3 are supported.
Examples
# Load the bundled example GFF3 annotation
gff_file <- system.file("extdata", "example.gff3", package = "comma")
if (requireNamespace("rtracklayer", quietly = TRUE)) {
ann <- loadAnnotation(gff_file)
ann <- loadAnnotation(gff_file, feature_types = "gene")
}
if (FALSE) { # \dontrun{
# Load only genes and CDS from your own file
ann <- loadAnnotation("my_genome.gff3", feature_types = c("gene", "CDS"))
} # }