Skip to content

Commit 813856d

Browse files
committed
Add signature data sets to creation parameters dialog. Refs #308
1 parent 032c04d commit 813856d

File tree

10 files changed

+281
-101
lines changed

10 files changed

+281
-101
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ public void run(TaskMonitor taskMonitor) throws Exception {
139139
.setAttributePrefix(map.getParams().getAttributePrefix())
140140
.setLoadedGMTGeneSets(signatureGenesets)
141141
.addSelectedGeneSetNames(selectedGenesetNames)
142-
.setName(Strings.isNullOrEmpty(name) ? autoName : name);
142+
.setName(Strings.isNullOrEmpty(name) ? autoName : name)
143+
.setSource(PostAnalysisParameters.SOURCE_LOCAL_FILE)
144+
.setGmtFile(gmtFile.getPath());
143145

144146
if(isBatch()) {
145147
builder.setDataSetName(null); // run in batch mode
@@ -205,7 +207,7 @@ private FilterMetric.MannWhit processMannWhitneyArgs(EnrichmentMap map, EMDataSe
205207
if(mannWhitRanks.isEmpty() && map.isSingleRanksPerDataset()) {
206208
String ranksName = dataset.getAllRanksNames().iterator().next();
207209
Ranking ranking = dataset.getRanksByName(ranksName);
208-
return new FilterMetric.MannWhit(cutoff, ranking, type);
210+
return new FilterMetric.MannWhit(cutoff, ranksName, ranking, type);
209211
} else if(mannWhitRanks.isEmpty()) {
210212
throw new IllegalArgumentException("At least one of the data sets you have specified has more than one ranks file. "
211213
+ "You must use the 'mannWhitRanks' parameter to specify which ranking to use for each data set.");
@@ -224,10 +226,10 @@ private FilterMetric.MannWhit processMannWhitneyArgs(EnrichmentMap map, EMDataSe
224226
if(rankFile == null && ranksNames.size() == 1) {
225227
String ranksName = ranksNames.iterator().next();
226228
Ranking ranking = dataset.getRanksByName(ranksName);
227-
return new FilterMetric.MannWhit(cutoff, ranking, type);
229+
return new FilterMetric.MannWhit(cutoff, ranksName, ranking, type);
228230
} else {
229231
Ranking ranking = dataset.getRanksByName(rankFile);
230-
return new FilterMetric.MannWhit(cutoff, ranking, type);
232+
return new FilterMetric.MannWhit(cutoff, rankFile, ranking, type);
231233
}
232234
}
233235
}

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,57 @@
11
package org.baderlab.csplugins.enrichmentmap.model;
22

3+
import java.util.Map;
4+
5+
import javax.annotation.Nullable;
6+
37
public class EMSignatureDataSet extends AbstractDataSet {
48

9+
// These fields were added in 3.1, sessions saved with 3.0 will not be able to restore these fields.
10+
// These are just to remember some of the creation parameters to show in the Creation Paramters Dialog.
11+
private @Nullable String source;
12+
private @Nullable String gmtFile;
13+
private @Nullable PostAnalysisFilterType type;
14+
private @Nullable Map<String,String> dataSetRankTestMessage;
15+
16+
517
public EMSignatureDataSet(EnrichmentMap map, String name) {
618
super(map, name);
719
}
820

21+
22+
public String getSource() {
23+
return source;
24+
}
25+
26+
public void setSource(String source) {
27+
this.source = source;
28+
}
29+
30+
public String getGmtFile() {
31+
return gmtFile;
32+
}
33+
34+
public void setGmtFile(String gmtFile) {
35+
this.gmtFile = gmtFile;
36+
}
37+
38+
public PostAnalysisFilterType getType() {
39+
return type;
40+
}
41+
42+
public void setType(PostAnalysisFilterType type) {
43+
this.type = type;
44+
}
45+
46+
public Map<String, String> getDataSetRankTestMessage() {
47+
return dataSetRankTestMessage;
48+
}
49+
50+
public void setDataSetRankTestMessage(Map<String, String> dataSetRankTestMessage) {
51+
this.dataSetRankTestMessage = dataSetRankTestMessage;
52+
}
53+
54+
955
@Override
1056
public int hashCode() {
1157
final int prime = 11;

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
public class PostAnalysisParameters {
5454

55+
public static final String SOURCE_LOCAL_FILE = "local file";
56+
5557
final public static String SIGNATURE_INTERACTION_TYPE = "sig";
5658
@Deprecated
5759
final public static String SIGNATURE_INTERACTION_TYPE_SET1 = "sig_set1";
@@ -65,6 +67,8 @@ public class PostAnalysisParameters {
6567
private final Collection<String> selectedGeneSetNames;
6668
private final String attributePrefix;
6769
private final Optional<String> datasetName;
70+
private final String source;
71+
private final String gmtFile;
6872

6973
private PostAnalysisParameters(PostAnalysisParameters.Builder builder) {
7074
this.name = builder.name;
@@ -73,6 +77,8 @@ private PostAnalysisParameters(PostAnalysisParameters.Builder builder) {
7377
this.selectedGeneSetNames = builder.selectedGeneSetNames;
7478
this.attributePrefix = builder.attributePrefix;
7579
this.datasetName = builder.datasetName;
80+
this.source = builder.source;
81+
this.gmtFile = builder.gmtFile;
7682
}
7783

7884
public String getName() {
@@ -98,6 +104,14 @@ public Collection<String> getSelectedGeneSetNames() {
98104
public String getAttributePrefix() {
99105
return attributePrefix;
100106
}
107+
108+
public String getSource() {
109+
return source;
110+
}
111+
112+
public String getGmtFile() {
113+
return gmtFile;
114+
}
101115

102116

103117
public static class Builder {
@@ -108,7 +122,8 @@ public static class Builder {
108122
private Set<String> selectedGeneSetNames = new HashSet<>();
109123
private String attributePrefix;
110124
private Optional<String> datasetName = Optional.empty();
111-
125+
private String source;
126+
private String gmtFile;
112127

113128
public static Builder from(PostAnalysisParameters other) {
114129
Builder b = new Builder();
@@ -118,6 +133,8 @@ public static Builder from(PostAnalysisParameters other) {
118133
b.addSelectedGeneSetNames(other.selectedGeneSetNames);
119134
b.setAttributePrefix(other.attributePrefix);
120135
b.setDataSetName(other.datasetName.orElse(null));
136+
b.setSource(other.source);
137+
b.setGmtFile(other.gmtFile);
121138
return b;
122139
}
123140

@@ -160,6 +177,16 @@ public Builder setAttributePrefix(String attributePrefix) {
160177
return this;
161178
}
162179

180+
public Builder setSource(String source) {
181+
this.source = source;
182+
return this;
183+
}
184+
185+
public Builder setGmtFile(String gmtFile) {
186+
this.gmtFile = gmtFile;
187+
return this;
188+
}
189+
163190
public PostAnalysisParameters build() {
164191
return new PostAnalysisParameters(this);
165192
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/task/postanalysis/CreatePANetworkTask.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,23 @@ public void run(TaskMonitor tm) {
144144
*/
145145
private EMSignatureDataSet createSignatureDataSet() {
146146
String name = params.getName();
147-
return new EMSignatureDataSet(map, name);
147+
EMSignatureDataSet sigDataSet = new EMSignatureDataSet(map, name);
148+
149+
// set fields that show up in the Creation Parameters dialog
150+
sigDataSet.setSource(params.getSource());
151+
sigDataSet.setGmtFile(params.getGmtFile());
152+
153+
FilterMetricSet rankTestParams = params.getRankTestParameters();
154+
sigDataSet.setType(rankTestParams.getType());
155+
156+
Map<String,String> dataSetMessages = new HashMap<>();
157+
for(String dataSetName : rankTestParams.getDataSetNames()) {
158+
FilterMetric metric = rankTestParams.get(dataSetName);
159+
dataSetMessages.put(dataSetName, metric.getDisplayString());
160+
}
161+
sigDataSet.setDataSetRankTestMessage(dataSetMessages);
162+
163+
return sigDataSet;
148164
}
149165

150166

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/task/postanalysis/FilterMetric.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public interface FilterMetric {
2929

3030
double moreSimilar(double x, double y);
3131

32+
String getDisplayString();
33+
3234

3335
abstract class BaseFilterMetric implements FilterMetric {
3436
protected final double cutoff;
@@ -71,6 +73,10 @@ public double computeValue(Set<Integer> geneSet, Set<Integer> sigSet, @Nullable
7173
return 0;
7274
}
7375

76+
public String getDisplayString() {
77+
return "no filter";
78+
}
79+
7480
}
7581

7682

@@ -92,6 +98,10 @@ public double computeValue(Set<Integer> geneSet, Set<Integer> sigSet, @Nullable
9298
Set<Integer> intersection = Sets.intersection(geneSet, sigSet);
9399
return (double) intersection.size() / (double) geneSet.size();
94100
}
101+
102+
public String getDisplayString() {
103+
return "(intersection size)/(gene set size) >= " + (cutoff / 100.0);
104+
}
95105
}
96106

97107

@@ -112,6 +122,10 @@ public double moreSimilar(double x, double y) {
112122
public double computeValue(Set<Integer> geneSet, Set<Integer> sigSet, @Nullable SignatureGenesetSimilarity similarity) {
113123
return Sets.intersection(geneSet, sigSet).size();
114124
}
125+
126+
public String getDisplayString() {
127+
return "intersection size >= " + cutoff;
128+
}
115129
}
116130

117131

@@ -133,6 +147,10 @@ public double computeValue(Set<Integer> geneSet, Set<Integer> sigSet, @Nullable
133147
Set<Integer> intersection = Sets.intersection(geneSet, sigSet);
134148
return (double) intersection.size() / (double) sigSet.size();
135149
}
150+
151+
public String getDisplayString() {
152+
return "(intersection size)/(signature gene set size) >= " + (cutoff / 100.0);
153+
}
136154
}
137155

138156

@@ -177,20 +195,26 @@ public double computeValue(Set<Integer> geneSet, Set<Integer> sigSet, @Nullable
177195

178196
return hyperPval;
179197
}
198+
199+
public String getDisplayString() {
200+
return "universe size = " + u;
201+
}
180202
}
181203

182204

183205
class MannWhit extends BaseFilterMetric {
184206

207+
private final String rankingName;
185208
private final Ranking ranks;
186209
private final MannWhitneyMemoized mannWhitneyCache = new MannWhitneyMemoized();
187210

188211

189-
public MannWhit(double filter, Ranking ranks, PostAnalysisFilterType type) {
212+
public MannWhit(double filter, String rankingName, Ranking ranks, PostAnalysisFilterType type) {
190213
super(type, filter);
191214
if(!type.isMannWhitney())
192215
throw new IllegalArgumentException("FilterType is not Mann Whitney: " + type);
193216
this.ranks = ranks;
217+
this.rankingName = rankingName;
194218
}
195219

196220
public boolean passes(double value) {
@@ -246,6 +270,10 @@ public double computeValue(Set<Integer> geneSet, Set<Integer> sigSet, @Nullable
246270
}
247271
}
248272
}
273+
274+
public String getDisplayString() {
275+
return "ranks: " + rankingName;
276+
}
249277
}
250278

251279

0 commit comments

Comments
 (0)