Skip to content

Commit

Permalink
Add track menu items for the indicators/fuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Feb 16, 2021
1 parent f41b301 commit 0b263b9
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 21 deletions.
12 changes: 7 additions & 5 deletions plugins/alignments/src/LinearPileupDisplay/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,14 @@ const stateModelFactory = (
return filters
},

get rendererConfig() {
const configBlob =
getConf(self, ['renderers', self.rendererTypeName]) || {}
return self.rendererType.configSchema.create(configBlob)
},

get renderProps() {
const view = getContainingView(self) as LGV
const config = self.rendererType.configSchema.create(
getConf(self, ['renderers', self.rendererTypeName]) || {},
)

return {
...self.composedRenderProps,
...getParentRenderProps(self),
Expand All @@ -377,7 +379,7 @@ const stateModelFactory = (
colorTagMap: JSON.parse(JSON.stringify(self.colorTagMap)),
filters: this.filters,
showSoftClip: self.showSoftClipping,
config,
config: this.rendererConfig,
}
},

Expand Down
67 changes: 61 additions & 6 deletions plugins/alignments/src/LinearSNPCoverageDisplay/models/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { types, cast } from 'mobx-state-tree'
import { getConf } from '@jbrowse/core/configuration'
import { getConf, readConfObject } from '@jbrowse/core/configuration'
import { getParentRenderProps } from '@jbrowse/core/util/tracks'
import {
linearWiggleDisplayModelFactory,
Expand All @@ -25,6 +25,8 @@ const stateModelFactory = (
linearWiggleDisplayModelFactory(pluginManager, configSchema),
types.model({
type: types.literal('LinearSNPCoverageDisplay'),
drawInterbaseFuzz: types.maybe(types.boolean),
drawIndicators: types.maybe(types.boolean),
filterBy: types.optional(
types.model({
flagInclude: types.optional(types.number, 0),
Expand All @@ -51,6 +53,42 @@ const stateModelFactory = (
self.filterBy = cast(filter)
},
}))
.views(self => ({
get rendererConfig() {
const configBlob =
getConf(self, ['renderers', self.rendererTypeName]) || {}

return self.rendererType.configSchema.create({
...configBlob,
drawInterbaseFuzz:
self.drawInterbaseFuzz === undefined
? configBlob.drawInterbaseFuzz
: self.drawInterbaseFuzz,
drawIndicators:
self.drawIndicators === undefined
? configBlob.drawIndicators
: self.drawIndicators,
})
},
get drawInterbaseFuzzSetting() {
return self.drawInterbaseFuzz !== undefined
? self.drawInterbaseFuzz
: readConfObject(this.rendererConfig, 'drawInterbaseFuzz')
},
get drawIndicatorsSetting() {
return self.drawIndicators !== undefined
? self.drawIndicators
: readConfObject(this.rendererConfig, 'drawIndicators')
},
}))
.actions(self => ({
toggleDrawIndicators() {
self.drawIndicators = !self.drawIndicators
},
toggleDrawInterbaseFuzz() {
self.drawInterbaseFuzz = !self.drawInterbaseFuzz
},
}))

.views(self => ({
get TooltipComponent() {
Expand All @@ -77,6 +115,27 @@ const stateModelFactory = (
return []
},

get composedTrackMenuItems() {
return [
{
label: 'Draw indicators',
type: 'checkbox',
checked: self.drawIndicatorsSetting,
onClick: () => {
self.toggleDrawIndicators()
},
},
{
label: 'Draw interbase fuzz',
type: 'checkbox',
checked: self.drawInterbaseFuzzSetting,
onClick: () => {
self.toggleDrawInterbaseFuzz()
},
},
]
},

// The SNPCoverage filters are called twice because the BAM/CRAM features
// pass filters and then the SNPCoverage score features pass through
// here, and those have no name/flags/tags so those are passed thru
Expand Down Expand Up @@ -128,10 +187,6 @@ const stateModelFactory = (
},

get renderProps() {
const config = self.rendererType.configSchema.create(
getConf(self, ['renderers', self.rendererTypeName]) || {},
)

return {
...self.composedRenderProps,
...getParentRenderProps(self),
Expand All @@ -141,7 +196,7 @@ const stateModelFactory = (
displayModel: self,
scaleOpts: this.scaleOpts,
filters: self.filters,
config,
config: self.rendererConfig,
}
},
}))
Expand Down
12 changes: 2 additions & 10 deletions plugins/alignments/src/SNPCoverageRenderer/SNPCoverageRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,9 @@ export default class SNPCoverageRenderer extends WiggleBaseRenderer {
for (const feature of features.values()) {
const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx)
const infoArray: BaseInfo[] = feature.get('snpinfo') || []
const total = infoArray.find(info => info.base === 'total')?.score || 0
const softclip =
infoArray.find(info => info.base === 'softclip')?.score || 0
const hardclip =
infoArray.find(info => info.base === 'hardclip')?.score || 0
const insertion =
infoArray.find(info => info.base === 'insertion')?.score || 0
const deletion =
infoArray.find(info => info.base === 'deletion')?.score || 0
const totalScore =
infoArray.find(info => info.base === 'total')?.score || 0

const totalScore = total - softclip - hardclip - insertion - deletion
const w = Math.max(rightPx - leftPx + 0.3, 1)
infoArray
.filter(
Expand Down

0 comments on commit 0b263b9

Please sign in to comment.