Search in sources :

Example 6 with Method

use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method in project EnrichmentMapApp by BaderLab.

the class SetOfGenesetsTest method before.

@Before
public void before(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load Genesets from the gmt file associated with this test
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/model/Genesetstestfile.gmt";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set gmt file name 
    params.getFiles().get(LegacySupport.DATASET1).setGMTFileName(testDataFileName);
    //Create a new Enrichment map
    map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
    Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
    DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
    dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
    //set up task
    GMTFileReaderTask task = new GMTFileReaderTask(dataset);
    task.run(taskMonitor);
}
Also used : Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) GMTFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask) Before(org.junit.Before)

Example 7 with Method

use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method in project EnrichmentMapApp by BaderLab.

the class FileReaderTest method testExpression1ReaderRnk.

@Test
public void testExpression1ReaderRnk(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test expression file
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/ExpressionTestFile.rnk";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set expression file name 
    params.getFiles().get(LegacySupport.DATASET1).setExpressionFileName(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);
    //make sure that the genes are empty
    assertEquals(0, map.getNumberOfGenes());
    //add the gene to the master list of genes
    map.addGene("GLS");
    map.addGene("PSMA1");
    map.addGene("ZP1");
    map.addGene("ZYX");
    //make sure all four genes have been associated
    assertEquals(4, map.getNumberOfGenes());
    //load expression file
    ExpressionFileReaderTask task = new ExpressionFileReaderTask(dataset);
    task.run(taskMonitor);
    //There was one more gene in the expression file that wasn't in the set of genes
    //make sure it was was added
    assertEquals(4, map.getNumberOfGenes());
    assertEquals(4, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumGenes());
    assertEquals(3, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
    assertEquals(0.47536945, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 0.0);
    assertEquals(0.5418719, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMaxExpression(), 0.0);
}
Also used : 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 8 with Method

use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method in project EnrichmentMapApp by BaderLab.

the class FileReaderTest method testExpression1ReaderEDBRnk.

@Test
public void testExpression1ReaderEDBRnk(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test expression file
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/ExpressionTestFile_edbrnk.rnk";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set gmt file name 
    params.getFiles().get(LegacySupport.DATASET1).setExpressionFileName(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);
    //make sure that the genes are empty
    assertEquals(0, map.getNumberOfGenes());
    //add the gene to the master list of genes
    map.addGene("GLS");
    map.addGene("PSMA1");
    map.addGene("ZP1");
    map.addGene("ZYX");
    //make sure all four genes have been associated
    assertEquals(4, map.getNumberOfGenes());
    //load expression file
    ExpressionFileReaderTask task = new ExpressionFileReaderTask(dataset);
    task.run(taskMonitor);
    //There was one more gene in the expression file that wasn't in the set of genes
    //make sure it was was added
    assertEquals(4, map.getNumberOfGenes());
    assertEquals(4, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumGenes());
    assertEquals(3, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
    assertEquals(0.47536945, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 0.0);
    assertEquals(0.5418719, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMaxExpression(), 0.0);
}
Also used : 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 9 with Method

use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method in project EnrichmentMapApp by BaderLab.

the class FileReaderTest method testGSEAEnrichmentsReader.

//test GSEA enrichment results reader
@Test
public void testGSEAEnrichmentsReader(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test enrichment files - GSEA creates two enrichment results files.
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/GSEA_enrichments1.xls";
    String testDataFileName2 = "src/test/resources/org/baderlab/csplugins/enrichmentmap/GSEA_enrichments2.xls";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set enrichment file name 
    params.getFiles().get(LegacySupport.DATASET1).setEnrichmentFileName1(testDataFileName);
    params.getFiles().get(LegacySupport.DATASET1).setEnrichmentFileName2(testDataFileName2);
    //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);
    ParseGSEAEnrichmentResults task = new ParseGSEAEnrichmentResults(dataset);
    task.run(taskMonitor);
    //Get the enrichment
    Map<String, EnrichmentResult> enrichments = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
    assertEquals(40, enrichments.size());
    //Check the contents of some of the genesets
    // example from file 1 (ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612)
    //check p-values
    assertEquals(0.0, ((GSEAResult) enrichments.get("ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612")).getPvalue(), 0.0);
    //check fdr value
    assertEquals(0.086938426, ((GSEAResult) enrichments.get("ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612")).getFdrqvalue(), 0.0);
    //check ES value
    assertEquals(0.6854155, ((GSEAResult) enrichments.get("ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612")).getES(), 0.0);
    //check NES
    assertEquals(2.1194055, ((GSEAResult) enrichments.get("ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612")).getNES(), 0.0);
    //check ranks at max
    assertEquals(836, ((GSEAResult) enrichments.get("ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612")).getRankAtMax());
    //check size
    assertEquals(27, ((GSEAResult) enrichments.get("ANTIGEN PROCESSING AND PRESENTATION%KEGG%HSA04612")).getGsSize());
    // example from file 2 (EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143)
    //check p-values
    assertEquals(0.040152963, ((GSEAResult) enrichments.get("EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143")).getPvalue(), 0.0);
    //check fdr value
    assertEquals(1.0, ((GSEAResult) enrichments.get("EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143")).getFdrqvalue(), 0.0);
    //check ES value
    assertEquals(-0.49066687, ((GSEAResult) enrichments.get("EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143")).getES(), 0.0);
    //check NES
    assertEquals(-1.477554, ((GSEAResult) enrichments.get("EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143")).getNES(), 0.0);
    //check ranks at max
    assertEquals(1597, ((GSEAResult) enrichments.get("EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143")).getRankAtMax());
    //check size
    assertEquals(17, ((GSEAResult) enrichments.get("EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143")).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 10 with Method

use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method 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)

Aggregations

Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)16 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)14 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)12 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)12 EnrichmentMapParameters (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters)11 Test (org.junit.Test)10 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)5 GMTFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask)3 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)3 Map (java.util.Map)2 ExpressionFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.ExpressionFileReaderTask)2 Inject (com.google.inject.Inject)1 File (java.io.File)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1