Skip to content

Commit

Permalink
Updatse
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 14, 2025
1 parent a82ba7b commit dea527f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
23 changes: 12 additions & 11 deletions plugins/alignments/src/SNPCoverageAdapter/generateCoverageBins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,18 @@ export async function generateCoverageBins({
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (bin) {
bin.mods = Object.fromEntries(
Object.entries(bin.mods).map(([key, val]) => {
return [
key,
{
...val,
avgProbability: val.probabilities.length
? sum(val.probabilities) / val.probabilities.length
: undefined,
},
] as const
}),
Object.entries(bin.mods).map(
([key, val]) =>
[
key,
{
...val,
avgProbability: val.probabilities.length
? sum(val.probabilities) / val.probabilities.length
: undefined,
},
] as const,
),
)
bin.nonmods = Object.fromEntries(
Object.entries(bin.nonmods).map(([key, val]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export function processModifications({
bins[epos] = {
depth: 0,
readsCounted: 0,
refbase: regionSequence[epos],
snps: {},
ref: {
probabilities: [],
Expand All @@ -54,6 +53,7 @@ export function processModifications({

const s = 1 - sum(allProbs)
const bin = bins[epos]
bin.refbase = regionSequence[epos]
if (twoColor && s > max(allProbs)) {
incWithProbabilities(bin, fstrand, 'nonmods', `nonmod_${type}`, s)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { RenderArgsDeserializedWithFeatures } from './types'
export default class SNPCoverageRenderer extends WiggleBaseRenderer {
// note: the snps are drawn on linear scale even if the data is drawn in log
// scape hence the two different scales being used
// @ts-expect-error
async draw(
ctx: CanvasRenderingContext2D,
props: RenderArgsDeserializedWithFeatures,
Expand Down
6 changes: 1 addition & 5 deletions plugins/alignments/src/SNPCoverageRenderer/makeImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,9 @@ export async function makeImage(
// are located to the left when forward and right when reversed
const extraHorizontallyFlippedOffset = region.reversed ? 1 / bpPerPx : 0

// @ts-expect-error
const drawingModifications = colorBy?.type === 'modifications'

Check failure on line 133 in plugins/alignments/src/SNPCoverageRenderer/makeImage.ts

View workflow job for this annotation

GitHub Actions / Lint, typecheck, test

Unnecessary optional chain on a non-nullish value
// @ts-expect-error
const drawingMethylation = colorBy?.type === 'methylation'

Check failure on line 134 in plugins/alignments/src/SNPCoverageRenderer/makeImage.ts

View workflow job for this annotation

GitHub Actions / Lint, typecheck, test

Unnecessary optional chain on a non-nullish value
const isolatedModification =
// @ts-expect-error
colorBy?.modifications?.isolatedModification
const isolatedModification = colorBy?.modifications?.isolatedModification

Check failure on line 135 in plugins/alignments/src/SNPCoverageRenderer/makeImage.ts

View workflow job for this annotation

GitHub Actions / Lint, typecheck, test

Unnecessary optional chain on a non-nullish value

// Second pass: draw the SNP data, and add a minimum feature width of 1px
// which can be wider than the actual bpPerPx This reduces overdrawing of
Expand Down
3 changes: 2 additions & 1 deletion plugins/alignments/src/SNPCoverageRenderer/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ModificationTypeWithColor } from '../shared/types'
import type { ColorBy, ModificationTypeWithColor } from '../shared/types'
import type { RenderArgsDeserialized as FeatureRenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType'
import type { Feature } from '@jbrowse/core/util'
import type { ScaleOpts } from '@jbrowse/plugin-wiggle'
Expand All @@ -16,4 +16,5 @@ export interface RenderArgsDeserializedWithFeatures
ticks: { values: number[] }
displayCrossHatches: boolean
visibleModifications?: Record<string, ModificationTypeWithColor>
colorBy: ColorBy
}

0 comments on commit dea527f

Please sign in to comment.