Skip to contents

Assemble a per-condition QtlSumStats from a variants x conditions Z-score matrix – the input shape the mash pipeline uses when only Z is available. Each column is one condition, and conditions are distinguished by context, trait, or both: the columns may be different cell types / tissues (contexts), different molecular phenotypes (traits), or arbitrary context x trait pairs. Chromosome / position are decoded from the row (variant) identifiers via parseVariantId (with a synthetic-position fallback for ids that do not encode coordinates); A1 / A2 / N are placeholders because a Z-only input carries no alleles or sample sizes (mash reads only Z). A pass-through qcInfo record is set so the result clears the mash QC gate.

Usage

qtlSumStatsFromZMatrix(
  z,
  study,
  ldSketch = NULL,
  context = colnames(z),
  trait = "mash",
  genome = "GRCh38",
  n = 1000L,
  a1 = "A",
  a2 = "G",
  role = "mash"
)

Arguments

z

Numeric matrix (variants x conditions). rownames(z) are variant ids (ideally chr:pos:A2:A1); colnames(z) label the conditions.

study

Study identifier (recycled across conditions).

ldSketch

A genotype panel (see readGenotypes) embedded in the collection, or NULL (default) – mash operates across conditions per variant and needs no LD reference.

context

Condition context label(s): a single value recycled across every column, or a length-ncol(z) vector (one per condition). Defaults to colnames(z) – one context per column.

trait

Condition trait label(s): a single value recycled across every column, or a length-ncol(z) vector. Default "mash". Pass colnames(z) here (with a constant context) when the columns are traits rather than contexts.

genome

Genome build. Default "GRCh38".

n

Placeholder per-variant sample size. Default 1000.

a1, a2

Placeholder alleles. Defaults "A" / "G".

role

Tag stored in the qcInfo record. Default "mash".

Value

A QtlSumStats with one entry per condition (column).

Examples

panel <- readGenotypes(
  system.file("extdata", "toy_ref.bed", package = "pecotmr"))
z <- matrix(rnorm(6), 2, 3, dimnames = list(
  c("chr22:1:A:G", "chr22:2:A:G"), c("brain", "blood", "muscle")))
qtlSumStatsFromZMatrix(z = z, study = "s1", ldSketch = panel,
  context = colnames(z), trait = "g1", genome = "hg38", n = 100)
#> QtlSumStats: 3 entries, genome build hg38
#>   1 studies, 3 contexts, 1 traits
#>   LD sketch: plink1 @ /tmp/RtmppU8QTb/temp_libpath984aa04109/pecotmr/extdata/toy_ref