Skip to content

Commit c087906

Browse files
committed
Updates
1 parent 1cc1807 commit c087906

File tree

21 files changed

+506
-323
lines changed

21 files changed

+506
-323
lines changed

plugins/variants/src/MultiVariantDisplay/components/VariantComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ const VariantComponent = observer(function VariantComponent({
268268
description:
269269
info.alt.length >= 3 ? 'multiple ALT alleles' : info.description,
270270
length: getBpDisplayStr(info.length),
271-
sampleName: source?.baseName ?? item.sourceName,
271+
sampleName: source?.sampleName ?? item.sourceName,
272272
name: item.sourceName,
273273
featureId: item.featureId,
274274
cell: {

plugins/variants/src/MultiVariantDisplay/components/computeVariantCells.ts

Lines changed: 37 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export function computeVariantCells({
118118
const getCachedRGBA = createCachedRGBA()
119119

120120
const alleleColorCache = {} as Record<string, string | undefined>
121+
const rawColorCache = {} as Record<string, string>
121122
const drawRef = referenceDrawingMode === 'draw'
122123

123124
const numSources = sources.length
@@ -173,26 +174,26 @@ export function computeVariantCells({
173174
? buildSampleIndexMap(mafs[0]!.feature.get('sampleNames') as string[])
174175
: undefined
175176

176-
if (renderingMode === 'phased') {
177-
for (const { feature, mostFrequentAlt } of mafs) {
178-
const featureId = feature.id()
179-
const start = feature.get('start')
180-
const end = feature.get('end')
181-
const featureType = (feature.get('type') as string) || ''
182-
const featureStrand = feature.get('strand') as number | undefined
183-
const bpLen = end - start
184-
const shape = getShapeType(featureType, featureStrand)
185-
const alt = feature.get('ALT') as string[]
186-
const ref = feature.get('REF') as string
187-
const featureName = feature.get('name') as string
188-
const description = feature.get('description') as string
189-
const renderedGenotypes = {} as Record<string, string>
190-
const renderEnd =
191-
shape === SHAPE_TRI_DOWN
192-
? getInsertionRenderEnd(start, end, alt, feature)
193-
: end
177+
for (const { feature, mostFrequentAlt } of mafs) {
178+
const featureId = feature.id()
179+
const start = feature.get('start')
180+
const end = feature.get('end')
181+
const featureType = (feature.get('type') as string) || ''
182+
const featureStrand = feature.get('strand') as number | undefined
183+
const bpLen = end - start
184+
const shape = getShapeType(featureType, featureStrand)
185+
const alt = feature.get('ALT') as string[]
186+
const ref = feature.get('REF') as string
187+
const featureName = feature.get('name') as string
188+
const description = feature.get('description') as string
189+
const renderedGenotypes = {} as Record<string, string>
190+
const renderEnd =
191+
shape === SHAPE_TRI_DOWN
192+
? getInsertionRenderEnd(start, end, alt, feature)
193+
: end
194194

195-
const callGt = getRawCallGenotype(feature)
195+
const callGt = getRawCallGenotype(feature)
196+
if (renderingMode === 'phased') {
196197
if (callGt && sampleIndexMap) {
197198
const callGtPhased = feature.get('callGenotypePhased') as
198199
| Uint8Array
@@ -201,9 +202,8 @@ export function computeVariantCells({
201202
const mostFreqAltInt = Number.parseInt(mostFrequentAlt, 10)
202203

203204
for (let j = 0; j < numSources; j++) {
204-
const { name, HP, baseName } = sources[j]!
205-
const sampleName = baseName ?? name
206-
const si = sampleIndexMap.get(sampleName)
205+
const { name, HP, sampleName } = sources[j]!
206+
const si = sampleIndexMap.get(sampleName ?? name)
207207
if (si === undefined) {
208208
continue
209209
}
@@ -265,9 +265,8 @@ export function computeVariantCells({
265265
}
266266

267267
for (let j = 0; j < numSources; j++) {
268-
const { name, HP, baseName } = sources[j]!
269-
const sampleName = baseName ?? name
270-
const genotype = samp[sampleName]
268+
const { name, HP, sampleName } = sources[j]!
269+
const genotype = samp[sampleName ?? name]
271270
if (genotype) {
272271
const isPhasedGt = genotype.includes('|')
273272
if (isPhasedGt) {
@@ -313,38 +312,7 @@ export function computeVariantCells({
313312
}
314313
}
315314
}
316-
317-
featureGenotypeMap[featureId] = {
318-
alt,
319-
ref,
320-
name: featureName,
321-
description,
322-
length: bpLen,
323-
genotypes: renderedGenotypes,
324-
}
325-
}
326-
} else {
327-
const rawColorCache = {} as Record<string, string>
328-
329-
for (const { mostFrequentAlt, feature } of mafs) {
330-
const featureId = feature.id()
331-
const start = feature.get('start')
332-
const end = feature.get('end')
333-
const featureType = (feature.get('type') as string) || ''
334-
const featureStrand = feature.get('strand') as number | undefined
335-
const bpLen = end - start
336-
const shape = getShapeType(featureType, featureStrand)
337-
const alt = feature.get('ALT') as string[]
338-
const ref = feature.get('REF') as string
339-
const featureName = feature.get('name') as string
340-
const description = feature.get('description') as string
341-
const renderedGenotypes = {} as Record<string, string>
342-
const renderEnd =
343-
shape === SHAPE_TRI_DOWN
344-
? getInsertionRenderEnd(start, end, alt, feature)
345-
: end
346-
347-
const callGt = getRawCallGenotype(feature)
315+
} else {
348316
if (callGt && sampleIndexMap) {
349317
const callGtPhased = feature.get('callGenotypePhased') as
350318
| Uint8Array
@@ -353,8 +321,8 @@ export function computeVariantCells({
353321
const mostFreqAltInt = Number.parseInt(mostFrequentAlt, 10)
354322

355323
for (let j = 0; j < numSources; j++) {
356-
const { name } = sources[j]!
357-
const si = sampleIndexMap.get(name)
324+
const { name, sampleName } = sources[j]!
325+
const si = sampleIndexMap.get(sampleName ?? name)
358326
if (si === undefined) {
359327
continue
360328
}
@@ -425,8 +393,8 @@ export function computeVariantCells({
425393
}
426394

427395
for (let j = 0; j < numSources; j++) {
428-
const { name } = sources[j]!
429-
const genotype = samp[name]
396+
const { name, sampleName } = sources[j]!
397+
const genotype = samp[sampleName ?? name]
430398
if (genotype) {
431399
const c = getAlleleColor(
432400
genotype,
@@ -451,15 +419,15 @@ export function computeVariantCells({
451419
}
452420
}
453421
}
422+
}
454423

455-
featureGenotypeMap[featureId] = {
456-
alt,
457-
ref,
458-
name: featureName,
459-
description,
460-
length: bpLen,
461-
genotypes: renderedGenotypes,
462-
}
424+
featureGenotypeMap[featureId] = {
425+
alt,
426+
ref,
427+
name: featureName,
428+
description,
429+
length: bpLen,
430+
genotypes: renderedGenotypes,
463431
}
464432
}
465433

plugins/variants/src/MultiVariantMatrixDisplay/components/VariantMatrixComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const VariantMatrixComponent = observer(function VariantMatrixComponent({
111111
const source = sources[rowIdx]
112112
const feature = cellData.featureData[featureIdx]
113113
if (source && feature) {
114-
const sampleName = source.baseName ?? source.name
114+
const sampleName = source.sampleName ?? source.name
115115
const genotype = feature.genotypes[sampleName]
116116
if (genotype) {
117117
return {

0 commit comments

Comments
 (0)