Skip to content

Commit

Permalink
Merge 4cd7613 into 7b17419
Browse files Browse the repository at this point in the history
  • Loading branch information
marouenbg authored Feb 18, 2022
2 parents 7b17419 + 4cd7613 commit 5102083
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions R/CRANE.R
Original file line number Diff line number Diff line change
Expand Up @@ -421,23 +421,29 @@ craneUnipartite = function(A,alpha=0.1,isSelfLoop=F){
alpacaComputeDifferentialScoreFromDWBM = function(dwbm,louv.memb){
louv.Ascores <- NULL
louv.Bscores <- NULL
for (i in 1:max(louv.memb)){
louv.Anames <- NULL
louv.Bnames <- NULL
for (i in seq_len(max(louv.memb)))
{
print(i)
this.comm <- names(louv.memb)[louv.memb==i]
this.tfs <- this.comm[grep("_A",this.comm)]
this.genes <- this.comm[grep("_B",this.comm)]
if (length(this.tfs)>1){
tf.sums <- apply(as.matrix(dwbm[this.tfs,this.genes]),1,sum)
gene.sums <- apply(as.matrix(dwbm[this.tfs,this.genes]),2,sum)
} else {
tf.sums <- sum(dwbm[this.tfs,this.genes])
gene.sums <- dwbm[this.tfs,this.genes]
this.tfs <- this.comm[grep("_A$",this.comm)]
this.genes <- this.comm[grep("_B$",this.comm)]
if (length(this.tfs)>0 && length(this.genes)>0)
{
dwbm.submat <- array(dwbm[this.tfs,this.genes],dim=c(length(this.tfs),length(this.genes)))
tf.sums <- apply(dwbm.submat,1,sum)
gene.sums <- apply(dwbm.submat,2,sum)
this.denom <- sum(dwbm[this.tfs,this.genes])
louv.Ascores <- c(louv.Ascores,tf.sums/this.denom)
louv.Bscores <- c(louv.Bscores,gene.sums/this.denom)
louv.Anames <- c(louv.Anames,this.tfs)
louv.Bnames <- c(louv.Bnames,this.genes)
}
this.denom <- sum(dwbm[this.tfs,this.genes])
louv.Ascores <- c(louv.Ascores,tf.sums/this.denom)
louv.Bscores <- c(louv.Bscores,gene.sums/this.denom)
}

louv.scores <- c(louv.Ascores,louv.Bscores)
names(louv.scores) <- c(louv.Anames,louv.Bnames)

return(louv.scores)
}
Expand Down

0 comments on commit 5102083

Please sign in to comment.