src/scBONITA/singleCell.py
def ProcessLocalSearchOutput(self, graph, graphName):
        """
        Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.

        Parameters:
            graphName: name of the graphml file originally provided for rule inference

        Returns:
            A Pandas DataFrame with the following columns:
            'Node': name of the node in the network
            'In_degree': in-degree in the processed network
            'Out_degree': out-degree in the processed network
            'Equivs_len'
            'Graph': the provided graphName
            'Number_of_Nodes': number of nodes in 'graph'
            'importanceScore': the importance score of each node in 'graph' as calculated by scBONITA
            'AvgLocalError': the average error of the local search in scBONITA-RD.
            'plainEquivs': the rules/equivalent rule set from the local search, in human-readable format
            'bitstringEquivs': the rules/equivalent rule set from the local search, in bitstring format - this is the internal representation of rules in scBONITA and may be ignored by users
            'minimalRules': the minimal rule set (minimizing the number of )

        """

        equivs = graphName + "_processed.graphml_equivs1.pickle"
        print(Path(graphName), Path(equivs))
        if (
            Path(graphName).is_file()
            and Path(equivs).is_file()
            and Path(graphName + "_processed.graphml_importanceScores.csv").is_file()
        ):

            errorsName = glob.glob(str(graphName) + "*_localErrors1.pickle")[0]
            localErrors = pickle.load(open(errorsName, "rb"))

            self._singleCell__inherit(
                graph, removeSelfEdges=False, restrictIncomingEdges=False
            )
            equivs = pickle.load(
                open(graphName + "_processed.graphml_equivs1.pickle", "rb")
            )

            equivs = [tuple(equivs[i]) for i in range(0, len(equivs))]
            # print(equivs)
            equivs_len = [len(equivs[i]) for i in range(0, len(equivs))]

            nodeList = list(self.nodeList)
            minimalRules = self.processERS_minimalRule(
                graphName + "_processed.graphml_equivs1.pickle"
            )
            plainEquivs = {}
            bitstringEquivs = {}
            minimalRulesNodes = {}
            for node in range(0, len(nodeList)):
                plainRules = []
                ers = equivs[node]
                for rule in ers:
                    plainRules.append(
                        self._ruleMaker__writeNode(
                            self.nodeList.index(self.nodeList[node]), rule, self
                        )
                    )
                plainEquivs[nodeList[node]] = set(plainRules)
                bitstringEquivs[nodeList[node]] = set(
                    tuple(ers[i]) for i in range(0, len(ers))
                )
                minimalRulesNodes[nodeList[node]] = self._ruleMaker__writeNode(
                    node,
                    minimalRules[
                        self.individualParse[node] : self.individualParse[node + 1]
                    ],
                    self,
                )
            in_degree = [graph.in_degree(node) for node in nodeList]
            out_degree = [graph.out_degree(node) for node in nodeList]
            # inOutRatio = [
            #    float(inDeg + 1) / (outDeg + 1)
            #    for inDeg, outDeg in zip(in_degree, out_degree)
            # ]
            # Get importance score
            importanceScoreDF = pd.read_csv(
                graphName + "_processed.graphml_importanceScores.csv"
            )
            importanceScoreDict = {}
            for n in list(importanceScoreDF["Node"]):
                temp = importanceScoreDF[importanceScoreDF.Node.isin({n})]
                importanceScoreDict[n] = list(temp["Importance Score"])[0]
            tempdf = pd.DataFrame(
                list(zip(nodeList, in_degree, out_degree, equivs_len)),
                columns=["Node", "In_degree", "Out_degree", "Equivs_len"],
            )
            tempdf["Graph"] = graphName
            tempdf["Number_of_Nodes"] = str(len(nodeList))
            tempdf["importanceScore"] = tempdf["Node"].map(importanceScoreDict)
            tempdf["AvgLocalError"] = localErrors
            tempdf["plainEquivs"] = tempdf["Node"].map(plainEquivs)
            tempdf["bitstringEquivs"] = tempdf["Node"].map(bitstringEquivs)
            tempdf["minimalRules"] = tempdf["Node"].map(minimalRulesNodes)
            return tempdf

        Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.

        Parameters:
            graphName: name of the graphml file originally provided for rule inference

        Returns:
            A Pandas DataFrame with the following columns:
            'Node': name of the node in the network
            'In_degree': in-degree in the processed network
            'Out_degree': out-degree in the processed network
            'Equivs_len'
            'Graph': the provided graphName
            'Number_of_Nodes': number of nodes in 'graph'
            'importanceScore': the importance score of each node in 'graph' as calculated by scBONITA
            'AvgLocalError': the average error of the local search in scBONITA-RD.
            'plainEquivs': the rules/equivalent rule set from the local search, in human-readable format
            'bitstringEquivs': the rules/equivalent rule set from the local search, in bitstring format - this is the internal representation of rules in scBONITA and may be ignored by users
            'minimalRules': the minimal rule set (minimizing the number of )

        
Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.
Processes the output of the local search component of scBONITA and returns a text file containing plain - text Boolean rules in the ERS and other information such as in - degree and out - degree for each node in the network .
def ProcessLocalSearchOutput(self, graph, graphName):
        equivs = graphName + "_processed.graphml_equivs1.pickle"
        print(Path(graphName), Path(equivs))
        if (
            Path(graphName).is_file()
            and Path(equivs).is_file()
            and Path(graphName + "_processed.graphml_importanceScores.csv").is_file()
        ):
            errorsName = glob.glob(str(graphName) + "*_localErrors1.pickle")[0]
            localErrors = pickle.load(open(errorsName, "rb"))
            self._singleCell__inherit(
                graph, removeSelfEdges=False, restrictIncomingEdges=False
            )
            equivs = pickle.load(
                open(graphName + "_processed.graphml_equivs1.pickle", "rb")
            )
            equivs = [tuple(equivs[i]) for i in range(0, len(equivs))]
            equivs_len = [len(equivs[i]) for i in range(0, len(equivs))]
            nodeList = list(self.nodeList)
            minimalRules = self.processERS_minimalRule(
                graphName + "_processed.graphml_equivs1.pickle"
            )
            plainEquivs = {}
            bitstringEquivs = {}
            minimalRulesNodes = {}
            for node in range(0, len(nodeList)):
                plainRules = []
                ers = equivs[node]
                for rule in ers:
                    plainRules.append(
                        self._ruleMaker__writeNode(
                            self.nodeList.index(self.nodeList[node]), rule, self
                        )
                    )
                plainEquivs[nodeList[node]] = set(plainRules)
                bitstringEquivs[nodeList[node]] = set(
                    tuple(ers[i]) for i in range(0, len(ers))
                )
                minimalRulesNodes[nodeList[node]] = self._ruleMaker__writeNode(
                    node,
                    minimalRules[
                        self.individualParse[node] : self.individualParse[node + 1]
                    ],
                    self,
                )
            in_degree = [graph.in_degree(node) for node in nodeList]
            out_degree = [graph.out_degree(node) for node in nodeList]
            importanceScoreDF = pd.read_csv(
                graphName + "_processed.graphml_importanceScores.csv"
            )
            importanceScoreDict = {}
            for n in list(importanceScoreDF["Node"]):
                temp = importanceScoreDF[importanceScoreDF.Node.isin({n})]
                importanceScoreDict[n] = list(temp["Importance Score"])[0]
            tempdf = pd.DataFrame(
                list(zip(nodeList, in_degree, out_degree, equivs_len)),
                columns=["Node", "In_degree", "Out_degree", "Equivs_len"],
            )
            tempdf["Graph"] = graphName
            tempdf["Number_of_Nodes"] = str(len(nodeList))
            tempdf["importanceScore"] = tempdf["Node"].map(importanceScoreDict)
            tempdf["AvgLocalError"] = localErrors
            tempdf["plainEquivs"] = tempdf["Node"].map(plainEquivs)
            tempdf["bitstringEquivs"] = tempdf["Node"].map(bitstringEquivs)
            tempdf["minimalRules"] = tempdf["Node"].map(minimalRulesNodes)
            return tempdf
def ProcessLocalSearchOutput ( self , graph , graphName ) : equivs = graphName + "_processed.graphml_equivs1.pickle" print ( Path ( graphName ) , Path ( equivs ) ) if ( Path ( graphName ) . is_file ( ) and Path ( equivs ) . is_file ( ) and Path ( graphName + "_processed.graphml_importanceScores.csv" ) . is_file ( ) ) : errorsName = glob . glob ( str ( graphName ) + "*_localErrors1.pickle" ) [ 0 ] localErrors = pickle . load ( open ( errorsName , "rb" ) ) self . _singleCell__inherit ( graph , removeSelfEdges = False , restrictIncomingEdges = False ) equivs = pickle . load ( open ( graphName + "_processed.graphml_equivs1.pickle" , "rb" ) ) equivs = [ tuple ( equivs [ i ] ) for i in range ( 0 , len ( equivs ) ) ] equivs_len = [ len ( equivs [ i ] ) for i in range ( 0 , len ( equivs ) ) ] nodeList = list ( self . nodeList ) minimalRules = self . processERS_minimalRule ( graphName + "_processed.graphml_equivs1.pickle" ) plainEquivs = { } bitstringEquivs = { } minimalRulesNodes = { } for node in range ( 0 , len ( nodeList ) ) : plainRules = [ ] ers = equivs [ node ] for rule in ers : plainRules . append ( self . _ruleMaker__writeNode ( self . nodeList . index ( self . nodeList [ node ] ) , rule , self ) ) plainEquivs [ nodeList [ node ] ] = set ( plainRules ) bitstringEquivs [ nodeList [ node ] ] = set ( tuple ( ers [ i ] ) for i in range ( 0 , len ( ers ) ) ) minimalRulesNodes [ nodeList [ node ] ] = self . _ruleMaker__writeNode ( node , minimalRules [ self . individualParse [ node ] : self . individualParse [ node + 1 ] ] , self , ) in_degree = [ graph . in_degree ( node ) for node in nodeList ] out_degree = [ graph . out_degree ( node ) for node in nodeList ] importanceScoreDF = pd . read_csv ( graphName + "_processed.graphml_importanceScores.csv" ) importanceScoreDict = { } for n in list ( importanceScoreDF [ "Node" ] ) : temp = importanceScoreDF [ importanceScoreDF . Node . isin ( { n } ) ] importanceScoreDict [ n ] = list ( temp [ "Importance Score" ] ) [ 0 ] tempdf = pd . DataFrame ( list ( zip ( nodeList , in_degree , out_degree , equivs_len ) ) , columns = [ "Node" , "In_degree" , "Out_degree" , "Equivs_len" ] , ) tempdf [ "Graph" ] = graphName tempdf [ "Number_of_Nodes" ] = str ( len ( nodeList ) ) tempdf [ "importanceScore" ] = tempdf [ "Node" ] . map ( importanceScoreDict ) tempdf [ "AvgLocalError" ] = localErrors tempdf [ "plainEquivs" ] = tempdf [ "Node" ] . map ( plainEquivs ) tempdf [ "bitstringEquivs" ] = tempdf [ "Node" ] . map ( bitstringEquivs ) tempdf [ "minimalRules" ] = tempdf [ "Node" ] . map ( minimalRulesNodes ) return tempdf
Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.
Processes the output of the local search component of scBONITA and returns a text file containing plain - text Boolean rules in the ERS and other information such as in - degree and out - degree for each node in the network .
"""
        Processes the output of the local search component of scBONITA and returns a text file containing plain-text Boolean rules in the ERS, and other information such as in-degree and out-degree for each node in the network.

        Parameters:
            graphName: name of the graphml file originally provided for rule inference

        Returns:
            A Pandas DataFrame with the following columns:
            'Node': name of the node in the network
            'In_degree': in-degree in the processed network
            'Out_degree': out-degree in the processed network
            'Equivs_len'
            'Graph': the provided graphName
            'Number_of_Nodes': number of nodes in 'graph'
            'importanceScore': the importance score of each node in 'graph' as calculated by scBONITA
            'AvgLocalError': the average error of the local search in scBONITA-RD.
            'plainEquivs': the rules/equivalent rule set from the local search, in human-readable format
            'bitstringEquivs': the rules/equivalent rule set from the local search, in bitstring format - this is the internal representation of rules in scBONITA and may be ignored by users
            'minimalRules': the minimal rule set (minimizing the number of )

        """ # print(equivs) # inOutRatio = [ #    float(inDeg + 1) / (outDeg + 1) #    for inDeg, outDeg in zip(in_degree, out_degree) # ] # Get importance score
