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

Add ability to color by per-base quality in alignment tracks #1601

Merged
merged 1 commit into from
Feb 19, 2021
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
10 changes: 8 additions & 2 deletions packages/core/util/offscreenCanvasPonyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ class PonyfillOffscreenContext {

// setters (no getters working)
set strokeStyle(style) {
this.commands.push({ type: 'strokeStyle', style })
if (style !== this.currentStrokeStyle) {
this.commands.push({ type: 'strokeStyle', style })
this.currentStrokeStyle = style
}
}

set fillStyle(style) {
this.commands.push({ type: 'fillStyle', style })
if (style !== this.currentFillStyle) {
this.commands.push({ type: 'fillStyle', style })
this.currentFillStyle = style
}
}

set font(style) {
Expand Down
6 changes: 6 additions & 0 deletions plugins/alignments/src/LinearPileupDisplay/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,12 @@ const stateModelFactory = (
self.setColorScheme({ type: 'pairOrientation' })
},
},
{
label: 'Per-base quality',
onClick: () => {
self.setColorScheme({ type: 'perBaseQuality' })
},
},
{
label: 'Insert size',
onClick: () => {
Expand Down
59 changes: 59 additions & 0 deletions plugins/alignments/src/PileupRenderer/PileupLayoutSession.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import deepEqual from 'deep-equal'
import { LayoutSession } from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType'
import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
import SerializableFilterChain from '@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain'
import GranularRectLayout from '@jbrowse/core/util/layouts/GranularRectLayout'
import MultiLayout from '@jbrowse/core/util/layouts/MultiLayout'
import { readConfObject } from '@jbrowse/core/configuration'

export interface PileupLayoutSessionProps {
config: AnyConfigurationModel
bpPerPx: number
filters: SerializableFilterChain
sortedBy: unknown
showSoftClip: unknown
}

type MyMultiLayout = MultiLayout<GranularRectLayout<unknown>, unknown>
interface CachedPileupLayout {
layout: MyMultiLayout
config: AnyConfigurationModel
filters: SerializableFilterChain
sortedBy: unknown
showSoftClip: boolean
}
// Sorting and revealing soft clip changes the layout of Pileup renderer
// Adds extra conditions to see if cached layout is valid
export class PileupLayoutSession extends LayoutSession {
sortedBy: unknown

showSoftClip = false

constructor(args: PileupLayoutSessionProps) {
super(args)
this.config = args.config
}

cachedLayoutIsValid(cachedLayout: CachedPileupLayout) {
return (
super.cachedLayoutIsValid(cachedLayout) &&
this.showSoftClip === cachedLayout.showSoftClip &&
deepEqual(this.sortedBy, cachedLayout.sortedBy)
)
}

cachedLayout: CachedPileupLayout | undefined

get layout(): MyMultiLayout {
if (!this.cachedLayout || !this.cachedLayoutIsValid(this.cachedLayout)) {
this.cachedLayout = {
layout: this.makeLayout(),
config: readConfObject(this.config),
filters: this.filters,
sortedBy: this.sortedBy,
showSoftClip: this.showSoftClip,
}
}
return this.cachedLayout.layout
}
}
Loading