Skip to content

Commit

Permalink
version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sutirtha Chakraborty authored and gaborcsardi committed Mar 12, 2013
1 parent c251540 commit f7562af
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 115 deletions.
17 changes: 9 additions & 8 deletions DESCRIPTION
Expand Up @@ -2,17 +2,18 @@ Package: svapls
Type: Package
Title: Surrogate variable analysis using partial least squares in a
gene expression study.
Version: 1.0
Date: 2012-07-23
Version: 1.1
Date: 2013-03-12
Author: Sutirtha Chakraborty, Somnath Datta and Susmita Datta
Maintainer: Sutirtha Chakraborty <s0chak10@louisville.edu>
Maintainer: Sutirtha Chakraborty <statistuta@gmail.com>
Depends: R (>= 2.0), class, stats, pls
Description: Accurate identification of genes that are truly
differentially expressed over two sample varieties, after
adjusting for hidden subject-specific effects of residual
heterogeneity.
differentially expressed between two varieties of samples,
after adjusting for the hidden subject-specific effects of
residual heterogeneity.
License: GPL-3
Collate: fitModel.R svpls.R hfp.R
Packaged: 2012-09-24 20:28:43 UTC; SUTIRTHA
Packaged: 2013-03-13 02:53:31 UTC; SUTIRTHA
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2012-09-25 17:07:59
Date/Publication: 2013-03-13 17:41:21
22 changes: 10 additions & 12 deletions MD5
@@ -1,13 +1,11 @@
22b427be5ded6e676355ef104798d908 *DESCRIPTION
8020920c147a56242b4276aed68b61e3 *NAMESPACE
a5074d94ccf8cce03a5bc531f91999d0 *R/fitModel.R
43fe41ebb6f2b5302809d25d3a4a5dff *R/hfp.R
8beb2a0dc9346babd370127d7664ef09 *R/svpls.R
ba13a5b0ce37b9c5b4e3445f6d41d508 *data/batch.dat.rda
531531b6d7d614fbfa6400aaa7f5bbee *data/hidden_fac.dat.rda
9856fb023050eadb7ba73ba949fab63f *man/batch.dat.Rd
8372275fad517d8ccfb853d40586b3a7 *man/fitModel.Rd
89a702f4be4052f9c71f79644c669835 *man/hfp.Rd
1e48e886f01b56784ac0cba7dfb64519 *DESCRIPTION
acbef90a3eebe2f8baf23da7175ce99a *NAMESPACE
6239c02ae48508b1eec0f0576d136017 *R/fitModel.R
6eca99de58e84deffcfc480a535a6efa *R/hfp.R
c91129a96eeb7c1d353389d01915ebd2 *R/svpls.R
3175666e8f260fa1044d2cce65af83d1 *data/hidden_fac.dat.rda
3f4818485f3f0081d7384c056ca789e0 *man/fitModel.Rd
4fd4079856d3e29d62847159d5ab416f *man/hfp.Rd
10e23268e511aba52e7436aeaa27de04 *man/hidden_fac.dat.Rd
3b4f5961141ed460346da7ba6936912b *man/svapls-package.Rd
90515ea4941d1a54b1c0fefbdece08c0 *man/svpls.Rd
2fbbc2ae2f861571df414ab5282740f0 *man/svapls-package.Rd
ccc334e123a778cff516d50f2148d039 *man/svpls.Rd
6 changes: 2 additions & 4 deletions NAMESPACE
@@ -1,8 +1,6 @@
importFrom(stats, heatmap)
import(pls)
exportClasses(fitModel, svpls)
exportMethods(print, summary)
export(fitModel, svpls, hfp)
S3method(print, fitModel)
S3method(print, svpls)
S3method(summary, fitModel)
S3method(summary, svpls)

