| computeBs {AffiXcan} | R Documentation |
Fit a linear model to impute a GReX for a certain gene
computeBs(assocRegions, pca, expr, covariates)
assocRegions |
A data.frame with the associations between regulatory regions and one expressed gene, and with colnames = c("REGULATORY_REGION", "EXPRESSED_REGION") |
pca |
The returningObject$pca from affiXcanTrain() |
expr |
A matrix containing the real total expression values, where the columns are genes and the rows are individual IIDs |
covariates |
A data.frame with covariates values for the population structure where the columns are the PCs and the rows are the individual IIDs |
A list containing three objects:
coefficients: An object containing the coefficients of the principal components used in the model, completely similar to the "coefficients" from the results of lm()
pval: The uncorrected anova pvalue of the model, retrieved from anova(model, modelReduced, test="F")$'Pr(>F)'[2]
r.sq: The coefficient of determination between the real total expression values and the imputed GReX, retrived from summary(model)$r.squared
if (interactive()) {
trainingTbaPaths <- system.file("extdata","training.tba.toydata.rds",
package="AffiXcan")
data(exprMatrix)
data(regionAssoc)
data(trainingCovariates)
assay <- "values"
assocRegions <- regionAssoc[regionAssoc$EXPRESSED_REGION==
"ENSG00000256377.1",]
regionsCount <- overlookRegions(trainingTbaPaths)
pca <- affiXcanPca(tbaPaths=trainingTbaPaths, varExplained=80, scale=TRUE,
regionsCount=regionsCount)
expr <- SummarizedExperiment::assays(exprMatrix)[[assay]]
expr <- t(as.data.frame(expr))
bs <- computeBs(assocRegions=assocRegions, pca=pca, expr=expr,
covariates=trainingCovariates)
}