PEATSA/Core/Classify.py
def intraGroupDependance(self, matrix, group, featureFinder, allFeatures, responseVariable):
    
        '''Compares the error of entries in matrix that have features in groups
        
        Params:
            matrix - The samples - Each sample is a mutation with a value for the responseVariabe
            group - A list of features e.g. residue positions, substitutions. This is a subset of allFeatures
            featureFinder - A method that when past a feature will return a list of entries in matrix with that feature
            allFeatures - The complete list of features (which group is a subset of)
        '''
            
    
        features = group[0]
        print 'Group - %s' % features
        
        if len(features) == 0:
            print 'Only one feature in group - cannot perform intra-group dependence'
            return
        
        print '%10s\t%10s\t%10s\t%10s' % ('Feature One', 'Feature Two', 'Samples', 'Mean')
        #Iterate over the group features
        for feature in features:
            #Get all data that has that feature
            data = getattr(matrix, featureFinder)([feature])
            for featureTwo in features:
                if featureTwo == feature:
                    continue
                    
                #Get the data that has both features
                submatrix = getattr(data, featureFinder)([featureTwo])
                if submatrix is not None:
                    error = [abs(el) for el in submatrix.columnWithHeader(responseVariable)]
                    meanError = reduce(operator.add, error)/float(len(error))
                    print '%10s\t%10s\t%10d\t%10.3lf' % (feature, featureTwo, len(error), meanError)
    
            #Now find mean of mutants with this mutation but NO other systematic mutation
            check = []
            check.extend(features)
            check.pop(check.index(feature))
            subset = [code for code in allFeatures if code not in check]
    
            submatrix = getattr(matrix, featureFinder)([feature], matchMode='All')
            submatrix = getattr(submatrix, featureFinder)(subset, matchMode='Exclusive')
            if submatrix is not None:
                error = [abs(el) for el in submatrix.columnWithHeader(responseVariable)]
                meanError = reduce(operator.add, error)/float(len(error))
                print '%10s\t%10s\t%10d\t%10.3lf' % (feature, 'Extra-Group', len(error), meanError)
Compares the error of entries in matrix that have features in groups
        
        Params:
            matrix - The samples - Each sample is a mutation with a value for the responseVariabe
            group - A list of features e.g. residue positions, substitutions. This is a subset of allFeatures
            featureFinder - A method that when past a feature will return a list of entries in matrix with that feature
            allFeatures - The complete list of features (which group is a subset of)
        
Compares the error of entries in matrix that have features in groups
Params:
matrix - The samples - Each sample is a mutation with a value for the responseVariabe
group - A list of features e.g. residue positions, substitutions. This is a subset of allFeatures
featureFinder - A method that when past a feature will return a list of entries in matrix with that feature
allFeatures - The complete list of features (which group is a subset of)
Compares the error of entries in matrix that have features in groups Params : matrix - The samples - Each sample is a mutation with a value for the responseVariabe group - A list of features e . g . residue positions substitutions . This is a subset of allFeatures featureFinder - A method that when past a feature will return a list of entries in matrix with that feature allFeatures - The complete list of features ( which group is a subset of )
def intraGroupDependance(self, matrix, group, featureFinder, allFeatures, responseVariable):
        features = group[0]
        print 'Group - %s' % features
        if len(features) == 0:
            print 'Only one feature in group - cannot perform intra-group dependence'
            return
        print '%10s\t%10s\t%10s\t%10s' % ('Feature One', 'Feature Two', 'Samples', 'Mean')
        for feature in features:
            data = getattr(matrix, featureFinder)([feature])
            for featureTwo in features:
                if featureTwo == feature:
                    continue
                submatrix = getattr(data, featureFinder)([featureTwo])
                if submatrix is not None:
                    error = [abs(el) for el in submatrix.columnWithHeader(responseVariable)]
                    meanError = reduce(operator.add, error)/float(len(error))
                    print '%10s\t%10s\t%10d\t%10.3lf' % (feature, featureTwo, len(error), meanError)
            check = []
            check.extend(features)
            check.pop(check.index(feature))
            subset = [code for code in allFeatures if code not in check]
            submatrix = getattr(matrix, featureFinder)([feature], matchMode='All')
            submatrix = getattr(submatrix, featureFinder)(subset, matchMode='Exclusive')
            if submatrix is not None:
                error = [abs(el) for el in submatrix.columnWithHeader(responseVariable)]
                meanError = reduce(operator.add, error)/float(len(error))
                print '%10s\t%10s\t%10d\t%10.3lf' % (feature, 'Extra-Group', len(error), meanError)
def intraGroupDependance ( self , matrix , group , featureFinder , allFeatures , responseVariable ) : features = group [ 0 ] print 'Group - %s' % features if len ( features ) == 0 : print 'Only one feature in group - cannot perform intra-group dependence' return print '%10s\t%10s\t%10s\t%10s' % ( 'Feature One' , 'Feature Two' , 'Samples' , 'Mean' ) for feature in features : data = getattr ( matrix , featureFinder ) ( [ feature ] ) for featureTwo in features : if featureTwo == feature : continue submatrix = getattr ( data , featureFinder ) ( [ featureTwo ] ) if submatrix is not None : error = [ abs ( el ) for el in submatrix . columnWithHeader ( responseVariable ) ] meanError = reduce ( operator . add , error ) / float ( len ( error ) ) print '%10s\t%10s\t%10d\t%10.3lf' % ( feature , featureTwo , len ( error ) , meanError ) check = [ ] check . extend ( features ) check . pop ( check . index ( feature ) ) subset = [ code for code in allFeatures if code not in check ] submatrix = getattr ( matrix , featureFinder ) ( [ feature ] , matchMode = 'All' ) submatrix = getattr ( submatrix , featureFinder ) ( subset , matchMode = 'Exclusive' ) if submatrix is not None : error = [ abs ( el ) for el in submatrix . columnWithHeader ( responseVariable ) ] meanError = reduce ( operator . add , error ) / float ( len ( error ) ) print '%10s\t%10s\t%10d\t%10.3lf' % ( feature , 'Extra-Group' , len ( error ) , meanError )
Compares the error of entries in matrix that have features in groups
Params:
matrix - The samples - Each sample is a mutation with a value for the responseVariabe
group - A list of features e.g.
Compares the error of entries in matrix that have features in groups Params : matrix - The samples - Each sample is a mutation with a value for the responseVariabe group - A list of features e . g .
'''Compares the error of entries in matrix that have features in groups
        
        Params:
            matrix - The samples - Each sample is a mutation with a value for the responseVariabe
            group - A list of features e.g. residue positions, substitutions. This is a subset of allFeatures
            featureFinder - A method that when past a feature will return a list of entries in matrix with that feature
            allFeatures - The complete list of features (which group is a subset of)
        ''' #Iterate over the group features #Get all data that has that feature #Get the data that has both features #Now find mean of mutants with this mutation but NO other systematic mutation
self
matrix
group
featureFinder
allFeatures
responseVariable