PubChemR
is an R package that provides an interface to the ‘PubChem’ database via the PUG REST and PUG View services. This package allows users to programmatically access chemical and biological data from ‘PubChem’, including compounds, substances, assays, and various other data types. Functions are available to retrieve data in different formats, perform searches, and access detailed annotations.
Installation
You can install the development version of PubChemR
from GitHub with:
# install.packages("devtools")
devtools::install_github("selcukorkmaz/PubChemR")
Usage
The PubChemR package provides functions to query PubChem’s database using their RESTful web service. Below are some examples of how to use the package:
Getting Compound Information Retrieve compound information by CID:
library(PubChemR)
Retrieving Compound Information
Get compound information by CID
compound_info <- get_compounds(c(2244, 305))
Searching for Compounds
Search for compounds by name:
Retrieving Assay Information
Get assay information by AID:
Downloading Chemical Structures
Download chemical structures in different formats:
download("SDF", "aspirin.sdf", 2244)
Functions
The package includes the following main functions:
get_compounds()
: Retrieve information about compounds. get_cids()
: Get compound identifiers for given names or other identifiers. get_aids()
: Obtain assay information for given assay identifiers. get_sids()
: Get substance identifiers related to compounds. get_properties()
: Retrieve specific properties of compounds. get_json()
: General function to retrieve data in JSON format. download()
: Download chemical structures and other data. Each function is documented with details on its parameters and return values. Use ?function_name in R to access the help page for a specific function.
Output Formats
The PubChemR package supports various output formats including JSON, SDF, CSV, PNG, and TXT.
HTTP Interface
PubChemR interacts with the PubChem API through HTTP requests, handling the construction of query URLs and parsing the responses.
Contributing
Contributions to PubChemR are welcome! Please refer to the CONTRIBUTING.md file for guidelines.
License
PubChemR is released under the MIT License. See the LICENSE file for more details.
Contact
For questions and feedback, please open an issue in the GitHub repository issue tracker.
Citation
If you use PubChemR in your research, please cite it as follows:
Korkmaz S, Goksuluk D (2023). PubChemR: Interface to the ‘PubChem’ Database for Chemical Data Retrieval. R package version 0.99-1, https://CRAN.R-project.org/package=PubChemR.
A BibTeX entry for LaTeX users is: