Learn R Programming

PubChemR (version 3.0.0)

pc_assay_activity_long: Convert PubChem Assay Summary to Long Activity Table

Description

Builds a normalized long-form table from the PubChem `compound/*/assaysummary/JSON` payload, suitable for `pc_activity_matrix()`.

Usage

pc_assay_activity_long(
  identifier = NULL,
  namespace = "cid",
  x = NULL,
  chunk_size = NULL,
  unique_rows = TRUE,
  add_outcome_value = TRUE,
  outcome_map = NULL,
  strict_outcome = FALSE,
  unknown_outcome = NA_real_,
  error_mode = c("stop", "result"),
  ...
)

Value

A tibble with normalized fields including `CID`, `AID`, and `ActivityOutcome` when available.

Arguments

identifier

Identifier vector used when `x` is `NULL`.

namespace

Namespace for `identifier` when requesting from PubChem.

x

Optional source object. One of: - `PubChemResult` from `pc_request(...)` - raw parsed payload list containing `Table/Columns/Row`

chunk_size

Optional chunk size for large identifier vectors.

unique_rows

Logical. Remove duplicate rows after normalization.

add_outcome_value

Logical. If `TRUE`, adds a numeric `ActivityOutcomeValue` column when `ActivityOutcome` exists.

outcome_map

Optional named mapping passed to `pc_activity_outcome_map()`.

strict_outcome

Logical. If `TRUE`, unknown outcome labels error.

unknown_outcome

Numeric fallback for unknown labels when `strict_outcome = FALSE`.

error_mode

Error behavior. `"stop"` (default) throws an error on failure. `"result"` returns a typed `PubChemResult` failure object.

...

Additional arguments forwarded to `pc_request()` when `x` is `NULL`.

Details

Input can be fetched directly from PubChem or provided as an already parsed payload. Column names are normalized to stable identifiers and optional numeric activity outcomes can be added for modeling workflows.

Examples

Run this code
payload <- list(
  Table = list(
    Columns = list(Column = c("CID", "AID", "Activity Outcome")),
    Row = list(
      list(Cell = c("2244", "367", "Active")),
      list(Cell = c("2244", "368", "Inactive"))
    )
  )
)
pc_assay_activity_long(x = payload)

Run the code above in your browser using DataLab