Skip to contents

Supply or overwrite one per-variant column of a GwasSumStats / QtlSumStats entry after construction – the usual case being an effect-allele frequency the source file did not carry. Dispatch is on value:

numeric

positional: the vector is in the entry's own variant order and must have exactly one value per variant. Length is checked hard, because a recycled or truncated vector is otherwise silently wrong.

GRanges

matched: paired to the entry on (chrom, pos, A1, A2) via matchVariants, so ordering does not matter. A1/A2 are required in mcols() so an allele swap can be detected, and exactly one other mcols column carries the values. Entry variants the replacement does not name are set NA.

An allele swap sends af to 1 - af, so af<- complements a flipped match. maf is min(af, 1 - af) and nSamples is a count, both swap-invariant, so neither is complemented.

Usage

af(x, ...) <- value

maf(x, ...) <- value

nSamples(x, ...) <- value

# S4 method for class 'SumStatsBase,numeric'
af(x, studyName = NULL, context = NULL, trait = NULL, ...) <- value

# S4 method for class 'SumStatsBase,GRanges'
af(x, studyName = NULL, context = NULL, trait = NULL, ...) <- value

# S4 method for class 'SumStatsBase,numeric'
maf(x, studyName = NULL, context = NULL, trait = NULL, ...) <- value

# S4 method for class 'SumStatsBase,GRanges'
maf(x, studyName = NULL, context = NULL, trait = NULL, ...) <- value

# S4 method for class 'SumStatsBase,numeric'
nSamples(x, studyName = NULL, context = NULL, trait = NULL, ...) <- value

# S4 method for class 'SumStatsBase,GRanges'
nSamples(x, studyName = NULL, context = NULL, trait = NULL, ...) <- value

Arguments

x

A GwasSumStats or QtlSumStats object.

...

Unused.

value

A numeric vector (positional) or a GRanges carrying A1/A2 plus one value column (matched).

studyName, context, trait

Selectors pinning one entry; context and trait are QtlSumStats-only.

Value

The object, with that entry's column replaced.

Examples

data(qtlSumStatsExample)
x <- qtlSumStatsExample
af(x) <- runif(length(variantIds(x)))
head(af(x))
#> [1] 0.02754518 0.04185241 0.90115290 0.70679542 0.13997709 0.11509195