testForStruEff: Testing for random structural effects of sample projections...

View source: R/func__testForStruEff.R

testForStruEffR Documentation

Testing for random structural effects of sample projections on each pattern of allele distributions

Description

This function tests for effects of bacterial subpopulations on each pattern of allele distributions across the whole population. This kind of effects constitutes a part (the group specific effect vg) of random effects of a linear mixed model (the other part is the environmental effect ve). More specifically, it carries out chi-square tests on the vector of structural effects gamma given observations (a pattern y and a relateness matrix K). Since the phylix package aims to identify physically linked bacterial genes, this function only tests for the structural effects of patterns that have been used for linear mixed models in the function findPhysLink.

This function is designed under the assumption that users have run functions findPhysLink and projectSamples.

Dependent package: parallel

Usage

testForStruEff(pat.h0, Y, C, K, L, n.cores = 0)

Arguments

pat.h0

A single data frame or a list of data frames of parameter estimates under null linear mixed models. It expects to take as input a concatenation of elements lmms.pat[["dif"/"idd"]]$h0 in outputs of the function findPhysLink.

Y

A column-wisely zero-centred pattern matrix for all haploid samples. An ideal input is the element alleles[["Y"]] on the output list of findPhysLink.

C

A projection matrix of samples on eigenvectors corresponding to positive eigenvalues. It is expected to be the element C on the output list of the function projectSamples. Sample names (row names) of C must be the same as those of Y (row names) and K (row and column names).

K

A relatedness matrix with row and column names. Importantly, row and column names, that is, sample names, must follow the same order as sample names in the Y matrix. The function findPhysLink ensures this match between samples in both matrices. This matrix can be acquired from the element K in the output of the function projectSamples.

L

The number of biallelic cgSNPs used to perform singular-value decomposition of the SNP matrix. Assuming assoc <- findPhysLink(...), L equals ncol(assoc[["snps"]][["G"]]).

n.cores

Number of computational cores that will be used in parallel for this function. It follows the same convention defined in the function findPhysLink. For simplicity, set it to zero to automatically detect and use all available cores; set it to -1 to leave one core out.

Author(s)

Yu Wan (wanyuac@126.com)

Examples

assoc <- findPhysLink(...)
C <- projectSamples(...)
s <- testForStruEff(pat.h0 = list(assoc[["lmms.pat"]][["dif"]][["h0"]], assoc[["lmms.pat"]][["idd"]][["h0"]]),
Y = assoc[["alleles"]][["Y"]], C = C[["C"]], K = C[["K"]], L = ncol(assoc[["snps"]][["G"]]) n.cores = 8)


wanyuac/GeneMates documentation built on Aug. 12, 2022, 7:37 a.m.