Skip to content

Commit

Permalink
oncoprint - fix bugs with removing tracks arising from putting more o…
Browse files Browse the repository at this point in the history
…ncoprint state in URL

Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <[email protected]>
  • Loading branch information
Abeshouse, Adam A./Sloan Kettering Institute committed Jan 14, 2020
1 parent 32b2847 commit 7c2ca45
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 28 deletions.
41 changes: 26 additions & 15 deletions end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, "");

const ONCOPRINT_TIMEOUT = 60000;

function getNthTrackOptionsElements(n) {
// n is one-indexed

const button_selector = "#oncoprintDiv .oncoprintjs__track_options__toggle_btn_img.nth-"+n;
const dropdown_selector = "#oncoprintDiv .oncoprintjs__track_options__dropdown.nth-"+n;

return {
button: $(button_selector),
button_selector,
dropdown: $(dropdown_selector),
dropdown_selector
};
}

describe("oncoprint screenshot tests", function() {
it("coadread_tcga_pub with clinical and heatmap tracks", function(){
var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=1&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%20NRAS%20BRAF&geneset_list=%20&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=coadread_tcga_pub_rna_seq_mrna_median_Zscores&show_samples=false&clinicallist=0%2C2%2CMETHYLATION_SUBTYPE&heatmap_track_groups=coadread_tcga_pub_rna_seq_mrna_median_Zscores%2CKRAS%2CNRAS%2CBRAF&`;
Expand Down Expand Up @@ -93,6 +107,18 @@ describe("oncoprint screenshot tests", function() {
var res = checkOncoprintElement('.oncoprintContainer');
assertScreenShotMatch(res);
});
it("removes top treatment track successfully", function() {
goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/results/oncoprint?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=ccle_broad_2019&case_set_id=ccle_broad_2019_cnaseq&data_priority=0&gene_list=TP53&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=ccle_broad_2019_cna&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=ccle_broad_2019_mutations&profileFilter=0&tab_index=tab_visualize&heatmap_track_groups=ccle_broad_2019_CCLE_drug_treatment_IC50%2CAfatinib-2%2CAKTinhibitorVIII-1&treatment_list=Afatinib-2%3BAKTinhibitorVIII-1`);
waitForOncoprint(ONCOPRINT_TIMEOUT);

const elements = getNthTrackOptionsElements(2);
setDropdownOpen(true, elements.button_selector, elements.dropdown_selector, "Couldnt open top treatment track options");
browser.click(elements.dropdown_selector + ' li:nth-child(3)'); // Click Remove
waitForOncoprint(ONCOPRINT_TIMEOUT);

var res = checkOncoprintElement('.oncoprintContainer');
assertScreenShotMatch(res);
});
});

