示例#1
0
def createHeatmap(graph, distanceGraph, timePoint):
    if graph.getSubGraph("heatmap") != None:
        heatmap = graph.getSubGraph("heatmap")
        graph.delSubGraph(heatmap)

    heatmap = graph.addCloneSubGraph("heatmap")
    heatmap.clear()
    tlp.copyToGraph(heatmap, distanceGraph)

    expression_lvl = heatmap.getDoubleProperty("Expression_lvl")
    tps = heatmap.getDoubleProperty("Tps")
    Locus = heatmap.getStringProperty("Locus")
    groupesHeatmap = heatmap.getDoubleProperty('resultMetric1')
    groupes = distanceGraph.getDoubleProperty('resultMetric1')
    for n in heatmap.getEdges():
        heatmap.delEdge(n)
    nodesListe = []
    #for n in heatmap.getNodes():
    count = 0
    for n in heatmap.getNodes():
        count = count + 1
        nodesListe.append(n)
    for n in nodesListe:
        expression_lvl[n] = timePoint[0][n]
        tps[n] = 1
        addedNodes = heatmap.addNodes(17)
        tps = heatmap.getDoubleProperty("Tps")
        for m in range(len(addedNodes)):
            expression_lvl[addedNodes[m]] = timePoint[m][n]
            tps[addedNodes[m]] = m + 1
            Locus[addedNodes[m]] = Locus[n]
            groupesHeatmap[addedNodes[m]] = groupesHeatmap[n]
    for n in nodesListe:
        heatmap.delNode(n)
    return heatmap
def createCleanCopy(graph, graph_to_copy, copy_name):

    copy = graph.addCloneSubGraph(copy_name)
    copy.clear()

    tlp.copyToGraph(copy, graph_to_copy)
    return copy
 def import_from_query():
     """Use the query drawer plugin to draw the built query"""
     params = tlp.getDefaultPluginParameters("QueryDrawer")
     params['Query'] = query.get()
     params['URI'] = self.dataSet['URI']
     params["User name"] = self.dataSet["User name"]
     params["Password"] = self.dataSet["Password"]
     params["Directory path"] = self.dataSet["Directory path"]
     tlp.copyToGraph(self.graph, tlp.importGraph("QueryDrawer", params))
     root.destroy()
def reinitializeSubgraph(graph, name, clone_name="clone"):

    if graph.getSubGraph(name) is None:
        print("creation of {} subGraph".format(name))
        sub = graph.addCloneSubGraph(name)
    else:
        sub = graph.getSubGraph(name)

    sub.clear()
    clone = graph.getSubGraph(clone_name)
    tlp.copyToGraph(sub, clone)
    return sub
示例#5
0
def createSmallMultiples(g, timelapse):
    smallMultiples = g.addSubGraph("smallMultiples")
    list_node = []
    gInteract = g.getSubGraph("Genes interactions")
    for n in gInteract.getNodes():
        list_node.append(n)
    i = 1
    for lapse in timelapse:
        name = "tp " + str(i)
        tp = smallMultiples.addSubGraph(name)
        tlp.copyToGraph(tp, gInteract)
        metricTP = tp.getDoubleProperty("viewMetric")
        for node in tp.getNodes():
            metricTP[node] = lapse[node]
        i += 1
示例#6
0
def buildSmallMultiples(smallMultiplesTree, geneInteractions, timepoints,
                        metric):
    for i in range(1, len(timepoints) + 1):
        tp = smallMultiplesTree.addSubGraph("tp" + str(i) + " s")

        inGraph = graph.getSubGraph("Genes interactions")
        tlp.copyToGraph(tp, inGraph, inSelection=None, outSelection=None)

    for time in timepoints:
        for sg in smallMultiplesTree.getSubGraphs():
            metric = sg.getLocalDoubleProperty("viewMetric")
            for n in sg.getNodes():
                timePropertyName = str(time).split(" ")
                timeName = timePropertyName[2] + " s"
                #Check if the name of the graph (associated to one timepoint) is equal to the right timepoint property
                if (timeName == sg.getName()):
                    metric[n] = time[n]
示例#7
0
def createHeatmap(graph, distanceGraph, timePoint):
    '''
  Crée une Heatmap en fonction des niveaux d'expression des gènes.
  Dans ce sous-graphe, chaque gène est présent en 17 exemplaire, un par pas de temps.
  '''
    if graph.getSubGraph("heatmap") != None:
        heatmap = graph.getSubGraph("heatmap")
        graph.delSubGraph(heatmap)

    heatmap = graph.addCloneSubGraph("heatmap")
    heatmap.clear()
    tlp.copyToGraph(heatmap, distanceGraph)

    expression_lvl = heatmap.getDoubleProperty("Expression_lvl")
    tps = heatmap.getDoubleProperty("Tps")
    Locus = heatmap.getStringProperty("Locus")
    groupesHeatmap = heatmap.getDoubleProperty('cluster1')
    groupes = distanceGraph.getDoubleProperty('cluster1')
    for n in heatmap.getEdges():
        heatmap.delEdge(n)
    nodesListe = []
    count = 0
    for n in heatmap.getNodes():
        count = count + 1
        nodesListe.append(n)
    for n in nodesListe:
        expression_lvl[n] = timePoint[0][n]
        tps[n] = 1
        addedNodes = heatmap.addNodes(17)
        tps = heatmap.getDoubleProperty("Tps")
        for m in range(len(addedNodes)):
            expression_lvl[addedNodes[m]] = timePoint[m][n]
            tps[addedNodes[m]] = m + 1
            Locus[addedNodes[m]] = Locus[n]
            groupesHeatmap[addedNodes[m]] = groupesHeatmap[n]
    for n in nodesListe:
        heatmap.delNode(n)
    return heatmap
示例#8
0
def createHierarchy(smallMultGraph, interactGraph, rootGraph):
    """ Function to create a subgraphes hierarchy into the small multiple graph, which is a subragraph of the root graph. 

  Each subgraph of the small multiple graph represents the gene interaction graph at a specific time point. The values
  of this time point will be stored in the double property of the subgraph "viewMetric".

  Args:
    smallMultGraph (tlp.Graph) : the small multiple graph 
    interactGraph (tlp.Graph) : the gene interaction graph
    rootGraph (tlp.Graph) : the root graph of the project 

  Returns:
    None
  """
    listNodes = []
    for index in range(1, 18):
        tp_i = rootGraph.getLocalDoubleProperty("tp{} s".format(index))
        subCopyGraph = smallMultGraph.addSubGraph("tp{}".format(index))
        tlp.copyToGraph(subCopyGraph, interactGraph)
        metric = subCopyGraph.getLocalDoubleProperty("viewMetric")
        tp_i = rootGraph.getDoubleProperty("tp{} s".format(index))
        metric.copy(tp_i)
        colorSmallMultiples(subCopyGraph, metric)
示例#9
0
def draw_timePoint_hierarchy(TPs, SM, gene):
    """
  Add a Small Multiples subgraph for each time points with the genes interractions properties.
  
  Time points data are set in the viewMetric columns and defined the graph colors.
  
  @type   TPs: list 
  @param  TPs: the Time points name 
  @type    SM: Tulip graph
  @param   SM: Small Multiples subgraph
  @type  gene: Tulip graph
  @param gene: Genes interactions subgraph
  """
    viewColor = graph.getColorProperty("viewColor")
    for tp in TPs:
        tmp = SM.addSubGraph(tp)
        tlp.copyToGraph(tmp, gene)
        Metric = tmp.getDoubleProperty("viewMetric")
        pr = tmp.getDoubleProperty(tp)
        for n in tmp.getNodes():
            properties = tmp.getNodePropertiesValues(n)
            Metric[n] = properties[tp]
        color_graph(tmp, pr, viewColor)
示例#10
0
def main(graph):
    #

    if graph.getSubGraph("Clone") == None:
        clone = graph.addCloneSubGraph("Clone")
    else:
        clone = graph.getSubGraph("Clone")

    if graph.getSubGraph("Working") == None:
        working = graph.addCloneSubGraph("Working")
    else:
        working = graph.getSubGraph("Working")
        working.clear(
        )  #A commenter si le projet est déjà chargé et l'on souhaite éviter de tout relancer
        tlp.copyToGraph(
            working, clone
        )  #A commenter si le projet est déjà chargé et l'on souhaite éviter de tout relancer

    Locus = working.getStringProperty("Locus")
    Negative = working.getBooleanProperty("Negative")
    Positive = working.getBooleanProperty("Positive")
    tp1_s = working.getDoubleProperty("tp1 s")
    tp10_s = working.getDoubleProperty("tp10 s")
    tp11_s = working.getDoubleProperty("tp11 s")
    tp12_s = working.getDoubleProperty("tp12 s")
    tp13_s = working.getDoubleProperty("tp13 s")
    tp14_s = working.getDoubleProperty("tp14 s")
    tp15_s = working.getDoubleProperty("tp15 s")
    tp16_s = working.getDoubleProperty("tp16 s")
    tp17_s = working.getDoubleProperty("tp17 s")
    tp2_s = working.getDoubleProperty("tp2 s")
    tp3_s = working.getDoubleProperty("tp3 s")
    tp4_s = working.getDoubleProperty("tp4 s")
    tp5_s = working.getDoubleProperty("tp5 s")
    tp6_s = working.getDoubleProperty("tp6 s")
    tp7_s = working.getDoubleProperty("tp7 s")
    tp8_s = working.getDoubleProperty("tp8 s")
    tp9_s = working.getDoubleProperty("tp9 s")
    viewBorderColor = working.getColorProperty("viewBorderColor")
    viewBorderWidth = working.getDoubleProperty("viewBorderWidth")
    viewColor = working.getColorProperty("viewColor")
    viewFont = working.getStringProperty("viewFont")
    viewFontSize = working.getIntegerProperty("viewFontSize")
    viewIcon = working.getStringProperty("viewIcon")
    viewLabel = working.getStringProperty("viewLabel")
    viewLabelBorderColor = working.getColorProperty("viewLabelBorderColor")
    viewLabelBorderWidth = working.getDoubleProperty("viewLabelBorderWidth")
    viewLabelColor = working.getColorProperty("viewLabelColor")
    viewLabelPosition = working.getIntegerProperty("viewLabelPosition")
    viewLayout = working.getLayoutProperty("viewLayout")
    viewMetric = working.getDoubleProperty("viewMetric")
    viewRotation = working.getDoubleProperty("viewRotation")
    viewSelection = working.getBooleanProperty("viewSelection")
    viewShape = working.getIntegerProperty("viewShape")
    viewSize = working.getSizeProperty("viewSize")
    viewSrcAnchorShape = working.getIntegerProperty("viewSrcAnchorShape")
    viewSrcAnchorSize = working.getSizeProperty("viewSrcAnchorSize")
    viewTexture = working.getStringProperty("viewTexture")
    viewTgtAnchorShape = working.getIntegerProperty("viewTgtAnchorShape")
    viewTgtAnchorSize = working.getSizeProperty("viewTgtAnchorSize")
    timePoint = [
        tp1_s, tp2_s, tp3_s, tp4_s, tp5_s, tp6_s, tp7_s, tp8_s, tp9_s, tp10_s,
        tp11_s, tp12_s, tp13_s, tp14_s, tp15_s, tp16_s, tp17_s
    ]

    pretraitement(working, Locus, Negative, Positive, viewColor, viewLabel,
                  viewLayout, viewSize)
    applyModelForce(working, viewLayout)
    distanceGraph = createDistanceGraph(working)
    maxDepth = 3
    partitionnement(distanceGraph, maxDepth)
    heatmap = createHeatmap(working, distanceGraph, timePoint)
    #heatmap = working.getSubGraph("heatmap")
    colorHeatmap(heatmap)
    construireGrille(distanceGraph, heatmap)
    #clone=graph.getSubGraph("Clone")
    regulateurs = trouverRegulateur(clone)
    trouverRegule(clone, regulateurs)
    saveClusters(distanceGraph, 0.0)
    saveClusters(distanceGraph, 1.0)
