Skip to content

Commit

Permalink
Merge pull request #20 from NathanSkene/dev-FixMeanCalc
Browse files Browse the repository at this point in the history
I had broken generate.celltype.data while trying to make it run faste…

Former-commit-id: 51e2907
  • Loading branch information
NathanSkene authored Sep 8, 2020
2 parents e3f8f2c + 4e66454 commit eb65c02
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/generate.celltype.data.r
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ generate.celltype.data <- function(exp,annotLevels,groupName,no_cores=1,savePath
}
ctd_oneLevel$mean_exp = as.matrix(expMatrix)
}else{
# Sum reads in each cell type
#mean_exp = apply(expMatrix,1,aggregate.over.celltypes,ctd_oneLevel$annot)
mm <- model.matrix(~ 0 + ctd_oneLevel$annot)
colnames(mm) <- names(table(ctd_oneLevel$annot))
mat.summary.mm1 <- expMatrix %*% mm

# Divide by the number of cells to get the mean
cellCounts = table(ctd_oneLevel$annot)
for(i in 1:dim(mat.summary.mm1)[2]){mat.summary.mm1[,i] = mat.summary.mm1[,i]/cellCounts[i]}

ctd_oneLevel$mean_exp = as.matrix(mat.summary.mm1)
}
return(ctd_oneLevel)
Expand Down

0 comments on commit eb65c02

Please sign in to comment.