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(
  studyName,
  genotypes,
  phenotypes,
  genotypeCovariates = matrix(numeric(0), nrow = 0, ncol = 0),
  scaleResiduals = TRUE,
  genotypeFilterParam = GenotypeFilterParam()
)

Arguments

studyName

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.

genotypeFilterParam

Which variants and samples to keep, built with GenotypeFilterParam. A bare list is refused, since it cannot be checked. Each field is recorded on the object and applied lazily, at extraction time inside genotypes() / residualizedGenotypes():

  • mafCutoff — drop variants with MAF < mafCutoff. Unset means 0 (no filter).

  • macCutoff — a minor-allele-count threshold, converted to a MAF threshold as max(mafCutoff, macCutoff / (2 * n)) with n the post-narrowing sample count of the extracted block. Unset means 0.

  • xvarCutoff — drop variants whose column variance is below this. Unset means 0.

  • imissCutoff — drop samples whose missing-genotype rate exceeds this. Unset means 0.

  • keepSamples — subset the dataset to these samples, narrowing colData and sampleMap together so the sample set has one home rather than two. Unset, or character(0), means no restriction.

  • keepVariants — retain only these variants, before per-block QC. Unset, or character(0), means no restriction.

  • keepIndel — when FALSE, drop variants whose alleles are not single nucleotides. Unset means TRUE.

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(
    studyName = "s1", genotypes = panel, phenotypes = list(brain = se)
)
#> QtlDataset for study 's1'
#>   1 context(s): brain
#>   1 unique traits across contexts
#>   Genotypes: plink1 @ /tmp/RtmpmBLZhq/temp_libpathaae388f3498/pecotmr/extdata/toy_ref
#>   Genotype covariates: 0 cols
#>   Samples: 165
#>   Scale residuals: TRUE