Description Usage Arguments Details Value Author(s) References Examples
This function takes functional covariates (xfd
) and response (yfd
) as
input, and returns a list of equivalent multivariate covariates (Xmat
)
and response (y
). Running penalized (or ordinary least square)
regression on y
and Xmat
is equivalent to the corresponding concurrent
functional regression with constant beta.
1 | equiv.regression(yfd, xfd, threshold=0.01)
|
yfd |
A list of functional objects as response variables. |
xfd |
A list of functional objects as covariates. |
threshold |
Any eigenvalue that explains less than this proportion of total variance will be discarded. Default to 0.01 (one percent of total variance). |
Technical details of this transformation is documented in Yun Zhang, Juilee Thakar, Xing Qiu (2016).
A list with the following objects
y |
A matrix of dimension KxM, where K is the number of
nontrivial eigenvalues kept in the transformation and M is the
dimension of |
Xmat |
A matrix of dimension KxP, where K is the number of
nontrivial eigenvalues kept in the transformation and P is the
dimension of |
cut.value |
|
Yun Zhang, Juilee Thakar, Xing Qiu
Yun Zhang, Juilee Thakar, Xing Qiu (2016) FUNNEL-GSEA: FUNctioNal ELastic-net Regression in Time-course Gene Set Enrichment Analysis, submitted to Bioinformatics.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | ## library(FUNNEL)
library(fda)
library(quadrupen)
## Let us first create some functional objects
data("H3N2-Subj1")
## Remove genes in predefined gene sets that are not present in X the
## filtered input data
genenames <- rownames(X)
newGenesets <- lapply(genesets, function(z) { intersect(z, genenames) } )
## Standardize time and X so that the smoothing penality is applicable
## to any real data with comparable signal-to-noise ratio
tt2 <- (tt - min(tt))/diff(range(tt))
X2 <- t(scale(t(X)))
## Smoothing
mybasis <- create.bspline.basis(range(tt2), length(tt2)+4-2, 4, tt2)
mypar <- fdPar(mybasis, 2, lambda=10^-3.5)
fdexpr <- smooth.basis(tt2, t(X2), mypar)$fd
## Take genes C5AR1 and C3AR1 as two examples
gene.i <- c("C5AR1", "C3AR1")
## They belong to the following two pathways
newGeneset.i <- newGenesets[c("NEUROACTIVE_LIGAND_RECEPTOR_INTERACTION", "COMPLEMENT_AND_COAGULATION_CASCADES")]
## The response is just the smoothed curves of these two genes
yfd <- fdexpr[gene.i]
##############
## Method 1 ##
##############
## Let us use the first 3 eigen-functions of both pathways as covariates
xfd <- FUNNEL:::PCA.genesets(fdexpr, newGeneset.i, nharm = 3, centerfns = FALSE)$harmonics
## Calculate the equivalent multivariate regression datasets
equiv <- equiv.regression(yfd, xfd, threshold = 0.01)
equiv.Y <- equiv$y; colnames(equiv.Y) <- gene.i #3x2 matrix
equiv.X <- equiv$Xmat #3x6 matrix
colnames(equiv.X) <- paste(rep(names(newGeneset.i), each=3), rep(paste0("eigfun", 1:3), length(newGeneset.i)), sep=".")
## Now we can run multivariate elastinet regression on the equivalent X and Y, as
## implemented in package quadrupen
en <- elastic.net(equiv.X, equiv.Y[, "C3AR1"], lambda1 = 0.4, lambda2 = 0.01, intercept = FALSE, normalize = FALSE)
## beta.en are the regression coefficients
beta.en <- as.numeric(attributes(en)$coef)
names(beta.en) <- colnames(equiv.X)
##############
## Method 2 ##
##############
## Alternatively, let us try using the first 2 eigen-functions and increase the variance
## threshold in the equivalence rotated regression to 0.1.
xfd2 <- FUNNEL:::PCA.genesets(fdexpr, newGeneset.i, nharm = 2, centerfns = FALSE)$harmonics
## Calculate the equivalent multivariate regression datasets
equiv2 <- equiv.regression(yfd, xfd2, threshold = 0.1)
equiv2.Y <- equiv2$y; colnames(equiv2.Y) <- gene.i #3x2 matrix
equiv2.X <- equiv2$Xmat #3x6 matrix
colnames(equiv2.X) <- paste(rep(names(newGeneset.i), each=2), rep(paste0("eigfun", 1:2), length(newGeneset.i)), sep=".")
## Now we can run multivariate elastinet regression on the equivalent X and Y, as
## implemented in package quadrupen
en2 <- elastic.net(equiv2.X, equiv2.Y[, "C3AR1"], lambda1 = 0.4, lambda2 = 0.01, intercept = FALSE, normalize = FALSE)
## beta.en are the regression coefficients
beta.en2 <- as.numeric(attributes(en2)$coef)
names(beta.en2) <- colnames(equiv2.X)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.