use of org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory 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.task.CreateEnrichmentMapTaskFactory 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.task.CreateEnrichmentMapTaskFactory in project EnrichmentMapApp by BaderLab.
the class MasterDetailDialogPage method finish.
@Override
public void finish() {
if (!validateInput())
return;
String prefix = legacySupport.getNextAttributePrefix();
SimilarityMetric similarityMetric = cutoffPanel.getSimilarityMetric();
double pvalue = cutoffPanel.getPValue();
double qvalue = cutoffPanel.getQValue();
NESFilter nesFilter = cutoffPanel.getNESFilter();
double cutoff = cutoffPanel.getCutoff();
double combined = cutoffPanel.getCombinedConstant();
Optional<Integer> minExperiments = cutoffPanel.getMinimumExperiments();
EMCreationParameters params = new EMCreationParameters(prefix, pvalue, qvalue, nesFilter, minExperiments, similarityMetric, cutoff, combined);
params.setCreateDistinctEdges(distinctEdgesCheckbox.isSelected());
List<DataSetParameters> dataSets = dataSetListModel.toList().stream().map(DataSetListItem::getDetailPanel).map(DetailPanel::createDataSetParameters).filter(x -> x != null).collect(Collectors.toList());
// Overwrite all the expression files if the common file has been provided
String exprPath = commonPanel.getExpressionFile();
if (!isNullOrEmpty(exprPath)) {
for (DataSetParameters dsp : dataSets) {
dsp.getFiles().setExpressionFileName(exprPath);
}
}
// Overwrite all the gmt files if a common file has been provided
String gmtPath = commonPanel.getGmtFile();
if (!isNullOrEmpty(gmtPath)) {
for (DataSetParameters dsp : dataSets) {
dsp.getFiles().setGMTFileName(gmtPath);
}
}
CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(params, dataSets);
TaskIterator tasks = taskFactory.createTaskIterator();
// Close this dialog after the progress dialog finishes normally
tasks.append(new AbstractTask() {
public void run(TaskMonitor taskMonitor) {
callback.close();
}
});
dialogTaskManager.execute(tasks);
}
use of org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory in project EnrichmentMapApp by BaderLab.
the class EMGseaCommandTask method buildEnrichmentMap.
private void buildEnrichmentMap() {
//set all files as extracted from the edb directory
List<DataSetParameters> dataSets = new ArrayList<>(2);
DataSetFiles files1 = initializeFiles(edbdir, expressionfile);
dataSets.add(new DataSetParameters(LegacySupport.DATASET1, Method.GSEA, files1));
//only add second dataset if there is a second edb directory.
if (edbdir2 != null && !edbdir2.equalsIgnoreCase("")) {
DataSetFiles files2 = initializeFiles(edbdir2, expressionfile2);
dataSets.add(new DataSetParameters(LegacySupport.DATASET2, Method.GSEA, files2));
}
SimilarityMetric metric = EnrichmentMapParameters.stringToSimilarityMetric(similaritymetric.getSelectedValue());
String prefix = legacySupport.getNextAttributePrefix();
EMCreationParameters creationParams = new EMCreationParameters(prefix, pvalue, qvalue, NESFilter.ALL, Optional.empty(), metric, overlap, combinedconstant);
CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(creationParams, dataSets);
insertTasksAfterCurrentTask(taskFactory.createTaskIterator());
}
use of org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory in project EnrichmentMapApp by BaderLab.
the class ResolverCommandTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
logger.info("Running EnrichmentMap Data Set Resolver Task");
// Scan root folder (note: throws exception if no data sets were found)
ResolverTask resolverTask = new ResolverTask(rootFolder);
// blocks
taskManager.execute(new TaskIterator(resolverTask));
List<DataSetParameters> dataSets = resolverTask.getDataSetResults();
logger.info("resolved " + dataSets.size() + " data sets");
dataSets.forEach(params -> logger.info(params.toString()));
// Overwrite all the expression files if the common file has been provided
if (commonExpressionFile != null) {
if (!commonExpressionFile.canRead()) {
throw new IllegalArgumentException("Cannot read commonExpressionFile: " + commonExpressionFile);
}
for (DataSetParameters dsp : dataSets) {
dsp.getFiles().setExpressionFileName(commonExpressionFile.getAbsolutePath());
}
}
// Overwrite all the gmt files if a common file has been provided
if (commonGMTFile != null) {
if (!commonGMTFile.canRead()) {
throw new IllegalArgumentException("Cannot read commonGMTFile: " + commonGMTFile);
}
for (DataSetParameters dsp : dataSets) {
dsp.getFiles().setGMTFileName(commonGMTFile.getAbsolutePath());
}
}
// Create Enrichment Map
String prefix = legacySupport.getNextAttributePrefix();
SimilarityMetric sm = SimilarityMetric.valueOf(similarityMetric.getSelectedValue());
NESFilter nesf = NESFilter.valueOf(nesFilter.getSelectedValue());
String info = String.format("prefix:%s, pvalue:%f, qvalue:%f, nesFilter:%s, minExperiments:%d, similarityMetric:%s, similarityCutoff:%f, combinedConstant:%f", prefix, pvalue, qvalue, nesf, minExperiments, sm, similarityCutoff, combinedConstant);
logger.info(info);
EMCreationParameters params = new EMCreationParameters(prefix, pvalue, qvalue, nesf, Optional.ofNullable(minExperiments), sm, similarityCutoff, combinedConstant);
params.setCreateDistinctEdges(distinctEdges);
CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(params, dataSets);
TaskIterator tasks = taskFactory.createTaskIterator();
taskManager.execute(tasks);
logger.info("Done.");
}
Aggregations