Skip to content

Commit b28846e

Browse files
committed
Set description properly for DAVID results. Fixes #380
1 parent 07aff93 commit b28846e

File tree

6 files changed

+57
-17
lines changed

6 files changed

+57
-17
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public static enum EdgeStrategy {
3737

3838
private GreatFilter greatFilter = GreatFilter.HYPER;
3939
private boolean fdr = false;
40+
private boolean david = false;
4041
private boolean emgmt = false;
4142
private double qvalueMin = 1.0;
4243
private double pvalueMin = 1.0;
@@ -171,6 +172,14 @@ public void setFDR(boolean fdr) {
171172
this.fdr = fdr;
172173
}
173174

175+
public void setDavid(boolean david) {
176+
this.david = david;
177+
}
178+
179+
public boolean isDavid() {
180+
return david;
181+
}
182+
174183
public boolean isEMgmt() {
175184
return emgmt;
176185
}
@@ -269,7 +278,7 @@ public String toString() {
269278
+ ", qValueColumnNames=" + qValueColumnNames + ", similarityCutoffColumnNames="
270279
+ similarityCutoffColumnNames + "]";
271280
}
272-
273-
281+
282+
274283

275284
}

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

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class GeneSet {
5959
private final Optional<String> simpleName;
6060
private final Optional<String> source;
6161
private final Optional<String> datasourceId;
62+
private final Optional<String> davidCategory;
6263

6364

6465
public GeneSet(String name, String description, Set<Integer> genes) {
@@ -67,6 +68,7 @@ public GeneSet(String name, String description, Set<Integer> genes) {
6768
this.genes = ImmutableSet.copyOf(genes);
6869
this.simpleName = Optional.empty();
6970
this.datasourceId = Optional.empty();
71+
this.davidCategory = Optional.empty();
7072

7173
// Baderlab geneset names
7274
String[] name_tokens = name.split("%");
@@ -76,20 +78,33 @@ public GeneSet(String name, String description, Set<Integer> genes) {
7678
this.source = Optional.empty();
7779
}
7880

79-
80-
GeneSet intersectionWith(Set<Integer> expressionGenes) {
81-
Set<Integer> intersection = new HashSet<>(genes);
82-
intersection.retainAll(expressionGenes);
83-
return new GeneSet(name, description, intersection, simpleName.orElse(null), source.orElse(null), datasourceId.orElse(null));
84-
}
85-
86-
public GeneSet(String name, String description, Set<Integer> genes, String simpleName, String datasource, String datasourceId) {
81+
private GeneSet(String name, String description, Set<Integer> genes,
82+
String simpleName, String datasource, String datasourceId, String davidCategory
83+
) {
8784
this.name = name;
8885
this.description = description;
8986
this.genes = ImmutableSet.copyOf(genes);
9087
this.simpleName = Optional.ofNullable(simpleName);
9188
this.source = Optional.ofNullable(datasource);
9289
this.datasourceId = Optional.ofNullable(datasourceId);
90+
this.davidCategory = Optional.ofNullable(davidCategory);
91+
}
92+
93+
94+
public static GeneSet createBaderLab(String name, String description, Set<Integer> genes, String simpleName, String datasource, String datasourceId) {
95+
return new GeneSet(name, description, genes, simpleName, datasource, datasourceId, null);
96+
}
97+
98+
public static GeneSet createDavid(String name, String description, Set<Integer> genes, String davidCategory) {
99+
return new GeneSet(name, description, genes, null, null, null, davidCategory);
100+
}
101+
102+
103+
protected GeneSet intersectionWith(Set<Integer> expressionGenes) {
104+
Set<Integer> intersection = new HashSet<>(genes);
105+
intersection.retainAll(expressionGenes);
106+
return new GeneSet(name, description, intersection,
107+
simpleName.orElse(null), source.orElse(null), datasourceId.orElse(null), davidCategory.orElse(null));
93108
}
94109

95110

@@ -117,6 +132,10 @@ public Optional<String> getSimpleName() {
117132
return simpleName;
118133
}
119134

135+
public Optional<String> getDavidCategory() {
136+
return davidCategory;
137+
}
138+
120139
public String getLabel() {
121140
if(simpleName.isPresent())
122141
return simpleName.get();

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/parsers/GMTFileReaderTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private GeneSet readBaderlabGeneSet(EnrichmentMap map, String line) {
191191
builder.add(hash);
192192
}
193193

194-
return new GeneSet(name, description, builder.build(), simpleName, datasource, id);
194+
return GeneSet.createBaderLab(name, description, builder.build(), simpleName, datasource, id);
195195
}
196196
return null;
197197
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/parsers/ParseDavidEnrichmentResults.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public void run(TaskMonitor taskMonitor) throws IOException {
7676
double FDRqvalue = 1.0;
7777
GenericResult result;
7878
int gs_size = 0;
79-
double NES = 1.0;
8079

8180
//The second column of the file is the name of the geneset
82-
final String name = tokens[1].toUpperCase().trim();
81+
String description = tokens[1].trim();
82+
String name = tokens[1].toUpperCase().trim();
8383

84-
//the first column of the file is the description
85-
final String description = tokens[0].toUpperCase();
84+
//the first column of the file is the category
85+
final String category = tokens[0].toUpperCase();
8686

8787
//when there are two different species it is possible that the gene set could
8888
//already exist in the set of genesets. if it does exist then add the genes
@@ -102,7 +102,7 @@ public void run(TaskMonitor taskMonitor) throws IOException {
102102

103103
//finished parsing that geneset
104104
//add the current geneset to the hashmap of genesets
105-
GeneSet gs = new GeneSet(name, description, builder.build());
105+
GeneSet gs = GeneSet.createDavid(name, description, builder.build(), category);
106106
genesets.put(name, gs);
107107

108108
//The 5th column is the nominal p-value
@@ -148,8 +148,11 @@ public void run(TaskMonitor taskMonitor) throws IOException {
148148
}
149149

150150
}
151-
if(FDR)
151+
152+
dataset.getMap().getParams().setDavid(true);
153+
if(FDR) {
152154
dataset.getMap().getParams().setFDR(FDR);
155+
}
153156
}
154157

155158
}

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/style/EMStyleBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public static class Columns {
7474
// Common attributes that apply to the entire network
7575
public static final ColumnDescriptor<String> NODE_NAME = new ColumnDescriptor<>("Name", String.class);
7676
public static final ColumnDescriptor<String> NODE_GS_DESCR = new ColumnDescriptor<>("GS_DESCR", String.class);
77+
public static final ColumnDescriptor<String> NODE_DAVID_CATEGORY = new ColumnDescriptor<>("david_category", String.class);
7778
public static final ColumnDescriptor<String> NODE_DATASOURCE = new ColumnDescriptor<>("GS_datasource", String.class);
7879
public static final ColumnDescriptor<String> NODE_DATASOURCEID = new ColumnDescriptor<>("GS_datasource_id", String.class);
7980
public static final ColumnDescriptor<String> NODE_GS_TYPE = new ColumnDescriptor<>("GS_Type", String.class);

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/task/CreateEMNetworkTask.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ private Map<String, CyNode> createNodes(CyNetwork network) {
137137
Columns.NODE_DATASOURCEID.set(row, prefix, null, geneSet.getDatasourceId().get());
138138
}
139139
}
140+
if(map.getParams().isDavid()) {
141+
if(geneSet.getDavidCategory().isPresent()) {
142+
Columns.NODE_DAVID_CATEGORY.set(row, prefix, null, geneSet.getDavidCategory().get());
143+
}
144+
}
140145
}
141146

142147
Columns.NODE_GS_TYPE.set(row, prefix, null, Columns.NODE_GS_TYPE_ENRICHMENT);
@@ -223,6 +228,9 @@ private CyTable createNodeColumns(CyNetwork network) {
223228
Columns.NODE_DATASOURCE.createColumn(table, prefix, null);
224229
Columns.NODE_DATASOURCEID.createColumn(table, prefix, null);
225230
}
231+
if(params.isDavid()) {
232+
Columns.NODE_DAVID_CATEGORY.createColumn(table, prefix, null);
233+
}
226234

227235
for (EMDataSet dataset : map.getDataSetList()) {
228236
Columns.NODE_PVALUE.createColumn(table, prefix, dataset);

0 commit comments

Comments
 (0)