Description Usage Arguments Value Examples
Fit a linear model to impute a GReX for a certain gene
1 |
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 |
Optrional; a data.frame with covariates values for the population structure where the columns are the PCs and the rows are the individual IIDs; default is NULL |
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()
p.val: The uncorrected anova pvalue of the model
r.sq: The coefficient of determination between the real total expression values and the imputed GReX, retrived from summary(model)$r.squared
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 33 34 35 36 37 38 39 | if (interactive()) {
data(exprMatrix)
data(trainingCovariates)
data(regionAssoc)
tbaPaths <- system.file("extdata","training.tba.toydata.rds",
package="AffiXcan")
regionsCount <- overlookRegions(tbaPaths)
assay <- "values"
sampleNames <- colnames(exprMatrix)
nSamples <- length(sampleNames)
sampGroups <- subsetKFold(k=5, n=nSamples)
for (i in seq(length(sampGroups))) {
sampGroups[[i]] <- colnames(exprMatrix)[sampGroups[[i]]]
}
testingSamples <- sampGroups[[1]]
trainingSamples <- sampleNames[!sampleNames %in% testingSamples]
pca <- affiXcanPca(tbaPaths=tbaPaths, varExplained=80, scale=TRUE,
regionsCount=regionsCount, trainingSamples=trainingSamples)
cov <- trainingCovariates
cov <- cov[rownames(cov) %in% trainingSamples,]
expr <- SummarizedExperiment::assays(exprMatrix)[[assay]]
expr <- expr[,colnames(expr) %in% trainingSamples]
expr <- t(as.data.frame(expr))
expressedRegions <- as.vector(unique(regionAssoc$EXPRESSED_REGION))
assocList <- BiocParallel::bplapply(X=expressedRegions, FUN=assoc2list,
regionAssoc)
names(assocList) <- expressedRegions
assocRegions <- assocList[[1]]
bs <- computeBs(assocRegions=assocRegions, pca=pca, expr=expr,
covariates=cov)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.