Search in sources :

Example 6 with EMSignatureDataSet

use of org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet in project EnrichmentMapApp by BaderLab.

the class CreateDiseaseSignatureNetworkTask method run.

/**
	 * This task is NOT cancellable.
	 */
@Override
public void run(TaskMonitor tm) {
    tm.setTitle("Post Analysis Geneset Similarities...");
    CyNetwork network = networkManager.getNetwork(map.getNetworkID());
    CyNetworkView networkView = getNetworKView(network);
    taskResult.setNetwork(network);
    taskResult.setNetworkView(networkView);
    // Gene universe is all enrichment genes in the map
    Set<Integer> geneUniverse = map.getAllEnrichmentGenes();
    String prefix = params.getAttributePrefix();
    //get the node attribute and edge attribute tables
    tm.setStatusMessage("Creating Columns");
    CyTable edgeTable = createEdgeColumns(network, "", prefix);
    CyTable nodeTable = createNodeColumns(network, "", prefix);
    tm.setProgress(0.1);
    tm.setStatusMessage("Caching Nodes");
    existingEdgeCache = createExistingEdgeCache(prefix, network, edgeTable);
    tm.setProgress(0.2);
    EMSignatureDataSet sigDataSet = createSignatureDataSet();
    // Create Signature Hub Nodes
    tm.setStatusMessage("Creating Nodes");
    signatureGeneSets.forEach(sigDataSet.getGeneSetsOfInterest()::addGeneSet);
    signatureGeneSets.forEach((hubName, sigGeneSet) -> createHubNode(hubName, network, networkView, prefix, edgeTable, nodeTable, geneUniverse, sigGeneSet, sigDataSet));
    tm.setProgress(0.3);
    // Layout nodes
    tm.setStatusMessage("Laying out Nodes");
    layoutHubNodes(networkView);
    tm.setProgress(0.4);
    // Create Signature Hub Edges
    tm.setStatusMessage("Creating Edges");
    DiscreteTaskMonitor dtm = new DiscreteTaskMonitor(tm, geneSetSimilarities.size(), 0.4, 0.9);
    dtm.setStatusMessageTemplate("Similarity {0} of {1}");
    for (SimilarityKey similarityKey : geneSetSimilarities.keySet()) {
        boolean passedCutoff = passesCutoff(similarityKey, sigDataSet);
        createEdge(similarityKey, network, networkView, prefix, edgeTable, nodeTable, passedCutoff, sigDataSet);
        dtm.inc();
    }
    // Set edge widths
    tm.setStatusMessage("Setting Edge Widths");
    widthFunctionProvider.get().setEdgeWidths(network, prefix, tm);
    tm.setProgress(1.0);
    // Add the new data set to the map
    map.addSignatureDataSet(sigDataSet);
}
Also used : CyTable(org.cytoscape.model.CyTable) DiscreteTaskMonitor(org.baderlab.csplugins.enrichmentmap.util.DiscreteTaskMonitor) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) CyNetwork(org.cytoscape.model.CyNetwork) SimilarityKey(org.baderlab.csplugins.enrichmentmap.model.SimilarityKey) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Aggregations

EMSignatureDataSet (org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet)6 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)3 CyNetwork (org.cytoscape.model.CyNetwork)3 Inject (com.google.inject.Inject)2 List (java.util.List)2 AbstractDataSet (org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet)2 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)2 CyEdge (org.cytoscape.model.CyEdge)2 CyNode (org.cytoscape.model.CyNode)2 CyNetworkView (org.cytoscape.view.model.CyNetworkView)2 Color (java.awt.Color)1 Paint (java.awt.Paint)1 File (java.io.File)1 InputStream (java.io.InputStream)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Optional (java.util.Optional)1