Skip to content

Commit

Permalink
Merge pull request #501 from KPMP/KPMP-5219_update_SNRNASeq_table_logic
Browse files Browse the repository at this point in the history
KPMP-5219: update table logic for DMR & SN table
  • Loading branch information
rlreamy authored Mar 18, 2024
2 parents 34e91fd + 44901d2 commit d990a8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/components/ExpressionTables/ExpressionXCellType.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class ExpressionXCellType extends Component {
clusterAbbrev: cluster,
clusterName: clusterName,
cellCount: cellCount ? cellCount : 0,
meanExp: formatNumberToPrecision(avgExp, 3),
pctCellsExpressing: formatNumberToPrecision(pct1Value, 3),
foldChange: formatNumberToPrecision(foldChange, 3),
pVal: formatNumberToPrecision(pVal, 3),
pValAdj: formatNumberToPrecision(pValAdj, 3)
meanExp: formatNumberToPrecision(avgExp, 3, false, this.props.dataType, this.props.tissueType),
pctCellsExpressing: formatNumberToPrecision(pct1Value, 3, false, this.props.dataType, this.props.tissueType),
foldChange: formatNumberToPrecision(foldChange, 3, false, this.props.dataType, this.props.tissueType),
pVal: formatNumberToPrecision(pVal, 3, false, this.props.dataType, this.props.tissueType),
pValAdj: formatNumberToPrecision(pValAdj, 3, false, this.props.dataType, this.props.tissueType)
}
});
};
Expand Down Expand Up @@ -85,14 +85,14 @@ class ExpressionXCellType extends Component {
Averaged expression values (logarithmic) for each cell cluster
</UncontrolledTooltip></span>,
name: 'avgExp',
getCellValue: row => formatNumberToPrecision(row.avgExp, 3)
getCellValue: row => formatNumberToPrecision(row.avgExp, 3, false, this.props.dataType, this.props.tissueType)
},
{
title: <span>% CELLS<br />EXPRESSING</span>,
name: 'pct1',
getCellValue: row => {
let newValue = (row.pct1 > 0) ? (row.pct1 * 100) : row.pct1;
return formatNumberToPrecision(newValue, 3);
return formatNumberToPrecision(newValue, 3, false, this.props.dataType, this.props.tissueType);
}
},
{
Expand All @@ -101,23 +101,23 @@ class ExpressionXCellType extends Component {
Log fold-change of the average expression between this cell cluster and all others. Positive values indicate that the feature is more highly expressed in this cell cluster.
</UncontrolledTooltip></span>,
name: 'foldChange',
getCellValue: row => formatNumberToPrecision(row.foldChange, 3)
getCellValue: row => formatNumberToPrecision(row.foldChange, 3, false, this.props.dataType, this.props.tissueType)
},
{
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 (unadjusted)
</UncontrolledTooltip></span>,
name: 'pVal',
getCellValue: row => formatNumberToPrecision(row.pVal, 3)
getCellValue: row => formatNumberToPrecision(row.pVal, 3, false, this.props.dataType, this.props.tissueType)
},
{
title: <span>ADJ<br />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>,
name: 'pValAdj',
getCellValue: row => formatNumberToPrecision(row.pValAdj, 3)
getCellValue: row => formatNumberToPrecision(row.pValAdj, 3, false, this.props.dataType, this.props.tissueType)
}
]
};
Expand Down Expand Up @@ -189,7 +189,7 @@ class ExpressionXCellType extends Component {
<Row xs='12' className='mt-5'>
<Col xs='11'>
<h5><span>{this.props.gene}</span> Expression Comparison across Cell Clusters in {formatTissueType(this.props.tissueType)}</h5>
<h6>NS = Not Significant</h6>
<h6>NS = Not Significant { (this.props.dataType === "sn" && this.props.tissueType === "dmr") && "| - = Not Calculated" }</h6>
</Col>
<Col xs='1' className='text-end'>
<CSVLink
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/Utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { fetchDataTypesForConcept } from './ApolloClient';

export const formatNumberToPrecision = (number, precision, keepAsInt = false) => {
export const formatNumberToPrecision = (number, precision, keepAsInt = false, dataType = "", tissueType = "") => {
if (number) {
return number.toPrecision(precision)
} else if (number === 0) {
return 0
} else {
if (dataType === "sn" && tissueType === "dmr") {
return "-"
}
return "NS"
}
};
Expand Down

0 comments on commit d990a8f

Please sign in to comment.