Skip to content

Commit

Permalink
fix cytoscape node color scale
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiaos committed Feb 20, 2019
1 parent 72d666e commit ca2832f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,19 @@ computeNodeDim <- function(maxVal, minVal, val){

# set color: min: blue, middle: white, max: red
computeNodeColor <- function(maxVal, minVal, val){
maxColor <- 1;
minColor <- 0;
# if all positive, map to [0.5, 1]
if(minVal > 0){
maxColor <- 1;
minColor <- 0.5;
} else if(maxVal < 0) { # all negative
maxColor <- 0.5;
minColor <- 0;
} else {
larger = Math.max(maxVal, Math.abs(minVal));
maxVal <- larger;
minVal <- -1.0*larger;
maxColor <- 1;
minColor <- 0;
}
return((val-minVal)/(maxVal-minVal)*(maxColor-minColor)+minColor)
}

0 comments on commit ca2832f

Please sign in to comment.