Description Usage Arguments Author(s) Examples
Function for estimating broad-sense heritability.
1 |
data |
|
snp.name |
|
trait.name |
|
covars |
Marcin Kierczak, Xia Shen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (data, snp.name, trait.name, covars = "")
{
snp.num <- which(snpnames(data) == snp.name)
gtypes <- as.factor(as.character(data@gtdata[, snp.num]))
phtypes <- data@phdata[, trait.name]
if (covars[1] == "") {
covars <- c("1")
dat <- data.frame(pheno = phtypes, geno = gtypes)
}
else {
dat <- data.frame(pheno = phtypes, geno = gtypes, data@phdata[,
covars])
names(dat) <- c("pheno", "geno", covars)
}
names.kept <- covars
lm.form <- paste("pheno ~ ", paste(names.kept, collapse = "+"),
sep = "")
lm.obj <- lm(lm.form, data = dat)
r2.1 <- summary(lm.obj)$r.squared
names.kept <- c("geno", covars)
lm.form <- paste("pheno ~ ", paste(names.kept, collapse = "+"),
sep = "")
lm.obj <- lm(lm.form, data = dat)
r2.2 <- summary(lm.obj)$r.squared
H2 <- abs(r2.2 - r2.1)
H2
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.