uniprot_background {GCModeller} R Documentation

Make a KEGG GSEA background from UniProt protein tables and KEGG KO links

Description

uniprot_background builds a GSEA background model by integrating: \itemize{ \item A protein table exported from UniProt (e.g. via the “proteinTable” tool). \item KEGG gene–KO mappings obtained from the KEGG REST API link/ko endpoint. } The function maps proteins (rows in proteinTable) to KEGG Orthology (KO) identifiers, then to KEGG reference pathways, and finally constructs a background object suitable for enrichment analysis with the gseakit framework.

Usage

uniprot_background(proteinTable, ko.maps,
    id.key = 'row.names',
    species.code = 'map',
    cluster.idset = NULL);

Arguments

proteinTable

Data frame. A protein table exported from UniProt. It should contain at least the following columns (names may vary): \itemize{ \item A gene/protein identifier column specified by id_key. \item name: protein name. \item geneName: gene symbol or primary gene name. \item KEGG: KEGG cross-reference identifiers (optional but recommended). } If id_key = "row.names" or "0", the row names of proteinTable are used as the gene identifier for linking to KO mappings.

ko.maps

Either a data frame or a directory path: \itemize{ \item If a data frame: must contain columns kegg_id and KO, representing mappings between KEGG gene identifiers (e.g. taes:803091) and KO identifiers (e.g. ko:K01810). This is the expected format after parsing KEGG link/ko results with columns named c("kegg_id", "KO"). \item If a directory path: the directory is assumed to contain text files generated by previous calls to link_ko (or directly to the KEGG REST API https://rest.kegg.jp/link/ko/...) . Each file should be a tab-delimited table with two columns: KEGG gene ID and KO ID. These files are read and combined into a single kegg_idKO mapping data frame. }

id.key

Character. Name of the column in proteinTable that contains the gene/protein identifier used to link to the KO mappings. Special values: \itemize{ \item "row.names" or "0": the row names of proteinTable are used as identifiers; a new column id_key is created with these row names. }

Details

The function performs the following steps: \enumerate{ \item If ko_maps is a directory, reads all .txt files inside it, expecting them to be KEGG link/ko results (tab-delimited: kegg_id \t KO), and combines them into a single data frame. \item Loads a standard reference KO set via background::KO_reference() and converts it to a gene set list using as.geneSet. \item Groups the kegg_idKO mapping by KO and creates a lookup list from each KO to its associated KEGG gene IDs. \item Normalizes proteinTable into a data frame and ensures the identifier column specified by id_key exists (using row names if requested). \item For each KEGG reference pathway (cluster): \itemize{ \item Parses the pathway ID and name from the cluster identifier (expected format "pathway_id - pathway_name"). \item Retrieves the set of KO identifiers associated with that pathway. \item Uses these KO identifiers to look up the corresponding KEGG gene IDs from the ko_maps lookup. \item Maps those KEGG gene IDs to rows in proteinTable and builds a data frame with columns: xref (gene identifier), name, alias, KEGG, uniprot. \item Wraps this data frame as a gsea_cluster object. } \item Collects all non-NULL clusters and converts them into a Background object via as.background. }

Authors

xieguigang

Value

An object of class Background from the gseakit framework, which represents a GSEA background model (see as.background). Conceptually, the returned object is a collection of clusters, where each cluster corresponds to a KEGG pathway or map, and each cluster entry contains protein-level annotations (identifier, name, alias, KEGG, UniProt) for the genes in that pathway.

Examples

#\dontrun{

# Example: build background from a UniProt protein table and a directory of
# KEGG link/ko results
# 1) UniProt protein table (exported via the UniProt "proteinTable" tool)
prot_tbl <- read.delim("uniprot_proteins.tsv")
# 2) Directory containing files from link_ko or direct KEGG REST calls, e.g.
# https://rest.kegg.jp/link/ko/taes:803091+taes:803092+taes:123456
ko_dir <- "./kegg_ko_links"
# 3) Build background model
bg <- uniprot_background(
proteinTable = prot_tbl,
ko_maps      = ko_dir,
id_key       = "row.names"   # use row names of prot_tbl as identifiers
)
# Inspect the background object
str(bg)

#}

[Package GCModeller version 1.1.0-beta Index]