Skip to contents

Slices the bhat, sbhat, and Z matrices by row (SNPs) and column (samples/conditions), and correspondingly subsets the vhat covariance matrix.

Usage

sliceMashData(data, vhat, snps, samples)

Arguments

data

A mash data list with elements bhat, sbhat, Z (matrices), and snp (character vector).

vhat

A square covariance matrix (conditions x conditions).

snps

Character vector of SNP IDs to retain (row names).

samples

Character vector of condition names to retain (column names).

Value

A list with data (sliced data list) and vhat (sliced covariance matrix).

Examples

cond <- c("brain", "blood", "muscle")
p <- 8
bhat <- matrix(rnorm(p * 3), p, 3,
  dimnames = list(sprintf("chr1:%d:A:G", 100L * (1:p)), cond))
sbhat <- matrix(abs(rnorm(p * 3)) + 0.1, p, 3,
  dimnames = list(sprintf("chr1:%d:A:G", 100L * (1:p)), cond))
dat <- list(bhat = bhat, sbhat = sbhat, Z = bhat / sbhat,
  snp = sprintf("chr1:%d:A:G", 100L * (1:p)))
vhat <- diag(3)
dimnames(vhat) <- list(cond, cond)
sliceMashData(dat, vhat = vhat, snps = 1:4, samples = NULL)
#> $data
#> $data$bhat
#>             
#> chr1:100:A:G
#> chr1:200:A:G
#> chr1:300:A:G
#> chr1:400:A:G
#> 
#> $data$sbhat
#>             
#> chr1:100:A:G
#> chr1:200:A:G
#> chr1:300:A:G
#> chr1:400:A:G
#> 
#> $data$Z
#>             
#> chr1:100:A:G
#> chr1:200:A:G
#> chr1:300:A:G
#> chr1:400:A:G
#> 
#> $data$snp
#> character(0)
#> 
#> 
#> $vhat
#> <0 x 0 matrix>
#>