Skip to content

Commit a1eab4f

Browse files
committed
Use NES chart when NES column is provided by build-table command.
Refs #421.
1 parent 504237d commit a1eab4f

File tree

5 files changed

+83
-37
lines changed

5 files changed

+83
-37
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/commands/ChartCommandTask.java

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
package org.baderlab.csplugins.enrichmentmap.commands;
22

3-
import static org.baderlab.csplugins.enrichmentmap.commands.tunables.CommandUtil.lssFromEnum;
4-
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.DATA_SET;
5-
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.EXPRESSION_DATA;
6-
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.FDR_VALUE;
7-
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.NES_VALUE;
8-
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.NONE;
9-
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.PHENOTYPES;
10-
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.P_VALUE;
11-
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.DATASET_PIE;
12-
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.HEAT_MAP;
13-
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.HEAT_STRIPS;
14-
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.RADIAL_HEAT_MAP;
15-
163
import java.util.Map;
174

5+
import org.baderlab.csplugins.enrichmentmap.commands.tunables.ChartTunables;
186
import org.baderlab.csplugins.enrichmentmap.commands.tunables.NetworkTunable;
197
import org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap;
208
import org.baderlab.csplugins.enrichmentmap.style.ChartData;
@@ -27,8 +15,6 @@
2715
import org.cytoscape.work.AbstractTask;
2816
import org.cytoscape.work.ContainsTunables;
2917
import org.cytoscape.work.TaskMonitor;
30-
import org.cytoscape.work.Tunable;
31-
import org.cytoscape.work.util.ListSingleSelection;
3218

3319
import com.google.inject.Inject;
3420

