| Title: | drugTargetInteractions: Mining the Druggable Genome |
|---|---|
| Description: | Utilities for identifying known drug-target interactions for a sets of query drug and/or target protein (gene) identifiers. The interaction information is obained from a series of drug/target databases. |
| Authors: | Thomas Girke [cre, aut] (ORCID: <https://orcid.org/0000-0003-0710-3777>), Kevin Horan [ctb] |
| Maintainer: | Thomas Girke <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 1.21.5 |
| Built: | 2026-07-25 05:02:16 UTC |
| Source: | https://github.com/bioc/drugTargetInteractions |
The drugTargetInteractions package provides utilities for identifying drug-target interactions for sets of small molecule or gene/protein identifiers. The required drug-target interaction information is obained from a local SQLite instance of the ChEMBL database.
The DESCRIPTION file:
| Package: | drugTargetInteractions |
| Type: | Package |
| Title: | drugTargetInteractions: Mining the Druggable Genome |
| Version: | 1.21.5 |
| Date: | 2026-07-24 |
| Authors@R: | c( person("Thomas", "Girke", email="[email protected]", role=c("cre", "aut"), comment=c(ORCID="0000-0003-0710-3777")), person("Kevin", "Horan", role="ctb")) |
| Description: | Utilities for identifying known drug-target interactions for a sets of query drug and/or target protein (gene) identifiers. The interaction information is obained from a series of drug/target databases. |
| Depends: | methods, R (>= 4.1) |
| Imports: | utils, stats, RSQLite, UniProt.ws, biomaRt,ensembldb, BiocFileCache,dplyr,rappdirs, AnnotationFilter, S4Vectors, httr2, readxl, jsonlite |
| Suggests: | RUnit, BiocStyle, knitr, rmarkdown, ggplot2, reshape2, DT, EnsDb.Hsapiens.v86, testthat (>= 3.0.0) |
| VignetteBuilder: | knitr |
| License: | Artistic-2.0 |
| Encoding: | UTF-8 |
| NeedsCompilation: | no |
| URL: | https://github.com/girke-lab/drugTargetInteractions |
| biocViews: | Cheminformatics, BiomedicalInformatics, Pharmacogenetics, Pharmacogenomics, Proteomics, Metabolomics |
| Config/testthat/edition: | 3 |
| BugReports: | https://github.com/girke-lab/drugTargetInteractions |
| Config/roxygen2/version: | 8.0.0 |
| Config/pak/sysreqs: | make libbz2-dev libicu-dev liblzma-dev libpng-dev libxml2-dev libssl-dev xz-utils zlib1g-dev |
| Repository: | https://bioc.r-universe.dev |
| Date/Publication: | 2026-07-24 23:06:05 UTC |
| RemoteUrl: | https://github.com/bioc/drugTargetInteractions |
| RemoteRef: | HEAD |
| RemoteSha: | d036d77685ef9ac6e556313b4ca7be3bd4ba191e |
| Author: | Thomas Girke [cre, aut] (ORCID: <https://orcid.org/0000-0003-0710-3777>), Kevin Horan [ctb] |
| Maintainer: | Thomas Girke <[email protected]> |
Index of help topics:
broadRepurposingHubAnnot
Query Broad Repurposing Hub drug-target
annotations bidirectionally
buildBroadRepurposingHubDb
Build (or fetch a cached) local SQLite database
of Repurposing Hub drug-target annotations
buildGenomeWideDrugTargetTable
Genome-wide, checkpointed drug-target
annotation build across the six annotation
sources, anchored on an HGNC gene table
buildGtoPdbDb Build (or fetch a cached) local SQLite database
of GtoPdb drug-target interactions
buildHgncSymbolMap Build a prev/alias-symbol -> current-symbol
normalization map
buildTtdDb Build (or fetch a cached) local SQLite database
of TTD interactions
buildUnichemDb Build (or fetch a cached) local SQLite of
UniChem compound cross-references
cmpIdMapping cmpIdMapping
combineDrugTargets Combine 'queryDrugTargets' results into one
table
downloadBroadRepurposingHub
Download the Broad Repurposing Hub drug/sample
annotation flat files
downloadChemblDb downloadChemblDb
downloadGtoPdb Download GtoPdb's bulk interactions (REST) and
HGNC mapping (flat file) data
downloadHgncTable Download (and cache) an HGNC complete-gene-set
TSV snapshot
downloadTTD Download the TTD flat files needed for
target-drug mapping
downloadUniChem downloadUniChem
downloadUnichemTables Download the UniChem table dumps needed for
compound cross-referencing
drugTargetAnnot drugTargetAnnot
drugTargetAnnotTable drugTargetAnnotTable
drugTargetBioactivity drugTargetBioactivity
drugTargetInteractions-package
drugTargetInteractions: Mining the Druggable
Genome
genConfig genConfig
getChemblBioactivities
Retrieve bioactivity measurements from the
ChEMBL REST API
getChemblBioassay Query raw ChEMBL bioassay measurements via the
queryBy interface
getChemblDrugTarget Query known drug-target annotations via the
ChEMBL REST API
getChemblMolecule Retrieve molecule records from the ChEMBL REST
API
getChemblTarget Search ChEMBL for a target by gene symbol or
name
getDgidbDrugs Retrieve DGIdb drug interactions for one or
more genes
getDgidbDrugTarget Query DGIdb interaction data via the uniform
queryBy interface
getDgidbTargets Retrieve DGIdb target interactions for one or
more drugs
getDrugTarget getDrugTarget
getEnsemblOrthologs Retrieve cross-species orthologs for one or
more genes from Ensembl
getEnsemblParalogs Retrieve within-species paralogs for one or
more genes from Ensembl
getHgncGeneTable Load the HGNC complete gene set as a
gene-centric data.frame
getOpenTargetsDrugIds Resolve many drug names to ChEMBL IDs in
batched GraphQL requests
getOpenTargetsDrugs Retrieve known drugs / clinical candidates for
one or more targets from Open Targets (target
-> drug)
getOpenTargetsDrugTarget
Query Open Targets drug/target data via the
uniform queryBy interface
getOpenTargetsIds Resolve many gene symbols to Ensembl IDs in
batched GraphQL requests
getOpenTargetsTargets Retrieve targets for one or more drugs from
Open Targets (drug -> target)
getParalogs getParalogs
getPubchemDrugs Retrieve PubChem bioactivities for one or more
genes (target -> drug)
getPubchemDrugTarget Query PubChem bioactivity data via the uniform
queryBy interface
getPubchemTargets Retrieve PubChem bioactivities for one or more
drugs (drug -> target)
getSymEnsUp Gene to Protein ID Mappings
getUnichemMapping Translate compound identifiers between
databases via a local UniChem SQLite
getUniprotIDs Retrieve UniProt IDs via ID and Cluster
Mappings
getUniprotMapping Map identifiers between databases via the
UniProt REST ID Mapping API
gtoPdbTargetAnnot Query GtoPdb drug-target interactions
bidirectionally
listBioassayFields List the fields available from a bioassay
source under 'fields = "all"'
listDrugTargetFields List the fields available from a drug-target
source under 'fields = "all"'
normalizeGeneSymbols Normalize gene symbols to their current
HGNC-approved form
processDrugage processDrugage
queryDrugTargets Query drug-target interactions across multiple
sources from any recognised starting identifier
runDrugTarget_Annot_Bioassay
runDrugTarget_Annot_Bioassay
transformTTD transformTTD
ttdTargetAnnot Query TTD target-drug interactions
bidirectionally
Thomas Girke [cre, aut] (ORCID: <https://orcid.org/0000-0003-0710-3777>), Kevin Horan [ctb]
Maintainer: Thomas Girke <[email protected]>
Queries the local Repurposing Hub SQLite built by
buildBroadRepurposingHubDb, using the same
queryBy = list(molType, idType, ids) convention as
ttdTargetAnnot - including its QueryIDs column:
every row of the result is tagged with the original query token it
matched, and query IDs that returned no rows still appear as a single
row with all other fields NA.
molType = "protein" (or "gene"), idType =
"symbol" -> target -> drug. The Repurposing Hub only exposes
gene symbols as targets (no accession/ID system of its own).
molType = "cmp", idType one of "name"
(pert_iname) or "broad_id" (a specific physical
sample/batch ID) -> drug -> target.
"symbol"/"name" lookups are case-insensitive (the
Repurposing Hub's own pert_iname values are lower-case, unlike
most other sources in this package); "broad_id" is exact-match.
A drug with no listed target still has one row with
target_gene = NA (see .brhExplodeTargets), so it
remains reachable by name/broad_id even though it can never surface
via a gene-side query.
broadRepurposingHubAnnot( queryBy = list(molType = NULL, idType = NULL, ids = NULL), brhDbPath, fields = "core" )broadRepurposingHubAnnot( queryBy = list(molType = NULL, idType = NULL, ids = NULL), brhDbPath, fields = "core" )
queryBy |
list with components |
brhDbPath |
character(1) path to the Repurposing Hub SQLite, e.g.
from |
fields |
|
idType = "broad_id" does not query broad_interactions
directly - since the 2026-07-22 two-table split (see
buildBroadRepurposingHubDb), broad_id lives only
in broad_samples. Each queried broad_id is first
resolved to its compound name(s) there, then dispatched exactly like
an idType = "name" lookup, with QueryIDs kept tagged to
the original broad_id rather than the resolved name. A
broad_id resolves to exactly one compound in the overwhelming
majority of cases; a small number (10 as of the 2025-08-18 release)
resolve to more than one due to genuine naming inconsistencies in
Broad's own source file (e.g. "prednisolone acetate" vs.
"prednisolone-acetate" sharing one broad_id) - handled
as a real one-to-many resolution (all matching compounds' full
target sets are returned) rather than collapsed to one or errored on.
A data.frame with columns QueryIDs,
target_gene, pert_iname, clinical_phase,
moa, disease_area, indication, smiles,
InChIKey, pubchem_cid, structure_ambiguous
(with the default fields = "core"), or a subset when
fields requests specific columns. structure_ambiguous
= TRUE means pert_iname covers more than one distinct
structure for that row (packed "; "-joined into
smiles/InChIKey/pubchem_cid, aligned segment-
by-segment across the three columns) - a real name collision in
the source data (different salts/stereoisomers sharing a display
name), not a parsing artifact; structure-sensitive work should key
on InChIKey, not pert_iname, for those rows. Sample-
level fields (purity, vendor, catalog_no,
qc_incompatible, expected_mass,
deprecated_broad_id) moved to broad_samples in the
same SQLite file - query it directly (keyed on broad_id)
for that data; it is not returned here.
buildBroadRepurposingHubDb, ttdTargetAnnot,
listDrugTargetFields
dbPath <- buildBroadRepurposingHubDb() broadRepurposingHubAnnot(list(molType = "protein", idType = "symbol", ids = c("FGFR1", "IL1B")), dbPath) broadRepurposingHubAnnot(list(molType = "cmp", idType = "name", ids = "pemigatinib"), dbPath)dbPath <- buildBroadRepurposingHubDb() broadRepurposingHubAnnot(list(molType = "protein", idType = "symbol", ids = c("FGFR1", "IL1B")), dbPath) broadRepurposingHubAnnot(list(molType = "cmp", idType = "name", ids = "pemigatinib"), dbPath)
Downloads the Repurposing Hub flat files (see
downloadBroadRepurposingHub) and writes **two** tables
to a local SQLite file, each kept at its own true grain rather than
flattened into one (see "Two-table design" below):
broad_interactions (one row per (pert_iname,
target_gene) drug-target edge) and broad_samples (physical-
sample/QC metadata, one or more rows per broad_id). The file
is cached via BiocFileCache under a name that includes the source
files' own "!File_date" (e.g. broad_repurposing_20250818.db),
so rebuilding is a no-op until the Hub actually republishes. As with
buildTtdDb, the package itself never ships or
redistributes this file - it is built into the caller's own local
cache the first time this is run.
buildBroadRepurposingHubDb(rerun = FALSE, config = genConfig())buildBroadRepurposingHubDb(rerun = FALSE, config = genConfig())
rerun |
logical(1); passed to
|
config |
list as returned by |
character(1) local file path to the SQLite database.
Originally a single flat broad_interactions table, mirroring
buildTtdDb's one-table shape - but unlike TTD, the
Repurposing Hub's sample-level file (sample, one row per
physical vial/lot, broad_id) genuinely has a *different*
grain than the drug-target edge the interaction table is meant to
represent: a single compound (pert_iname) routinely has
several physical samples (verified live: 67
than one broad_id, up to 8), and each sample can itself carry
several repeat QC/purity readings. A one-table design merging
sample straight into the exploded target table (via
pert_iname, deduplicated only by
sample[!duplicated(sample), ], which drops exact duplicate
*rows*, not duplicate *join keys*) confirmed to multiply rows in
practice - a real, shipped bug: 3.57x overall row inflation
(17,996 true drug-target edges vs. 64,336 rows), with one
compound-target pair duplicated 175x, driven by repeat purity
readings for a single broad_id that survived the row-level
dedup untouched. Fixed by never merging sample into the
interaction table at all: broad_interactions draws its
compound-level structure fields from
.brhCompoundStructure instead (a proper one-row-per-
compound reduction of sample, packing the rare cases where a
name genuinely covers multiple structures rather than picking one
arbitrarily), and everything else sample carries (purity,
vendor, catalog_no, qc_incompatible, etc.) - which was never
actually a property of a drug-target edge to begin with, only of a
physical vial - moves to broad_samples, kept at its own
natural grain. broad_interactions' grain is asserted, not
just assumed, via .assertUniqueKey immediately after
the reduction, so a future Repurposing Hub release that breaks this
assumption fails the build loudly instead of silently reinflating
results. idType = "broad_id" queries
(broadRepurposingHubAnnot) now resolve broad_id
-> pert_iname via broad_samples first, then dispatch into
broad_interactions - which, given the 67
is also a correctness improvement for that query path, not just a
side effect of the split.
downloadBroadRepurposingHub, broadRepurposingHubAnnot
dbPath <- buildBroadRepurposingHubDb() dbPathdbPath <- buildBroadRepurposingHubDb() dbPath
Loops getChemblDrugTarget/getDgidbDrugTarget/
getOpenTargetsDrugTarget/ttdTargetAnnot/
broadRepurposingHubAnnot/gtoPdbTargetAnnot
over every gene in hgncTable (default: all human protein-coding
genes from getHgncGeneTable), in checkpointed chunks
written to outDir as it goes - so an interrupted run resumes
from the last completed chunk instead of starting over. Deliberately
excludes ChEMBL's bioassay function and PubChem (see the file header
and the "Genome-Wide Master Table" vignette section for why).
buildGenomeWideDrugTargetTable( hgncTable = NULL, sources = c("chembl", "dgidb", "opentargets", "ttd", "broad", "gtopdb"), ttdDbPath = NULL, brhDbPath = NULL, gtoPdbDbPath = NULL, outDir, chunkGenes = 500L, rerun = FALSE, verbose = TRUE, ... )buildGenomeWideDrugTargetTable( hgncTable = NULL, sources = c("chembl", "dgidb", "opentargets", "ttd", "broad", "gtopdb"), ttdDbPath = NULL, brhDbPath = NULL, gtoPdbDbPath = NULL, outDir, chunkGenes = 500L, rerun = FALSE, verbose = TRUE, ... )
hgncTable |
data.frame from |
sources |
character vector, any of |
ttdDbPath |
character(1) path to a local TTD SQLite (see
|
brhDbPath |
character(1) path to a local Broad Repurposing Hub
SQLite (see |
gtoPdbDbPath |
character(1) path to a local GtoPdb SQLite (see
|
outDir |
character(1) directory to write checkpoint chunks and the manifest to; created if it doesn't exist. |
chunkGenes |
integer(1) genes per checkpoint chunk (default 500)
- a coarser grouping purely for resumability; each source's own
function still does its own finer-grained request batching
( |
rerun |
logical(1); if |
verbose |
logical(1); default |
... |
additional arguments passed through to the ChEMBL/DGIdb/
Open Targets calls (e.g. |
A single target-centric run already answers the reverse drug -> target question too: every row already carries whichever drug matched that gene, so filtering the assembled table by drug identifier gives that direction for free - no separate compound- centric run is needed.
A named list, one data.frame per successfully-built source,
each row tagged with hgnc_id/symbol/ensembl_gene_id
alongside that source's own native columns (not run through
combineDrugTargets's harmonization, to keep maximum
information - apply that separately if wanted). Also cached via
genConfig's BiocFileCache under a name that
encodes the HGNC source snapshot and build date, so a completed
build is reusable without recomputation; the cache path is recorded
in attr(., "cachePath").
getHgncGeneTable, queryDrugTargets,
combineDrugTargets
## Small illustrative run, not genome-wide - see the "Genome-Wide ## Master Table" vignette section for the full workflow (takes ## hours at full scale, not run here). hgncSmall <- getHgncGeneTable()[1:3, ] res <- buildGenomeWideDrugTargetTable( hgncTable = hgncSmall, sources = c("dgidb", "opentargets"), outDir = tempfile("dti_build_")) names(res)## Small illustrative run, not genome-wide - see the "Genome-Wide ## Master Table" vignette section for the full workflow (takes ## hours at full scale, not run here). hgncSmall <- getHgncGeneTable()[1:3, ] res <- buildGenomeWideDrugTargetTable( hgncTable = hgncSmall, sources = c("dgidb", "opentargets"), outDir = tempfile("dti_build_")) names(res)
Downloads GtoPdb's bulk interaction data and HGNC mapping (see
downloadGtoPdb), filters interactions to
targetSpecies == "Human", left-joins in the HGNC gene symbol
per targetId (a target ID may map to more than one gene for
multi-subunit complexes - kept as separate rows, not collapsed), and
writes a single denormalized, indexed gtp_interactions table
to a local SQLite file - the same one-table shape as
buildTtdDb/buildBroadRepurposingHubDb. The
file is cached via BiocFileCache under a name that includes GtoPdb's
own release version (e.g. gtopdb_2026.2.db), so rebuilding is a
no-op until GtoPdb actually republishes. As with the other local-SQLite
sources, the package itself never ships or redistributes this file -
it is built into the caller's own local cache the first time this is
run (see the file header for why that is a conservative default here,
not a licensing requirement).
buildGtoPdbDb(rerun = FALSE, config = genConfig())buildGtoPdbDb(rerun = FALSE, config = genConfig())
rerun |
logical(1); passed to |
config |
list as returned by |
character(1) local file path to the SQLite database.
downloadGtoPdb, gtoPdbTargetAnnot
dbPath <- buildGtoPdbDb() dbPathdbPath <- buildGtoPdbDb() dbPath
DGIdb and TTD (and potentially any other external gene list) echo
back whatever symbol was current when their records were
curated; a nontrivial fraction are now outdated relative to HGNC.
This builds a lookup from every historical prev_symbol/
alias_symbol value to its gene's current approved
symbol, so incoming symbols from those sources can be routed
through it before joining back to an HGNC-anchored table.
buildHgncSymbolMap(hgncTable)buildHgncSymbolMap(hgncTable)
hgncTable |
data.frame as returned by |
A named character vector (old symbol -> current symbol).
Old symbols that map to more than one current symbol (real cases
exist, e.g. shared paralog aliases) keep only the first
(alphabetically, for determinism) and are also reported via
attr(., "ambiguous") (a named list of all candidate current
symbols for each flagged old symbol); a warning() is raised
if any ambiguity is found.
getHgncGeneTable, normalizeGeneSymbols
hgncTable <- getHgncGeneTable() symbolMap <- buildHgncSymbolMap(hgncTable)hgncTable <- getHgncGeneTable() symbolMap <- buildHgncSymbolMap(hgncTable)
Downloads the TTD flat files (see downloadTTD), parses
them, and writes a single denormalized ttd_interactions table
(TTD's target-drug relationship is a simple 1-hop mapping, unlike
ChEMBL's multi-table mechanism/activity schema, so one flat, indexed
table is the natural queryable shape) to a local SQLite file. The
file is cached via BiocFileCache under a name that includes TTD's own
release version (e.g. ttd_10.1.01.db), so rebuilding is a
no-op until TTD actually publishes a new version. As with
downloadChemblDb, the package itself never ships or
redistributes this file - it is built into the caller's own local
cache the first time this is run.
buildTtdDb(rerun = FALSE, config = genConfig())buildTtdDb(rerun = FALSE, config = genConfig())
rerun |
logical(1); passed to |
config |
list as returned by |
character(1) local file path to the SQLite database. The
database additionally carries a ttd_release table (columns
file, version, date) recording every downloaded
TTD file's own embedded release stamp separately, since TTD does not
reliably move these together across files - see the file header
note. ttdTargetAnnot attaches this as
attr(result, "ttd_release").
dbPath <- buildTtdDb() dbPathdbPath <- buildTtdDb() dbPath
Downloads UniChem's bulk table dumps (see
downloadUnichemTables), loads reference.tsv.gz in
chunks (never all in memory at once), filters to compounds with a
cross-reference to at least minSources distinct databases, and
writes two tables to a local SQLite file: unichem_xref(uci,
src_id, compound_id) and unichem_sources(src_id, name,
name_long, description) (a direct copy of source.tsv.gz, used
by getUnichemMapping to resolve source-name arguments).
The file is cached via BiocFileCache under a name that includes the
build date (UniChem's bulk dumps carry no release-version string the
way TTD's flat files do); rerun = FALSE reuses any
previously-built unichem_*.db regardless of which day it was
built (see .unichemLatestCachedDb - an exact same-day
match would otherwise silently miss yesterday's build and trigger an
unwanted ~hour-long rebuild).
buildUnichemDb( rerun = TRUE, config = genConfig(), minSources = 2L, anchorSources = .unichemAnchorSources, chunkSize = 500000L, verbose = FALSE )buildUnichemDb( rerun = TRUE, config = genConfig(), minSources = 2L, anchorSources = .unichemAnchorSources, chunkSize = 500000L, verbose = FALSE )
rerun |
logical(1); passed to |
config |
list as returned by |
minSources |
integer(1) minimum distinct sources per UCI to keep
(default 2) - see |
anchorSources |
character vector of UniChem source names a kept
UCI must reference at least one of, or |
chunkSize |
integer(1) rows read per batch while loading
|
verbose |
logical(1); if TRUE, message progress throughout. |
This is a substantially heavier operation than the package's other
build*Db()/download*Db() functions - live-tested
2026-07-17: ~1.5GB download, ~166M source rows to load/filter/index.
Expect this to take real time (minutes, not seconds) and several GB
of temporary disk space for the unfiltered staging table before
filtering shrinks it down.
character(1) local file path to the SQLite database.
downloadUnichemTables, getUnichemMapping
dbPath <- buildUnichemDb(verbose = TRUE) dbPathdbPath <- buildUnichemDb(verbose = TRUE) dbPath
Function to generate compound ID mappings UniChem.
This function requires the ID mapping files "src1src2.txt.gz", "src1src22.txt.gz", and
"src1src7.txt.gz" to exist in a directory called "downloads" before being run. These
can be generated with the downloadUniChem function.
It will do some processing on these files and output an RDS file
at outfile. This file can then be used in other functions,
such as drugTargetAnnot.
cmpIdMapping(outfile=file.path(config$resultsPath,"cmp_ids.rds"), rerun=TRUE,config=genConfig())cmpIdMapping(outfile=file.path(config$resultsPath,"cmp_ids.rds"), rerun=TRUE,config=genConfig())
outfile |
Path to output file. |
rerun |
If true, runs processing, otherwise does nothing. |
config |
General configuration. See |
Generates an RDS file at outfile.
Thomas Girke
cmpIdMapping("cmp_ids.rds",rerun=FALSE)cmpIdMapping("cmp_ids.rds",rerun=FALSE)
queryDrugTargets results into one tableRow-binds a small set of canonical columns across whichever sources
are present in results, mapping each source's own column names
to a shared vocabulary (see .dtiCombineColMap). This is
deliberately just column-name alignment and row append - not
deduplication, not cross-source identity resolution (the same
compound or target appearing under different native IDs in different
sources is not merged). A more principled harmonized container (an S4
class, analysed but not yet built) is a separate, deferred phase;
this function is the "just append them" version to use in the
meantime, and every
source's full original data remains available unchanged in
results itself.
combineDrugTargets( results, columns = c("query_id", "gene_symbol", "drug_name", "action", "source"), resolveGeneSymbol = FALSE, taxId = 9606L )combineDrugTargets( results, columns = c("query_id", "gene_symbol", "drug_name", "action", "source"), resolveGeneSymbol = FALSE, taxId = 9606L )
results |
a named list as returned by |
columns |
character vector of canonical columns to include, any
of |
resolveGeneSymbol |
logical(1); if |
taxId |
integer(1) passed to |
action is a best-effort common label, not a perfectly aligned
concept: ChEMBL's Action_Type and Open Targets'
action_type are categorical mechanism labels (e.g.
"INHIBITOR"); TTD's MOA, DGIdb's interaction_types,
the Broad Repurposing Hub's moa (free text, e.g.
"fgfr inhibitor", not a controlled vocabulary) and GtoPdb's
action (e.g. "Inhibition") are similar. PubChem is not
one of the
combinable sources at all (see .dtiMetaSources): its
bioactivity data has no mechanism-of-action concept to align to in
the first place.
A single data.frame with columns columns, one
row per row of every source in results.
res <- queryDrugTargets(list(molType = "gene", idType = "symbol", ids = "FGFR1"), sources = c("chembl", "dgidb", "opentargets")) combineDrugTargets(res) combineDrugTargets(res, resolveGeneSymbol = TRUE) ## fills ChEMBL's gene_symbol toores <- queryDrugTargets(list(molType = "gene", idType = "symbol", ids = "FGFR1"), sources = c("chembl", "dgidb", "opentargets")) combineDrugTargets(res) combineDrugTargets(res, resolveGeneSymbol = TRUE) ## fills ChEMBL's gene_symbol too
Downloads (or reuses previously cached copies of) the two Repurposing
Hub flat files via the package's existing .downloadFile()/
BiocFileCache infrastructure - the same mechanism downloadTTD()
uses. Files land in the local BiocFileCache (see .getCache(),
rappdirs::user_cache_dir(appname = "drugTargetInteractions")) -
no Repurposing Hub data is bundled with or downloaded by the package
itself until this is called explicitly.
downloadBroadRepurposingHub(rerun = TRUE, config = genConfig())downloadBroadRepurposingHub(rerun = TRUE, config = genConfig())
rerun |
logical(1); if |
config |
list as returned by |
repo-hub.broadinstitute.org has been observed to serve an
incomplete TLS certificate chain (see this file's header comment) -
if the first download attempt fails for any reason, this function
retries once with a CA bundle extended to include the one
legitimate, publicly-issued intermediate certificate the server
itself omits (.brhWithSupplementalCa()); a genuine failure
(network down, file moved, etc.) still surfaces as an error after
that retry.
A named list of local file paths: drug, sample.
paths <- downloadBroadRepurposingHub() pathspaths <- downloadBroadRepurposingHub() paths
Download ChEMBL sqlite db for use by several other functions in the package.
downloadChemblDb(version=.chemblLatestVersion(),rerun=TRUE,config=genConfig())downloadChemblDb(version=.chemblLatestVersion(),rerun=TRUE,config=genConfig())
version |
The ChEMBL version to download. Defaults to the latest release,
resolved live from ChEMBL's REST |
rerun |
If TRUE, the file will be downloaded, otherwise do nothing. |
config |
The configuration object. This gives the location to put the downloaded chembl db. |
No return value.
Kevin Horan
downloadChemblDb(27)downloadChemblDb(27)
Downloads (or reuses previously cached copies of) GtoPdb's bulk
/services/interactions REST response and its
GtP_to_HGNC_mapping.tsv flat file via the package's existing
.downloadFile()/BiocFileCache infrastructure - the same
mechanism downloadTTD()/downloadBroadRepurposingHub()
use. Files land in the local BiocFileCache (see .getCache(),
rappdirs::user_cache_dir(appname = "drugTargetInteractions")) -
no GtoPdb data is bundled with or downloaded by the package itself
until this is called explicitly.
downloadGtoPdb(rerun = TRUE, config = genConfig())downloadGtoPdb(rerun = TRUE, config = genConfig())
rerun |
logical(1); if |
config |
list as returned by |
A named list of local file paths: interactions,
hgncMapping.
paths <- downloadGtoPdb() pathspaths <- downloadGtoPdb() paths
Download (and cache) an HGNC complete-gene-set TSV snapshot
downloadHgncTable( archiveFile = NULL, current = FALSE, rerun = TRUE, config = genConfig(), verbose = FALSE )downloadHgncTable( archiveFile = NULL, current = FALSE, rerun = TRUE, config = genConfig(), verbose = FALSE )
archiveFile |
character(1) or |
current |
logical(1); if |
rerun |
logical(1); if |
config |
list from |
verbose |
logical(1). |
character(1) local file path to the cached TSV.
hgncPath <- downloadHgncTable()hgncPath <- downloadHgncTable()
Downloads (or reuses previously cached copies of) the TTD target,
drug, drug-target-mapping, drug cross-matching and drug-disease
indication flat files via the package's existing
.downloadFile()/BiocFileCache infrastructure - the same
mechanism downloadChemblDb() and downloadUniChem() use.
Files land in the local BiocFileCache (see .getCache(),
rappdirs::user_cache_dir(appname = "drugTargetInteractions")|) -
no TTD data is bundled with or downloaded by the package itself until
this is called explicitly.
downloadTTD(rerun = TRUE, config = genConfig())downloadTTD(rerun = TRUE, config = genConfig())
rerun |
logical(1); if |
config |
list as returned by |
A named list of local file paths: targets, drugs,
mapping, crossmatch, drugDisease.
paths <- downloadTTD() pathspaths <- downloadTTD() paths
Downloads UniChem compound ID mappings from https://www.ebi.ac.uk/unichem/ucquery/listSources. Mappings are downloaded for DrugBank, PubChem, and ChEBI.
downloadUniChem(rerun=TRUE, config=genConfig())downloadUniChem(rerun=TRUE, config=genConfig())
rerun |
If true, downloads the files, else does nothing. |
config |
General configuration. See |
Generates the following output files: "src1src2.txt.gz", "src1src22.txt.gz", and "src1src7.txt.gz". These correspond to mappings from ChEMBL to DrugBank, PubChem, and ChEBI, respectivly.
Thomas Girke
https://www.ebi.ac.uk/unichem/ucquery/listSources
downloadUniChem(rerun=TRUE)downloadUniChem(rerun=TRUE)
Downloads (or reuses previously cached copies of) UniChem's
reference (UCI/source/compound-ID triples, ~1.5GB) and
source (source-ID/name lookup, ~3KB) table dumps via the
package's existing .downloadFile()/BiocFileCache
infrastructure - the same mechanism downloadChemblDb() and
downloadTTD() use. structure.tsv.gz (actual chemical
structures, ~13.4GB) is deliberately not downloaded - see the file
header.
downloadUnichemTables(rerun = TRUE, config = genConfig())downloadUnichemTables(rerun = TRUE, config = genConfig())
rerun |
logical(1); if |
config |
list as returned by |
A named list of local file paths: reference,
source.
paths <- downloadUnichemTables() pathspaths <- downloadUnichemTables() paths
Function to query known drug-target annotations.
drugTargetAnnot(queryBy=list(molType=NULL, idType=NULL, ids=NULL), cmpid_file=file.path(config$resultsPath,"cmp_ids.rds"), config=genConfig())drugTargetAnnot(queryBy=list(molType=NULL, idType=NULL, ids=NULL), cmpid_file=file.path(config$resultsPath,"cmp_ids.rds"), config=genConfig())
queryBy |
A list defining the query, as described in |
cmpid_file |
Path to a compound ID mapping file, generated by |
config |
General configuration. See |
Returns the query results as a data frame.
Thomas Girke
# Tthese are just sample files included in the package. # You should use your own data files. config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) queryBy <- list(molType="cmp", idType="chembl_id", ids=c("CHEMBL1233058", "CHEMBL1200916", "CHEMBL437765")) qresult <- drugTargetAnnot(queryBy, config=config)# Tthese are just sample files included in the package. # You should use your own data files. config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) queryBy <- list(molType="cmp", idType="chembl_id", ids=c("CHEMBL1233058", "CHEMBL1200916", "CHEMBL437765")) qresult <- drugTargetAnnot(queryBy, config=config)
Generates a drug target annotation TSV file. This file includes target information from ChEMBL, drugbank, pubchem, and chembi.
This function requires the ID mapping files "src1src2.txt.gz", "src1src22.txt.gz", and
"src1src7.txt.gz" to exist in a directory called "downloads" before being run. These
can be generated with the downloadUniChem function.
drugTargetAnnotTable(outfile, rerun=TRUE,config=genConfig())drugTargetAnnotTable(outfile, rerun=TRUE,config=genConfig())
outfile |
The name of the output file to write the results to. |
rerun |
If true, download and generate output file. Otherwise do nothing. |
config |
General configuration. See |
Writes output file to outfile.
Thomas Girke
config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions")) drugTargetAnnotTable(outfile="drugTargetAnnot.xls", config=config)config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions")) drugTargetAnnotTable(outfile="drugTargetAnnot.xls", config=config)
Function to query bioactivity data by target or compound ids
drugTargetBioactivity( queryBy=list(molType=NULL, idType=NULL, ids=NULL), cmpid_file=file.path(config$resultsPath,"cmp_ids.rds"),config=genConfig())drugTargetBioactivity( queryBy=list(molType=NULL, idType=NULL, ids=NULL), cmpid_file=file.path(config$resultsPath,"cmp_ids.rds"),config=genConfig())
queryBy |
A list defining the query, as described in |
cmpid_file |
Path to a compound ID mapping file, generated by |
config |
General configuration. See |
Returns results as a data frame.
Thomas Girke
config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) queryBy <- list(molType="protein", idType="uniprot", ids=c("P05979", "P35354", "P33033", "Q8VCT3", "P29475", "P51511")) qresult <- drugTargetBioactivity( queryBy, config=config) queryBy <- list(molType="cmp", idType="molregno", ids=c("101036", "101137", "1384464")) qresult <- drugTargetBioactivity( queryBy, config=config) queryBy <- list(molType="cmp", idType="DrugBank_ID", ids=c("DB00945", "DB00316", "DB01050")) qresult <- drugTargetBioactivity(queryBy, config=config) queryBy <- list(molType="cmp", idType="PubChem_ID", ids=c("2244", "3672", "1983")) qresult <- drugTargetBioactivity(queryBy, config=config)config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) queryBy <- list(molType="protein", idType="uniprot", ids=c("P05979", "P35354", "P33033", "Q8VCT3", "P29475", "P51511")) qresult <- drugTargetBioactivity( queryBy, config=config) queryBy <- list(molType="cmp", idType="molregno", ids=c("101036", "101137", "1384464")) qresult <- drugTargetBioactivity( queryBy, config=config) queryBy <- list(molType="cmp", idType="DrugBank_ID", ids=c("DB00945", "DB00316", "DB01050")) qresult <- drugTargetBioactivity(queryBy, config=config) queryBy <- list(molType="cmp", idType="PubChem_ID", ids=c("2244", "3672", "1983")) qresult <- drugTargetBioactivity(queryBy, config=config)
Create a default configuration object.
genConfig( chemblDbPath = "chembldb.db", downloadPath = "downloads", resultsPath = "results" )genConfig( chemblDbPath = "chembldb.db", downloadPath = "downloads", resultsPath = "results" )
chemblDbPath |
Path or filename of ChEMBL SQLite db file. |
downloadPath |
The name of a directory to put downloaded files in. |
resultsPath |
The name of a directory to put output files in. |
A config object that can be passed to ther functions.
Kevin Horan
config = genConfig()config = genConfig()
Pulls activity rows for a given ChEMBL target ID, optionally filtered
to a standard activity type (e.g. IC50, Ki). Paginates through the REST
activity resource up to maxRows.
getChemblBioactivities( targetChemblId, standardType = NA, maxRows = 1000L, pageSize = 1000L, verbose = FALSE )getChemblBioactivities( targetChemblId, standardType = NA, maxRows = 1000L, pageSize = 1000L, verbose = FALSE )
targetChemblId |
character(1), e.g. |
standardType |
character(1) or NA; e.g. |
maxRows |
integer(1) cap on returned rows. |
pageSize |
integer(1) rows per REST page (max 1000). |
verbose |
logical(1) progress messages. |
A data.frame with columns molecule_chembl_id,
target_chembl_id, standard_type, standard_relation,
standard_value, standard_units, pchembl_value,
assay_chembl_id, assay_description. Empty on failure.
act <- getChemblBioactivities("CHEMBL1862", standardType = "IC50", maxRows = 50) head(act)act <- getChemblBioactivities("CHEMBL1862", standardType = "IC50", maxRows = 50) head(act)
Bidirectional, batched REST equivalent of the package's legacy
local-ChEMBL-SQLite drugTargetBioactivity() query
(R/drugTargetAnnotations_Fct.R): given one or more UniProt
accessions, returns every bioassay measurement recorded against
ChEMBL targets matching those accessions (target -> drug bioassay
direction); given one or more ChEMBL molecule IDs, returns every
measurement recorded for those compounds (drug -> target bioassay
direction). This is the raw-measurement counterpart to
getChemblDrugTarget's curated drug_mechanism
annotations - see the "Bioassay Queries" vignette section for the
annotation-vs-bioassay distinction. Unlike
getChemblBioactivities (a simple single-target
convenience lookup, kept as-is), this batches arbitrarily many IDs and
supports both query directions, matching
getChemblDrugTarget's interface.
getChemblBioassay( queryBy = list(molType = NULL, idType = NULL, ids = NULL), standardType = NA, fields = "core", verbose = FALSE, chunkSize = 200L )getChemblBioassay( queryBy = list(molType = NULL, idType = NULL, ids = NULL), standardType = NA, fields = "core", verbose = FALSE, chunkSize = 200L )
queryBy |
named list with components |
standardType |
character(1) or |
fields |
|
verbose |
logical(1); if TRUE, message progress per batch. |
chunkSize |
integer(1), same batching convention as
|
A data.frame with columns QueryIDs,
chembl_id, Drug_Name, ChEMBL_TID,
UniProt_ID, Organism, Desc,
assay_chembl_id, assay_description,
standard_type, standard_relation,
standard_value, standard_units, pchembl_value
(with fields = "core", the default), plus further
activity.-prefixed columns when fields requests more.
Query IDs that return no rows still appear as a single row with all
other fields NA.
getChemblDrugTarget, getChemblBioactivities,
listBioassayFields
## target -> drug bioassay: FGFR1 getChemblBioassay(list(molType = "protein", idType = "Uniprot", ids = "P11362"), standardType = "IC50") ## drug -> target bioassay: dasatinib getChemblBioassay(list(molType = "cmp", idType = "chembl_id", ids = "CHEMBL1421"))## target -> drug bioassay: FGFR1 getChemblBioassay(list(molType = "protein", idType = "Uniprot", ids = "P11362"), standardType = "IC50") ## drug -> target bioassay: dasatinib getChemblBioassay(list(molType = "cmp", idType = "chembl_id", ids = "CHEMBL1421"))
REST-API equivalent of drugTargetAnnot for the package's
local ChEMBL SQLite path: given one or more UniProt accessions, returns
the drugs annotated (via ChEMBL's drug_mechanism table) as acting
on that target (target -> drug); given one or more ChEMBL molecule IDs,
returns the targets annotated for that compound's mechanism of action
(drug -> target). Reproduces drugTargetAnnot()'s join across
drug_mechanism, molecule_dictionary,
target_dictionary/target_components/
component_sequences and drug_indication using the ChEMBL
REST target, mechanism, molecule and
drug_indication resources, so a local ChEMBL SQLite download is
not required.
getChemblDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), verbose = FALSE, chunkSize = 200L, fields = "core" )getChemblDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), verbose = FALSE, chunkSize = 200L, fields = "core" )
queryBy |
named list with components |
verbose |
logical(1); if TRUE, message progress per batch. |
chunkSize |
integer(1) max IDs sent per HTTP request via a
|
fields |
|
Only ChEMBL's own native identifiers are supported directly:
UniProt accession for the target direction, ChEMBL molecule ID for the
drug direction. Translating a different starting identifier (Ensembl
gene ID, PubChem CID, DrugBank ID, ...) into one of these is left to a
separate, source-agnostic ID-translation step (see
cmpIdMapping for the compound side and
getUniprotIDs/getParalogs for the protein
side) so that this function's interface stays uniform across sources.
A data.frame with columns QueryIDs,
chembl_id, Drug_Name, MOA, Action_Type,
Max_Phase, First_Approval, ChEMBL_TID,
UniProt_ID, Desc, Organism,
Mesh_Indication (with fields = "core", the default), plus
further source-prefixed columns when fields requests more. Query
IDs that return no rows still appear as a single row with all other
fields NA, so callers can always confirm which of their input
IDs were resolved.
drugTargetAnnot, getChemblMolecule,
listDrugTargetFields
## target -> drug: FGFR1 getChemblDrugTarget(list(molType = "protein", idType = "Uniprot", ids = "P11362")) ## drug -> target: dasatinib getChemblDrugTarget(list(molType = "cmp", idType = "chembl_id", ids = "CHEMBL1421")) ## every available field getChemblDrugTarget(list(molType = "cmp", idType = "chembl_id", ids = "CHEMBL1421"), fields = "all")## target -> drug: FGFR1 getChemblDrugTarget(list(molType = "protein", idType = "Uniprot", ids = "P11362")) ## drug -> target: dasatinib getChemblDrugTarget(list(molType = "cmp", idType = "chembl_id", ids = "CHEMBL1421")) ## every available field getChemblDrugTarget(list(molType = "cmp", idType = "chembl_id", ids = "CHEMBL1421"), fields = "all")
Queries the public ChEMBL REST endpoint for one or more molecules by
ChEMBL ID and returns a tidy data.frame of the most commonly
used identifiers, structures and computed properties. Complements the
package's local-SQLite path (downloadChemblDb) for cases
where only a handful of compounds are needed or a local database is not
available.
getChemblMolecule(chemblIds, verbose = FALSE, chunkSize = 200L)getChemblMolecule(chemblIds, verbose = FALSE, chunkSize = 200L)
chemblIds |
character vector of ChEMBL molecule IDs
(e.g. |
verbose |
logical(1); if TRUE, message progress per batch. |
chunkSize |
integer(1) max IDs looked up per HTTP request
(see |
A data.frame with one row per input ID (duplicates and
input order preserved) and columns: chembl_id, pref_name,
molecule_type, max_phase, first_approval,
canonical_smiles, standard_inchi_key, mw_freebase,
alogp, hba, hbd, psa, rtb,
qed_weighted. IDs that fail to resolve yield a row of NAs.
getChemblDrugTarget, downloadChemblDb
## Requires internet access to www.ebi.ac.uk df <- getChemblMolecule(c("CHEMBL25", "CHEMBL1201585")) df[, c("chembl_id", "pref_name", "max_phase")]## Requires internet access to www.ebi.ac.uk df <- getChemblMolecule(c("CHEMBL25", "CHEMBL1201585")) df[, c("chembl_id", "pref_name", "max_phase")]
Uses the ChEMBL REST target resource to resolve a query string
(gene symbol, protein or preferred name) to ChEMBL target IDs.
getChemblTarget(query, organism = "Homo sapiens", limit = 25L)getChemblTarget(query, organism = "Homo sapiens", limit = 25L)
query |
character(1) search term, e.g. |
organism |
character(1) optional NCBI organism name filter,
e.g. |
limit |
integer(1) maximum number of hits to return. |
A data.frame with columns target_chembl_id,
pref_name, target_type, organism. Empty
data.frame if nothing matches or the API is unreachable.
getChemblTarget("FGFR1", organism = "Homo sapiens")getChemblTarget("FGFR1", organism = "Homo sapiens")
Queries the DGIdb interactions(geneNames: ...) GraphQL field
and returns a tidy data.frame of gene-drug interaction rows.
This is the target -> drug direction; see getDgidbTargets
for the reverse.
getDgidbDrugs( genes, pageSize = 500L, maxRows = 5000L, verbose = FALSE, fields = "core" )getDgidbDrugs( genes, pageSize = 500L, maxRows = 5000L, verbose = FALSE, fields = "core" )
genes |
character vector of HGNC gene symbols (case-insensitive; unmatched symbols simply contribute no rows, no error). |
pageSize |
integer(1) rows per GraphQL page (default 500). |
maxRows |
integer(1) cap on total returned rows (default 5000). |
verbose |
logical(1); if TRUE, message progress per chunk/page. |
fields |
|
A data.frame with columns gene_name,
drug_name, drug_concept_id (e.g.
"chembl:CHEMBL1201585"), drug_approved,
interaction_types, directionality,
interaction_score, evidence_score, sources
(upstream provenance), db. Empty if none / offline.
getDgidbTargets, getDgidbDrugTarget
df <- getDgidbDrugs(c("FGFR1", "KLB")) table(df$gene_name)df <- getDgidbDrugs(c("FGFR1", "KLB")) table(df$gene_name)
Thin queryBy-dispatching wrapper over getDgidbDrugs
(target -> drug) and getDgidbTargets (drug -> target),
matching the queryBy = list(molType, idType, ids) interface used
by drugTargetAnnot, getChemblDrugTarget and
getPubchemDrugTarget. Since DGIdb normalizes matched names
to its own canonical casing (see the file header note), the returned
QueryIDs column is matched back to the original queryBy$ids
token case-insensitively rather than by verbatim string equality.
getDgidbDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ... )getDgidbDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ... )
queryBy |
named list with components |
... |
additional arguments passed through to
|
A data.frame in the same column shape as
getDgidbDrugs / getDgidbTargets, plus a
leading QueryIDs column echoing the original queryBy$ids
token each row case-insensitively matched to. Query IDs that returned
no rows still appear as a single row with all other fields NA.
getDgidbDrugs, getDgidbTargets,
getChemblDrugTarget, getPubchemDrugTarget,
listDrugTargetFields
## target -> drug: FGFR1, KLB getDgidbDrugTarget(list(molType = "gene", idType = "symbol", ids = c("FGFR1", "KLB"))) ## drug -> target: imatinib getDgidbDrugTarget(list(molType = "cmp", idType = "name", ids = "imatinib")) ## every available field getDgidbDrugTarget(list(molType = "cmp", idType = "name", ids = "imatinib"), fields = "all")## target -> drug: FGFR1, KLB getDgidbDrugTarget(list(molType = "gene", idType = "symbol", ids = c("FGFR1", "KLB"))) ## drug -> target: imatinib getDgidbDrugTarget(list(molType = "cmp", idType = "name", ids = "imatinib")) ## every available field getDgidbDrugTarget(list(molType = "cmp", idType = "name", ids = "imatinib"), fields = "all")
Queries the DGIdb interactions(drugNames: ...) GraphQL field
and returns a tidy data.frame of drug-gene interaction rows.
This is the drug -> target direction; see getDgidbDrugs
for the reverse. Same columns/shape as getDgidbDrugs
since Interaction nodes always carry both endpoints.
getDgidbTargets( drugs, pageSize = 500L, maxRows = 5000L, verbose = FALSE, fields = "core" )getDgidbTargets( drugs, pageSize = 500L, maxRows = 5000L, verbose = FALSE, fields = "core" )
drugs |
character vector of drug names (case-insensitive; unmatched names simply contribute no rows, no error). |
pageSize |
integer(1) rows per GraphQL page (default 500). |
maxRows |
integer(1) cap on total returned rows (default 5000). |
verbose |
logical(1); if TRUE, message progress per chunk/page. |
fields |
|
A data.frame; see getDgidbDrugs for columns.
getDgidbDrugs, getDgidbDrugTarget
df <- getDgidbTargets(c("imatinib", "aspirin")) table(df$drug_name, useNA = "no")df <- getDgidbTargets(c("imatinib", "aspirin")) table(df$drug_name, useNA = "no")
This function allows you to query a subset of the data
fetched by drugTargetAnnotTable.
getDrugTarget(dt_file=file.path(config$resultsPath,"drugTargetAnnot.xls"), queryBy=list(molType=NULL, idType=NULL, ids=NULL), id_mapping=c(chembl="chembl_id", pubchem="PubChem_ID", uniprot="UniProt_ID"), columns,config=genConfig())getDrugTarget(dt_file=file.path(config$resultsPath,"drugTargetAnnot.xls"), queryBy=list(molType=NULL, idType=NULL, ids=NULL), id_mapping=c(chembl="chembl_id", pubchem="PubChem_ID", uniprot="UniProt_ID"), columns,config=genConfig())
dt_file |
The drug target annotation file. This can be generated with |
queryBy |
A list defining the query, as described in |
id_mapping |
A list providing the id columns for ChEMBL, PubChem, and UniProt. It should contain the fields "chembl", "pubchem", and "uniprot", each wit the column name of the respective id number in the drug target annotation file. See default value above for an example. |
columns |
A list of column indexes to select as a subset of the final result set. |
config |
General configuration. See |
Returns the query result as a data frame.
Thomas Girke
config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) id_mapping <- c(chembl="chembl_id", pubchem="PubChem_ID", uniprot="UniProt_ID", drugbank="DrugBank_ID") queryBy <- list(molType="cmp", idType="chembl", ids=c("CHEMBL25", "CHEMBL1742471")) getDrugTarget(queryBy=queryBy, id_mapping=id_mapping, columns=c(1,5,8,16,17),config=config) queryBy <- list(molType="cmp", idType="pubchem", ids=c("2244", "65869", "2244")) getDrugTarget(queryBy=queryBy, id_mapping=id_mapping, columns=c(1,5,8,16,17),config=config) queryBy <- list(molType="protein", idType="uniprot", ids=c("P43166", "P00915", "P43166")) getDrugTarget(queryBy=queryBy, id_mapping=id_mapping, columns=c(1,5,8,16,17),config=config)config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) id_mapping <- c(chembl="chembl_id", pubchem="PubChem_ID", uniprot="UniProt_ID", drugbank="DrugBank_ID") queryBy <- list(molType="cmp", idType="chembl", ids=c("CHEMBL25", "CHEMBL1742471")) getDrugTarget(queryBy=queryBy, id_mapping=id_mapping, columns=c(1,5,8,16,17),config=config) queryBy <- list(molType="cmp", idType="pubchem", ids=c("2244", "65869", "2244")) getDrugTarget(queryBy=queryBy, id_mapping=id_mapping, columns=c(1,5,8,16,17),config=config) queryBy <- list(molType="protein", idType="uniprot", ids=c("P43166", "P00915", "P43166")) getDrugTarget(queryBy=queryBy, id_mapping=id_mapping, columns=c(1,5,8,16,17),config=config)
Unlike getParalogs (biomaRt, human paralogs only), this
also covers true cross-species orthologs - see
getEnsemblParalogs for the shared rationale and the
type/taxonomy_level interpretation.
getEnsemblOrthologs( genes, species = "human", targetSpecies = NULL, condensed = FALSE, verbose = FALSE )getEnsemblOrthologs( genes, species = "human", targetSpecies = NULL, condensed = FALSE, verbose = FALSE )
genes |
character vector of gene symbols. |
species |
character(1) Ensembl species name or alias for
|
targetSpecies |
character vector of Ensembl species names/aliases
to restrict orthologs to (e.g. |
condensed |
logical(1); see |
verbose |
logical(1); if TRUE, message progress per gene. |
A data.frame; see getEnsemblParalogs for
columns (homolog_species varies here). Genes with no
orthologs simply contribute no rows.
getEnsemblParalogs, getParalogs
getEnsemblOrthologs("NLRP3", targetSpecies = "mouse")getEnsemblOrthologs("NLRP3", targetSpecies = "mouse")
Direct replacement for getParalogs (biomaRt), which is
left in place unmodified as a historical/backup option but is not the
recommended path going forward - see the idTranslation.R file
header for the full rationale.
getEnsemblParalogs( genes, species = "human", condensed = FALSE, verbose = FALSE )getEnsemblParalogs( genes, species = "human", condensed = FALSE, verbose = FALSE )
genes |
character vector of gene symbols. |
species |
character(1) Ensembl species name or alias for
|
condensed |
logical(1); if |
verbose |
logical(1); if TRUE, message progress per gene. |
type (e.g. "other_paralog", "within_species_
paralog", "gene_split") and taxonomy_level come from
Ensembl Compara's gene-tree reconciliation, not raw sequence-identity
thresholding - already a more principled "relatedness" signal than
perc_id alone. perc_id/perc_pos are useful for
ranking within a type tier.
A data.frame with columns query_gene,
homolog_id, homolog_protein_id, homolog_species
(always the same as species here), type,
taxonomy_level, perc_id, perc_pos (the latter
two NA when condensed = TRUE). Genes with no paralogs
simply contribute no rows.
getEnsemblOrthologs, getParalogs
getEnsemblParalogs("FGFR1")getEnsemblParalogs("FGFR1")
Reads the cached HGNC TSV (see downloadHgncTable),
optionally restricts to protein-coding genes (~19,200 of them), and
reshapes the pipe-separated multi-value columns
(prev_symbol/alias_symbol/uniprot_ids) into
list-columns - one row per approved HGNC gene report. Isoform-suffixed
UniProt accessions (e.g. "P12345-2") are stripped defensively,
though HGNC's own cross-references are already canonical-only.
getHgncGeneTable( proteinCodingOnly = TRUE, archiveFile = NULL, current = FALSE, rerun = FALSE, config = genConfig(), verbose = FALSE )getHgncGeneTable( proteinCodingOnly = TRUE, archiveFile = NULL, current = FALSE, rerun = FALSE, config = genConfig(), verbose = FALSE )
proteinCodingOnly |
logical(1); if |
archiveFile, current, rerun, config, verbose
|
passed to
|
A data.frame with columns hgnc_id, symbol,
prev_symbol (list-column), alias_symbol (list-column),
entrez_id, ensembl_gene_id, uniprot_ids
(list-column), locus_group. attr(., "hgncSource")
records the source filename for provenance.
downloadHgncTable, buildHgncSymbolMap,
buildGenomeWideDrugTargetTable
hgncTable <- getHgncGeneTable() nrow(hgncTable) hgncTable[hgncTable$symbol == "FGFR1", c("symbol", "uniprot_ids")]hgncTable <- getHgncGeneTable() nrow(hgncTable) hgncTable[hgncTable$symbol == "FGFR1", c("symbol", "uniprot_ids")]
Vectorised, batched the same way getOpenTargetsIds
batches target-symbol resolution. Open Targets drug IDs *are* ChEMBL
IDs.
getOpenTargetsDrugIds(names, chunkSize = 100L, pause = 0.1, verbose = FALSE)getOpenTargetsDrugIds(names, chunkSize = 100L, pause = 0.1, verbose = FALSE)
names |
character vector of drug names (ChEMBL IDs pass through
unresolved - checked via a plain |
chunkSize |
integer(1) names per HTTP request (default 100). |
pause |
numeric(1) seconds to sleep between requests (politeness). |
verbose |
logical(1) progress messages. |
A named character vector (names = input drug names) of ChEMBL
IDs; unresolved names are NA. Order matches the input.
getOpenTargetsDrugIds(c("aspirin", "imatinib", "NOT_A_DRUG"))getOpenTargetsDrugIds(c("aspirin", "imatinib", "NOT_A_DRUG"))
Accepts many genes (symbols and/or Ensembl IDs), resolves symbols in
bulk via getOpenTargetsIds, then pulls
drugAndClinicalCandidates for up to chunkSize targets per
HTTP request using GraphQL aliasing. One input target can expand into
several output rows (a drug may act on the target via more than one
mechanism and may be developed against more than one disease); the
cartesian expansion is controlled by expand. Note that
agonist / undrugged-direct targets (e.g. FGF21, NLRP3, TFEB, ADIPOR)
legitimately return zero rows.
getOpenTargetsDrugs( genes, expand = c("mechanism", "disease", "drug"), chunkSize = 25L, pause = 0.1, verbose = FALSE, fields = "core" )getOpenTargetsDrugs( genes, expand = c("mechanism", "disease", "drug"), chunkSize = 25L, pause = 0.1, verbose = FALSE, fields = "core" )
genes |
character vector of gene symbols and/or Ensembl gene IDs. |
expand |
character(1); |
chunkSize |
integer(1) targets per HTTP request (default 25; kept modest so per-request payloads and server load stay reasonable). |
pause |
numeric(1) seconds to sleep between requests. |
verbose |
logical(1) progress messages. |
fields |
|
The Open Targets GraphQL schema evolves between platform releases;
this function targets the v4 schema in which rows are of type
ClinicalTargetFromTarget (fields maxClinicalStage,
drug, diseases) and mechanism data lives under
drug.mechanismsOfAction.rows. If Open Targets changes these
names, update .dtiDrugSelection.
A data.frame with columns ensembl_id,
approved_symbol, drug_id (ChEMBL), drug_name,
drug_type, max_clinical_stage, mechanism_of_action,
action_type, disease_id, disease_name. Genes with
no known drugs simply contribute no rows. Empty data.frame if
nothing / offline.
getOpenTargetsIds, getOpenTargetsTargets,
getOpenTargetsDrugTarget
drugs <- getOpenTargetsDrugs(c("FGFR1", "KLB")) head(drugs[, c("drug_name", "mechanism_of_action", "max_clinical_stage")])drugs <- getOpenTargetsDrugs(c("FGFR1", "KLB")) head(drugs[, c("drug_name", "mechanism_of_action", "max_clinical_stage")])
Thin queryBy-dispatching wrapper over
getOpenTargetsDrugs (target -> drug) and
getOpenTargetsTargets (drug -> target), matching the
queryBy = list(molType, idType, ids) interface used by
drugTargetAnnot, getChemblDrugTarget,
getPubchemDrugTarget and getDgidbDrugTarget.
Unlike getDgidbDrugTarget (which joins on a
case-normalized display name), this joins the QueryIDs column on
the stable resolved ID (Ensembl gene ID / ChEMBL ID) that Open Targets
already returns verbatim in every output row, so no casing ambiguity
arises; the tradeoff is one extra batched ID-resolution call inside the
wrapper (see the file header note).
getOpenTargetsDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ... )getOpenTargetsDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ... )
queryBy |
named list with components |
... |
additional arguments passed through to
|
A data.frame in the same column shape as
getOpenTargetsDrugs / getOpenTargetsTargets,
plus a leading QueryIDs column echoing the original
queryBy$ids token each row resolved from. Query IDs that
returned no rows still appear as a single row with all other fields
NA.
getOpenTargetsDrugs, getOpenTargetsTargets,
getChemblDrugTarget, getPubchemDrugTarget,
getDgidbDrugTarget, listDrugTargetFields
## target -> drug: FGFR1, KLB getOpenTargetsDrugTarget(list(molType = "gene", idType = "symbol", ids = c("FGFR1", "KLB"))) ## drug -> target: aspirin getOpenTargetsDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin")) ## every available field getOpenTargetsDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin"), fields = "all")## target -> drug: FGFR1, KLB getOpenTargetsDrugTarget(list(molType = "gene", idType = "symbol", ids = c("FGFR1", "KLB"))) ## drug -> target: aspirin getOpenTargetsDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin")) ## every available field getOpenTargetsDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin"), fields = "all")
Uses GraphQL field-aliasing to resolve up to chunkSize symbols
per HTTP request, so resolving many genes takes a handful of requests
rather than one per gene.
getOpenTargetsIds(symbols, chunkSize = 100L, pause = 0.1, verbose = FALSE)getOpenTargetsIds(symbols, chunkSize = 100L, pause = 0.1, verbose = FALSE)
symbols |
character vector of gene symbols (Ensembl gene IDs pass
through unresolved - checked via a plain |
chunkSize |
integer(1) symbols per HTTP request (default 100). |
pause |
numeric(1) seconds to sleep between requests (politeness). |
verbose |
logical(1) progress messages. |
A named character vector (names = input symbols) of Ensembl
gene IDs; unresolved symbols are NA. Order matches the input.
getOpenTargetsIds(c("FGFR1", "KLB", "NOT_A_GENE"))getOpenTargetsIds(c("FGFR1", "KLB", "NOT_A_GENE"))
Accepts many drugs (names and/or ChEMBL IDs), resolves names in bulk
via getOpenTargetsDrugIds, then pulls
mechanismsOfAction for up to chunkSize drugs per HTTP
request using GraphQL aliasing. This is the drug -> target counterpart
of getOpenTargetsDrugs. A single mechanism-of-action row
can list more than one target (e.g. aspirin's "Cyclooxygenase
inhibitor" mechanism lists both PTGS1 and PTGS2); the cartesian
expansion is controlled by expand.
getOpenTargetsTargets( drugs, expand = c("target", "mechanism"), chunkSize = 25L, pause = 0.1, verbose = FALSE, fields = "core" )getOpenTargetsTargets( drugs, expand = c("target", "mechanism"), chunkSize = 25L, pause = 0.1, verbose = FALSE, fields = "core" )
drugs |
character vector of drug names and/or ChEMBL IDs. |
expand |
character(1); |
chunkSize |
integer(1) drugs per HTTP request (default 25). |
pause |
numeric(1) seconds to sleep between requests. |
verbose |
logical(1) progress messages. |
fields |
|
A data.frame with columns chembl_id,
drug_name, drug_type, max_clinical_stage,
mechanism_of_action, action_type, moa_target_name,
target_id (Ensembl), approved_symbol. Drugs with no
known targets simply contribute no rows. Empty data.frame if
nothing / offline.
getOpenTargetsDrugIds, getOpenTargetsDrugs,
getOpenTargetsDrugTarget
tgts <- getOpenTargetsTargets("aspirin") tgts[, c("approved_symbol", "mechanism_of_action")]tgts <- getOpenTargetsTargets("aspirin") tgts[, c("approved_symbol", "mechanism_of_action")]
Using biomaRt, obtain for query genes the corresponding UniProt IDs as well
as paralogs. Query genes can be Gene Names or ENSEMBL Gene IDs from
H sapiens. The result is similar to IDMs and SSNNs from getUniprotIDs
function, but instead of UNIREF clusters, biomaRt's paralogs are used to
obtain SSNNs.
getParalogs(queryBy)getParalogs(queryBy)
queryBy |
A list defining the query, as described in |
Returns a list with the paralogs for the given genes.
Thomas Girke
queryBy <- list(molType="gene", idType="external_gene_name", ids=c("ZPBP", "MAPK1", "EGFR")) #requires network connection and is slow result <- getParalogs(queryBy)queryBy <- list(molType="gene", idType="external_gene_name", ids=c("ZPBP", "MAPK1", "EGFR")) #requires network connection and is slow result <- getParalogs(queryBy)
Ports the validated R_Py_code/pubchem_fetch.py reference:
resolves each gene symbol to a human NCBI GeneID, pulls its concise
bioactivity table, keeps Active + numeric + potency-endpoint rows,
collapses to the most potent row per CID (capped at maxCids),
and looks up each surviving CID's name and SMILES.
getPubchemDrugs( genes, taxid = 9606L, keepActivities = .dtiPotencyEndpoints, maxCids = 400L, pause = 0.34, verbose = FALSE, fields = "core" )getPubchemDrugs( genes, taxid = 9606L, keepActivities = .dtiPotencyEndpoints, maxCids = 400L, pause = 0.34, verbose = FALSE, fields = "core" )
genes |
character vector of HGNC gene symbols (or NCBI GeneIDs, which pass through unresolved). |
taxid |
integer(1) NCBI taxonomy ID for symbol resolution (default 9606 = human). |
keepActivities |
character vector of Activity Name values to
keep (default IC50/Ki/Kd/EC50/AC50/Potency); |
maxCids |
integer(1) cap on CIDs kept per gene (default 400). |
pause |
numeric(1) seconds between requests (NCBI: <=3 req/s without an API key). |
verbose |
logical(1) progress messages. |
fields |
|
A data.frame with columns gene_symbol,
geneid, target_accession, cid, drug_name
(~27
breadth), canonical_smiles, activity_name,
activity_value_uM, assay_name, db. Empty if
none / offline.
getPubchemTargets, getPubchemDrugTarget
df <- getPubchemDrugs(c("FGFR1", "KLB")) table(df$gene_symbol)df <- getPubchemDrugs(c("FGFR1", "KLB")) table(df$gene_symbol)
Thin queryBy-dispatching wrapper over getPubchemDrugs
(target -> drug) and getPubchemTargets (drug -> target),
matching the queryBy = list(molType, idType, ids) interface used by
drugTargetAnnot and getChemblDrugTarget, so a
future cross-source ID-translation/meta layer can dispatch to any source
function the same way. PubChem's two directions are genuinely asymmetric
(no shared bulk filter covers both, unlike ChEMBL's
drug_mechanism join), so this only adds a QueryIDs column
and unmatched-ID NA-row padding on top of the two underlying functions -
it does not change their query logic.
getPubchemDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ... )getPubchemDrugTarget( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ... )
queryBy |
named list with components |
... |
additional arguments passed through to
|
A data.frame in the same column shape as
getPubchemDrugs / getPubchemTargets, plus a
leading QueryIDs column echoing the original queryBy$ids
token each row resolved from. Query IDs that returned no rows still
appear as a single row with all other fields NA, so callers can
always confirm which of their input IDs were resolved.
getPubchemDrugs, getPubchemTargets,
getChemblDrugTarget, listDrugTargetFields
## target -> drug: FGFR1, KLB getPubchemDrugTarget(list(molType = "gene", idType = "symbol", ids = c("FGFR1", "KLB"))) ## drug -> target: aspirin getPubchemDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin")) ## every available field getPubchemDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin"), fields = "all")## target -> drug: FGFR1, KLB getPubchemDrugTarget(list(molType = "gene", idType = "symbol", ids = c("FGFR1", "KLB"))) ## drug -> target: aspirin getPubchemDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin")) ## every available field getPubchemDrugTarget(list(molType = "cmp", idType = "name", ids = "aspirin"), fields = "all")
Drug -> target counterpart of getPubchemDrugs: resolves
each drug name to a CID, pulls its compound-centric assay-summary
table (batched), keeps Active + numeric + potency-endpoint rows,
collapses to the most potent row per (CID, GeneID) pair, and resolves
each target GeneID to a gene symbol - filtered to taxid
(default human), since compound assay data spans whatever species
each assay used (see file header note).
getPubchemTargets( drugs, taxid = 9606L, keepActivities = .dtiPotencyEndpoints, maxCidsPerBatch = 50L, pause = 0.2, verbose = FALSE, fields = "core" )getPubchemTargets( drugs, taxid = 9606L, keepActivities = .dtiPotencyEndpoints, maxCidsPerBatch = 50L, pause = 0.2, verbose = FALSE, fields = "core" )
drugs |
character vector of drug/compound names (or PubChem CIDs, which pass through unresolved). |
taxid |
integer(1) or |
keepActivities |
character vector of Activity Name values to
keep (default IC50/Ki/Kd/EC50/AC50/Potency); |
maxCidsPerBatch |
integer(1) CIDs per |
pause |
numeric(1) seconds between name-resolution requests. |
verbose |
logical(1) progress messages. |
fields |
|
A data.frame with columns cid, drug_name,
gene_symbol, geneid, taxid,
target_accession, activity_name,
activity_value_uM, assay_name, db. Empty if
none / offline.
getPubchemDrugs, getPubchemDrugTarget
df <- getPubchemTargets("aspirin") df[, c("drug_name", "gene_symbol", "activity_name", "activity_value_uM")]df <- getPubchemTargets("aspirin") df[, c("drug_name", "gene_symbol", "activity_name", "activity_value_uM")]
The getSymEnsUp function returns for a query of gene or protein IDs a mapping
table containing: ENSEMBL Gene IDs, Gene Names/Symbols, UniProt IDs and ENSEMBL
Protein IDs. Subsequent slots contain the corresponding named character vectors.
Internally, the function uses the ensembldb package.
getSymEnsUp(EnsDb = "EnsDb.Hsapiens.v86", ids, idtype)getSymEnsUp(EnsDb = "EnsDb.Hsapiens.v86", ids, idtype)
EnsDb |
|
ids |
Character vector with IDs matching the type specified under |
idtype |
Character vector of length one containing one of: |
List object with following components:
idDF |
ID mapping |
ens_gene_id |
named character vector |
up_ens_id |
named character vector |
up_gene_id |
named character vector |
Thomas Girke
gene_name <- c("CA7", "CFTR") getSymEnsUp(EnsDb="EnsDb.Hsapiens.v86", ids=gene_name, idtype="GENE_NAME")gene_name <- c("CA7", "CFTR") getSymEnsUp(EnsDb="EnsDb.Hsapiens.v86", ids=gene_name, idtype="GENE_NAME")
Genuinely source-agnostic: from/to accept any source
name (or raw numeric source ID) present in the unichem_sources
table of the database built by buildUnichemDb - not a
fixed enum hand-coded per database. A source this package has no
dedicated accessor for (e.g. "gtopdb", "drugcentral",
or any source added to a future UniChem refresh) works identically to
"chembl" or "pubchem" the moment it is present in the
underlying data - no code changes needed. Implemented as a single SQL
self-join on the shared UniChem structure cluster ID (UCI), which is
what makes this generic: the query never references a specific source
by name in its logic, only in the two parameter values.
getUnichemMapping(ids, from, to, dbPath)getUnichemMapping(ids, from, to, dbPath)
ids |
character vector of source-database identifiers. |
from |
character(1) source database name (e.g. |
to |
character(1) target database name or numeric source ID. |
dbPath |
character(1) path to the UniChem SQLite, e.g. from
|
A data.frame with columns From and To.
IDs with no cross-reference to to contribute no row (the
underlying table only carries compounds with >= 2 source
cross-references in the first place - see
buildUnichemDb - so an unmapped ID may mean either no
to-side entry exists, or the compound had no cross-reference
to *any* other source and was excluded from the table entirely).
buildUnichemDb, getUniprotMapping
dbPath <- buildUnichemDb() getUnichemMapping("CHEMBL25", from = "chembl", to = "pubchem", dbPath) getUnichemMapping("CHEMBL25", from = "chembl", to = "drugbank", dbPath)dbPath <- buildUnichemDb() getUnichemMapping("CHEMBL25", from = "chembl", to = "pubchem", dbPath) getUnichemMapping("CHEMBL25", from = "chembl", to = "drugbank", dbPath)
The following returns for a set of query IDs (e.g. Ensembl gene IDs) the corresponding UniProt IDs based on two independent approaches: ID mappings (IDMs) and sequence similarity nearest neighbors (SSNNs) using UNIREF clusters. Note, the 'keys' or query IDs (e.g. ENSEMBL genes) can only be reliably maintained in the SSNN results when 'chunksize=1' since batch queries for protein clusters with 'UnitProt.ws' will often drop the query IDs. To address this, the query result contains an extra 'QueryID' column when 'chunksize=1', but not when it is set to a different value than 1.
The getParalogs function is similar but it uses biomaRt's paralogs instead of UNIREF clusters.
getUniprotIDs(taxId = 9606, kt = "ENSEMBL", keys, seq_cluster = "UNIREF90", chunksize=20)getUniprotIDs(taxId = 9606, kt = "ENSEMBL", keys, seq_cluster = "UNIREF90", chunksize=20)
taxId |
An NCBI taxonomy ID |
kt |
Should be either "ENSEMBL" or "UNIPROTKB". |
keys |
Query IDs. |
seq_cluster |
Which cluster to use. Should be one of 'UNIREF100', 'UNIREF90', 'UNIREF50'. |
chunksize |
Queries are done in batches, this parameter sets the size of each batch. |
Returns a list of data.
Thomas Girke
keys <- c("ENSG00000145700", "ENSG00000135441", "ENSG00000120071", "ENSG00000120088", "ENSG00000185829", "ENSG00000185829", "ENSG00000185829", "ENSG00000238083", "ENSG00000012061", "ENSG00000104856", "ENSG00000104936", "ENSG00000117877", "ENSG00000130202", "ENSG00000130202", "ENSG00000142252", "ENSG00000189114", "ENSG00000234906") res_list100 <- getUniprotIDs(taxId=9606, kt="ENSEMBL", keys=keys, seq_cluster="UNIREF100")keys <- c("ENSG00000145700", "ENSG00000135441", "ENSG00000120071", "ENSG00000120088", "ENSG00000185829", "ENSG00000185829", "ENSG00000185829", "ENSG00000238083", "ENSG00000012061", "ENSG00000104856", "ENSG00000104936", "ENSG00000117877", "ENSG00000130202", "ENSG00000130202", "ENSG00000142252", "ENSG00000189114", "ENSG00000234906") res_list100 <- getUniprotIDs(taxId=9606, kt="ENSEMBL", keys=keys, seq_cluster="UNIREF100")
Direct replacement for getUniprotIDs (UniProt.ws), which
is left in place unmodified as a historical/backup option but is not
the recommended path going forward - see the idTranslation.R
file header for the full rationale (reliability and a real
organism-filtering bug in UniProt.ws that this direct implementation
avoids by construction, since it calls the same REST service
UniProt.ws itself wraps).
getUniprotMapping( ids, from, to, taxId = 9606L, pollInterval = 1, maxWait = 120, verbose = FALSE )getUniprotMapping( ids, from, to, taxId = 9606L, pollInterval = 1, maxWait = 120, verbose = FALSE )
ids |
character vector of source-database identifiers (e.g. gene symbols, UniProt accessions, Ensembl gene IDs). Deduplicated internally before submission. |
from |
character(1) source database name, in UniProt's own
vocabulary (e.g. |
to |
character(1) target database name (e.g.
|
taxId |
integer(1) or |
pollInterval |
numeric(1) seconds between job-status polls. |
maxWait |
numeric(1) seconds to wait for job completion before erroring. |
verbose |
logical(1); if TRUE, message the job ID and size on submission. |
Submits an asynchronous ID mapping job, polls until it finishes, and
returns every (From, To) pair found, paginating through all
result pages automatically.
A data.frame with columns From and To.
IDs that don't map contribute no row (matching the underlying API's
behavior - there is no per-ID failure signal to NA-pad against, only
an aggregate list of unmapped IDs the API does not currently surface
in the paginated JSON results). Note: to = "Ensembl" results
carry a version suffix (e.g. "ENSG00000077782.24"), unlike
the bare IDs returned elsewhere in this package - strip
sub("\\..*$", "", x) if a bare ID is needed.
getUniprotMapping(c("FGFR1", "KLB"), from = "Gene_Name", to = "UniProtKB-Swiss-Prot") getUniprotMapping("P11362", from = "UniProtKB_AC-ID", to = "Ensembl")getUniprotMapping(c("FGFR1", "KLB"), from = "Gene_Name", to = "UniProtKB-Swiss-Prot") getUniprotMapping("P11362", from = "UniProtKB_AC-ID", to = "Ensembl")
Queries the local GtoPdb SQLite built by buildGtoPdbDb,
using the same queryBy = list(molType, idType, ids) convention
as ttdTargetAnnot/broadRepurposingHubAnnot
- including its QueryIDs column: every row of the result is
tagged with the original query token it matched, and query IDs that
returned no rows still appear as a single row with all other fields
NA.
molType = "protein" (or "gene"), idType
one of "symbol" (HGNC gene symbol) or
"gtp_target_id" (GtoPdb's own numeric target ID) -> target
-> drug.
molType = "cmp", idType one of "name"
(ligand name) or "gtp_ligand_id" (GtoPdb's own numeric
ligand ID) -> drug -> target.
"symbol"/"name" lookups are case-insensitive; the
"gtp_target_id"/"gtp_ligand_id" ID lookups are
exact-match.
gtoPdbTargetAnnot( queryBy = list(molType = NULL, idType = NULL, ids = NULL), gtoPdbDbPath, fields = "core" )gtoPdbTargetAnnot( queryBy = list(molType = NULL, idType = NULL, ids = NULL), gtoPdbDbPath, fields = "core" )
queryBy |
list with components |
gtoPdbDbPath |
character(1) path to the GtoPdb SQLite, e.g. from
|
fields |
|
A data.frame with columns QueryIDs,
target_gene, targetId, targetName, species,
primaryTarget, ligandId, ligandName, type,
action, affinity, affinityParameter,
selectivity, refIds (with the default
fields = "core"), or a subset when fields requests
specific columns.
buildGtoPdbDb, ttdTargetAnnot,
broadRepurposingHubAnnot, listDrugTargetFields
dbPath <- buildGtoPdbDb() gtoPdbTargetAnnot(list(molType = "protein", idType = "symbol", ids = c("FGFR1", "IL1B")), dbPath) gtoPdbTargetAnnot(list(molType = "cmp", idType = "name", ids = "pemigatinib"), dbPath)dbPath <- buildGtoPdbDb() gtoPdbTargetAnnot(list(molType = "protein", idType = "symbol", ids = c("FGFR1", "IL1B")), dbPath) gtoPdbTargetAnnot(list(molType = "cmp", idType = "name", ids = "pemigatinib"), dbPath)
fields = "all"
The bioassay-track counterpart of listDrugTargetFields,
kept as a separate function rather than adding new source keys there -
this package deliberately keeps drug-target annotation data
(curated mechanism-of-action calls: ChEMBL/DGIdb/Open Targets/TTD, see
listDrugTargetFields) and raw bioassay
measurements (individual assay results: ChEMBL/PubChem, this function)
as two distinct tracks everywhere, including field discovery. See the
"Bioassay Queries" vignette section for the full distinction.
listBioassayFields(source = c("chembl", "pubchem"), queryBy = NULL, ...)listBioassayFields(source = c("chembl", "pubchem"), queryBy = NULL, ...)
source |
character(1); one of |
queryBy |
optional |
... |
additional arguments passed to the source function when
|
character vector of column names.
getChemblBioassay, getPubchemDrugTarget,
listDrugTargetFields
listBioassayFields("chembl")listBioassayFields("chembl")
fields = "all"
A quick reference for what getChemblDrugTarget(),
getPubchemDrugTarget(), getDgidbDrugTarget(),
getOpenTargetsDrugTarget(), ttdTargetAnnot(),
broadRepurposingHubAnnot() and gtoPdbTargetAnnot() can
return when called with fields = "all" (or requested
individually via fields = c(...)). By default this returns a
documented list with no network/database call; pass queryBy to
instead run a live single-query probe through the matching source
function and report the columns it actually returned (slower, but
exact for that query's shape - useful since some fields only appear
for certain record types, e.g. protein-family ChEMBL targets vs single
proteins; for "ttd"/"broad"/"gtopdb" this is
exact rather than best-effort either way, see
ttdTargetAnnot et al.). The local-SQLite sources
("ttd", "broad", "gtopdb") additionally require
their database path (ttdDbPath, brhDbPath,
gtoPdbDbPath respectively) passed via ... when
queryBy is supplied.
listDrugTargetFields( source = c("chembl", "pubchem", "dgidb", "opentargets", "ttd", "broad", "gtopdb"), queryBy = NULL, ... )listDrugTargetFields( source = c("chembl", "pubchem", "dgidb", "opentargets", "ttd", "broad", "gtopdb"), queryBy = NULL, ... )
source |
character(1); one of |
queryBy |
optional |
... |
additional arguments passed to the source function when
|
character vector of column names.
getChemblDrugTarget, getPubchemDrugTarget,
getDgidbDrugTarget, getOpenTargetsDrugTarget,
ttdTargetAnnot, broadRepurposingHubAnnot,
gtoPdbTargetAnnot
listDrugTargetFields("chembl") listDrugTargetFields("ttd")listDrugTargetFields("chembl") listDrugTargetFields("ttd")
Passes already-current symbols straight through; resolves anything
else via a prev/alias-symbol map (see buildHgncSymbolMap);
anything still unresolved becomes NA, with the unmapped input
symbols reported via attr(., "unmapped") rather than silently
dropped.
normalizeGeneSymbols(symbols, symbolMap = NULL, hgncTable = NULL)normalizeGeneSymbols(symbols, symbolMap = NULL, hgncTable = NULL)
symbols |
character vector of gene symbols to normalize. |
symbolMap |
named character vector as returned by
|
hgncTable |
data.frame as returned by |
character vector, same length/order as symbols.
buildHgncSymbolMap, getHgncGeneTable
hgncTable <- getHgncGeneTable() normalizeGeneSymbols(c("FGFR1", "ABL"), hgncTable = hgncTable)hgncTable <- getHgncGeneTable() normalizeGeneSymbols(c("FGFR1", "ABL"), hgncTable = hgncTable)
Download Drug Age data from genomics.senescence.info/drugs. Process the data and write it out as a TSV spreadsheet.
processDrugage(drugagefile=file.path(config$resultsPath,"drugage_id_mapping.xls"), redownloaddrugage=TRUE,config=genConfig())processDrugage(drugagefile=file.path(config$resultsPath,"drugage_id_mapping.xls"), redownloaddrugage=TRUE,config=genConfig())
drugagefile |
The name of the output file. |
redownloaddrugage |
If true, download the data file. Otherwise assume the file is already downloaded. |
config |
General configuration. See |
Output is written to drugagefile.
Thomas Girke
tryCatch({ config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions")) processDrugage("druage_id_mapping.xls",TRUE,config) }, error=function(e){ message("Failed to run processDrugage(), please try again later") } )tryCatch({ config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions")) processDrugage("druage_id_mapping.xls",TRUE,config) }, error=function(e){ message("Failed to run processDrugage(), please try again later") } )
The tying-together piece of the ID-translation layer (see
idTranslation.R, unichemAccess.R): resolves
queryBy$ids to whatever native identifier each requested
source needs (see .resolveGeneIds/
.resolveCompoundIds for how), then dispatches to that
source's own bidirectional annotation query function
(getChemblDrugTarget, getDgidbDrugTarget,
getOpenTargetsDrugTarget, ttdTargetAnnot,
broadRepurposingHubAnnot, gtoPdbTargetAnnot).
Named queryDrugTargets(), not getDrugTarget() - that
name is already taken by an older, unrelated function in
drugTargetAnnotations_Fct.R.
queryDrugTargets( queryBy = list(molType = NULL, idType = NULL, ids = NULL), sources = names(.dtiMetaSources), ttdDbPath = NULL, brhDbPath = NULL, gtoPdbDbPath = NULL, unichemDbPath = NULL, taxId = 9606L, verbose = FALSE, ... )queryDrugTargets( queryBy = list(molType = NULL, idType = NULL, ids = NULL), sources = names(.dtiMetaSources), ttdDbPath = NULL, brhDbPath = NULL, gtoPdbDbPath = NULL, unichemDbPath = NULL, taxId = 9606L, verbose = FALSE, ... )
queryBy |
named list with components |
sources |
character vector, any of |
ttdDbPath |
character(1) path to a local TTD SQLite (see
|
brhDbPath |
character(1) path to a local Broad Repurposing Hub
SQLite (see |
gtoPdbDbPath |
character(1) path to a local GtoPdb SQLite (see
|
unichemDbPath |
character(1) path to a local UniChem SQLite (see
|
taxId |
integer(1) NCBI taxonomy ID for gene/protein-side
resolution (default 9606L = human); passed to
|
verbose |
logical(1); if TRUE, message resolution and per-source progress, and why a source was skipped. |
... |
additional arguments passed through to each dispatched
source function (e.g. |
PubChem is intentionally not one of the dispatchable sources:
its REST accessors return raw bioassay measurements, not curated
drug-target annotations, a different data type from what this
function and combineDrugTargets harmonize. Use
getPubchemDrugTarget directly, or
getChemblBioassay for ChEMBL's own bioassay data - see
the "Bioassay Queries" vignette section.
Returns a named list, one element per successfully-queried source -
not one unified table. Cross-source schema harmonization (e.g.
a proper S4 container) is a separate, deferred phase; this function's
job is ID resolution and dispatch, not schema design. A source
contributes no list element
at all (rather than an empty data.frame) when none of queryBy$ids
resolved to that source's native ID type, or when the source's own
function raised an error (e.g. a required local database path was not
supplied) - set verbose = TRUE to see why.
A named list, one element (a data.frame) per source
that returned a result. attr(result, "resolved") holds the
per-source ID-resolution vectors (named by the original
queryBy$ids, as returned by .resolveGeneIds/
.resolveCompoundIds) for tracing which input ID led to
which rows.
getChemblDrugTarget, getDgidbDrugTarget,
getOpenTargetsDrugTarget, ttdTargetAnnot,
broadRepurposingHubAnnot, gtoPdbTargetAnnot,
getPubchemDrugTarget, getChemblBioassay,
getUniprotMapping, getUnichemMapping
## target -> drug, starting from an Ensembl gene ID, all live sources res <- queryDrugTargets( list(molType = "gene", idType = "ensembl", ids = "ENSG00000077782"), sources = c("chembl", "dgidb", "opentargets")) names(res) res$chembl ## drug -> target, starting from a DrugBank ID (needs a UniChem SQLite) res2 <- queryDrugTargets( list(molType = "cmp", idType = "drugbank_id", ids = "DB00945"), sources = "chembl", unichemDbPath = buildUnichemDb(rerun = FALSE))## target -> drug, starting from an Ensembl gene ID, all live sources res <- queryDrugTargets( list(molType = "gene", idType = "ensembl", ids = "ENSG00000077782"), sources = c("chembl", "dgidb", "opentargets")) names(res) res$chembl ## drug -> target, starting from a DrugBank ID (needs a UniChem SQLite) res2 <- queryDrugTargets( list(molType = "cmp", idType = "drugbank_id", ids = "DB00945"), sources = "chembl", unichemDbPath = buildUnichemDb(rerun = FALSE))
Meta-function to obtain in one step both drug-target annotation and bioassay data.
runDrugTarget_Annot_Bioassay(res_list, up_col_id="ID", ens_gene_id, cmpid_file=file.path(config$resultsPath,"cmp_ids.rds") ,config=genConfig(), ...)runDrugTarget_Annot_Bioassay(res_list, up_col_id="ID", ens_gene_id, cmpid_file=file.path(config$resultsPath,"cmp_ids.rds") ,config=genConfig(), ...)
res_list |
Object obtained from |
up_col_id |
Column name in |
ens_gene_id |
Named character vector with ENSEMBL gene IDs in name slot and gene symbols or other ID type in value slot |
cmpid_file |
Path to CMP ID mapping file, often named |
config |
General configuration. See |
... |
Slot to pass on additional arguments. |
List with two components each containing a data.frame. The first one (Annotation)
contains drug-target annotation data, and the second one (Bioassay) contains drug-target
bioassay data.
Thomas Girke
References to be added...
See also: drugTargetAnnot and drugTargetBioactivity
config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) ## (1) Translate gene symbols to ENSEMBL gene IDs ensembl_gene_id <- c("ENSG00000001626", "ENSG00000168748") idMap <- getSymEnsUp(EnsDb="EnsDb.Hsapiens.v86", ids=ensembl_gene_id, idtype="ENSEMBL_GENE_ID") ens_gene_id <- idMap$ens_gene_id ## (2a) Retrieve UniProt IDs with both IDMs and SSNN paralogs queryBy <- list(molType="gene", idType="ensembl_gene_id", ids=names(ens_gene_id)) #this function is slow and requires a network connection res_list <- getParalogs(queryBy) ## (3) Obtain Drug-Target Annotation and Bioassay Data drug_target_list <- runDrugTarget_Annot_Bioassay(res_list=res_list, up_col_id="ID_up_sp", ens_gene_id,config=config )config = genConfig(chemblDbPath= system.file("extdata", "chembl_sample.db", package="drugTargetInteractions"), resultsPath = system.file("extdata", "results", package="drugTargetInteractions")) ## (1) Translate gene symbols to ENSEMBL gene IDs ensembl_gene_id <- c("ENSG00000001626", "ENSG00000168748") idMap <- getSymEnsUp(EnsDb="EnsDb.Hsapiens.v86", ids=ensembl_gene_id, idtype="ENSEMBL_GENE_ID") ens_gene_id <- idMap$ens_gene_id ## (2a) Retrieve UniProt IDs with both IDMs and SSNN paralogs queryBy <- list(molType="gene", idType="ensembl_gene_id", ids=names(ens_gene_id)) #this function is slow and requires a network connection res_list <- getParalogs(queryBy) ## (3) Obtain Drug-Target Annotation and Bioassay Data drug_target_list <- runDrugTarget_Annot_Bioassay(res_list=res_list, up_col_id="ID_up_sp", ens_gene_id,config=config )
Integration with Therapeutic Target Database (TTD). This function downloads a data file from idrblab.org and returns it as a data frame.
transformTTD(ttdfile=file.path(config$downloadPath,"TTD_IDs.txt"), redownloadTTD=TRUE,config=genConfig())transformTTD(ttdfile=file.path(config$downloadPath,"TTD_IDs.txt"), redownloadTTD=TRUE,config=genConfig())
ttdfile |
The name of the output file to write the downloaded file to. |
redownloadTTD |
If true, data file will be downloaded again. If false, we assume the file
already exists at |
config |
General configuration. See |
Returns a data frame with TTD data in it.
Thomas Girke
ttd=tryCatch( transformTTD(), error=function(e){ message("Failed to download TTD file, please try again later") } )ttd=tryCatch( transformTTD(), error=function(e){ message("Failed to download TTD file, please try again later") } )
Queries the local TTD SQLite built by buildTtdDb, using
the same queryBy = list(molType, idType, ids) convention as the
package's ChEMBL-SQL drugTargetAnnot - including its
QueryIDs column: every row of the result is tagged with the
original query token it matched, and query IDs that returned no rows
still appear as a single row with all other fields NA, so
callers can always confirm which of their input IDs were resolved
(unlike the standalone R_Py_code/ttdAccess.R reference this was
ported from, which returned only the matched rows with no such
bookkeeping).
molType = "protein", idType one of
"symbol", "uniprot", "ttd_target_id" ->
target -> drug
molType = "cmp", idType one of "name",
"ttd_drug_id" -> drug -> target
Symbol/name lookups are case-insensitive; ID lookups
("uniprot", "ttd_target_id", "ttd_drug_id") are
exact-match. Note: TTD's "uniprot" field (and the col
used for idType = "uniprot" lookups here) is the UniProt
*mnemonic entry name* (e.g. "FGFR1_HUMAN"), NOT the accession
number (e.g. "P11362") used by the package's ChEMBL-SQL side
(drugTargetAnnot) - a real cross-source naming
inconsistency confirmed to persist even in TTD's own dedicated UniProt
file, not a bug; the separate Uniprot_acc column carries a
resolved accession where available (see buildTtdDb for
how, and its uniprot_source sibling column for why a given row
may still be NA), so query by idType = "uniprot" still
needs the mnemonic, but downstream joins to other sources can use
Uniprot_acc directly.
ttdTargetAnnot( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ttdDbPath, fields = "core" )ttdTargetAnnot( queryBy = list(molType = NULL, idType = NULL, ids = NULL), ttdDbPath, fields = "core" )
queryBy |
list with components |
ttdDbPath |
character(1) path to the TTD SQLite, e.g. from
|
fields |
|
A data.frame with columns QueryIDs,
TargetID, GeneName, Uniprot, TargetType,
DrugID, DrugName, Smiles, Highest_status,
MOA, Uniprot_acc, uniprot_source,
molecule_type, PubChem_CID, PubChem_SID,
CAS, ChEBI_ID, Indication (with the default
fields = "core"), or a subset when fields requests
specific columns. Also carries attr(result, "ttd_release"), a
data.frame of every source TTD file's own (file, version,
date) release stamp (see buildTtdDb); NULL for
a ttdDbPath built before this attribute was added.
buildTtdDb, drugTargetAnnot,
listDrugTargetFields
dbPath <- buildTtdDb() ttdTargetAnnot(list(molType = "protein", idType = "symbol", ids = c("FGFR1", "IL1B")), dbPath) ttdTargetAnnot(list(molType = "cmp", idType = "name", ids = "Pemigatinib"), dbPath)dbPath <- buildTtdDb() ttdTargetAnnot(list(molType = "protein", idType = "symbol", ids = c("FGFR1", "IL1B")), dbPath) ttdTargetAnnot(list(molType = "cmp", idType = "name", ids = "Pemigatinib"), dbPath)