use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testGenericFileReader_5columns.
@Test
public void testGenericFileReader_5columns(Provider<EnrichmentMapParameters> empFactory) throws Exception {
//load the test expression file
String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/generic_enr_5col.txt";
//create a new instance of the parameters
EnrichmentMapParameters params = empFactory.get();
//set enrichment results 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);
// check if empty
assertEquals(0, map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments().size());
// read
ParseGenericEnrichmentResults task = new ParseGenericEnrichmentResults(dataset);
task.run(taskMonitor);
Map<String, EnrichmentResult> results = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
// check we have 4 results
assertEquals(4, results.size());
// check pValues
assertEquals(0.01, ((GenericResult) results.get("GO:0000346")).getPvalue(), 0.0);
assertEquals(0.05, ((GenericResult) results.get("GO:0030904")).getPvalue(), 0.0);
assertEquals(0.05, ((GenericResult) results.get("GO:0008623")).getPvalue(), 0.0);
assertEquals(5.60E-42, ((GenericResult) results.get("GO:0046540")).getPvalue(), 0.0);
// check getFdrqvalues
assertEquals(0.02, ((GenericResult) results.get("GO:0000346")).getFdrqvalue(), 0.0);
assertEquals(0.10, ((GenericResult) results.get("GO:0030904")).getFdrqvalue(), 0.0);
assertEquals(0.12, ((GenericResult) results.get("GO:0008623")).getFdrqvalue(), 0.0);
assertEquals(0.03, ((GenericResult) results.get("GO:0046540")).getFdrqvalue(), 0.0);
// check phenotypes
assertEquals(1.0, ((GenericResult) results.get("GO:0000346")).getNES(), 0.0);
assertEquals(1.0, ((GenericResult) results.get("GO:0030904")).getNES(), 0.0);
assertEquals(-1.0, ((GenericResult) results.get("GO:0008623")).getNES(), 0.0);
assertEquals(-1.0, ((GenericResult) results.get("GO:0046540")).getNES(), 0.0);
return;
}
use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet in project EnrichmentMapApp by BaderLab.
the class FileReaderTest method testGSEAEDBEnrichmentsReader.
//test GSEA enrichment results reader
@Test
public void testGSEAEDBEnrichmentsReader(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/task/LoadDataset/GSEA_example_results/edb/results.edb";
//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);
ParseEDBEnrichmentResults task = new ParseEDBEnrichmentResults(dataset);
task.run(taskMonitor);
//Get the enrichment
Map<String, EnrichmentResult> enrichments = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
assertEquals(14, 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.2271, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getPvalue(), 0.0);
//check fdr value
assertEquals(0.2447, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getFdrqvalue(), 0.0);
//check ES value
assertEquals(0.7852, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getES(), 0.0);
//check NES
assertEquals(1.1793, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getNES(), 0.0);
//check ranks at max
assertEquals(6, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getRankAtMax());
//check size
assertEquals(2, ((GSEAResult) enrichments.get("PROTEASOME ACTIVATOR COMPLEX%GO%GO:0008537")).getGsSize());
// example from file 2 (EMBRYONIC HEART TUBE MORPHOGENESIS%GO%GO:0003143)
//check p-values
assertEquals(0.4545, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getPvalue(), 0.0);
//check fdr value
assertEquals(0.8650, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getFdrqvalue(), 0.0);
//check ES value
assertEquals(-0.4707, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getES(), 0.0);
//check NES
assertEquals(-0.9696, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getNES(), 0.0);
//check ranks at max
//The Rank at max in the edb file is different from the excel files. In the excel file that we have been
// using up until now they convert the rank as if you are counting from the bottom of the list but in the
//edb file they count from the top of the ranked list (going from positive to negative ES scores)
assertEquals(15, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getRankAtMax());
//check size
assertEquals(39, ((GSEAResult) enrichments.get("PROTEASOME COMPLEX%GO%GO:0000502")).getGsSize());
}
use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet in project EnrichmentMapApp by BaderLab.
the class BaseNetworkTest method runPostAnalysis.
protected void runPostAnalysis(CyNetwork emNetwork, PostAnalysisParameters.Builder builder, String dataSetName) throws Exception {
// Set up mocks
when(applicationManager.getCurrentNetwork()).thenReturn(emNetwork);
CyNetworkView networkViewMock = mock(CyNetworkView.class);
when(applicationManager.getCurrentNetworkView()).thenReturn(networkViewMock);
when(networkViewManager.getNetworkViews(emNetwork)).thenReturn(Arrays.asList(networkViewMock));
@SuppressWarnings("unchecked") View<CyNode> nodeViewMock = Mockito.mock(View.class);
when(networkViewMock.getNodeView(Matchers.<CyNode>anyObject())).thenReturn(nodeViewMock);
when(nodeViewMock.getVisualProperty(BasicVisualLexicon.NODE_Y_LOCATION)).thenReturn(Double.valueOf(0.0));
EnrichmentMap map = emManager.getEnrichmentMap(emNetwork.getSUID());
assertNotNull(map);
// Load the gene-sets from the file
SerialTestTaskManager testTaskManager = new SerialTestTaskManager();
File file = new File(builder.getSignatureGMTFileName());
LoadSignatureSetsActionListener loader = loadSignatureSetsActionListenerFactory.create(file, new FilterMetric.None(), map);
loader.setTaskManager(testTaskManager);
loader.setGeneSetCallback(builder::setLoadedGMTGeneSets);
loader.setFilteredSignatureSetsCallback(builder::addSelectedGeneSetNames);
loader.actionPerformed(null);
PostAnalysisParameters paParams = builder.build();
// Run post-analysis
EMDataSet dataSet = map.getDataSet(dataSetName);
CreateDiseaseSignatureTaskParallel signatureTask = buildDiseaseSignatureTaskFactory.create(paParams, map, Arrays.asList(dataSet));
testTaskManager = new SerialTestTaskManager();
testTaskManager.execute(new TaskIterator(signatureTask));
}
use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet in project EnrichmentMapApp by BaderLab.
the class LoadBingoResultsTest method testLoad2BingoResult_withoutexpression.
@Test
public void testLoad2BingoResult_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);
//for a dataset we require genesets, an expression file (optional), enrichment results
String testBingoResultsFileName2 = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/bingo_output/24Hr_topgenes.bgo";
DataSetFiles files2 = new DataSetFiles();
files2.setEnrichmentFileName1(testBingoResultsFileName2);
//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);
//Load second dataset
//create a dataset
EMDataSet dataset2 = em.createDataSet(LegacySupport.DATASET2, Method.Specialized, files2);
//create a DatasetTask
ParseBingoEnrichmentResults enrichmentResultsFiles2Task = new ParseBingoEnrichmentResults(dataset2);
enrichmentResultsFiles2Task.run(taskMonitor);
CreateDummyExpressionTask dummyExpressionTask = new CreateDummyExpressionTask(dataset);
dummyExpressionTask.run(taskMonitor);
CreateDummyExpressionTask dummyExpressionTask2 = new CreateDummyExpressionTask(dataset2);
dummyExpressionTask2.run(taskMonitor);
//check to see if the two datasets are distinct
if (!((dataset.getDataSetGenes().containsAll(dataset2.getDataSetGenes())) && (dataset2.getDataSetGenes().containsAll(dataset.getDataSetGenes()))))
em.setDistinctExpressionSets(true);
em.filterGenesets();
InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(em);
genesets_init.run(taskMonitor);
// ComputeSimilarityTask similarities = new ComputeSimilarityTask(em);
// similarities.run(taskMonitor);
dataset = em.getDataSet(LegacySupport.DATASET1);
//get the stats for the first dataset
//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 43 genes in the geneset "nucleolus"
assertEquals(43, dataset.getSetOfGeneSets().getGeneSets().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());
dataset2 = em.getDataSet(LegacySupport.DATASET2);
//check the stats for dataset2
//check to see if the dataset loaded - there should be 74 genesets
assertEquals(87, dataset2.getSetOfGeneSets().getGeneSets().size());
//there should also be 74 enrichments (the genesets are built from the bgo file)
assertEquals(87, dataset2.getEnrichments().getEnrichments().size());
//there should be 11 genesets in the enrichments of interest
assertEquals(2, dataset2.getGeneSetsOfInterest().getGeneSets().size());
//there should be 43 genes in the geneset "nucleolus"
assertEquals(318, dataset2.getSetOfGeneSets().getGeneSets().get("INTRACELLULAR").getGenes().size());
//make sure the dummy expression has values for all the genes
assertEquals(398, dataset2.getExpressionSets().getNumGenes());
assertEquals(398, dataset2.getDataSetGenes().size());
//there should be 20 edges (2 edges for every node because of the distinct expresison sets)
//assertEquals(24,em.getGenesetSimilarity().size());
//there should be a total of 366 genes
assertEquals(704, em.getNumberOfGenes());
}
use of org.baderlab.csplugins.enrichmentmap.model.EMDataSet in project EnrichmentMapApp by BaderLab.
the class LoadEdbDatasetTest method testEdbLoad.
@Test
public void testEdbLoad() throws Exception {
//for a dataset we require genesets, an expression file (optional), enrichment results
String testEdbResultsFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_example_results/edb/results.edb";
String testgmtFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_example_results/edb/gene_sets.gmt";
String testrnkFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_example_results/edb/Expressionfile.rnk";
DataSetFiles files = new DataSetFiles();
files.setEnrichmentFileName1(testEdbResultsFileName);
files.setGMTFileName(testgmtFileName);
files.setRankedFile(testrnkFileName);
//set the method to gsea
double similarityCutoff = 0.5;
double pvalue = 1.0;
double qvalue = 1.0;
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.GSEA, files);
//create a DatasetTask
//create a DatasetTask
//load Data
GMTFileReaderTask task = new GMTFileReaderTask(dataset);
task.run(taskMonitor);
ParseEDBEnrichmentResults enrichmentResultsFilesTask = new ParseEDBEnrichmentResults(dataset);
enrichmentResultsFilesTask.run(taskMonitor);
//create dummy expression
CreateDummyExpressionTask dummyExpressionTask = new CreateDummyExpressionTask(dataset);
dummyExpressionTask.run(taskMonitor);
em.filterGenesets();
InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(em);
genesets_init.run(taskMonitor);
//check to see if the dataset loaded
//although the original analysis had 193 genesets because this is loaded from
//edb version it only stores the genesets that overlapped with the dataset analyzed.
assertEquals(14, dataset.getSetOfGeneSets().getGeneSets().size());
assertEquals(14, dataset.getEnrichments().getEnrichments().size());
assertEquals(41, dataset.getDataSetGenes().size());
assertEquals(41, dataset.getExpressionSets().getNumGenes());
}
Aggregations