use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap in project EnrichmentMapApp by BaderLab.
the class PostAnalysisPanelMediator method showDialog.
@SuppressWarnings("serial")
public void showDialog(Component parent, CyNetworkView netView) {
final EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
invokeOnEDT(() -> {
final PostAnalysisInputPanel panel = panelFactory.create(map);
final JDialog dialog = new JDialog(swingApplication.getJFrame(), "Add Signature Gene Sets", ModalityType.APPLICATION_MODAL);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
JButton helpButton = SwingUtil.createOnlineHelpButton(EnrichmentMapBuildProperties.USER_MANUAL_URL, "Online Manual...", serviceRegistrar);
JButton resetButton = new JButton("Reset");
resetButton.addActionListener(e -> panel.reset());
JButton closeButton = new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
JButton runButton = new JButton(new AbstractAction("Add") {
@Override
public void actionPerformed(ActionEvent e) {
if (panel.isReady()) {
Optional<PostAnalysisParameters> params = buildPostAnalysisParameters(panel, map, dialog);
if (params.isPresent()) {
addGeneSets(netView, params.get());
dialog.dispose();
} else {
JOptionPane.showMessageDialog(panel, "Could not run post analysis.", "EnrichmentMap: Error", JOptionPane.WARNING_MESSAGE);
}
}
}
});
JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(runButton, closeButton, helpButton, resetButton);
dialog.getContentPane().add(panel, BorderLayout.CENTER);
dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), runButton.getAction(), closeButton.getAction());
dialog.getRootPane().setDefaultButton(runButton);
dialog.pack();
dialog.setLocationRelativeTo(swingApplication.getJFrame());
dialog.setVisible(true);
});
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap 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.EnrichmentMap in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testGMTFileReader.
@Test
public void testGMTFileReader(Provider<EnrichmentMapParameters> empFactory) throws Exception {
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/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
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);
//set up task
GMTFileReaderTask task = new GMTFileReaderTask(dataset);
task.run(taskMonitor);
//test to make sure that the file loaded in 10 genesets with a total of 75 genes
assertEquals(10, map.getAllGeneSets().size());
assertEquals(75, map.getNumberOfGenes());
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap in project EnrichmentMapApp by BaderLab.
the class LoadBingoResultsTest method testLoadBingoResult_withoutexpression.
@Test
public void testLoadBingoResult_withoutexpression() throws Exception {
//for a dataset we require genesets, an expression file (optional), enrichment results
String testBingoResultsFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/bingo_output/12Hr_topgenes.bgo";
DataSetFiles files = new DataSetFiles();
files.setEnrichmentFileName1(testBingoResultsFileName);
//set the method to Bingo
double pvalue = 0.00005;
// 5.0 X 10-8
double qvaule = 0.00000005;
double similarityCutoff = 0.25;
EMCreationParameters params = new EMCreationParameters("EM1_", pvalue, qvaule, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, similarityCutoff, 0.5);
//create an new enrichment Map
EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.Specialized, files);
ParseBingoEnrichmentResults enrichmentResultsFilesTask = new ParseBingoEnrichmentResults(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 74 genesets
assertEquals(74, dataset.getSetOfGeneSets().getGeneSets().size());
//there should also be 74 enrichments (the genesets are built from the bgo file)
assertEquals(74, dataset.getEnrichments().getEnrichments().size());
//there should be 11 genesets in the enrichments of interest
assertEquals(5, dataset.getGeneSetsOfInterest().getGeneSets().size());
//there should be 6 edges
assertEquals(6, baton.supplier().get().size());
//there should be a total of 366 genes
assertEquals(446, em.getNumberOfGenes());
//there should be 43 genes in the geneset "nucleolus"
assertEquals(43, em.getAllGeneSets().get("NUCLEOLUS").getGenes().size());
//make sure the dummy expression has values for all the genes
assertEquals(446, dataset.getExpressionSets().getNumGenes());
assertEquals(446, dataset.getDataSetGenes().size());
}
use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap in project EnrichmentMapApp by BaderLab.
the class LoadDatasetTaskTest method testLoadDataset1GSEAResult_withexpression.
@Test
public void testLoadDataset1GSEAResult_withexpression() throws Exception {
//for a dataset we require genesets, an expression file (optional), enrichment results
String testGMTFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/gs_apop_mouse.gmt";
String testExpressionFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/Expressiontestfile.gct";
String testGSEAResults1FileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_enrichments1.xls";
String testGSEAResults2FileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_enrichments2.xls";
DataSetFiles files = new DataSetFiles();
files.setGMTFileName(testGMTFileName);
files.setExpressionFileName(testExpressionFileName);
files.setEnrichmentFileName1(testGSEAResults1FileName);
files.setEnrichmentFileName2(testGSEAResults2FileName);
EMCreationParameters params = new EMCreationParameters("EM1_", 0.1, 0.1, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, 0.1, 0.1);
//create an new enrichment Map
EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
//create a dataset
EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.Generic, files);
//load Data
GMTFileReaderTask task = new GMTFileReaderTask(dataset);
task.run(taskMonitor);
ParseGSEAEnrichmentResults enrichmentResultsFilesTask = new ParseGSEAEnrichmentResults(dataset);
enrichmentResultsFilesTask.run(taskMonitor);
//load expression file
ExpressionFileReaderTask exptask = new ExpressionFileReaderTask(dataset);
exptask.run(taskMonitor);
//check to see if the dataset loaded
assertEquals(193, dataset.getSetOfGeneSets().getGeneSets().size());
assertEquals(14, dataset.getEnrichments().getEnrichments().size());
assertEquals(41, dataset.getDataSetGenes().size());
assertEquals(41, dataset.getExpressionSets().getNumGenes());
}
Aggregations