示例#11
0
def main(graph):
    #
    if graph.getSubGraph("Clone") == None:
        clone = graph.addCloneSubGraph("Clone")
    else:
        clone = graph.getSubGraph("Clone")
    if graph.getSubGraph("Working") == None:
        working = graph.addCloneSubGraph("Working")
    else:
        working = graph.getSubGraph("Working")
        working.clear()
        tlp.copyToGraph(working, clone)


#  working = graph.getSubGraph("Working")

    Locus = working.getStringProperty("Locus")
    Negative = working.getBooleanProperty("Negative")
    Positive = working.getBooleanProperty("Positive")
    tp1_s = working.getDoubleProperty("tp1 s")
    tp10_s = working.getDoubleProperty("tp10 s")
    tp11_s = working.getDoubleProperty("tp11 s")
    tp12_s = working.getDoubleProperty("tp12 s")
    tp13_s = working.getDoubleProperty("tp13 s")
    tp14_s = working.getDoubleProperty("tp14 s")
    tp15_s = working.getDoubleProperty("tp15 s")
    tp16_s = working.getDoubleProperty("tp16 s")
    tp17_s = working.getDoubleProperty("tp17 s")
    tp2_s = working.getDoubleProperty("tp2 s")
    tp3_s = working.getDoubleProperty("tp3 s")
    tp4_s = working.getDoubleProperty("tp4 s")
    tp5_s = working.getDoubleProperty("tp5 s")
    tp6_s = working.getDoubleProperty("tp6 s")
    tp7_s = working.getDoubleProperty("tp7 s")
    tp8_s = working.getDoubleProperty("tp8 s")
    tp9_s = working.getDoubleProperty("tp9 s")
    viewBorderColor = working.getColorProperty("viewBorderColor")
    viewBorderWidth = working.getDoubleProperty("viewBorderWidth")
    viewColor = working.getColorProperty("viewColor")
    viewFont = working.getStringProperty("viewFont")
    viewFontSize = working.getIntegerProperty("viewFontSize")
    viewIcon = working.getStringProperty("viewIcon")
    viewLabel = working.getStringProperty("viewLabel")
    viewLabelBorderColor = working.getColorProperty("viewLabelBorderColor")
    viewLabelBorderWidth = working.getDoubleProperty("viewLabelBorderWidth")
    viewLabelColor = working.getColorProperty("viewLabelColor")
    viewLabelPosition = working.getIntegerProperty("viewLabelPosition")
    viewLayout = working.getLayoutProperty("viewLayout")
    viewMetric = working.getDoubleProperty("viewMetric")
    viewRotation = working.getDoubleProperty("viewRotation")
    viewSelection = working.getBooleanProperty("viewSelection")
    viewShape = working.getIntegerProperty("viewShape")
    viewSize = working.getSizeProperty("viewSize")
    viewSrcAnchorShape = working.getIntegerProperty("viewSrcAnchorShape")
    viewSrcAnchorSize = working.getSizeProperty("viewSrcAnchorSize")
    viewTexture = working.getStringProperty("viewTexture")
    viewTgtAnchorShape = working.getIntegerProperty("viewTgtAnchorShape")
    viewTgtAnchorSize = working.getSizeProperty("viewTgtAnchorSize")
    timePoint = [
        tp1_s, tp2_s, tp3_s, tp4_s, tp5_s, tp6_s, tp7_s, tp8_s, tp9_s, tp10_s,
        tp11_s, tp12_s, tp13_s, tp14_s, tp15_s, tp16_s, tp17_s
    ]
    '''
  count=0
  for i in working.getNodes():
    count=count+1
    if count >100:
      working.delNode(i)
  '''

    pretraitement(working, Locus, Negative, Positive, viewColor, viewLabel,
                  viewLayout, viewSize)
    applyModelForce(working, viewLayout)
    distanceGraph = createDistanceGraph(working)
    maxDepth = 3
    partitionnement(distanceGraph, maxDepth)
    heatmap = createHeatmap(working, distanceGraph, timePoint)
    #heatmap = working.getSubGraph("heatmap")
    colorHeatmap(heatmap)
    #  distanceGraph = working.getSubGraph("distanceGraph")
    #  heatmap = working.getSubGraph("heatmap")
    construireGrille(distanceGraph, heatmap, maxDepth)