-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display interpretation instead of ClinVar id
Signed-off-by: Onur Sumer <s.onur.sumer@gmail.com>
- Loading branch information
Showing
10 changed files
with
209 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
packages/react-mutation-mapper/src/component/clinvar/ClinVarId.tsx
This file was deleted.
Oops, something went wrong.
146 changes: 146 additions & 0 deletions
146
packages/react-mutation-mapper/src/component/clinvar/ClinVarSummary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { | ||
DefaultTooltip, | ||
pluralize, | ||
TruncatedText, | ||
} from 'cbioportal-frontend-commons'; | ||
import { getClinVarId } from 'cbioportal-utils'; | ||
import { ClinVar, MyVariantInfo } from 'genome-nexus-ts-api-client'; | ||
import _ from 'lodash'; | ||
import * as React from 'react'; | ||
|
||
export type ClinVarSummaryProps = { | ||
myVariantInfo?: MyVariantInfo; | ||
}; | ||
|
||
export enum ClinVarOrigin { | ||
GERMLINE = 'germline', | ||
SOMATIC = 'somatic', | ||
} | ||
|
||
export type RcvData = { | ||
origin: string; | ||
evidences: { | ||
clinicalSignificance: string; | ||
count: number; | ||
}[]; | ||
}; | ||
|
||
export type RcvCountMap = { | ||
[origin: string]: { [clinicalSignificance: string]: number }; | ||
}; | ||
|
||
export function getRcvCountMap(clinVar: ClinVar): RcvCountMap { | ||
const filteredRcv = clinVar.rcv.filter( | ||
rcv => | ||
rcv.origin === ClinVarOrigin.GERMLINE || | ||
rcv.origin === ClinVarOrigin.SOMATIC | ||
); | ||
|
||
// first map by origin, then count evidence number for each origin group | ||
const rcvMap = _.groupBy(filteredRcv, d => d.origin); | ||
|
||
return _.mapValues(rcvMap, rcvs => | ||
_.countBy(rcvs, rcv => rcv.clinicalSignificance) | ||
); | ||
} | ||
|
||
export function getRcvData(rcvCountMap: RcvCountMap): RcvData[] { | ||
return _.map(rcvCountMap, (clinicalSignificanceCountMap, origin) => ({ | ||
origin, | ||
evidences: _.map( | ||
clinicalSignificanceCountMap, | ||
(count, clinicalSignificance) => ({ clinicalSignificance, count }) | ||
), | ||
})); | ||
} | ||
|
||
export function formatClinicalSignificanceText(rcvData: RcvData[]) { | ||
return _.uniq( | ||
_.flatten( | ||
rcvData.map(d => d.evidences.map(e => e.clinicalSignificance)) | ||
) | ||
).join(', '); | ||
} | ||
|
||
export const ClinVarRcvInterpretation = (props: { | ||
rcvData: RcvData[]; | ||
className?: string; | ||
}) => { | ||
return ( | ||
<div className={props.className}> | ||
{props.rcvData.map(d => ( | ||
<div key={d.origin}> | ||
<strong>{`${_.upperFirst(d.origin)}: `}</strong> | ||
{d.evidences | ||
.map( | ||
e => | ||
`${e.clinicalSignificance} (${ | ||
e.count | ||
} ${pluralize('evidence', e.count)})` | ||
) | ||
.join(', ')} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
const NoClinVarData = () => { | ||
return ( | ||
<DefaultTooltip | ||
placement="topLeft" | ||
overlay={<span>Variant has no ClinVar data.</span>} | ||
> | ||
<span | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'block', | ||
overflow: 'hidden', | ||
}} | ||
> | ||
| ||
</span> | ||
</DefaultTooltip> | ||
); | ||
}; | ||
|
||
const ClinVarSummary = (props: ClinVarSummaryProps) => { | ||
const clinVar = props.myVariantInfo | ||
? props.myVariantInfo.clinVar | ||
: undefined; | ||
|
||
if (!clinVar) { | ||
return <NoClinVarData />; | ||
} else { | ||
const clinVarId = getClinVarId(props.myVariantInfo); | ||
const clinVarLink = `https://www.ncbi.nlm.nih.gov/clinvar/variation/${clinVarId}/`; | ||
const rcvData = getRcvData(getRcvCountMap(clinVar)); | ||
|
||
return ( | ||
<TruncatedText | ||
maxLength={30} | ||
text={ | ||
rcvData.length > 0 | ||
? formatClinicalSignificanceText(rcvData) | ||
: 'Unknown' | ||
} | ||
addTooltip="always" | ||
tooltip={ | ||
<div style={{ maxWidth: 300 }}> | ||
<ClinVarRcvInterpretation rcvData={rcvData} /> | ||
<div> | ||
(ClinVar ID:{' '} | ||
<a href={clinVarLink} target="_blank"> | ||
{clinVarId} | ||
</a> | ||
) | ||
</div> | ||
</div> | ||
} | ||
/> | ||
); | ||
} | ||
}; | ||
|
||
export default ClinVarSummary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.