describe("track group headers", function() {
Expand Down Expand Up @@ -153,21 +179,6 @@ describe("track group headers", function() {
});

describe("sorting", function(){

function getNthTrackOptionsElements(n) {
// n is one-indexed

const button_selector = "#oncoprintDiv .oncoprintjs__track_options__toggle_btn_img.nth-"+n;
const dropdown_selector = "#oncoprintDiv .oncoprintjs__track_options__dropdown.nth-"+n;

return {
button: $(button_selector),
button_selector,
dropdown: $(dropdown_selector),
dropdown_selector
};
}

it("oncoprint should sort patients correctly in coadread_tcga_pub", function(){
goToUrlAndSetLocalStorage(CBIOPORTAL_URL);

Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"private": true,
"version": "0.0.0",
"workspaces": {
"packages": [".", "packages/*"]
"packages": [
".",
"packages/*"
]
},
"description": "",
"scripts": {
Expand Down Expand Up @@ -172,7 +175,7 @@
"node-sass": "^4.9.3",
"numeral": "^2.0.6",
"object-sizeof": "^1.2.0",
"oncoprintjs": "4.0.9",
"oncoprintjs": "4.1.3",
"parameter-validator": "^1.0.2",
"pdfobject": "^2.0.201604172",
"pegjs": "^0.10.0",
Expand Down
13 changes: 10 additions & 3 deletions src/shared/components/oncoprint/DeltaUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,9 @@ function tryRemoveTrack(
// removeCallback to forget its track ID
const trackId = trackSpecKeyToTrackId[prevSpec.key];
if (typeof trackId !== "undefined") {
oncoprint.removeTrack(trackId);
if (oncoprint.getTracks().includes(trackId)) {
oncoprint.removeTrack(trackId);
}
delete trackSpecKeyToTrackId[prevSpec.key];
}
return true;
Expand Down Expand Up @@ -864,8 +866,10 @@ function transitionClinicalTrack(
label: nextSpec.label,
description: ((nextSpec.label || "").trim() === (nextSpec.description || "").trim()) ? undefined : nextSpec.description,
removable: true,
removeCallback: ()=>{
removeCallback: () => {
delete getTrackSpecKeyToTrackId()[nextSpec.key];
},
onClickRemoveInTrackMenu: ()=>{
nextProps.onDeleteClinicalTrack && nextProps.onDeleteClinicalTrack(nextSpec.key);
},
sort_direction_changeable: true,
Expand Down Expand Up @@ -1015,7 +1019,10 @@ export function transitionHeatmapTrack(
na_legend_label: nextSpec.naLegendLabel,
removeCallback: ()=>{
delete getTrackSpecKeyToTrackId()[nextSpec.key];
if (nextSpec.onRemove) nextSpec.onRemove();
nextSpec.onRemove && nextSpec.onRemove();
},
onClickRemoveInTrackMenu:()=>{
nextSpec.onClickRemoveInTrackMenu && nextSpec.onClickRemoveInTrackMenu();
},
sort_direction_changeable: ifNotDefined(nextSpec.sortDirectionChangeable, true),
sortCmpFn: heatmapTrackSortComparator,
Expand Down
3 changes: 2 additions & 1 deletion src/shared/components/oncoprint/Oncoprint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export interface IBaseHeatmapTrackSpec {
export interface IHeatmapTrackSpec extends IBaseHeatmapTrackSpec {
data: IBaseHeatmapTrackDatum[]; // can be IGeneHeatmapTrackDatum or ITreatmentHeatmapTrackDatum
naLegendLabel?:string;
onRemove?: () => void;
info?: string;
labelColor?: string;
labelCircleColor?: string;
Expand All @@ -131,6 +130,8 @@ export interface IHeatmapTrackSpec extends IBaseHeatmapTrackSpec {
movable?:boolean;
sortDirectionChangeable?:boolean; // never updated
trackLinkUrl?: string | undefined;
onRemove?:()=>void;
onClickRemoveInTrackMenu?: ()=>void;
molecularProfileName?: string;
pivotThreshold?: number;
sortOrder?: string;
Expand Down
5 changes: 2 additions & 3 deletions src/shared/components/oncoprint/OncoprintUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ export function makeHeatmapTracksMobxPromise(oncoprint:ResultsViewOncoprint, sam
data
),
trackGroupIndex: molecularProfileIdToHeatmapTracks[molecularProfileId].trackGroupIndex,
onRemove:action(()=>{
onClickRemoveInTrackMenu:action(()=>{
const trackGroup = oncoprint.molecularProfileIdToHeatmapTracks[molecularProfileId];
if (trackGroup) {
const newEntities = _.keys(trackGroup.entities).filter((entity)=>entity!==gene);
Expand Down Expand Up @@ -799,8 +799,7 @@ export function makeTreatmentProfileHeatmapTracksMobxPromise(oncoprint:ResultsVi
sortOrder: sortOrder,
trackLinkUrl: treatmentLinkMap[treatmentId],
trackGroupIndex: molecularProfileIdToHeatmapTracks[molecularProfileId]!.trackGroupIndex,
onRemove:action(()=>{

onClickRemoveInTrackMenu:action(()=>{
const trackGroup = oncoprint.molecularProfileIdToHeatmapTracks[molecularProfileId]!;
if (trackGroup){
const newEntities = _.keys(trackGroup.entities).filter((entity)=>entity!==treatmentId);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15699,10 +15699,10 @@ oncokb-styles@~0.1.2:
resolved "https://registry.yarnpkg.com/oncokb-styles/-/oncokb-styles-0.1.2.tgz#8b26c0a0829787cdc1b595d3a021b3266607102b"
integrity sha512-tuy5s3qFxgf1ogMATQSRPNgLlAMrvOOTCAN1dm/wJ+VZoStbJ7g36/qHwc99UPfh3vrB05broLodF+k58p5tUw==

oncoprintjs@4.0.9:
version "4.0.9"
resolved "https://registry.yarnpkg.com/oncoprintjs/-/oncoprintjs-4.0.9.tgz#d4b7bb673e50c571a435a4a27e82247dfd2d0249"
integrity sha512-T6VutMr3g+hx8e6E/873CrnuWS3s+3rfSqfU0sjgboV3N6hajU3WX/PMe3WNFBCSRHYLIi1SQV9bWcwdouZNkw==
oncoprintjs@4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/oncoprintjs/-/oncoprintjs-4.1.3.tgz#aca0528fc18d04e5c505333d603f871b1f40dec9"
integrity sha512-iP3mXiokJT5j1M3vsRaU9lxQUyt9zY57RSATlFa1rpegbZGyVwMwdZawZRd+Gov9P49JHNPvKeM/qagYo1Gglg==
dependencies:
gl-matrix "2.3.2"
jquery "^3.0.0"
Expand Down

0 comments on commit 7c2ca45

Please sign in to comment.