Search in sources :

Example 6 with RankValue

use of org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue in project EnrichmentMapApp by BaderLab.

the class ClusterRankingOption method computeRanking.

@Override
public CompletableFuture<Optional<Map<Integer, RankValue>>> computeRanking(Collection<Integer> genes) {
    if (genes.size() < 2) {
        // The HierarchicalClusterTask requires at least 2 genes
        return CompletableFuture.completedFuture(Optional.of(Collections.emptyMap()));
    }
    HierarchicalClusterTask task = new HierarchicalClusterTask(map, genes, distance.getMetric());
    CompletableFuture<Optional<Map<Integer, RankValue>>> future = new CompletableFuture<>();
    taskManager.execute(new TaskIterator(task), new TaskObserver() {

        @Override
        public void taskFinished(ObservableTask task) {
            if (task instanceof HierarchicalClusterTask) {
                HierarchicalClusterTask clusterTask = (HierarchicalClusterTask) task;
                Optional<Map<Integer, RankValue>> ranking = clusterTask.getActualResults();
                future.complete(ranking);
            }
        }

        @Override
        public void allFinished(FinishStatus finishStatus) {
            // Don't see why this would ever happen
            if (!future.isDone()) {
                future.completeExceptionally(new RuntimeException("Failed"));
            }
        }
    });
    return future;
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) CompletableFuture(java.util.concurrent.CompletableFuture) TaskIterator(org.cytoscape.work.TaskIterator) Optional(java.util.Optional) FinishStatus(org.cytoscape.work.FinishStatus) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) HierarchicalClusterTask(org.baderlab.csplugins.enrichmentmap.task.cluster.HierarchicalClusterTask)

Aggregations

RankValue (org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue)6 HashMap (java.util.HashMap)3 Optional (java.util.Optional)3 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)2 GeneExpression (org.baderlab.csplugins.enrichmentmap.model.GeneExpression)2 Rank (org.baderlab.csplugins.enrichmentmap.model.Rank)2 Collection (java.util.Collection)1 List (java.util.List)1 AvgLinkHierarchicalClustering (org.baderlab.csplugins.brainlib.AvgLinkHierarchicalClustering)1 DistanceMatrix (org.baderlab.csplugins.brainlib.DistanceMatrix)1 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)1 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)1 GSEAResult (org.baderlab.csplugins.enrichmentmap.model.GSEAResult)1 GeneExpressionMatrix (org.baderlab.csplugins.enrichmentmap.model.GeneExpressionMatrix)1 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)1 Ranking (org.baderlab.csplugins.enrichmentmap.model.Ranking)1