PolyGeniusData
Create a new PolyGeniusData object
Description
Creates a new instance of a PolyGeniusData coupling:
-
PRS model information — extracted from the provided
models -
Genotype information — available from the provided genotype information
This method enables two complementary behaviors depending on the expressions supplied on the left (i, observation-side) and right (j, model-side):
-
Sub-setting mode — If an index/expression can be evaluated in the caller’s environment (numeric / character / logical), or the fetched value resolves to a logical vector aligned with the chosen side, the object is subset accordingly and a new
PolyGeniusDatais returned. -
Fetching mode — Otherwise, expressions are resolved via
x$fetch()and the requested observation/model information is returned. If only one side is provided, the corresponding table is returned. If both sides are provided, a named list with$obsand$modtables is returned (class“PolyGeniusDataFetchResult”).
Note that if both sides are supplied they must resolve to the same mode. Otherwise an error is riased (e.g., subsetting observations while fetching models or vise versa is not permitted).
subset() for PolyGeniusData provides a convenient interface. It accepts one expression for the observation side (obs) and one for the model side (mod), evaluates each in either the caller’s environment or by calling fetch (to disambiguate logical predicates), validates the indices, and returns a new subsetted PolyGeniusData.
This method intentionally does not fetch values to return them. If you wish to retrieve observation/model information (rather than subset the object), use the bracket method x[i, j] or call x$fetch(…) directly.
Usage
PolyGeniusData(
name,
models,
genotypes,
obs = NULL,
obsm = NULL,
obsp = NULL,
obsu = NULL,
mod = NULL,
modm = NULL,
modp = NULL,
modu = NULL,
uns = NULL
)
## S3 method for class 'PolyGeniusData'
x[i, j, drop = FALSE]
## S3 method for class 'PolyGeniusData'
x[[..., exact = TRUE]]
## S3 method for class 'PolyGeniusData'
subset(x, obs, mod, ...)
Arguments
name
|
Name for |
models
|
A |
genotypes
|
A |
obs
|
For |
obsm
|
Optional named list of observation-aligned rectangular objects appended into |
obsp
|
Optional named list of observation-by-observation rectangular objects appended into |
obsu
|
Optional named list of unstructured observation-related objects appended into |
mod
|
For |
modm
|
Optional named list of model-aligned rectangular objects appended into |
modp
|
Optional named list of model-by-model rectangular objects appended into |
modu
|
Optional named list of unstructured model-related objects appended into |
uns
|
Optional named list of unstructured objects appended into |
x
|
A |
i
|
Observation-side index or expression(s) (unquoted). May be a direct index (numeric/character/logical) that evaluates in the caller, or an expression(s) to be resolved via |
j
|
Model-side index or expression(s) (unquoted). Same semantics as |
drop
|
Ignored; included for S3 signature compatibility. |
…
|
Ignored; for S3 signature compatibility. |
exact
|
Ignored (S3 compatibility). |
Details
A special case is when a single logical expression is to be fetched for either observations or models, as it is unclear if it should be used as a logical vector for subsetting the PolyGeniusData object or alternatively to be returned. To resolve ambiguity
Value
A new PolyGeniusData object
-
In Subsetting mode: a new
PolyGeniusDatasubsetted on observations/models. -
In Fetching mode: a table (single side) or a list with
$obsand$modtables of class“PolyGeniusDataFetchResult”(both sides). -
If both
iandjare missing:NULL.
Whatever x[ , c(<name>)] returns (typically a tibble).
A new PolyGeniusData subsetted on observations and/or models.
Examples
## Not run:
# Subset observations by logical predicate to be evaluated in the caller's environment (if both age and sex exist in the environment)
# or by data$fetch(age, sex, .context="obs")
# they
data[age > 65 & sex == "M", ]
# Subset models by name
data[, c("prs_1","prs_3")]
# Fetch observation-side columns (resolved via fetch)
dat[, c(age, PCA)]
# Fetch both sides at once
dat[c(trait, gwas), c(age, PCA)]
## End(Not run)
## Not run:
# Subset observations by predicate (evaluates in caller)
subset(data, obs = age > 65 & sex == "M")
# Subset models by name
subset(data, mod = c("prs_1", "prs_3"))
# Use a logical column that lives inside the object (resolves to a single logical via fetch)
subset(data, obs = case_status == 1)
# If you intend to fetch (not subset), use the bracket method:
data[, c(age, PCA)]
## End(Not run)