Skip to content

Commit

Permalink
Phased
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 28, 2025
1 parent e832413 commit f1a427c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function stateModelFactory(
...superProps,
notReady:
superProps.notReady || !self.sources || !self.featuresVolatile,
phasedMode: self.phasedMode,
renderingMode: self.renderingMode,
minorAlleleFrequencyFilter: self.minorAlleleFrequencyFilter,
height: self.totalHeight,
sources: self.sources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ export function makeImageData({
canvasHeight: number
renderArgs: RenderArgsDeserializedWithFeaturesAndLayout
}) {
const { phasedMode, minorAlleleFrequencyFilter, sources, features } =
renderArgs
const {
renderingMode: renderingMode,
minorAlleleFrequencyFilter,
sources,
features,
} = renderArgs
const h = canvasHeight / sources.length
const mafs = getFeaturesThatPassMinorAlleleFrequencyFilter(
features.values(),
Expand All @@ -95,7 +99,7 @@ export function makeImageData({
const genotype = samp[name]
if (genotype) {
const isPhased = genotype.includes('|')
if (phasedMode === 'phasedOnly') {
if (renderingMode === 'phased') {
if (isPhased) {
const alleles = genotype.split('|')
drawPhased(alleles, ctx, x, y, w, h, HP!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export interface RenderArgsDeserialized extends BoxRenderArgsDeserialized {
minorAlleleFrequencyFilter: number
highResolutionScaling: number
height: number
phasedMode: string
renderingMode: string
}

export interface RenderArgsDeserializedWithFeaturesAndLayout
extends RenderArgsDeserialized {
sources: Source[]
features: Map<string, Feature>
phasedMode: string
renderingMode: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class MultiVariantGetSimplifiedFeatures extends RpcMethodTypeWithFiltersA
sampleInfo[key] = {
maxPloidy: Math.max(
sampleInfo[key]?.maxPloidy || 0,
val.split(/|/).length,
val.split('|').length,
),
isPhased: sampleInfo[key]?.isPhased || isPhased,
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/variants/src/shared/ClusterDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const useStyles = makeStyles()(theme => ({
},
}))

export default function HierarchicalCluster({
export default function ClusterDialog({
model,
handleClose,
}: {
Expand Down
21 changes: 11 additions & 10 deletions plugins/variants/src/shared/MultiVariantBaseModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function MultiVariantBaseModelF(
/**
* #property
*/
phasedMode: types.optional(types.string, 'none'),
renderingMode: types.optional(types.string, 'none'),
}),
)
.volatile(() => ({
Expand Down Expand Up @@ -144,7 +144,7 @@ export default function MultiVariantBaseModelF(
* #action
*/
setPhasedMode(arg: string) {
self.phasedMode = arg
self.renderingMode = arg
},
/**
* #action
Expand Down Expand Up @@ -179,7 +179,7 @@ export default function MultiVariantBaseModelF(
)
for (const row of this.preSources) {
// make separate rows for each haplotype in phased mode
if (self.phasedMode === 'phasedOnly') {
if (self.renderingMode === 'phased') {
const info = self.sampleInfo?.[row.name]
if (info?.isPhased) {
const ploidy = info.maxPloidy
Expand Down Expand Up @@ -240,34 +240,35 @@ export default function MultiVariantBaseModelF(
self.setShowSidebarLabels(!self.showSidebarLabelsSetting)
},
},

...(self.hasPhased
? [
{
label: 'Phased mode',
label: 'Rendering mode',
type: 'subMenu',
subMenu: [
{
label: 'Draw unphased (maps allele count to color)',
label: 'Allele count mode',
type: 'radio',
checked: self.phasedMode === 'none',
checked: self.renderingMode === 'none',
onClick: () => {
self.setPhasedMode('none')
},
},
{
label: 'Draw phased (split into haplotype rows)',
checked: self.phasedMode === 'phasedOnly',
label: 'Phased mode',
checked: self.renderingMode === 'phased',
type: 'radio',
onClick: () => {
self.setPhasedMode('phasedOnly')
self.setPhasedMode('phased')
},
},
],
},
]
: []),
{
label: 'Set minor allele frequency filter',
label: 'Filter by minor allele frequency',
onClick: () => {
getSession(self).queueDialog(handleClose => [
MAFFilterDialog,
Expand Down

0 comments on commit f1a427c

Please sign in to comment.