Construct a GwasSumStats S4 DFrame-subclass collection
from per-study tuple vectors and a list of GRanges entries (one per
study), plus a single LD sketch handle and a single genome build that apply
to the whole collection.
Each GRanges entry must carry per-variant statistics in its mcols (at
minimum SNP, A1, A2, Z, N; optionally
MAF, INFO, BETA, SE, P).
Usage
GwasSumStats(
study,
entry,
genome,
ldSketch = NULL,
varY = NA_real_,
nCase = NULL,
nControl = NULL,
nSample = NULL,
qcInfo = list(),
ldBlocks = NULL,
blockId = NULL,
...
)Arguments
- study
Character vector of study identifiers (must be unique).
- entry
A
SimpleListorlistofGRanges, one per study.- genome
Single character string giving the genome build (e.g.,
"hg19","hg38"). Uniform across the collection because all entries share the same LD sketch.- ldSketch
A genotype panel (see
readGenotypes) carrying the LD reference.- varY
Optional numeric vector of per-study phenotype variances (
NA_real_entries allowed). Used by the sufficient-statistic interface; z-score RSS analyses should leave entries as NA.- nCase, nControl
Optional per-study case / control counts. The columns are attached only when supplied (default
NULL), so quantitative-trait collections keep the original schema. When given, pass length 1 or length(study) (useNAfor the non-case/control studies in a mixed collection). For case/control GWAS, downstream consumers (e.g.colocboostPipeline) use the effective sample size4 / (1/nCase + 1/nControl)in place of the per-variantN.- nSample
Optional per-study total sample size (numeric; default
NULL). Attached only when supplied (length 1 or length(study)). Used as the study-level fallback for the per-variantNwhen a study has no per-variantNcolumn and no case/control counts. NamednSampleto avoid clashing withgetNSamples()(the LD-panel sample size).- qcInfo
A
listrecording which QC steps ran. Emptylist()on construction; populated bysummaryStatsQc()with a per-step audit record. Fine-mapping / TWAS pipelines reject inputs wherelength(getQcInfo(x)) == 0.- ldBlocks
Optional LD-block specification: an
LdBlocks, aGRanges, a data.frame withchrom/start/end(plus an optionalblockId), or a path to such a table. When supplied, each study's variants are split into one element per block rather than one per chromosome, andblockIdtakes the block's key (itsnames, else ablockIdmetadata column, else its coordinates). cTWAS needs this granularity: its EM estimates parameters across blocks, so a per-chromosome split is too coarse. Variants overlapping no block are dropped with a warning, because a variant outside every block has no block-local LD to be fine-mapped against.- blockId
Optional character vector of block keys, one per
entry, for entries that are already split by block. Use it to carry existing keys through a rebuild; without it a rebuild would re-derive them as seqnames and collapse distinct blocks onto one key. Mutually exclusive withldBlocks.- ...
Additional per-study columns to attach to the collection.
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)
GwasSumStats(study = "t1", entry = list(gr), genome = "hg38",
ldSketch = panel)
#> GwasSumStats: 1 studies, genome build hg38
#> LD sketch: plink1 @ /tmp/RtmppU8QTb/temp_libpath984aa04109/pecotmr/extdata/toy_ref