39 changes: 26 additions & 13 deletions R/fitModel.R
@@ -1,5 +1,4 @@
fitModel <-
function(k1,k2,Y,n.surr){
fitModel <- function(k1,k2,Y,n.surr){
Y <- Y[,-1]
G <- nrow(Y)
n <- k1 + k2
Expand All @@ -14,9 +13,9 @@ if (n.surr == 0){

G.hat <- V1.hat <- GV1.hat <- rep(0,G)
for (i in 1:G){
G.hat[i] <- mean(Y[i,]) - mean(Y)
V1.hat[i] <- mean(Y[,1:k1]) - mean(Y)
GV1.hat[i] <- mean(Y[i,1:k1]) - mean(Y[,1:k1])
G.hat[i] <- mean(Y[i,]) - mean(Y)
V1.hat[i] <- mean(Y[,1:k1]) - mean(Y)
GV1.hat[i] <- mean(Y[i,1:k1]) - mean(Y[,1:k1])
}
mu.hat <- mean(Y)
V2.hat <- -(k1/k2)*V1.hat
Expand Down Expand Up @@ -171,12 +170,18 @@ if (n.surr > 0){
if (n.surr == 0) coef <- coef1
if (n.surr != 0) coef <- coef2
class(coef) <- c("fitModel","list","vector")

return(coef)
}

## new summary function S3
summary.fitModel <- function(object, ... ){
summary.fitModel <- function(object){
cat("mu.hat: \n", object$mu.hat, "\n")
cat("G.hat: \n")
print(object$G.hat)
cat("\n")
cat("V.hat: \n")
print(object$V.hat)
cat("\n")
cat("GV.hat: \n")
print(object$GV.hat)
cat("\n")
Expand All @@ -186,6 +191,15 @@ cat("\n")
cat("beta.hat: \n")
print(object$beta.hat)
cat("\n")
cat("GZ1.hat: \n")
print(object$GZ1.hat)
cat("\n")
cat("VZ1.hat: \n")
print(object$VZ1.hat)
cat("\n")
cat("Vhat.GV.hat: \n")
print(object$vhat.gvh)
cat("\n")
cat("MSE: \n")
print(object$MSE)
cat("\n")
Expand All @@ -195,18 +209,17 @@ cat("\n")
}

## new print function S3
print.fitModel <- function(x, ...){
print.fitModel <- function(x){
cat("Estimated coefficients of the surrogate variables: \n")
print(x$beta.hat)
cat("\n")
cat("Estimated Gene-variety interaction effects: \n")
print(x$GV.hat)
cat("\n")
cat("Estimated Mean Squared Error of the fitted model: \n")
print(x$MSE)
cat("\n")
cat("AIC value of the fitted model: \n")
print(x$AIC)
cat("\n")
}




}
2 changes: 1 addition & 1 deletion R/hfp.R
Expand Up @@ -5,6 +5,6 @@ function (obj,gen,ind,Y){
gen.index <- rep(0,num)
for (i in 1:num) gen.index[i] <- which(genes == gen[i])
W_imp <- obj$PLS.imp
if (max(W_imp) != 0) heatmap(t(W_imp[gen.index,ind]),Rowv = NA,Colv = NA,labRow=as.character(ind),labCol=gen,xlab="Genes",ylab="Specified subjects")
if (max(W_imp) != 0) heatmap(t(W_imp[gen.index,ind]),Rowv = NA,Colv = NA,labRow=as.character(ind),labCol=gen,xlab="Specified subjects")
if (max(W_imp) == 0) print("No trace of hidden subject-specific variation is found in the data")
}
36 changes: 15 additions & 21 deletions R/svpls.R
@@ -1,5 +1,4 @@
svpls <-
function(k1,k2,Y,pmax=3,fdr=0.05){
svpls <- function(k1,k2,Y,pmax=3,fdr=0.05){
G <- nrow(Y)
k <- k1 + k2
n <- G*k
Expand All @@ -12,14 +11,14 @@ function(k1,k2,Y,pmax=3,fdr=0.05){
opt_model <- which(model_aic == min(model_aic))

if(opt_model == 1){
beta_hat <- NULL
Y.corr <- PLS.imp <- matrix(0,500,20)
gv_diff <- (1+k1/k2)*model_res[[1]][[4]][,1]
mse <- model_res[[1]][[5]]
aic.opt <- model_res[[1]][[6]]
t <- pval.opt <- rep(0,G)
for (i in 1:G){
t[i] <- gv_diff[i]/sqrt((1-1/G)*(1/k1 + 1/k2)*mse)
beta_hat <- NULL
PLS.imp <- matrix(0,G,k)
gv_diff <- (1+k1/k2)*model_res[[1]][[4]][,1]
mse <- model_res[[1]][[5]]
aic.opt <- model_res[[1]][[6]]
t <- pval.opt <- rep(0,G)
for (i in 1:G){
t[i] <- gv_diff[i]/sqrt((1-1/G)*(1/k1 + 1/k2)*mse)
pval.opt[i] <- 2*(1 - pt(abs(t[i]),n-2*G))
}
p.opt <- sort(pval.opt)
Expand Down Expand Up @@ -52,7 +51,7 @@ if (opt_model != 1){
surr <- rep(0,k)
for (l in 1:(opt_model-1)) surr <- surr + beta_hat[l]*sc[,l]
for (i in 1:G) R[i,] <- surr

GZ.Z <- outer(est_gz1,sc[,1],function(u,v) u*v)

for (i in 1:G){
Expand All @@ -65,7 +64,7 @@ if (opt_model != 1){
t <- pval.opt <- rep(0,G)
for (i in 1:G) {
t[i] <- gv_diff[i]/sqrt(gv.diff_var[i] * mse.opt)
pval.opt[i] <- 2 * (1 - pt(abs(t[i]), n*G - 3*G - pmax))
pval.opt[i] <- 2 * (1 - pt(abs(t[i]), n - 3*G - pmax))
}
p.opt <- sort(pval.opt)
sig <- 0
Expand All @@ -83,13 +82,13 @@ if (opt_model != 1){

Y.corr <- cbind(Y[,1],Y[,-1] - PLS.imp)

res <- list(opt.model=opt_model, PLS.imp=PLS.imp, Y.corr=Y.corr, pvalues.adj=pval.opt, genes = sig_genes.opt, AIC.opt = aic.opt)
res <- list(opt.model=opt_model, PLS.imp=PLS.imp, Y.corr, pvalues.adj=pval.opt, genes = sig_genes.opt, AIC.opt = aic.opt)
class(res) <- c("svpls","list","vector")
return(res)
}

## new summary function S3
summary.svpls <- function(object, ...){
summary.svpls <- function(object){
cat("Optimum model is \n")
print(object$opt_model)
cat("AIC value for the optimal model is \n")
Expand All @@ -105,16 +104,11 @@ print(object$genes)
}

## new print function S3
print.svpls <- function(x, ... ){
print.svpls <- function(x){
cat("The Optimal Model is: \n")
print(x$opt.model)
cat("\n")
cat("The differentially expressed genes are: \n")
print(x$genes)
cat("\n")
}





}
Binary file removed data/batch.dat.rda
Binary file not shown.
Binary file modified data/hidden_fac.dat.rda
Binary file not shown.
24 changes: 0 additions & 24 deletions man/batch.dat.Rd

This file was deleted.

14 changes: 5 additions & 9 deletions man/fitModel.Rd
@@ -1,7 +1,5 @@
\name{fitModel}
\alias{fitModel}
\alias{summary.fitModel}
\alias{print.fitModel}
\title{
Function to fit an ANCOVA model to the log transformed gene expression
data, with a certain specified number of surrogate variables.
Expand Down Expand Up @@ -38,9 +36,6 @@ fitModel(k1, k2, Y, n.surr)
}
}
\value{
\code{fitModel} returns an object of \code{\link{class}} "\code{fitModel}". The object
contains a list of the following components:

\item{mu.hat }{Intercept (general mean effect).}
\item{G.hat }{Main effects of the genes.}
\item{V.hat }{Main effects of the varieties.}
Expand All @@ -57,8 +52,8 @@ contains a list of the following components:
\references{
Sutirtha Chakraborty, Somnath Datta and Susmita Datta. (2012)
Surrogate Variable Analysis Using Partial Least Squares in Gene
Expression Studies. Bioinformatics.
Surrogate Variable Analysis Using Partial Least Squares (SVA-PLS) in Gene Expression Studies. Bioinformatics, 28(6): 799-806.
Martens, H., Naes, T. (1989) Multivariate Calibration. Chicestor:Wiley.
}
Expand All @@ -70,14 +65,15 @@ Sutirtha Chakraborty, Somnath Datta and Susmita Datta.
\code{\link{svpls}}, \code{\link{hfp}}
}
\examples{
data(batch.dat)
data(hidden_fac.dat)
## Fitting an ANCOVA model with 5 surrogate variables
fit <- fitModel(10,10,batch.dat,n.surr = 5)
fit <- fitModel(10,10,hidden_fac.dat,n.surr = 5)
print(fit)
}
\keyword{models}
\keyword{classes}
\keyword{print}
\keyword{methods}
4 changes: 2 additions & 2 deletions man/hfp.Rd
Expand Up @@ -37,8 +37,7 @@ factors in the gene expression data.
}
\references{
Sutirtha Chakraborty, Somnath Datta and Susmita Datta. (2012)
Surrogate Variable Analysis Using Partial Least Squares in Gene
Expression Studies. Bioinformatics.
Surrogate Variable Analysis Using Partial Least Squares (SVA-PLS) in Gene Expression Studies. Bioinformatics, 28(6): 799-806.
}
\author{
Sutirtha Chakraborty, Somnath Datta and Susmita Datta.
Expand All @@ -57,6 +56,7 @@ genes <- c(1,20,55,70,100,150,250,450)
subjects <- c(1,4,7,10,11,15,17,20)

hfp(fit,genes,subjects,hidden_fac.dat)

}

\keyword{print}
16 changes: 7 additions & 9 deletions man/svapls-package.Rd
Expand Up @@ -16,8 +16,8 @@ in a gene expression data.
\tabular{ll}{
Package: \tab svapls\cr
Type: \tab Package\cr
Version: \tab 1.0\cr
Date: \tab 2012-07-23\cr
Version: \tab 1.1\cr
Date: \tab 2013-03-12\cr
License: \tab GPL-3\cr
}
The package can be used to find the genes that are truly differentially expressed
Expand All @@ -35,19 +35,17 @@ specific factors, for any specified set of genes and subjects.
\author{
Sutirtha Chakraborty, Somnath Datta and Susmita Datta.

Maintainer: Sutirtha Chakraborty <s0chak10@louisville.edu>
Maintainer: Sutirtha Chakraborty <statistuta@gmail.com>
}
\references{
Sutirtha Chakraborty, Somnath Datta and Susmita Datta. (2012)
Surrogate Variable Analysis Using Partial Least Squares in Gene
Expression Studies. Bioinformatics.
Sutirtha Chakraborty, Somnath Datta and Susmita Datta. (SVA-PLS) in Gene Expression Studies. Bioinformatics 28(6):799-806.
}

\keyword{package}
\keyword{models}

\examples{
data(batch.dat)
fit <- svpls(10,10,batch.dat,pmax = 5)
data(hidden_fac.dat)
fit <- svpls(10,10,hidden_fac.dat,pmax = 5)
fit$genes
Y.corrected <- fit$Y.corr

Expand Down

0 comments on commit f7562af

Please sign in to comment.