Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e97820a
Emit an event to transfer legend value to state
lingyun1010 Mar 12, 2019
74c965e
Create a new component for receiving emit event
lingyun1010 Mar 12, 2019
09c814b
Filter clustered json payload by props
lingyun1010 Mar 12, 2019
42b21f0
Change the endpoint for gene expression and use ..
lingyun1010 Mar 12, 2019
5543a84
Update package with react-emit
lingyun1010 Mar 12, 2019
fb77a4a
Fix code style and change example experiment
lingyun1010 Mar 12, 2019
ac96f83
Add a stateful wrapper for gene expression plot
lingyun1010 Mar 14, 2019
ff55a59
Add an eventEmiter
lingyun1010 Mar 14, 2019
4cffce7
Emit an event by clicking legend in cluster tsne
lingyun1010 Mar 14, 2019
522b30b
Filter the gene expression series data to sync with cluster
lingyun1010 Mar 14, 2019
9132554
Remove react-emit package
lingyun1010 Mar 14, 2019
eb781f3
Add propType for gene expression wrapper component
lingyun1010 Mar 14, 2019
dc8a170
Fix config of babel to enable test
lingyun1010 Mar 14, 2019
1549144
Add cluster props in gene expression plot test
lingyun1010 Mar 14, 2019
6c5b2ef
Add a test for gene expression wrapper
lingyun1010 Mar 14, 2019
b9355ed
Update snapshots
lingyun1010 Mar 14, 2019
2d8f93f
Delete gene expression wrapper files and tests
lingyun1010 Mar 15, 2019
93c199d
Emit an event with legend name and visibility
lingyun1010 Mar 15, 2019
d04ef2d
Pass eventEmiiter from gene expression to scatter
lingyun1010 Mar 15, 2019
2b976e5
Pass eventEmitter to highchart
lingyun1010 Mar 15, 2019
3ec508a
Listen on eventEmitter and toggle series visible
lingyun1010 Mar 15, 2019
fd3afc0
Refactor code with gene expression plot not wrapper
lingyun1010 Mar 15, 2019
73a32e3
Add a reference for geneId example
lingyun1010 Mar 15, 2019
87739b4
Reformat props
lingyun1010 Mar 29, 2019
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
11 changes: 10 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
"presets": [
"@babel/preset-react",
[
"@babel/preset-env", {
"targets": {
"node": "current"
}
}
]
]
}
29 changes: 15 additions & 14 deletions __test__/GeneExpressionTSnePlot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import renderer from 'react-test-renderer'
import Color from 'color'

import Enzyme from 'enzyme'
import {mount} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

import {_colourizeExpressionLevel} from '../src/GeneExpressionTSnePlot'
Expand All @@ -13,27 +12,27 @@ import '../src/util/MathRound'
import {gradientColourRanges, randomHighchartsSeries, randomHighchartsSeriesWithNamesAndMaxPoints, plotData, randomHighchartsSeriesWithSeed} from './Utils'

Enzyme.configure({ adapter: new Adapter() })
const cluster = `Maximum overkill`

