Skip to contents

Construct a QtlDataset: one study's individual-level QTL data as a MultiAssayExperiment. The genotype handle becomes a genotype experiment whose dosage assay reads lazily through it, and each named phenotype SummarizedExperiment becomes one context experiment. The sampleMap is derived from the column names actually present in each, so contexts observing different sample subsets are recorded rather than assumed away.

Usage

QtlDataset(
  study,
  genotypes,
  phenotypes,
  genotypeCovariates = matrix(numeric(0), nrow = 0, ncol = 0),
  scaleResiduals = TRUE,
  mafCutoff = 0,
  macCutoff = 0,
  xvarCutoff = 0,
  imissCutoff = 0,
  keepSamples = character(0),
  keepVariants = character(0),
  keepIndel = TRUE
)

Arguments

study

Character (length 1). Study identifier.

genotypes

A genotype panel (see readGenotypes).

phenotypes

Named list of SummarizedExperiment objects, keyed by context. Each SE must have rowRanges carrying trait positions and colData carrying per-context phenotype covariates. The name "genotype" is reserved.

genotypeCovariates

Numeric matrix of genotype-derived covariates (e.g., ancestry PCs); rows are samples. Becomes the colData of the genotype experiment.

scaleResiduals

Logical (length 1). Default TRUE.

mafCutoff

Numeric (length 1). Minor allele frequency threshold; variants with MAF < mafCutoff are dropped at extraction time inside getGenotypes() / getResidualizedGenotypes(). Default 0 (no filter).

macCutoff

Numeric (length 1). Minor allele count threshold; converted to a MAF threshold using max(mafCutoff, macCutoff / (2 * n)) where n is the post-narrowing sample count of the extracted block. Default 0 (no filter).

xvarCutoff

Numeric (length 1). Per-variant genotype variance threshold; variants with column variance below this are dropped at extraction time. Default 0 (no filter).

imissCutoff

Numeric (length 1). Per-sample genotype-missingness threshold; samples with a missing-genotype rate above this are dropped at extraction time. Default 0 (no filter).

keepSamples

Character vector of sample identifiers to retain. The dataset is subset to them, narrowing colData and sampleMap together, so the sample set has one home rather than two. Length 0 means no restriction.

keepVariants

Character vector of variant identifiers to retain prior to per-block QC. Length 0 means no restriction.

keepIndel

Logical (length 1). When FALSE, variants whose alleles are not single nucleotides (indels) are dropped at extraction. Default TRUE (keep all variants).

Value

A QtlDataset object.

Examples

panel <- readGenotypes(
  system.file("extdata", "toy_ref.bed", package = "pecotmr")
)
rng <- GenomicRanges::GRanges(
  "chr22", IRanges::IRanges(14600000L, width = 1000L)
)
names(rng) <- "ENSG1"
se <- SummarizedExperiment::SummarizedExperiment(
  assays = list(expression = matrix(
    rnorm(ncol(panel)), 1,
    dimnames = list("ENSG1", colnames(panel))
  )),
  rowRanges = rng
)
QtlDataset(study = "s1", genotypes = panel, phenotypes = list(brain = se))
#> QtlDataset for study 's1'
#>   1 context(s): brain
#>   1 unique traits across contexts
#>   Genotypes: plink1 @ /tmp/RtmppU8QTb/temp_libpath984aa04109/pecotmr/extdata/toy_ref
#>   Genotype covariates: 0 cols
#>   Samples: 165
#>   Scale residuals: TRUE