Skip to contents

This function takes two vectors A and B, an API key, a database name, and performs a search operation on the specified database using the search terms from A and B. It then generates a dataframe of search results and optionally exports it as a .csv file. Use plot_pubmatrix_heatmap() to visualize the results as a heatmap.

Usage

PubMatrix(
  file = NULL,
  A = NULL,
  B = NULL,
  API.key = NULL,
  Database = "pubmed",
  daterange = NULL,
  outfile = NULL,
  export_format = NULL
)

Arguments

file

A file containing search terms (optional). If NULL, search terms will be read from A and B vectors.

A

A vector of search terms to be paired with B. If NULL, search terms will be read from the file.

B

A vector of search terms to be paired with A. If NULL, search terms will be read from the file.

API.key

An API key obtained from Entrez; not necessary.

Database

Either 'pubmed' or 'pmc'. Determines the database to search.

daterange

A range of dates to search if desired. Should be a vector of two elements: the start and end date.

outfile

A file path to export the search dataframe with hyperlinks. If NULL (default), no file will be exported. Ignored if export_format is not specified.

export_format

Format for exporting the hyperlinked dataframe with clickable links. Options are: NULL (default, no export), 'csv', or 'ods'. When NULL, only returns the dataframe to R without saving. 'csv' exports as Excel-compatible format with HYPERLINK formulas; 'ods' exports as OpenDocument Spreadsheet format compatible with LibreOffice/OpenOffice. Requires outfile parameter when not NULL.

Value

A dataframe of search results. Each element of the dataframe is the number of search results for a pair of search terms from A and B.

Examples

# Note: This example requires internet connection
A <- c("WNT1", "WNT2")
B <- c("FZD1", "FZD2")
# result <- PubMatrix(A = A, B = B, Database = "pubmed", daterange = c(2020, 2023))
# print(result)
message("Example commented out to avoid internet dependency in checks")
#> Example commented out to avoid internet dependency in checks