Contents
PolyGeniusAssociation
Association result container
PolyGeniusAssociation is the standard result object returned by association workflows. It is
a PolyGeniusResult carrying $results, $fits, $indices, $artifacts, $diagnostics
and $metadata; the constructor is exported so a custom producer can emit the same object
every associate$*() function does.
plot() draws the default plot for the object's schema, resolving the schema's declared
default.plot token through the visualize plot registry. It aborts when $results mixes more
than one schema, or when no plot is registered for that schema; use the specific
visualize$associations$*() function in either case.
merge() combines any number of PolyGeniusAssociation objects into one,
binding result rows and table-like artifacts. An optional .id column can be
added to trace each row back to its source object.
Usage
PolyGeniusAssociation(
results = NULL,
fits = NULL,
multiplicity = NULL,
artifacts = list(),
diagnostics = list(),
metadata = list()
)
print.PolyGeniusAssociation(x, ...)
summary.PolyGeniusAssociation(object, ...)
print.summary.PolyGeniusAssociation(x, ...)S3 method for class 'PolyGeniusAssociation'
plot(x, ...)S3 method for class 'PolyGeniusAssociation'
merge(..., .id = NULL)S3 method for class 'PolyGeniusAssociation'
c(..., recursive = FALSE)Arguments
| Argument | Description |
|---|---|
results | A data.frame, a data.table, or NULL (default). Inferential rows, coerced to data.table; NULL gives an empty $results. |
fits | A data.frame, a data.table, or NULL (default). Per-fit lookup keyed by the integer .fit column; NULL for an object whose tables are already narrow. |
multiplicity | A data.frame, a data.table, or NULL (default). Adjustment-family declaration keyed by adj.family.id (see $indices above); NULL when $results carries no BH-adjusted column. |
artifacts | Named list of plot-ready artifact tables, default list(). A bare data.frame is wrapped as a single entry named messages. |
diagnostics | Named list of diagnostic tables, default list(). A bare data.frame is wrapped as a single entry named messages. |
metadata | Named list, default list(). Stored as given. |
x | A PolyGeniusAssociation; for print() of a summary, the summary.PolyGeniusAssociation that summary() returned. |
... | For merge() and c(), further PolyGeniusAssociation objects or named lists of them. Passed on to the resolved plot function by plot(); unused by print() and summary(). |
object | A PolyGeniusAssociation. |
.id | Character scalar, or NULL (default). When supplied, a source-label column of this name is added to the merged results, artifacts and diagnostics; labels come from the input names, or the input position when unnamed. A column already carrying that name, such as family, is overwritten without warning, so pick a name the tables do not use. |
recursive | Logical scalar, default FALSE. Accepted for compatibility with the c() generic and ignored; nested lists of objects are always flattened. |
Value
A list with class c("PolyGeniusAssociation", "PolyGeniusResult", "list"), carrying
$results, $fits, $indices, $artifacts, $diagnostics, $metadata and
$provenance.
print() returns x invisibly; called for its console output, which lists the schemas,
families, result-row and fit counts, a not-fitted count when any fit failed, one line per
artifact and diagnostic entry, and a closing line summarising the provenance record.
summary() returns a summary.PolyGeniusAssociation list with
$counts (a data.table of per schema/family result-row and fit counts) and $failures
(a data.table with one deduplicated row per not-fitted/error cause, with a fit count n).
Both are empty typed tables when $results has no rows.
plot() returns whatever the registered plot function builds: a ggplot, a
patchwork composite, or a PolyGeniusGenomeTrack, depending on the schema's
default.plot.
merge() returns one PolyGeniusAssociation. .fit and adj.family.id are offset
per input so keys stay unique, multiplicity families are re-keyed rather than recomputed, and
$metadata records merged, n.objects and sources. Aborts when no object is supplied or
any input is not a PolyGeniusAssociation.
c() returns the same merged PolyGeniusAssociation merge() does. A .id passed to
c() reaches merge(), so c(a = x, b = y, .id = "source") adds the source column.
Details
$results is a long-format data.table where each row is one statistical claim (coefficient,
test, ...), stored fully materialized so it reads directly. Every row carries columns .fit,
fit.id, schema, family, outcome, predictor, term, estimate, se, lower,
upper, pval, adj.pval, adj.family.id and n. adj.family.id is NA on a row
adj.pval was never computed for (e.g. km, which carries no coefficient-scale test); where
it is populated it keys into $indices$multiplicity.
$fits (equivalently $indices$fits) is the per-fit lookup table: one row per .fit carrying
the fit-level-invariant metadata (fit.id, family, outcome, predictor, stratum,
formula, counts, ...). Row-heavy $artifacts and $diagnostics tables store only the
integer .fit key plus their own value columns; the identifying columns are factored out here
so they are stored once per fit rather than once per row. Use artifacts() to retrieve an
artifact with the $fits metadata joined back on. $fits is NULL (and $indices empty) for
analysis types whose tables are already narrow (e.g. meta, mediation, compare).
$indices is the PolyGeniusResult normalization-index slot: a named list of tables, each
joined to $results by an integer key. Association carries two today: fits (keyed by .fit,
association-only) and multiplicity (keyed by adj.family.id, shared with evaluation -- one
row per BH-adjustment family, declaring p.adjust.method, the grouping columns, and family
size n, so adj.pval stays traceable to what produced it across merge() and subsetting).
$artifacts is a named list of plot-ready derived tables such as prediction grids, survival
curves, risk tables, and cumulative-incidence curves. $diagnostics is a named list of
diagnostic tables recording fit warnings, errors, exclusions, and convergence notes.
$metadata is open space, stored as given; $provenance is the record of how the object was
made, read with provenance(x). See $metadata and $provenance in PolyGeniusResult.
dplyr verbs
filter(), slice(), arrange(), mutate(), select(), rename(), transmute(),
distinct(), group_by(), and ungroup() operate on $results and return a
PolyGeniusAssociation. Row-filtering verbs also prune $artifacts, $diagnostics, $fits and
$indices$multiplicity to surviving identifiers. summarise() and pull() operate on $results
but return a plain dplyr table or bare vector rather than a PolyGeniusAssociation. These verbs
are implemented once, shared with PolyGeniusEvaluation -- see PolyGeniusResult.
Examples
rows <- data.frame(
.fit = 1L, fit.id = "f1", schema = "regression", family = "gaussian",
outcome = "ldl", predictor = "prs", term = "prs",
estimate = 0.21, se = 0.04, lower = 0.13, upper = 0.29, pval = 1e-7, n = 900L
)
assoc <- PolyGeniusAssociation(results = rows, metadata = list(source = "example"))
nrow(assoc$results)See Also
PolyGeniusResult for the shared subsetting/dplyr-verb implementation, PolyGeniusEvaluation for the sibling subclass.
Other result-objects:
PolyGeniusEvaluation(),
PolyGeniusResult(),
artifacts(),
diagnostics(),
federate(),
provenance()