Skip to contents

Construct a QtlSumStats S4 DFrame-subclass collection from per-tuple vectors and a list of GRanges entries (one per tuple), plus a single LD reference and a single genome build that apply to the whole collection. Each GRanges entry must carry per-variant statistics in its mcols (SNP, A1, A2, Z, N; plus optional MAF, INFO, BETA, SE, P).

Usage

QtlSumStats(
  studyName,
  context,
  trait,
  entry,
  genome,
  ldReference = NULL,
  varY = NA_real_,
  nSample = NULL,
  qcInfo = list(),
  traitPos = NULL,
  extraCols = list()
)

Arguments

studyName

Character vector of study identifiers (per tuple).

context

Character vector of context labels (per tuple).

trait

Character vector of trait identifiers (per tuple).

entry

A list / SimpleList of GRanges, one per tuple. Same length as study, context, and trait.

genome

Single character string giving the genome build (e.g., "hg19", "hg38"). Uniform across the collection because all entries share the same LD reference.

ldReference

The LD reference: a genotype panel (see readGenotypes), a GenotypeMixture or an LdMatrix.

varY

Optional numeric vector of per-tuple phenotype variances (NA_real_ entries allowed).

nSample

Optional per-tuple total sample size (numeric; default NULL). Attached only when supplied (length 1 or length(study)). Used as the study-level fallback for the per-variant N when a tuple has no per-variant N column. Named nSample to avoid clashing with nSamples() (the LD-panel sample size). Unlike GWAS, QTL collections carry no case/control counts (molecular traits are quantitative), so only this total-N fallback is exposed.

qcInfo

A list recording which QC steps ran. Empty list() on construction; populated by summaryStatsQc() with a per-step audit record. Fine-mapping / TWAS pipelines reject inputs where length(qcInfo(x)) == 0.

traitPos

Optional per-row trait genomic anchor (a GRanges or NULL), carried forward as provenance; not part of the identity key. NULL (default) omits the column.

extraCols

Optional named list of additional per-tuple columns to attach to the collection's mcols. Named rather than variadic because the base class's own constructor, GRangesList(...), uses ... for its elements: a bare ... here would read as adding an entry rather than a metadata column.

Value

A QtlSumStats object.

Examples

panel <- readGenotypes(
  system.file("extdata", "toy_ref.bed", package = "pecotmr"))
gr <- GenomicRanges::GRanges("chr1", IRanges::IRanges(100 * 1:3, width = 1))
S4Vectors::mcols(gr) <- S4Vectors::DataFrame(SNP = paste0("rs", 1:3),
  A1 = "A", A2 = "G", Z = rnorm(3), N = 100L)
QtlSumStats(studyName = "s1", context = "brain", trait = "g1", entry =
  list(gr), genome = "hg38", ldReference = panel)
#> QtlSumStats: 1 entries, genome build hg38
#>   1 studies, 1 contexts, 1 traits
#>   LD reference: plink1 @ /tmp/RtmpmBLZhq/temp_libpathaae388f3498/pecotmr/extdata/toy_ref