Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KPMP-5219: update table logic for DMR & SN table #501

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading