Search in sources :

Example 41 with EMDataSet

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

the class LoadDavidResultTest method testLoadDavidResult_withoutexpression.

@Test
public void testLoadDavidResult_withoutexpression() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testDavidResultsFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/david_output/12hr_David_Output.txt";
    DataSetFiles files = new DataSetFiles();
    files.setEnrichmentFileName1(testDavidResultsFileName);
    //set the method to David
    double similarityCutoff = 0.25;
    double pvalue = 0.005;
    // 5.0 X 10-3
    double qvalue = 0.005;
    EMCreationParameters params = new EMCreationParameters("EM1_", pvalue, qvalue, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, similarityCutoff, 0.5);
    //create an new enrichment Map
    EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
    //Load data set
    //create a dataset
    EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.Specialized, files);
    //create a DatasetTask
    ParseDavidEnrichmentResults enrichmentResultsFilesTask = new ParseDavidEnrichmentResults(dataset);
    enrichmentResultsFilesTask.run(taskMonitor);
    CreateDummyExpressionTask dummyExpressionTask = new CreateDummyExpressionTask(dataset);
    dummyExpressionTask.run(taskMonitor);
    em.filterGenesets();
    InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(em);
    genesets_init.run(taskMonitor);
    Baton<Map<SimilarityKey, GenesetSimilarity>> baton = new Baton<>();
    ComputeSimilarityTaskParallel similarities = new ComputeSimilarityTaskParallel(em, baton.consumer());
    similarities.run(taskMonitor);
    //check to see if the dataset loaded - there should be 215 genesets
    assertEquals(215, dataset.getSetOfGeneSets().getGeneSets().size());
    //there should also be 215 enrichments (the genesets are built from the txt file)
    assertEquals(215, dataset.getEnrichments().getEnrichments().size());
    //there should be 7 genesets in the enrichments of interest
    assertEquals(7, dataset.getGeneSetsOfInterest().getGeneSets().size());
    //there should be 7 * 6 edges
    assertEquals(11, baton.supplier().get().size());
    //there should be a total of 366 genes
    assertEquals(414, em.getNumberOfGenes());
    //there should be 43 genes in the geneset "nucleolus"
    assertEquals(114, em.getAllGeneSets().get("ACETYLATION").getGenes().size());
    //make sure the dummy expression has values for all the genes
    assertEquals(414, dataset.getExpressionSets().getNumGenes());
    assertEquals(414, dataset.getDataSetGenes().size());
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) Baton(org.baderlab.csplugins.enrichmentmap.util.Baton) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Map(java.util.Map) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) ParseDavidEnrichmentResults(org.baderlab.csplugins.enrichmentmap.parsers.ParseDavidEnrichmentResults) Test(org.junit.Test)

Example 42 with EMDataSet

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

the class FileReaderTest method testExpression1ReaderNormal.

@Test
public void testExpression1ReaderNormal(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test expression file
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/Expressiontestfile.gct";
    //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);
    //in order to load expression data the genes have to be registered with the application
    //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(59, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
    assertEquals(0.008720342, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 0.0);
    assertEquals(5.131481026, 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 43 with EMDataSet

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

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

the class FileReaderTest method testExpression1ReaderCommentLines.

@Test
public void testExpression1ReaderCommentLines(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test expression file
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/Expressiontestfile_comments.gct";
    //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(5.131481026, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMaxExpression(), 0.0);
    assertEquals(4, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumGenes());
    assertEquals(59, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
    assertEquals(0.008720342, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 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 45 with EMDataSet

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

the class ControlPanelMediator method createChart.

public CyCustomGraphics2<?> createChart(EMStyleOptions options) {
    CyCustomGraphics2<?> chart = null;
    ChartOptions chartOptions = options.getChartOptions();
    ChartData data = chartOptions != null ? chartOptions.getData() : null;
    if (data != null && data != ChartData.NONE) {
        // Ignore Signature Data Sets in charts
        Set<EMDataSet> dataSets = filterDataSets(options.getDataSets());
        if (dataSets.size() > 1) {
            ColumnDescriptor<Double> columnDescriptor = data.getColumnDescriptor();
            List<CyColumnIdentifier> columns = ChartUtil.getSortedColumnIdentifiers(options.getAttributePrefix(), dataSets, columnDescriptor, columnIdFactory);
            ChartType type = chartOptions.getType();
            Map<String, Object> props = new HashMap<>(type.getProperties());
            props.put("cy_dataColumns", columns);
            List<Double> range = ChartUtil.calculateGlobalRange(options.getNetworkView().getModel(), columns);
            props.put("cy_range", range);
            props.put("cy_autoRange", false);
            props.put("cy_globalRange", true);
            props.put("cy_showItemLabels", chartOptions.isShowLabels());
            props.put("cy_colors", chartOptions.getColorScheme().getColors());
            try {
                CyCustomGraphics2Factory<?> factory = chartFactoryManager.getChartFactory(type.getId());
                if (factory != null)
                    chart = factory.getInstance(props);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    return chart;
}
Also used : ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) HashMap(java.util.HashMap) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions)

Aggregations

EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)58 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)30 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)20 Test (org.junit.Test)19 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)13 EnrichmentMapParameters (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters)11 Map (java.util.Map)10 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)10 Set (java.util.Set)8 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)8 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)7 CyNode (org.cytoscape.model.CyNode)7 JPanel (javax.swing.JPanel)6 Inject (com.google.inject.Inject)5 Color (java.awt.Color)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 JLabel (javax.swing.JLabel)5 CyEdge (org.cytoscape.model.CyEdge)5 CyNetwork (org.cytoscape.model.CyNetwork)5