Skip to content

Commit

Permalink
Changes based on review comments received
Browse files Browse the repository at this point in the history
  • Loading branch information
Diana Baiceanu committed Aug 19, 2020
1 parent a426d25 commit 05553aa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
14 changes: 7 additions & 7 deletions src/pages/patientView/SampleManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,27 +294,27 @@ class SampleManager {
}

getClinicalAttributeList(samples: Array<ClinicalDataBySampleId>) {
let clinicalAttributeIds: { [id: string]: ClinicalAttribute } = {};
let clinicalAttributes: { id: string; value: string }[] = [];
let clinicalAttributes: { [id: string]: ClinicalAttribute } = {};
let output: { id: string; value: string }[] = [];
samples.forEach((sample, sampleIndex) => {
sample.clinicalData.forEach((clinicalData, clinicalDataIndex) => {
if (
clinicalAttributeIds[clinicalData.clinicalAttributeId] ===
clinicalAttributes[clinicalData.clinicalAttributeId] ===
undefined
) {
clinicalAttributes.push({
output.push({
id: clinicalData.clinicalAttributeId,
value: clinicalData.clinicalAttribute.displayName,
});
clinicalAttributeIds[clinicalData.clinicalAttributeId] =
clinicalAttributes[clinicalData.clinicalAttributeId] =
clinicalData.clinicalAttribute;
}
});
});
return clinicalAttributes;
return output;
}

getClinicalAttributeSampleList(
getClinicalValueToSamplesMap(
samples: Array<ClinicalDataBySampleId>,
clinicalAttributeId: string
) {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/patientView/mutation/VAFLineChartUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ export function computeRenderData(
mutationProfileId: string,
coverageInformation: CoverageInformation,
groupByOption: string,
sampleGroup: { [s: string]: string }
sampleIdToClinicalValue: { [sampleId: string]: string }
) {
const grayPoints: IPoint[] = []; // points that are purely interpolated for rendering, dont have data of their own
const lineData: IPoint[][] = [];

if (groupByOption && groupByOption != GROUP_BY_NONE)
mutations = splitMutationsBySampleGroup(mutations, sampleGroup);
mutations = splitMutationsBySampleGroup(
mutations,
sampleIdToClinicalValue
);

for (const mergedMutation of mutations) {
// determine data points in line for this mutation
Expand Down
40 changes: 20 additions & 20 deletions src/pages/patientView/timeline2/VAFChartWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export default class VAFChartWrapper extends React.Component<
this.props.mutationProfileId,
this.props.coverageInformation,
this.props.store.groupByOption!,
this.sampleGroupByValue
this.sampleToClinicalValue
);
}

Expand Down Expand Up @@ -286,54 +286,54 @@ export default class VAFChartWrapper extends React.Component<
);
}

@computed get sampleGroupByColors() {
let groupByColors: { [clinicalValue: string]: string } = {};
@computed get clinicalValueToColor() {
let clinicalValueToColor: { [clinicalValue: string]: string } = {};
const uniqueColorGetter = makeUniqueColorGetter();
const clinicalAttributeSamplesMap = this.props.sampleManager.getClinicalAttributeSampleList(
const clinicalAttributeSamplesMap = this.props.sampleManager.getClinicalValueToSamplesMap(
this.props.sampleManager.samples,
this.props.store.groupByOption!
);
clinicalAttributeSamplesMap.forEach(
(sampleList: string[], clinicalValue: any) => {
groupByColors[clinicalValue] = uniqueColorGetter();
clinicalValueToColor[clinicalValue] = uniqueColorGetter();
}
);
return groupByColors;
return clinicalValueToColor;
}

@computed get sampleGroupByLabels() {
let groupByLabels: string[] = [];
@computed get clinicalValuesForGrouping() {
let clinicalValuesForGrouping: string[] = [];
const uniqueColorGetter = makeUniqueColorGetter();
const clinicalAttributeSamplesMap = this.props.sampleManager.getClinicalAttributeSampleList(
const clinicalAttributeSamplesMap = this.props.sampleManager.getClinicalValueToSamplesMap(
this.props.sampleManager.samples,
this.props.store.groupByOption!
);
clinicalAttributeSamplesMap.forEach(
(sampleList: string[], clinicalValue: any) => {
groupByLabels.push(clinicalValue);
clinicalValuesForGrouping.push(clinicalValue);
}
);
return groupByLabels;
return clinicalValuesForGrouping;
}

@computed get sampleGroupByValue() {
let groupByValue: { [sampleId: string]: string } = {};
@computed get sampleToClinicalValue() {
let sampleToClinicalValue: { [sampleId: string]: string } = {};
if (
!(
this.props.store.groupByOption == null ||
this.props.store.groupByOption === GROUP_BY_NONE
)
) {
this.props.sampleManager.samples.forEach((sample, i) => {
groupByValue[
sampleToClinicalValue[
sample.id
] = SampleManager!.getClinicalAttributeInSample(
sample,
this.props.store.groupByOption!
)!.value;
});
}
return groupByValue;
return sampleToClinicalValue;
}

@computed get sampleYPosition() {
Expand All @@ -349,7 +349,7 @@ export default class VAFChartWrapper extends React.Component<
)
) {
// get for each clinical attribute value the list of corresponding samples
let clinicalAttributeSamplesMap = this.props.sampleManager.getClinicalAttributeSampleList(
let clinicalAttributeSamplesMap = this.props.sampleManager.getClinicalValueToSamplesMap(
this.props.sampleManager.samples,
this.props.store.groupByOption!
);
Expand Down Expand Up @@ -555,8 +555,8 @@ export default class VAFChartWrapper extends React.Component<
GROUP_BY_NONE
)
)
color = this.sampleGroupByColors[
this.sampleGroupByValue[d.sampleId]
color = this.clinicalValueToColor[
this.sampleToClinicalValue[d.sampleId]
];

return (
Expand Down Expand Up @@ -616,14 +616,14 @@ export default class VAFChartWrapper extends React.Component<
)}
</g>
<g transform={`translate(0,${this.dataHeight})`}>
{this.sampleGroupByLabels.map((label, index) => {
{this.clinicalValuesForGrouping.map((label, index) => {
return (
<g transform={`translate(0,0)`}>
<text
y={this.sampleYPosition[label] + 15 + 7.5}
font-family="sans-serif"
font-size="12px"
fill={this.sampleGroupByColors[label]}
fill={this.clinicalValueToColor[label]}
>
{label}
</text>
Expand Down

0 comments on commit 05553aa

Please sign in to comment.