@@ -40,24 +26,9 @@ public class ChartCommandTask extends AbstractTask {
4026
@ContainsTunables @Inject
4127
public NetworkTunable networkTunable;
4228

43-
@Tunable(description = "Sets the chart data to show.")
44-
public ListSingleSelection<String> data;
45-
46-
@Tunable(description = "Sets the chart type.")
47-
public ListSingleSelection<String> type;
48-
49-
@Tunable(description = "Sets the chart colors.")
50-
public ListSingleSelection<String> colors;
51-
52-
@Tunable
53-
public boolean showChartLabels = true;
54-
29+
@ContainsTunables @Inject
30+
public ChartTunables chartTunable;
5531

56-
public ChartCommandTask() {
57-
data = lssFromEnum(NES_VALUE, P_VALUE, FDR_VALUE, PHENOTYPES, DATA_SET, EXPRESSION_DATA, NONE); // want NES to be the default
58-
type = lssFromEnum(RADIAL_HEAT_MAP, HEAT_STRIPS, HEAT_MAP); // don't include DATASET_PIE
59-
colors = lssFromEnum(ColorScheme.values());
60-
}
6132

6233
@Override
6334
public void run(TaskMonitor taskMonitor) {
@@ -67,9 +38,9 @@ public void run(TaskMonitor taskMonitor) {
6738
if(networkView == null || map == null)
6839
throw new IllegalArgumentException("network is not an EnrichmentMap network");
6940

70-
ChartData chartData = ChartData.valueOf(data.getSelectedValue());
71-
ChartType chartType = chartData == DATA_SET ? DATASET_PIE : ChartType.valueOf(type.getSelectedValue());
72-
ColorScheme colorScheme = ColorScheme.valueOf(colors.getSelectedValue());
41+
ChartData chartData = chartTunable.getChartData();
42+
ChartType chartType = chartTunable.getChartType();
43+
ColorScheme colorScheme = chartTunable.getColorScheme();
7344

7445
// validate
7546
if(chartData == ChartData.EXPRESSION_DATA && !networkTunable.isAssociatedEnrichmenMap())
@@ -81,7 +52,7 @@ public void run(TaskMonitor taskMonitor) {
8152
if(chartData == ChartData.FDR_VALUE && !map.getParams().isFDR())
8253
throw new IllegalArgumentException("data=FDR_VALUE cannot be used on this network");
8354

84-
ChartOptions options = new ChartOptions(chartData, chartType, colorScheme, showChartLabels);
55+
ChartOptions options = new ChartOptions(chartData, chartType, colorScheme, chartTunable.showChartLabels());
8556

8657
Map<Long,ViewParams> viewParamsMap = controlPanelMediator.getAllViewParams();
8758
ViewParams params = viewParamsMap.get(networkView.getSUID());

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/commands/TableCommandTask.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.cytoscape.work.TaskMonitor;
1616
import org.cytoscape.work.Tunable;
1717

18+
import com.google.common.base.Strings;
1819
import com.google.inject.Inject;
1920

2021
public class TableCommandTask extends AbstractTask {
@@ -42,6 +43,10 @@ public void run(TaskMonitor taskMonitor) {
4243
if(filterArgs.networkName != null && !filterArgs.networkName.trim().isEmpty())
4344
creationParams.setNetworkName(filterArgs.networkName);
4445

46+
// https://github.com/BaderLab/EnrichmentMapApp/issues/421#issuecomment-675400000
47+
if(!Strings.isNullOrEmpty(tableParams.getNesColumn()))
48+
creationParams.setForceNES(true);
49+
4550
String dataSetName = this.dataSetName == null ? "Data Set 1" : this.dataSetName;
4651
DataSetParameters dsParams = new DataSetParameters(dataSetName, tableParams, tableExpressionParams);
4752
List<DataSetParameters> dataSets = Collections.singletonList(dsParams);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package org.baderlab.csplugins.enrichmentmap.commands.tunables;
2+
3+
import static org.baderlab.csplugins.enrichmentmap.commands.tunables.CommandUtil.lssFromEnum;
4+
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.DATA_SET;
5+
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.EXPRESSION_DATA;
6+
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.FDR_VALUE;
7+
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.NES_VALUE;
8+
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.NONE;
9+
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.PHENOTYPES;
10+
import static org.baderlab.csplugins.enrichmentmap.style.ChartData.P_VALUE;
11+
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.DATASET_PIE;
12+
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.HEAT_MAP;
13+
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.HEAT_STRIPS;
14+
import static org.baderlab.csplugins.enrichmentmap.style.ChartType.RADIAL_HEAT_MAP;
15+
16+
import org.baderlab.csplugins.enrichmentmap.style.ChartData;
17+
import org.baderlab.csplugins.enrichmentmap.style.ChartType;
18+
import org.baderlab.csplugins.enrichmentmap.style.ColorScheme;
19+
import org.cytoscape.work.Tunable;
20+
import org.cytoscape.work.util.ListSingleSelection;
21+
22+
public class ChartTunables {
23+
24+
@Tunable(description = "Sets the chart data to show.")
25+
public ListSingleSelection<String> data;
26+
27+
@Tunable(description = "Sets the chart type.")
28+
public ListSingleSelection<String> type;
29+
30+
@Tunable(description = "Sets the chart colors.")
31+
public ListSingleSelection<String> colors;
32+
33+
@Tunable
34+
public boolean showChartLabels = true;
35+
36+
37+
public ChartTunables() {
38+
data = lssFromEnum(NES_VALUE, P_VALUE, FDR_VALUE, PHENOTYPES, DATA_SET, EXPRESSION_DATA, NONE); // want NES to be the default
39+
type = lssFromEnum(RADIAL_HEAT_MAP, HEAT_STRIPS, HEAT_MAP); // don't include DATASET_PIE
40+
colors = lssFromEnum(ColorScheme.values());
41+
}
42+
43+
44+
public ChartData getChartData() {
45+
return ChartData.valueOf(data.getSelectedValue());
46+
}
47+
48+
public ChartType getChartType() {
49+
return getChartData() == DATA_SET ? DATASET_PIE : ChartType.valueOf(type.getSelectedValue());
50+
}
51+
52+
public ColorScheme getColorScheme() {
53+
return ColorScheme.valueOf(colors.getSelectedValue());
54+
}
55+
56+
public boolean showChartLabels() {
57+
return showChartLabels;
58+
}
59+
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/model/EMCreationParameters.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public static enum EdgeStrategy {
4545
private String networkName;
4646
private EdgeStrategy edgeStrategy;
4747

48+
private transient boolean forceNES = false;
49+
4850
/**
4951
* This is calculated based on the edge strategy, number of data sets and expressions.
5052
* See FilterGenesetsByDatasetGenes and ComputeSimilarityTaskParallel.
@@ -264,6 +266,13 @@ public boolean isParseBaderlabGeneSets() {
264266
return parseBaderlab;
265267
}
266268

269+
public void setForceNES(boolean forceNES) {
270+
this.forceNES = forceNES;
271+
}
272+
273+
public boolean isForceNES() {
274+
return forceNES;
275+
}
267276

268277
@Override
269278
public String toString() {

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/view/control/ControlPanelMediator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ private void setDefaults(EMViewControlPanel viewPanel, EnrichmentMap map) {
654654
if(map.isTwoPhenotypeGeneric()) {
655655
chartData = ChartData.PHENOTYPES;
656656
} else if(params != null && map.hasNonGSEADataSet()) {
657-
if(params.isFDR())
657+
if(params.isForceNES())
658+
chartData = ChartData.NES_VALUE;
659+
else if(params.isFDR())
658660
chartData = ChartData.FDR_VALUE;
659661
else
660662
chartData = ChartData.P_VALUE;

0 commit comments

Comments
 (0)