Skip to content

Commit

Permalink
fix alpaca single gene community
Browse files Browse the repository at this point in the history
  • Loading branch information
marouenbg committed Oct 29, 2021
1 parent 5373c00 commit 5515895
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions R/ALPACA.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,22 @@ alpaca <- function(net.table,file.stem,verbose=FALSE)
louv.Bscores <- 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){
if (length(this.tfs)>1){
tf.sums <- apply(dwbm[this.tfs,this.genes],1,sum)
gene.sums <- apply(dwbm[this.tfs,this.genes],2,sum)
if (length(this.genes)==1){
gene.sums <- sum(dwbm[this.tfs,this.genes])
tf.sums <- dwbm[this.tfs,this.genes]
}else if (length(this.genes)>1){
tf.sums <- apply(dwbm[this.tfs,this.genes],1,sum)
gene.sums <- apply(dwbm[this.tfs,this.genes],2,sum)
}
} else if (length(this.tfs)==1) {
tf.sums <- sum(dwbm[this.tfs,this.genes])
gene.sums <- dwbm[this.tfs,this.genes]
} else if (length(this.genes)==1){
gene.sums <- sum(dwbm[this.tfs,this.genes])
tf.sums <- dwbm[this.tfs,this.genes]
}
this.denom <- sum(dwbm[this.tfs,this.genes])
louv.Ascores <- c(louv.Ascores,tf.sums/this.denom)
Expand Down

0 comments on commit 5515895

Please sign in to comment.