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 21, 2020
1 parent ed7e3f9 commit a9f1811
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 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
15 changes: 11 additions & 4 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 @@ -1010,12 +1014,15 @@ export function transitionHeatmapTrack(
track_label_font_weight: nextSpec.labelFontWeight,
track_label_left_padding: nextSpec.labelLeftPadding,
target_group: nextSpec.trackGroupIndex,
removable: !!nextSpec.onRemove,
removable: !!nextSpec.onRemove || !!nextSpec.onClickRemoveInTrackMenu,
movable: nextSpec.movable,
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

0 comments on commit a9f1811

Please sign in to comment.