Skip to content

Commit

Permalink
Updated the CHANGELOG (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkerpedjiev authored Feb 26, 2021
1 parent 6dbc68a commit e904f66
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

**v0.2.9**
- New method for log value-scaling

**v0.2.5**
- Add a `selectRows` option to enable filtering and aggregating bars

Expand Down
28 changes: 27 additions & 1 deletion src/scripts/StackedBarTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,20 @@ const StackedBarTrack = (HGC, ...args) => {
const visibleAndFetched = this.visibleAndFetchedTiles();

for (let i = 0; i < visibleAndFetched.length; i++) {
this.updateTile(visibleAndFetched[i]);
const tile = visibleAndFetched[i];
tile.matrix = null;

this.updateTile(tile);
}

for (let i = 0; i < visibleAndFetched.length; i++) {
const tile = visibleAndFetched[i];

this.renderTile(tile);
}

this.rescaleTiles();

this.draw();
}

Expand Down Expand Up @@ -327,6 +337,22 @@ const StackedBarTrack = (HGC, ...args) => {
matrix[j] = singleBar;
}
}

if (this.options.valueScaling === 'log') {
const pseudocount = this.options.pseudocount == undefined ? 1 : this.options.pseudocount;

for (let j = 0; j < shapeY; j++) {
const matrixMod = matrix[j].map(x => x + pseudocount)
const total = matrixMod.reduce((x,y) => x + y, 0)

const logs = matrixMod.map(x => Math.log(x));
const logsTotal = logs.reduce((x,y) => x+y, 0)
const totalLog = Math.log(total);
const proportions = logs.map(x => (x / logsTotal) * totalLog)
matrix[j] = proportions;
}
}

return matrix;
}

Expand Down

0 comments on commit e904f66

Please sign in to comment.