From 1dadbfeba2f9438590f4cba5a6891aeec2a2025c Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 11:53:33 -0500 Subject: [PATCH 1/8] KPMP-4954: RP Diffex in table --- .../ExpressionTables/DiffexByCluster.js | 137 ++++++++++-------- src/helpers/ApolloClient.js | 33 +++++ 2 files changed, 112 insertions(+), 58 deletions(-) diff --git a/src/components/ExpressionTables/DiffexByCluster.js b/src/components/ExpressionTables/DiffexByCluster.js index 54ab6d7c..cd9793ce 100644 --- a/src/components/ExpressionTables/DiffexByCluster.js +++ b/src/components/ExpressionTables/DiffexByCluster.js @@ -2,7 +2,7 @@ import React, { Component } from 'react'; import MaterialTable from 'material-table'; import { Col, Row, Container, Spinner, UncontrolledTooltip } from 'reactstrap'; import { formatNumberToPrecision, formatDataType } from '../../helpers/Utils' -import { fetchGeneExpression, fetchRegionalTranscriptomicsByStructure } from '../../helpers/ApolloClient'; +import { fetchGeneExpression, fetchRegionalTranscriptomicsByStructure, fetchRegionalProteomicsByStructure } from '../../helpers/ApolloClient'; import { CSVLink } from 'react-csv'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faDownload, faInfoCircle } from '@fortawesome/free-solid-svg-icons'; @@ -26,6 +26,17 @@ class DiffexByCluster extends Component { fetchGeneExpression = () => { if (this.props.dataType === 'rt') { fetchRegionalTranscriptomicsByStructure(this.props.cluster).then( + (geneExpressionData) => { + this.setState({diffexData: geneExpressionData, isLoading: false}) + }, + (error) => { + this.setState({diffexData: []}); + console.log('There was a problem getting the data: ' + error) + } + ); + } + if (this.props.dataType === 'rp') { + fetchRegionalProteomicsByStructure(this.props.cluster).then( (geneExpressionData) => { this.setState({ diffexData: geneExpressionData, isLoading: false }) }, @@ -58,72 +69,82 @@ class DiffexByCluster extends Component { return }; - getColumns = () => [ - { - title: 'GENE', - field: 'gene', - align: 'left', - width: "15%", - headerStyle: { fontSize: "11px" }, - cellStyle: { fontSize: '14px', padding: "2px" }, - render: rowData => this.getGeneLink(rowData.gene) - }, - { - title: FOLD CHANGE + getColumns = () => { + let columns = []; + columns.push( + { + title: 'GENE', + field: 'gene', + align: 'left', + width: "15%", + headerStyle: { fontSize: "11px" }, + cellStyle: { fontSize: '14px', padding: "2px" }, + render: rowData => this.getGeneLink(rowData.gene) + }, + { + title: FOLD CHANGE Fold change of a gene is calculated by dividing the average expression of the gene in the segment/cluster of interest by its average expression in all other segments/clusters being compared. , - field: 'foldChange', - align: 'right', - width: "15%", - sorting: true, defaultSort: 'desc', - headerStyle: { fontSize: '15px', textAlign: 'center' }, - cellStyle: { - fontSize: '14px', - padding: '2px', - textAlign: 'center' - }, - type: 'numeric', - render: rowData => formatNumberToPrecision(rowData.foldChange, 3) - }, - { - title: P VALUE + field: 'foldChange', + align: 'right', + width: "15%", + sorting: true, defaultSort: 'desc', + headerStyle: { fontSize: '15px', textAlign: 'center' }, + cellStyle: { + fontSize: '14px', + padding: '2px', + textAlign: 'center' + }, + type: 'numeric', + render: rowData => formatNumberToPrecision(rowData.foldChange, 3) + } + ); + if (this.props.dataType !== 'rp') { + columns.push( + { + title: P VALUE P value was calculated using a Wilcoxon rank sum test between the expression of the gene in the segment/cluster of interest and its expression in all other segments/clusters. , - field: 'pVal', - align: 'right', - width: "15%", - sorting: true, - type: 'numeric', - headerStyle: { fontSize: '15px', textAlign: 'right' }, - cellStyle: { fontSize: '14px', padding: '2px', textAlign: 'right' }, - render: rowData => formatNumberToPrecision(rowData.pVal, 3) - }, - { - title: ADJ P VALUE + field: 'pVal', + align: 'right', + width: "15%", + sorting: true, + type: 'numeric', + headerStyle: { fontSize: '15px', textAlign: 'right' }, + cellStyle: { fontSize: '14px', padding: '2px', textAlign: 'right' }, + render: rowData => formatNumberToPrecision(rowData.pVal, 3) + } + ); + } + columns.push( + { + title: ADJ P VALUE Adjusted p-value, based on bonferroni correction using all features in the dataset. , - field: 'pValAdj', - align: 'right', - width: "15%", - sorting: true, - type: 'numeric', - headerStyle: { fontSize: '15px', textAlign: 'right' }, - cellStyle: { fontSize: '14px', padding: '2px', textAlign: 'right' }, - render: rowData => formatNumberToPrecision(rowData.pValAdj, 3, true) - }, - { - title: 'hidden', - field: 'hidden', - sorting: false, - width: "40%", - className: "diffex-hidden-column", - headerStyle: { fontSize: '15px', textAlign: 'center', color: "rgba(0,0,0,0)" }, - cellStyle: { fontSize: '14px', padding: '2px', textAlign: 'center', color: "rgba(0,0,0,0)" }, - } - ]; + field: 'pValAdj', + align: 'right', + width: "15%", + sorting: true, + type: 'numeric', + headerStyle: { fontSize: '15px', textAlign: 'right' }, + cellStyle: { fontSize: '14px', padding: '2px', textAlign: 'right' }, + render: rowData => formatNumberToPrecision(rowData.pValAdj, 3, true) + }, + { + title: 'hidden', + field: 'hidden', + sorting: false, + width: "40%", + className: "diffex-hidden-column", + headerStyle: { fontSize: '15px', textAlign: 'center', color: "rgba(0,0,0,0)" }, + cellStyle: { fontSize: '14px', padding: '2px', textAlign: 'center', color: "rgba(0,0,0,0)" }, + } + ); + return columns + } handleClick = (gene) => { this.props.setGene({ symbol: gene, name: '' }, this.props.dataType); diff --git a/src/helpers/ApolloClient.js b/src/helpers/ApolloClient.js index ef1c27dd..0fe84786 100644 --- a/src/helpers/ApolloClient.js +++ b/src/helpers/ApolloClient.js @@ -456,6 +456,39 @@ export const fetchRegionalTranscriptomicsByStructure = async (structure) => { } } +export const fetchRegionalProteomicsByStructure = async (structure) => { + let query = gql` + query { + getRPGeneExpressionByStructure(structure: "${structure}") { + id + geneSymbol + fdrConfidence + accession + description + coveragePct + numPeptides + numUniquePeptides + comparison + region: segment + foldChange + adjPVal: pValLog10 + tissueType + sampleCount + } + }`; + + const response = await apolloClient.query({ + query: query, + fetchPolicy: 'cache-first' + }); + + if (response.data && response.data.getRTGeneExpressionByStructure) { + return response.data.getRTGeneExpressionByStructure; + } else { + store.dispatch(sendMessageToBackend("Could not retrieve regional transcriptomics data: " + response.error)); + } +} + export const fetchSummaryData = async (dataType) => { let query = gql` query { From bce6cdcfb9c05f93b76c2188fd323501f46cf44b Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 12:12:47 -0500 Subject: [PATCH 2/8] KPMP-4954: field alias --- src/helpers/ApolloClient.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/ApolloClient.js b/src/helpers/ApolloClient.js index 3b4f39ed..633c50c7 100644 --- a/src/helpers/ApolloClient.js +++ b/src/helpers/ApolloClient.js @@ -470,9 +470,9 @@ export const fetchRegionalProteomicsByStructure = async (structure) => { numPeptides numUniquePeptides comparison - region: segment + segment: region foldChange - adjPVal: pValLog10 + pValLog10: adjPVal tissueType sampleCount } From d5d06e8399be7b60084c3811a7cb4a7a42d703dd Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 12:28:47 -0500 Subject: [PATCH 3/8] KPMP-4954: field alias take 2 --- src/helpers/ApolloClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/ApolloClient.js b/src/helpers/ApolloClient.js index 633c50c7..00ad61da 100644 --- a/src/helpers/ApolloClient.js +++ b/src/helpers/ApolloClient.js @@ -472,7 +472,7 @@ export const fetchRegionalProteomicsByStructure = async (structure) => { comparison segment: region foldChange - pValLog10: adjPVal + pValAdj: adjPVal tissueType sampleCount } From c40b9739c03a3ed676d40e0ef2a6bdac40b98075 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 13:03:11 -0500 Subject: [PATCH 4/8] KPMP-4954: else --- src/components/ExpressionTables/DiffexByCluster.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/ExpressionTables/DiffexByCluster.js b/src/components/ExpressionTables/DiffexByCluster.js index cd9793ce..12a9b6a2 100644 --- a/src/components/ExpressionTables/DiffexByCluster.js +++ b/src/components/ExpressionTables/DiffexByCluster.js @@ -34,8 +34,7 @@ class DiffexByCluster extends Component { console.log('There was a problem getting the data: ' + error) } ); - } - if (this.props.dataType === 'rp') { + } else if (this.props.dataType === 'rp') { fetchRegionalProteomicsByStructure(this.props.cluster).then( (geneExpressionData) => { this.setState({ diffexData: geneExpressionData, isLoading: false }) From 7f5cb153b855bb986e8c5fe6c82044ded4e87487 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 13:22:52 -0500 Subject: [PATCH 5/8] KPMP-4954: never copy/paste! --- src/helpers/ApolloClient.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helpers/ApolloClient.js b/src/helpers/ApolloClient.js index 00ad61da..5c0a1228 100644 --- a/src/helpers/ApolloClient.js +++ b/src/helpers/ApolloClient.js @@ -483,10 +483,10 @@ export const fetchRegionalProteomicsByStructure = async (structure) => { fetchPolicy: 'cache-first' }); - if (response.data && response.data.getRTGeneExpressionByStructure) { - return response.data.getRTGeneExpressionByStructure; + if (response.data && response.data.getRPGeneExpressionByStructure) { + return response.data.getRPGeneExpressionByStructure; } else { - store.dispatch(sendMessageToBackend("Could not retrieve regional transcriptomics data: " + response.error)); + store.dispatch(sendMessageToBackend("Could not retrieve regional proteomics data: " + response.error)); } } From ad92ab20d646f7f8058b9f2b39d966f1776df511 Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 13:33:18 -0500 Subject: [PATCH 6/8] KPMP-4954: another alias --- src/helpers/ApolloClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/ApolloClient.js b/src/helpers/ApolloClient.js index 5c0a1228..0e6d1e5e 100644 --- a/src/helpers/ApolloClient.js +++ b/src/helpers/ApolloClient.js @@ -462,7 +462,7 @@ export const fetchRegionalProteomicsByStructure = async (structure) => { query { getRPGeneExpressionByStructure(structure: "${structure}") { id - geneSymbol + gene: geneSymbol fdrConfidence accession description From 0897470354e16dd5d5be7b5cf2b5b7b22828e6ae Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 13:40:47 -0500 Subject: [PATCH 7/8] KPMP-4954: handle that RP data tyoe --- src/components/ExpressionTables/DiffexByClusterContainer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ExpressionTables/DiffexByClusterContainer.js b/src/components/ExpressionTables/DiffexByClusterContainer.js index 5481a616..ab06d8d9 100644 --- a/src/components/ExpressionTables/DiffexByClusterContainer.js +++ b/src/components/ExpressionTables/DiffexByClusterContainer.js @@ -15,7 +15,7 @@ const mapDispatchToProps = (dispatch, props) => ({ setGene(gene, dataType) { dispatch(setGene(gene)); - if (dataType === 'rt') { + if (dataType === 'rt' || dataType === 'rp') { dispatch((dispatch) => window.open("/explorer/regionalviz", '_self')); } else { dispatch((dispatch) => window.open("/explorer/dataviz", '_self')); From 0c86cfbfcdc2d9ba358f901bc62dc81d9f693b8b Mon Sep 17 00:00:00 2001 From: Zach Wright Date: Mon, 18 Dec 2023 13:45:34 -0500 Subject: [PATCH 8/8] KPMP-4954: it's a different page, actually --- src/components/ExpressionTables/DiffexByClusterContainer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ExpressionTables/DiffexByClusterContainer.js b/src/components/ExpressionTables/DiffexByClusterContainer.js index ab06d8d9..1c8f4b8e 100644 --- a/src/components/ExpressionTables/DiffexByClusterContainer.js +++ b/src/components/ExpressionTables/DiffexByClusterContainer.js @@ -15,8 +15,10 @@ const mapDispatchToProps = (dispatch, props) => ({ setGene(gene, dataType) { dispatch(setGene(gene)); - if (dataType === 'rt' || dataType === 'rp') { + if (dataType === 'rt') { dispatch((dispatch) => window.open("/explorer/regionalviz", '_self')); + } else if (dataType === 'rp') { + dispatch((dispatch) => window.open("/explorer/regionalpro", '_self')); } else { dispatch((dispatch) => window.open("/explorer/dataviz", '_self')); }