Parses, filters, and caches the CTD chemical-gene interactions file so that
it can be used by enrichment_CTD. This function must be called
once before running any enrichment analysis.
The raw data file must be downloaded manually from the CTD website. The required file is CTD_chem_gene_ixns.csv.gz, available at https://ctdbase.org/reports/CTD_chem_gene_ixns.csv.gz.
Details
Processing steps performed by import_CTD:
Reads the CSV, skipping the 27 CTD header lines.
Filters interactions to Homo sapiens only (OrganismID 9606).
For each chemical, collects the associated Entrez gene IDs.
Maps Entrez IDs to HGNC gene symbols via org.Hs.eg.db.
Saves four cached objects to the user cache directory:
chemicals,ChemicalName_GeneEntrezIds,ChemicalName_GeneSymbols, andctd_interactions(a long-format table of chemical–gene–action triples used byenrichment_CTD(interaction_types = ...)).
The cache is stored under rappdirs::user_cache_dir("ctdR"). To
re-import (e.g. after downloading a newer CTD release), simply call
import_CTD() again — existing cache files will be overwritten.
Filtering by interaction type (e.g., to retain only
"increases^expression" interactions) is done at enrichment time via
the interaction_types argument of enrichment_CTD,
not here — so a single import supports any combination of filters without
re-running this step.
Data Licensing Disclaimer
This package does not bundle or redistribute any CTD data. The Comparative Toxicogenomics Database is maintained by NC State University and its data are subject to specific licensing terms. Users are responsible for downloading the data directly from https://ctdbase.org and for complying with the CTD Terms of Service (https://ctdbase.org/about/legal.jsp). By using this function you acknowledge that you have read and accepted those terms.
See also
enrichment_CTD for running enrichment analysis after
import, including the interaction_types filter.
Examples
sample_file <- system.file(
"extdata", "CTD_chem_gene_ixns_sample.csv",
package = "ctdR"
)
import_CTD(sample_file)
#> Reading CTD chemical-gene interactions from: /home/runner/work/_temp/Library/ctdR/extdata/CTD_chem_gene_ixns_sample.csv
#> Filtered to 86 human interactions
#> Mapping genes for 10 chemicals...
#> Warning: 10 ChemicalID(s) appear with more than one ChemicalName in the CTD file; only the first name per ID is retained. Affected IDs: D000082, D001564, D002104, D003907, D004958 ... (and 5 more)
#> CTD data cached successfully in: ~/.cache/ctdR
#> 10 chemicals | 17 unique genes | 0 s