A Pandas DataFrame with the following columns:
'Node': name of the node in the network
'In_degree': in-degree in the processed network
'Out_degree': out-degree in the processed network
'Equivs_len'
'Graph': the provided graphName
'Number_of_Nodes': number of nodes in 'graph'
'importanceScore': the importance score of each node in 'graph' as calculated by scBONITA
'AvgLocalError': the average error of the local search in scBONITA-RD.
'plainEquivs': the rules/equivalent rule set from the local search, in human-readable format
'bitstringEquivs': the rules/equivalent rule set from the local search, in bitstring format - this is the internal representation of rules in scBONITA and may be ignored by users
'minimalRules': the minimal rule set (minimizing the number of )
A Pandas DataFrame with the following columns : ' Node ' : name of the node in the network ' In_degree ' : in - degree in the processed network ' Out_degree ' : out - degree in the processed network ' Equivs_len ' ' Graph ' : the provided graphName ' Number_of_Nodes ' : number of nodes in ' graph ' ' importanceScore ' : the importance score of each node in ' graph ' as calculated by scBONITA ' AvgLocalError ' : the average error of the local search in scBONITA - RD . ' plainEquivs ' : the rules / equivalent rule set from the local search in human - readable format ' bitstringEquivs ' : the rules / equivalent rule set from the local search in bitstring format - this is the internal representation of rules in scBONITA and may be ignored by users ' minimalRules ' : the minimal rule set ( minimizing the number of )
self
graph
graphName
name of the graphml file originally provided for rule inference
name of the graphml file originally provided for rule inference