use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult in project EnrichmentMapApp by BaderLab.
the class CreateEMNetworkTask method createNodes.
private Map<String, CyNode> createNodes(CyNetwork network) {
Map<String, CyNode> nodes = new HashMap<>();
Map<String, Set<Integer>> geneSets = map.unionAllGeneSetsOfInterest();
for (String genesetName : geneSets.keySet()) {
CyNode node = network.addNode();
nodes.put(genesetName, node);
// Set common attributes
CyRow row = network.getRow(node);
row.set(CyNetwork.NAME, genesetName);
Columns.NODE_FORMATTED_NAME.set(row, prefix, null, formatLabel(genesetName));
// MKTODO why is this column needed?
Columns.NODE_NAME.set(row, prefix, null, genesetName);
Columns.NODE_GS_DESCR.set(row, prefix, null, map.findGeneSetDescription(genesetName));
Columns.NODE_GS_TYPE.set(row, prefix, null, Columns.NODE_GS_TYPE_ENRICHMENT);
Set<Integer> geneIds = geneSets.get(genesetName);
List<String> genes = geneIds.stream().map(map::getGeneFromHashKey).collect(Collectors.toList());
Columns.NODE_GENES.set(row, prefix, null, genes);
Columns.NODE_GS_SIZE.set(row, prefix, null, genes.size());
// Set attributes specific to each dataset
for (EMDataSet ds : map.getDataSetList()) {
if (ds.getGeneSetsOfInterest().getGeneSets().containsKey(genesetName))
ds.addNodeSuid(node.getSUID());
Map<String, EnrichmentResult> enrichmentResults = ds.getEnrichments().getEnrichments();
EnrichmentResult result = enrichmentResults.get(genesetName);
// if result is null it will fail both instanceof checks
if (result instanceof GSEAResult)
setGSEAResultNodeAttributes(row, ds.getName(), (GSEAResult) result);
else if (result instanceof GenericResult)
setGenericResultNodeAttributes(row, ds.getName(), (GenericResult) result);
}
}
return nodes;
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult in project EnrichmentMapApp by BaderLab.
the class CreateGMTEnrichmentMapTask method buildEnrichmentMap.
public void buildEnrichmentMap() {
dataset.setMethod(Method.Generic);
// in this case all the genesets are of interest
dataset.setGeneSetsOfInterest(dataset.getSetOfGeneSets());
Map<String, GeneSet> currentSets = dataset.getSetOfGeneSets().getGeneSets();
// create an new Set of Enrichment Results
SetOfEnrichmentResults setOfEnrichments = new SetOfEnrichmentResults();
Map<String, EnrichmentResult> currentEnrichments = setOfEnrichments.getEnrichments();
// need also to put all genesets into enrichment results
for (Iterator<String> i = currentSets.keySet().iterator(); i.hasNext(); ) {
String geneset1Name = i.next();
GeneSet gs = currentSets.get(geneset1Name);
GenericResult tempResult = new GenericResult(gs.getName(), gs.getDescription(), 0.01, gs.getGenes().size());
currentEnrichments.put(gs.getName(), tempResult);
}
dataset.setEnrichments(setOfEnrichments);
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testDavidEnrichmentsReader.
//test David enrichment results reader
@Test
public void testDavidEnrichmentsReader(Provider<EnrichmentMapParameters> empFactory) throws Exception {
//load the test enrichment files - Bingo
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/DavidResults.txt";
//create a new instance of the parameters
EnrichmentMapParameters params = empFactory.get();
//set enrichment file name
params.getFiles().get(LegacySupport.DATASET1).setEnrichmentFileName1(testDataFileName);
//Create a new Enrichment map
EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
//get the default dataset
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
ParseDavidEnrichmentResults task = new ParseDavidEnrichmentResults(dataset);
task.run(taskMonitor);
//Get the enrichment
Map<String, EnrichmentResult> enrichments = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
assertEquals(215, enrichments.size());
//check p-values
assertEquals(0.00000005210169741980237, ((GenericResult) enrichments.get("GO:0031974~MEMBRANE-ENCLOSED LUMEN")).getPvalue(), 0.0);
//check fdr value
assertEquals(0.000016724505445320226, ((GenericResult) enrichments.get("GO:0031974~MEMBRANE-ENCLOSED LUMEN")).getFdrqvalue(), 0.0);
//check geneset siz
assertEquals(95, ((GenericResult) enrichments.get("GO:0031974~MEMBRANE-ENCLOSED LUMEN")).getGsSize());
//check p-values
assertEquals(0.0009179741851709047, ((GenericResult) enrichments.get(((String) "domain:Leucine-zipper").toUpperCase())).getPvalue(), 0.0);
//check fdr value
assertEquals(0.46717397126592464, ((GenericResult) enrichments.get(((String) "domain:Leucine-zipper").toUpperCase())).getFdrqvalue(), 0.0);
//check geneset siz
assertEquals(11, ((GenericResult) enrichments.get(((String) "domain:Leucine-zipper").toUpperCase())).getGsSize());
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testBingoEnrichmentsReader.
//test Bingo enrichment results
@Test
public void testBingoEnrichmentsReader(Provider<EnrichmentMapParameters> empFactory) throws Exception {
//load the test enrichment files - Bingo
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/BingoResults.bgo";
//create a new instance of the parameters
EnrichmentMapParameters params = empFactory.get();
//set enrichment file name
params.getFiles().get(LegacySupport.DATASET1).setEnrichmentFileName1(testDataFileName);
//Create a new Enrichment map
EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
//get the default dataset
Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
ParseBingoEnrichmentResults task = new ParseBingoEnrichmentResults(dataset);
task.run(taskMonitor);
//Get the enrichment
Map<String, EnrichmentResult> enrichments = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
assertEquals(74, enrichments.size());
//check p-values
assertEquals(0.0010354, ((GenericResult) enrichments.get("NUCLEOLAR PART")).getPvalue(), 0.0);
//check fdr value
assertEquals(0.047796, ((GenericResult) enrichments.get("NUCLEOLAR PART")).getFdrqvalue(), 0.0);
//check geneset siz
assertEquals(5, ((GenericResult) enrichments.get("NUCLEOLAR PART")).getGsSize());
//check p-values
assertEquals(0.0000000000016209, ((GenericResult) enrichments.get("NUCLEOLUS")).getPvalue(), 0.0);
//check fdr value
assertEquals(0.0000000042203, ((GenericResult) enrichments.get("NUCLEOLUS")).getFdrqvalue(), 0.0);
//check geneset siz
assertEquals(43, ((GenericResult) enrichments.get("NUCLEOLUS")).getGsSize());
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult in project EnrichmentMapApp by BaderLab.
the class GSEALeadingEdgeRankingOption method initializeLeadingEdge.
/**
* Collates the current selected nodes genes to represent the expression of
* the genes that are in all the selected nodes. and sets the expression
* sets (both if there are two datasets)
*/
private void initializeLeadingEdge() {
Map<String, EnrichmentResult> results = dataset.getEnrichments().getEnrichments();
GSEAResult result = (GSEAResult) results.get(geneSetName);
scoreAtMax = result.getScoreAtMax();
if (scoreAtMax == DetermineEnrichmentResultFileReader.DefaultScoreAtMax) {
scoreAtMax = result.getNES();
}
rankAtMax = result.getRankAtMax();
}
Aggregations