Skip to content

Commit

Permalink
Merge pull request #1134 from dondi/maika-1068
Browse files Browse the repository at this point in the history
#1068 Allow node coloring for PPI by matching the gene name (MERGE #1080 first)
  • Loading branch information
dondi authored Nov 4, 2024
2 parents 9b24710 + 5f1ab4e commit f978dbb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions server/dals/expression-dal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var sequelize = new Sequelize(
const buildExpressionGenesQuery = function (geneString) {
let genes = "";
let geneList = geneString.split(",");
geneList.forEach(x => genes += ( `(gene_expression.gene.display_gene_id =\'${x}\') OR `));
geneList.forEach(x => genes += ( `(LOWER(gene_expression.gene.display_gene_id) = LOWER(\'${x}\')) OR `));
return genes.substring(0, genes.length - 4);
};

Expand Down Expand Up @@ -62,7 +62,7 @@ const buildExpressionQuery = function (query) {
const listExpressionGeneData = function (gene, totalOutput) {
let listOfData = [];
totalOutput.forEach(function (x) {
if (x.display_gene_id === gene) {
if (x.display_gene_id.toLowerCase() === gene.toLowerCase()) {
listOfData.push(Number(x.expression));
}
});
Expand Down
12 changes: 9 additions & 3 deletions web-client/public/js/graph.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Grid from "d3-v4-grid";
import { grnState } from "./grnstate";
import { modifyChargeParameter, modifyLinkDistanceParameter, valueValidator } from "./update-app";
import {
modifyChargeParameter,
modifyLinkDistanceParameter,
valueValidator,
adjustGeneNameForExpression,
} from "./update-app";
import {
ENDS_IN_EXPRESSION_REGEXP,
VIEWPORT_FIT,
Expand Down Expand Up @@ -1086,11 +1091,12 @@ export var drawGraph = function (workbook) {
.selectAll(".coloring")
.data(function () {
if (grnState.workbook.expression[dataset]) {
const geneName = adjustGeneNameForExpression(p);
if (
grnState.workbook.expression[dataset].data[p.name]
grnState.workbook.expression[dataset].data[geneName]
) {
const result = getExpressionData(
p.name,
geneName,
dataset,
average
);
Expand Down
14 changes: 12 additions & 2 deletions web-client/public/js/update-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,14 @@ const enableNodeColoringUI = function () {
$(LOG_FOLD_CHANGE_MAX_VALUE_HEADER).removeClass("hidden");
};

const adjustGeneNameForExpression = function (gene) {
const geneName = gene.name;
return grnState.workbook.meta.data.workbookType === NETWORK_PPI_MODE &&
geneName.endsWith("p")
? geneName.slice(0, -1)
: geneName;
};

const loadExpressionDatabase = function (isTopDataset) {
const dataset = isTopDataset ? grnState.nodeColoring.topDataset : grnState.nodeColoring.bottomDataset;
startLoadingIcon();
Expand All @@ -394,7 +402,9 @@ const loadExpressionDatabase = function (isTopDataset) {
queryExpressionDatabase({
type:"ExpressionData",
dataset,
genes : grnState.workbook.genes.map(gene => {return gene.name;}).join(","),
genes: grnState.workbook.genes
.map(adjustGeneNameForExpression)
.join(","),
timepoints: timepointsResponse[dataset]
}).then(function (response) {
if (isTopDataset) {
Expand Down Expand Up @@ -1027,4 +1037,4 @@ export const updateApp = grnState => {
};


export { stopLoadingIcon, startLoadingIcon};
export { stopLoadingIcon, startLoadingIcon, adjustGeneNameForExpression};

0 comments on commit f978dbb

Please sign in to comment.