use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.
the class EMBuildCommandTask method buildEnrichmentMap.
/**
* buildEnrichmentMap - parses all GSEA input files and creates an enrichment map
*/
public void buildEnrichmentMap() {
// Note we must continue to use the old constants from EnrichmentMapParameters for backwards compatibility
Method method = EnrichmentMapParameters.stringToMethod(analysisType.getSelectedValue());
SimilarityMetric metric = EnrichmentMapParameters.stringToSimilarityMetric(coeffecients.getSelectedValue());
//Set Dataset1 Files
DataSetFiles dataset1files = new DataSetFiles();
if (gmtFile != null)
dataset1files.setGMTFileName(gmtFile.getAbsolutePath());
if (expressionDataset1 != null)
dataset1files.setExpressionFileName(expressionDataset1.getAbsolutePath());
if (enrichmentsDataset1 != null)
dataset1files.setEnrichmentFileName1(enrichmentsDataset1.getAbsolutePath());
if (enrichments2Dataset1 != null)
dataset1files.setEnrichmentFileName2(enrichments2Dataset1.getAbsolutePath());
if (ranksDataset1 != null)
dataset1files.setRankedFile(ranksDataset1.getAbsolutePath());
if (classDataset1 != null)
dataset1files.setClassFile(classDataset1.getAbsolutePath());
if (phenotype1Dataset1 != null)
dataset1files.setPhenotype1(phenotype1Dataset1);
if (phenotype2Dataset1 != null)
dataset1files.setPhenotype2(phenotype2Dataset1);
//Set Dataset2 Files
DataSetFiles dataset2files = new DataSetFiles();
if (expressionDataset2 != null)
dataset2files.setExpressionFileName(expressionDataset2.getAbsolutePath());
if (enrichmentsDataset2 != null)
dataset2files.setEnrichmentFileName1(enrichmentsDataset2.getAbsolutePath());
if (enrichments2Dataset2 != null)
dataset2files.setEnrichmentFileName2(enrichments2Dataset2.getAbsolutePath());
if (ranksDataset2 != null)
dataset2files.setRankedFile(ranksDataset2.getAbsolutePath());
if (classDataset2 != null)
dataset2files.setClassFile(classDataset2.getAbsolutePath());
if (phenotype1Dataset2 != null)
dataset2files.setPhenotype1(phenotype1Dataset2);
if (phenotype2Dataset2 != null)
dataset2files.setPhenotype2(phenotype2Dataset2);
List<DataSetParameters> dataSets = new ArrayList<>(2);
dataSets.add(new DataSetParameters(LegacySupport.DATASET1, method, dataset1files));
if (!dataset2files.isEmpty()) {
dataSets.add(new DataSetParameters(LegacySupport.DATASET2, method, dataset2files));
}
String prefix = legacySupport.getNextAttributePrefix();
EMCreationParameters creationParams = new EMCreationParameters(prefix, pvalue, qvalue, NESFilter.ALL, Optional.empty(), metric, similaritycutoff, propertyManager.getDefaultCombinedConstant());
if (distinctEdges != null)
creationParams.setCreateDistinctEdges(distinctEdges);
else if (!dataset2files.isEmpty())
creationParams.setCreateDistinctEdges(true);
CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(creationParams, dataSets);
insertTasksAfterCurrentTask(taskFactory.createTaskIterator());
}
use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.
the class BaseNetworkTest method buildEnrichmentMap.
protected void buildEnrichmentMap(EMCreationParameters params, DataSetFiles datasetFiles, Method method, String datasetName) {
List<DataSetParameters> dataSets = Arrays.asList(new DataSetParameters(datasetName, method, datasetFiles));
CreateEnrichmentMapTaskFactory taskFactory = masterMapTaskFactoryFactory.create(params, dataSets);
TaskIterator taskIterator = taskFactory.createTaskIterator();
// make sure the task iterator completes
TaskObserver observer = new TaskObserver() {
public void taskFinished(ObservableTask task) {
}
public void allFinished(FinishStatus finishStatus) {
if (finishStatus == null)
fail();
if (finishStatus.getType() != FinishStatus.Type.SUCCEEDED)
throw new AssertionError("TaskIterator Failed", finishStatus.getException());
}
};
SerialTestTaskManager testTaskManager = new SerialTestTaskManager();
testTaskManager.ignoreTask(CreateEMViewTask.class);
testTaskManager.execute(taskIterator, observer);
}
use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.
the class CreateEnrichmentMapTaskTest method buildEnrichmentMap.
protected void buildEnrichmentMap(EMCreationParameters params, DataSetFiles datasetFiles, String datasetName) {
List<DataSetParameters> dataSets = Arrays.asList(new DataSetParameters(datasetName, Method.Generic, datasetFiles));
CreateEnrichmentMapTaskFactory.Factory masterMapTaskFactoryFactory = injector.getInstance(CreateEnrichmentMapTaskFactory.Factory.class);
CreateEnrichmentMapTaskFactory taskFactory = masterMapTaskFactoryFactory.create(params, dataSets);
TaskIterator taskIterator = taskFactory.createTaskIterator();
SerialTestTaskManager taskManager = new SerialTestTaskManager();
taskManager.execute(taskIterator);
}
use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.
the class CreateEnrichmentMapTaskFactory method createTaskIterator.
@Override
public TaskIterator createTaskIterator() {
TaskIterator tasks = new TaskIterator();
if (dataSets.isEmpty())
return tasks;
tasks.append(new TitleTask("Building EnrichmentMap"));
EnrichmentMap map = new EnrichmentMap(params, serviceRegistrar);
for (DataSetParameters dataSetParameters : dataSets) {
String datasetName = dataSetParameters.getName();
Method method = dataSetParameters.getMethod();
DataSetFiles files = dataSetParameters.getFiles();
EMDataSet dataset = map.createDataSet(datasetName, method, files);
// Load GMT File
if (!Strings.isNullOrEmpty(dataset.getSetOfGeneSets().getFilename())) {
tasks.append(new GMTFileReaderTask(dataset));
}
// Load the enrichments
tasks.append(new DetermineEnrichmentResultFileReader(dataset).getParsers());
// If there is no expression file then create a dummy file to associate with this dataset so we can still use the expression viewer (heat map)
if (Strings.isNullOrEmpty(dataset.getDataSetFiles().getExpressionFileName())) {
tasks.append(new CreateDummyExpressionTask(dataset));
} else {
tasks.append(new ExpressionFileReaderTask(dataset));
}
// Load ranks if present
String ranksName = dataset.getMethod() == Method.GSEA ? Ranking.GSEARanking : datasetName;
if (dataset.getExpressionSets().getRanksByName(ranksName) != null) {
String filename = dataset.getExpressionSets().getRanksByName(ranksName).getFilename();
tasks.append(new RanksFileReaderTask(filename, dataset, ranksName, false));
}
if (!Strings.isNullOrEmpty(dataset.getDataSetFiles().getClassFile())) {
tasks.append(new ClassFileReaderTask(dataset));
}
}
// NOTE: First filter out genesets that don't pass the thresholds,
// Then filter the remaining genesets of interest to only contain genes from the expression file.
// Filter out genesets that don't pass the p-value and q-value thresholds
InitializeGenesetsOfInterestTask genesetsTask = new InitializeGenesetsOfInterestTask(map);
// genesetsTask.setThrowIfMissing(false); // TEMPORARY
tasks.append(genesetsTask);
// Trim the genesets to only contain the genes that are in the data file.
tasks.append(new FilterGenesetsByDatasetGenes(map));
// Link the ComputeSimilarityTask to the MasterMapNetworkTask by a "pipe"
Baton<Map<SimilarityKey, GenesetSimilarity>> pipe = new Baton<>();
// Compute the geneset similarities
tasks.append(new ComputeSimilarityTaskParallel(map, pipe.consumer()));
// Create the network
tasks.append(createEMNetworkTaskFactory.create(map, pipe.supplier()));
// Create style and layout
if (!headless) {
tasks.append(createEMViewTaskFactory.create(map));
}
return tasks;
}
use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.
the class EditDataSetPanel method createDataSetParameters.
@Override
public DataSetParameters createDataSetParameters() {
String name = nameText.getText().trim();
Method method = getMethod();
DataSetFiles files = new DataSetFiles();
if (!enrichments1Text.isEmpty())
files.setEnrichmentFileName1(enrichments1Text.getText());
if (!enrichments2Text.isEmpty() && method == Method.GSEA)
files.setEnrichmentFileName2(enrichments2Text.getText());
if (!expressionsText.isEmpty())
files.setExpressionFileName(expressionsText.getText());
if (!gmtText.isEmpty())
files.setGMTFileName(gmtText.getText());
if (!ranksText.isEmpty())
files.setRankedFile(ranksText.getText());
if (!classesText.isEmpty())
files.setClassFile(classesText.getText());
String positive = positiveText.getText();
String negative = negativeText.getText();
if (!isNullOrEmpty(positive) && !isNullOrEmpty(negative) && classes != null) {
files.setPhenotype1(positive);
files.setPhenotype2(negative);
files.setTemp_class1(classes);
}
return new DataSetParameters(name, method, files);
}
Aggregations