propagate diffexp state through component tree (#2135)

This commit is contained in:
Bruce Martin
2021-03-31 12:23:38 -07:00
committed by GitHub
parent ae30b66123
commit 2fa19c756c
4 changed files with 58 additions and 27 deletions
@@ -452,6 +452,7 @@ class HistogramBrush extends React.PureComponent {
{!mini ? ( {!mini ? (
<HistogramFooter <HistogramFooter
isObs={isObs} isObs={isObs}
isDiffExp={isDiffExp}
displayName={field} displayName={field}
hideRanges={asyncProps.isSingleValue} hideRanges={asyncProps.isSingleValue}
rangeMin={asyncProps.unclippedRange[0]} rangeMin={asyncProps.unclippedRange[0]}
+20 -4
View File
@@ -62,7 +62,9 @@ class Gene extends React.Component {
isColorAccessor, isColorAccessor,
isScatterplotXXaccessor, isScatterplotXXaccessor,
isScatterplotYYaccessor, isScatterplotYYaccessor,
isDiffexp, isDiffExp,
pvalAdj,
logFoldChange,
} = this.props; } = this.props;
const { geneIsExpanded } = this.state; const { geneIsExpanded } = this.state;
const genesetNameLengthVisible = 310; /* this magic number determines how much of a long geneset name we see */ const genesetNameLengthVisible = 310; /* this magic number determines how much of a long geneset name we see */
@@ -114,11 +116,15 @@ class Gene extends React.Component {
</Truncate> </Truncate>
</div> </div>
{!geneIsExpanded ? ( {!geneIsExpanded ? (
<HistogramBrush isUserDefined field={gene} mini /> isDiffExp ? (
<HistogramBrush isDiffExp field={gene} mini />
) : (
<HistogramBrush isUserDefined field={gene} mini />
)
) : null} ) : null}
</div> </div>
<div style={{ flexShrink: 0, marginLeft: 2 }}> <div style={{ flexShrink: 0, marginLeft: 2 }}>
{!isDiffexp ? ( {!isDiffExp ? (
<AnchorButton <AnchorButton
minimal minimal
small small
@@ -174,7 +180,17 @@ class Gene extends React.Component {
/> />
</div> </div>
</div> </div>
{geneIsExpanded ? <HistogramBrush isUserDefined field={gene} /> : null} {geneIsExpanded &&
(isDiffExp ? (
<HistogramBrush
isDiffExp
field={gene}
pvalAdj={pvalAdj}
logFoldChange={logFoldChange}
/>
) : (
<HistogramBrush isUserDefined field={gene} />
))}
</div> </div>
); );
} }
+29 -12
View File
@@ -1,5 +1,4 @@
import React from "react"; import React from "react";
import _ from "lodash";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { Tooltip, Position, Switch } from "@blueprintjs/core"; import { Tooltip, Position, Switch } from "@blueprintjs/core";
import { FaChevronRight, FaChevronDown } from "react-icons/fa"; import { FaChevronRight, FaChevronDown } from "react-icons/fa";
@@ -85,8 +84,35 @@ class GeneSet extends React.Component {
this.setState({ toggleSummaryHisto: !toggleSummaryHisto }); this.setState({ toggleSummaryHisto: !toggleSummaryHisto });
}; };
renderGenes() {
const { setName, setGenes, isDiffExp, diffExp } = this.props;
if (isDiffExp) {
// [ [gene, logfoldchange, pval, pval_adj], ...]
return setGenes.map((gene, idx) => {
const logFoldChange = diffExp[idx][1];
const pvalAdj = diffExp[idx][3];
return (
<Gene
key={gene}
gene={gene}
geneset={setName}
isDiffExp
logFoldChange={logFoldChange}
pvalAdj={pvalAdj}
/>
);
});
}
// otherwise...
return setGenes.map((gene) => {
return <Gene key={gene} gene={gene} geneset={setName} />;
});
}
render() { render() {
const { setName, setGenes, isDiffexp } = this.props; const { setName, setGenes } = this.props;
const { isOpen, toggleSummaryHisto } = this.state; const { isOpen, toggleSummaryHisto } = this.state;
const genesetNameLengthVisible = 120; /* this magic number determines how much of a long geneset name we see */ const genesetNameLengthVisible = 120; /* this magic number determines how much of a long geneset name we see */
return ( return (
@@ -166,16 +192,7 @@ class GeneSet extends React.Component {
{isOpen && {isOpen &&
(!toggleSummaryHisto (!toggleSummaryHisto
? _.map(setGenes, (gene) => { ? this.renderGenes()
return (
<Gene
key={gene}
gene={gene}
geneset={setName}
isDiffexp={isDiffexp}
/>
);
})
: setGenes.length > 0 && ( : setGenes.length > 0 && (
<HistogramBrush <HistogramBrush
isGeneSetSummary isGeneSetSummary
+8 -11
View File
@@ -31,23 +31,20 @@ class GeneExpression extends React.Component {
renderDiffexpGeneSets = () => { renderDiffexpGeneSets = () => {
const { differential } = this.props; const { differential } = this.props;
const { diffExp } = differential;
if (!diffExp) return null;
const setGenes = []; // [ [gene, logfoldchange, pval, pval_adj], ...]
const setGenes = diffExp.map((diffExpGene) => diffExpGene[0]);
if (differential.diffExp) { return (
differential.diffExp.forEach((diffexpGene) => {
setGenes.push(diffexpGene[0]);
});
}
return differential.diffExp ? (
<GeneSet <GeneSet
key="Temp DiffExp Set" key="Temp DiffExp Set"
setGenes={setGenes} setGenes={setGenes}
isDiffexp isDiffExp
diffExp={diffExp}
setName="Temp DiffExp Set" setName="Temp DiffExp Set"
/> />
) : null; );
}; };
handleActivateCreateGenesetMode = () => { handleActivateCreateGenesetMode = () => {