Search in sources :

Example 11 with EnrichmentResult

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;
}
Also used : EnrichmentResult(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult) GSEAResult(org.baderlab.csplugins.enrichmentmap.model.GSEAResult) Set(java.util.Set) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) HashMap(java.util.HashMap) CyRow(org.cytoscape.model.CyRow) GenericResult(org.baderlab.csplugins.enrichmentmap.model.GenericResult) CyNode(org.cytoscape.model.CyNode) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 12 with EnrichmentResult

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);
}
Also used : EnrichmentResult(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult) GeneSet(org.baderlab.csplugins.enrichmentmap.model.GeneSet) SetOfEnrichmentResults(org.baderlab.csplugins.enrichmentmap.model.SetOfEnrichmentResults) GenericResult(org.baderlab.csplugins.enrichmentmap.model.GenericResult)

Example 13 with EnrichmentResult

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());
}
Also used : EnrichmentResult(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult) EnrichmentMapParameters(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) Test(org.junit.Test)

Example 14 with EnrichmentResult

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());
}
Also used : EnrichmentResult(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult) EnrichmentMapParameters(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) Test(org.junit.Test)

Example 15 with EnrichmentResult

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();
}
Also used : EnrichmentResult(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult) GSEAResult(org.baderlab.csplugins.enrichmentmap.model.GSEAResult)

Aggregations

EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)15 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)10 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)8 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)7 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)6 GenericResult (org.baderlab.csplugins.enrichmentmap.model.GenericResult)6 NullTaskMonitor (org.baderlab.csplugins.enrichmentmap.util.NullTaskMonitor)6 Test (org.junit.Test)6 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)5 EnrichmentMapParameters (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 GSEAResult (org.baderlab.csplugins.enrichmentmap.model.GSEAResult)4 SetOfEnrichmentResults (org.baderlab.csplugins.enrichmentmap.model.SetOfEnrichmentResults)3 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)2 Ranking (org.baderlab.csplugins.enrichmentmap.model.Ranking)2 CyRow (org.cytoscape.model.CyRow)2 HashMap (java.util.HashMap)1 Set (java.util.Set)1 BaseIntegrationTest (org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest)1 SessionFile (org.baderlab.csplugins.enrichmentmap.integration.SessionFile)1