src/scBONITA/singleCell.py
def processERS_minimalRule(self, equivsName):
        """Create an individual from the ERS generated by the local search, for importance score calculation"""
        ersFile = open(str(equivsName), "rb")
        ers = pickle.load(ersFile)
        ersFile.close()
        individual = []
        for i in range(len(ers)):
            ruleSet = ers[i]
            numOrRules = [sum(ruleSet[j]) for j in range(len(ruleSet))]
            deciderVar = max(numOrRules)  # maximal or rules
            maxOrRules = ruleSet[
                numOrRules.index(deciderVar)
            ]  # rules with maximum or terms
            maxUpstreamNodes = 0
            minimalRule = []
            for orRule in [maxOrRules]:
                if sum(orRule) > 0:
                    numUpstreamNodes = [
                        self.andNodeList[i][orTerm]
                        for orTerm in range(len(orRule))
                        if orRule[orTerm] == 1
                    ]
                else:
                    minimalRule = orRule
                    continue
                numUpstreamNodes = [len(element) for element in numUpstreamNodes]
                numUpstreamNodes = sum(numUpstreamNodes)
                if numUpstreamNodes > maxUpstreamNodes:
                    maxUpstreamNodes = numUpstreamNodes
                    minimalRule = orRule
                else:
                    maxUpstreamNodes = maxUpstreamNodes
                    minimalRule = minimalRule
            individual.extend(minimalRule)
        return individual
Create an individual from the ERS generated by the local search, for importance score calculation
Create an individual from the ERS generated by the local search, for importance score calculation
Create an individual from the ERS generated by the local search for importance score calculation
def processERS_minimalRule(self, equivsName):
        ersFile = open(str(equivsName), "rb")
        ers = pickle.load(ersFile)
        ersFile.close()
        individual = []
        for i in range(len(ers)):
            ruleSet = ers[i]
            numOrRules = [sum(ruleSet[j]) for j in range(len(ruleSet))]
            deciderVar = max(numOrRules)  
            maxOrRules = ruleSet[
                numOrRules.index(deciderVar)
            ]  
            maxUpstreamNodes = 0
            minimalRule = []
            for orRule in [maxOrRules]:
                if sum(orRule) > 0:
                    numUpstreamNodes = [
                        self.andNodeList[i][orTerm]
                        for orTerm in range(len(orRule))
                        if orRule[orTerm] == 1
                    ]
                else:
                    minimalRule = orRule
                    continue
                numUpstreamNodes = [len(element) for element in numUpstreamNodes]
                numUpstreamNodes = sum(numUpstreamNodes)
                if numUpstreamNodes > maxUpstreamNodes:
                    maxUpstreamNodes = numUpstreamNodes
                    minimalRule = orRule
                else:
                    maxUpstreamNodes = maxUpstreamNodes
                    minimalRule = minimalRule
            individual.extend(minimalRule)
        return individual
def processERS_minimalRule ( self , equivsName ) : ersFile = open ( str ( equivsName ) , "rb" ) ers = pickle . load ( ersFile ) ersFile . close ( ) individual = [ ] for i in range ( len ( ers ) ) : ruleSet = ers [ i ] numOrRules = [ sum ( ruleSet [ j ] ) for j in range ( len ( ruleSet ) ) ] deciderVar = max ( numOrRules ) maxOrRules = ruleSet [ numOrRules . index ( deciderVar ) ] maxUpstreamNodes = 0 minimalRule = [ ] for orRule in [ maxOrRules ] : if sum ( orRule ) > 0 : numUpstreamNodes = [ self . andNodeList [ i ] [ orTerm ] for orTerm in range ( len ( orRule ) ) if orRule [ orTerm ] == 1 ] else : minimalRule = orRule continue numUpstreamNodes = [ len ( element ) for element in numUpstreamNodes ] numUpstreamNodes = sum ( numUpstreamNodes ) if numUpstreamNodes > maxUpstreamNodes : maxUpstreamNodes = numUpstreamNodes minimalRule = orRule else : maxUpstreamNodes = maxUpstreamNodes minimalRule = minimalRule individual . extend ( minimalRule ) return individual
Create an individual from the ERS generated by the local search, for importance score calculation
Create an individual from the ERS generated by the local search for importance score calculation
"""Create an individual from the ERS generated by the local search, for importance score calculation""" # maximal or rules # rules with maximum or terms
self
equivsName