An R6 class to represent transcriptome annotation with protein mapping. Specifically, it provides the following features:
Transcriptome annotation:
Association of transcript IDs with gene IDs, RNA types, and species
Association of gene IDs with gene symbols, protein IDs (UniProt), etc.
Details
For more information on how to specify the arguments, please refer to the vignette defining file formats.
Methods
Method new()
Initialize a new Annotation object.
This method initializes a new Annotation object.
Usage
Annotation$new(
annotation = NULL,
format_gff = TRUE,
idmapping = NULL,
annotation_dir = NULL,
log_level = "WARN",
suffix_pattern = "\\.\\d+$",
gff_type_filter = c(".*RNA", ".*transcript"),
gff_source = c("ncbi", "ensembl")
)Arguments
annotationPath to the annotation file in GFF format / or as described in the vignette. It can be a vector of files.
format_gffIf
TRUE, the annotation file is in GFF format.idmappingPath to the idmapping file, which allows the mapping of uniprot id to gene id. If not give, the idmapping file will be downloaded from uniprot using taxon ID from annotation file.
annotation_dirPath to a directory containing annotation CSV files (previously generated by
write_to_directory). If provided, this takes precedence overannotationandidmapping.log_levelLogging level, e.g., "INFO", "WARN", "DEBUG".
suffix_patternThe regex pattern used see clean_txid_versions method.
gff_type_filterVector of regex patterns to filter the type column (3rd column of GFF)
gff_sourceGFF format source: "ncbi" (default) or "ensembl". NCBI style looks for ID, Parent, gene, Dbxref, gbkey attributes. Ensembl style looks for ID (with transcript: prefix), gene_id, transcript_id, Parent (with gene: prefix), and Name attributes.
Method generate_translate_dict()
generate a translate dictionary (named vector) from and id to another based on the annotation
Details
Below is precised what is available and id type for value depending on id type for keys
Entrez Gene ID
gid(Or equivalent on Ensembl,UCSC...)Gene symbol
symbolProtein name
protein_namesProtein ID
uniprotTaxon ID
tax_idTaxon name
tax_nameTyped gene ID
tgid
RefSeq transcript ID
txid(Or equivalent on Ensembl,UCSC...)Entrez Gene ID
gidrna type
typeTaxon ID
tax_idTaxon name
tax_nameTyped gene ID
tgid
Typed gene ID
tgidi.e. gene id with type concatenated (sep is _) (one gene can have several type, some coding, some not coding)Gene symbol
symbolProtein name
protein_names(warning even if not coding type)Protein ID
uniprot(warning even if not coding type)rna type
typeTaxon ID
tax_idTaxon name
tax_name
Uniprot protein ID
uniprotEntrez Gene ID
gidProtein name
protein_namesGene symbol
symbol
Gene symbol
symbolEntrez Gene ID
gidProtein ID
uniprot
Method export_to_df()
Export annotation data to a data.frame for a given 'from' ID type.
For a specified 'from' ID type, this method creates a data.frame where each row corresponds to a unique 'from' ID, and columns represent all associated 'to' ID types. Missing associations will be represented as NA.
Method write_to_directory()
Write all annotation data frames to a specified directory.
This method iterates through all available 'from' ID types,
generates a data.frame for each using self$export_to_df(),
and writes each data.frame to a CSV file named after the
'from' ID type (e.g., "gid.csv") in the specified directory.
Method clean_txid_versions()
Clean version suffixes from transcript IDs within the internal annotation structures.
This method iterates through the private$annotations object.
If a from_key (names of a mapping) is "txid", it cleans these names.
If a to_key (values of a mapping) is "txid", it cleans these values.
It uses the remove_id_version_suffix utility function.