Skip to content

Commit

Permalink
Merge pull request #458 from KPMP/KPMP-4954_RP_Diffex
Browse files Browse the repository at this point in the history
Kpmp 4954 rp diffex
  • Loading branch information
rlreamy authored Dec 18, 2023
2 parents 65d57fc + 0c86cfb commit a41ebdb
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 58 deletions.
136 changes: 78 additions & 58 deletions src/components/ExpressionTables/DiffexByCluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -26,6 +26,16 @@ 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)
}
);
} else if (this.props.dataType === 'rp') {
fetchRegionalProteomicsByStructure(this.props.cluster).then(
(geneExpressionData) => {
this.setState({ diffexData: geneExpressionData, isLoading: false })
},
Expand Down Expand Up @@ -58,72 +68,82 @@ class DiffexByCluster extends Component {
return <button onClick={() => this.handleClick(gene)} type='button' className='table-column btn btn-link text-start p-0'>{gene}</button>
};

getColumns = () => [
{
title: 'GENE',
field: 'gene',
align: 'left',
width: "15%",
headerStyle: { fontSize: "11px" },
cellStyle: { fontSize: '14px', padding: "2px" },
render: rowData => this.getGeneLink(rowData.gene)
},
{
title: <span>FOLD CHANGE <span className="icon-info"><FontAwesomeIcon className='kpmp-light-blue' id='fold-change-info' icon={faInfoCircle} /></span>
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: <span>FOLD CHANGE <span className="icon-info"><FontAwesomeIcon className='kpmp-light-blue' id='fold-change-info' icon={faInfoCircle} /></span>
<UncontrolledTooltip placement='bottom' target='fold-change-info' >
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.
</UncontrolledTooltip></span>,
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: <span>P VALUE <span className="icon-info"><FontAwesomeIcon className='kpmp-light-blue' id='pvalue-info' icon={faInfoCircle} /></span>
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: <span>P VALUE <span className="icon-info"><FontAwesomeIcon className='kpmp-light-blue' id='pvalue-info' icon={faInfoCircle} /></span>
<UncontrolledTooltip placement='bottom' target='pvalue-info' >
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.
</UncontrolledTooltip></span>,
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: <span>ADJ P VALUE <span className="icon-info"><FontAwesomeIcon id='pvalue-adj-info' className='kpmp-light-blue' icon={faInfoCircle} /></span>
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: <span>ADJ P VALUE <span className="icon-info"><FontAwesomeIcon id='pvalue-adj-info' className='kpmp-light-blue' icon={faInfoCircle} /></span>
<UncontrolledTooltip placement='bottom' target='pvalue-adj-info' >
Adjusted p-value, based on bonferroni correction using all features in the dataset.
</UncontrolledTooltip></span>,
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);
Expand Down
2 changes: 2 additions & 0 deletions src/components/ExpressionTables/DiffexByClusterContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const mapDispatchToProps = (dispatch, props) =>
dispatch(setGene(gene));
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'));
}
Expand Down
33 changes: 33 additions & 0 deletions src/helpers/ApolloClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,39 @@ export const fetchRegionalTranscriptomicsByStructure = async (structure) => {
}
}

export const fetchRegionalProteomicsByStructure = async (structure) => {
let query = gql`
query {
getRPGeneExpressionByStructure(structure: "${structure}") {
id
gene: geneSymbol
fdrConfidence
accession
description
coveragePct
numPeptides
numUniquePeptides
comparison
segment: region
foldChange
pValAdj: adjPVal
tissueType
sampleCount
}
}`;

const response = await apolloClient.query({
query: query,
fetchPolicy: 'cache-first'
});

if (response.data && response.data.getRPGeneExpressionByStructure) {
return response.data.getRPGeneExpressionByStructure;
} else {
store.dispatch(sendMessageToBackend("Could not retrieve regional proteomics data: " + response.error));
}
}

export const fetchSummaryData = async (dataType) => {
let query = gql`
query {
Expand Down

0 comments on commit a41ebdb

Please sign in to comment.