describe(`GeneExpressionTSnePlot colourize function`, () => {

test(`must not change the number of series`, () => {
const seriesNames = [`0`, `1`, `2`, `3`, `4`]
const maxPointsPerSeries = 1000
const randomSeries = randomHighchartsSeriesWithNamesAndMaxPoints(seriesNames, maxPointsPerSeries)
expect(_colourizeExpressionLevel(gradientColourRanges(), [])(plotData(randomSeries))).toHaveLength(seriesNames.length)
expect(_colourizeExpressionLevel(gradientColourRanges(), [], cluster)(plotData(randomSeries))).toHaveLength(seriesNames.length)
})

test(`must not change the number of points in each series`, () => {
const randomSeries = randomHighchartsSeries()
_colourizeExpressionLevel(gradientColourRanges(), [])(plotData(randomSeries)).forEach((series, i) => {
_colourizeExpressionLevel(gradientColourRanges(), [], cluster)(plotData(randomSeries)).forEach((series, i) => {
expect(series.data).toHaveLength(randomSeries[i].data.length)
})
})

test(`adds a color field to all points`, () => {
const randomSeries = randomHighchartsSeries()

_colourizeExpressionLevel(gradientColourRanges(), [])(plotData(randomSeries)).forEach((series) => {
_colourizeExpressionLevel(gradientColourRanges(), [], cluster)(plotData(randomSeries)).forEach((series) => {
series.data.forEach((point) => {
expect(point).toHaveProperty(`colorValue`)
})
Expand All @@ -42,18 +41,18 @@ describe(`GeneExpressionTSnePlot colourize function`, () => {

test(`assigns maximum colour scale to the point with highest expression`, () => {
const randomSeries = randomHighchartsSeries()
const maximum = 10000;
const maximum = 10000
randomSeries[randomSeries.length - 1].data.push({
x: 0,
y: 0,
expressionLevel: maximum,
name: "Maximum overkill"
name: cluster
})

const allPoints = randomSeries.reduce((acc, series) => acc.concat(series.data), [])
const maxExpressionLevel = Math.round10(Math.max(...allPoints.map((point) => point.expressionLevel)), -2)

const maxExpressionLevelPoints = _colourizeExpressionLevel(gradientColourRanges(), [])(plotData(randomSeries))
const maxExpressionLevelPoints = _colourizeExpressionLevel(gradientColourRanges(), [], cluster)(plotData(randomSeries))
.reduce((acc, series) => {
acc.push(series.data.filter((point) => point.expressionLevel === maxExpressionLevel, -2))
return acc
Expand All @@ -78,7 +77,7 @@ describe(`GeneExpressionTSnePlot colourize function`, () => {
const allPoints = randomSeries.reduce((acc, series) => acc.concat(series.data), [])
const minExpressionLevel = Math.round10(Math.min(...allPoints.map((point) => point.expressionLevel)), -2)

const minExpressionLevelPoints = _colourizeExpressionLevel(gradientColourRanges(), [])(plotData(randomSeries))
const minExpressionLevelPoints = _colourizeExpressionLevel(gradientColourRanges(), [], cluster)(plotData(randomSeries))
.reduce((acc, series) => {
acc.push(series.data.filter((point) => point.expressionLevel === minExpressionLevel, -2))
return acc
Expand All @@ -94,7 +93,7 @@ describe(`GeneExpressionTSnePlot colourize function`, () => {
test(`rounds expression level to two decimal places`, () => {
const randomSeries = randomHighchartsSeries()

_colourizeExpressionLevel(gradientColourRanges(), [])(plotData(randomSeries)).forEach((series) => {
_colourizeExpressionLevel(gradientColourRanges(), [], cluster)(plotData(randomSeries)).forEach((series) => {
series.data.forEach((point) => {
if (String(point.expressionLevel).includes(`.`)) {
expect(String(point.expressionLevel).split(`.`)[1].length).toBeLessThanOrEqual(2)
Expand All @@ -104,7 +103,7 @@ describe(`GeneExpressionTSnePlot colourize function`, () => {
})

test(`assigns default colour, i.e. lightgrey, if points have no expression level property`, () => {
_colourizeExpressionLevel(gradientColourRanges(), [])({
_colourizeExpressionLevel(gradientColourRanges(), [], cluster)({
series: [
{
name: `Cluster 1`,
Expand Down Expand Up @@ -136,8 +135,8 @@ describe(`GeneExpressionTSnePlot colourize function`, () => {
max: 100.0
}).forEach((series) => {
series.data.forEach((point) => {
expect(point).toHaveProperty(`color`, Color(`lightgrey`).alpha(0.65).rgb().toString())
})
expect(point).toHaveProperty(`color`, Color(`lightgrey`).alpha(0.65).rgb().toString())
})
})
})
})
Expand All @@ -148,7 +147,9 @@ describe(`GeneExpressionTSnePlot`, () => {
const onSelectGeneId = () => {}

const tree = renderer
.create(<GeneExpressionTSnePlot height={600} expressionGradientColours={gradientColourRanges()} atlasUrl={``} suggesterEndpoint={``} onSelectGeneId={onSelectGeneId} loading={true} plotData={plotData(randomSeries)} highlightClusters={[]} speciesName={``}/>)
.create(<GeneExpressionTSnePlot height={600} expressionGradientColours={gradientColourRanges()} atlasUrl={``}
suggesterEndpoint={``} onSelectGeneId={onSelectGeneId} loading={true} cluster={cluster}
plotData={plotData(randomSeries)} highlightClusters={[]} speciesName={``}/>)
.toJSON()

expect(tree).toMatchSnapshot()
Expand Down
Loading