Skip to content

Commit

Permalink
Merge pull request #26 from cafletezbrant/master
Browse files Browse the repository at this point in the history
Fixed the bug from a month ago
  • Loading branch information
jtleek authored Apr 28, 2017
2 parents 605e5c2 + d12b538 commit 7e4aa44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/ComBat.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ComBat <- function (dat, batch, mod = NULL, par.prior = TRUE, prior.plots = FALS
##Standardize Data across genes
cat('Standardizing Data across genes\n')
if (!NAs){
B.hat <- solve(crossprod(design), crossprod(design, as.matrix(dat)))
B.hat <- solve(crossprod(design), tcrossprod(t(design), as.matrix(dat)))
} else {
B.hat <- apply(dat, 1, Beta.NA, design) # FIXME
}
Expand Down Expand Up @@ -152,7 +152,8 @@ ComBat <- function (dat, batch, mod = NULL, par.prior = TRUE, prior.plots = FALS
message("Fitting L/S model and finding priors")
batch.design <- design[, 1:n.batch]
if (!NAs){
gamma.hat <- solve(crossprod(batch.design), crossprod(batch.design, as.matrix(s.data)))
gamma.hat <- solve(crossprod(batch.design), tcrossprod(t(batch.design),
as.matrix(s.data)))
} else{
gamma.hat <- apply(s.data, 1, Beta.NA, batch.design) # FIXME
}
Expand All @@ -168,7 +169,7 @@ ComBat <- function (dat, batch, mod = NULL, par.prior = TRUE, prior.plots = FALS
##Find Priors
gamma.bar <- rowMeans(gamma.hat)
t2 <- rowVars(gamma.hat)
a.prior <- apply(delta.hat, 1, aprior) # FIXME
a.prior <- apply(delta.hat, 1, aprior) # FIXME
b.prior <- apply(delta.hat, 1, bprior) # FIXME

## Plot empirical and parametric priors
Expand Down
2 changes: 2 additions & 0 deletions R/helper.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
library(BiocParallel)

sva.class2Model <- function(classes) {
return(model.matrix(~factor(classes)))
}
Expand Down

0 comments on commit 7e4aa44

Please sign in to comment.