PEATSA/Core/Classify.py
def createDataSet(self, matrix, features, recordRetriever, responseVariable):
    
        '''Creates a mvpva.dataset.Dataset instance from the provided data
    
        Parameters:
            matrix - A matrix where each row corresponds to a mutant.
                The mutant is identified by the column labeled 'Mutations'
                One of the other columns of the matrix must contain the data on the response variable to be examined
            features -
                A list containing a set of features. A feature is some property of each mutant.
                The point of the classifications is to see which features influence the response variable
            recordRetreiver -
                A function that take a feature and returns all mutants that have that feature.
            responseVariable -
                A string which identifies the column in matrix containing the response variable to tbe examined'''
    
        #Create the dataset matrix
        rows = []
        mutations = list(matrix.mutations)
        for i in range(len(mutations)):
            rows.append(len(features)*[0])
    
        mutationColumnIndex = matrix.indexOfColumnWithHeader('Mutations')
        for i in range(len(features)):
            #Get all the mutants that have feature
            feature = features[i]
            if type(feature) != list:
                feature = [feature]
    
            matching = recordRetriever(feature)
            for row in matching:
                mutation = row[mutationColumnIndex]
                index = mutations.index(mutation)
                rows[index][i] = 1
    
        responses = matrix.__getattr__(responseVariable)
        responses = [abs(response) for response in responses]
    
        #Create the classifier data set
        matrix = Core.Matrix.Matrix(rows=rows, headers=features)
        stream = open('.temp.csv', 'w+')
        stream.write(matrix.csvRepresentation())
        stream.close()
    
        matrix = numpy.loadtxt('.temp.csv', delimiter=',', skiprows=1)
        data = mvpa.datasets.Dataset(samples=matrix, labels=responses)
    
        os.remove('.temp.csv')
    
        return data
Creates a mvpva.dataset.Dataset instance from the provided data
    
        Parameters:
            matrix - A matrix where each row corresponds to a mutant.
                The mutant is identified by the column labeled 'Mutations'
                One of the other columns of the matrix must contain the data on the response variable to be examined
            features -
                A list containing a set of features. A feature is some property of each mutant.
                The point of the classifications is to see which features influence the response variable
            recordRetreiver -
                A function that take a feature and returns all mutants that have that feature.
            responseVariable -
                A string which identifies the column in matrix containing the response variable to tbe examined
Creates a mvpva.dataset.Dataset instance from the provided data
Parameters:
matrix - A matrix where each row corresponds to a mutant.
The mutant is identified by the column labeled 'Mutations'
One of the other columns of the matrix must contain the data on the response variable to be examined
features
A list containing a set of features. A feature is some property of each mutant.
The point of the classifications is to see which features influence the response variable
recordRetreiver
A function that take a feature and returns all mutants that have that feature.
responseVariable
A string which identifies the column in matrix containing the response variable to tbe examined
Creates a mvpva . dataset . Dataset instance from the provided data Parameters : matrix - A matrix where each row corresponds to a mutant . The mutant is identified by the column labeled ' Mutations ' One of the other columns of the matrix must contain the data on the response variable to be examined features A list containing a set of features . A feature is some property of each mutant . The point of the classifications is to see which features influence the response variable recordRetreiver A function that take a feature and returns all mutants that have that feature . responseVariable A string which identifies the column in matrix containing the response variable to tbe examined
def createDataSet(self, matrix, features, recordRetriever, responseVariable):
        rows = []
        mutations = list(matrix.mutations)
        for i in range(len(mutations)):
            rows.append(len(features)*[0])
        mutationColumnIndex = matrix.indexOfColumnWithHeader('Mutations')
        for i in range(len(features)):
            feature = features[i]
            if type(feature) != list:
                feature = [feature]
            matching = recordRetriever(feature)
            for row in matching:
                mutation = row[mutationColumnIndex]
                index = mutations.index(mutation)
                rows[index][i] = 1
        responses = matrix.__getattr__(responseVariable)
        responses = [abs(response) for response in responses]
        matrix = Core.Matrix.Matrix(rows=rows, headers=features)
        stream = open('.temp.csv', 'w+')
        stream.write(matrix.csvRepresentation())
        stream.close()
        matrix = numpy.loadtxt('.temp.csv', delimiter=',', skiprows=1)
        data = mvpa.datasets.Dataset(samples=matrix, labels=responses)
        os.remove('.temp.csv')
        return data
def createDataSet ( self , matrix , features , recordRetriever , responseVariable ) : rows = [ ] mutations = list ( matrix . mutations ) for i in range ( len ( mutations ) ) : rows . append ( len ( features ) * [ 0 ] ) mutationColumnIndex = matrix . indexOfColumnWithHeader ( 'Mutations' ) for i in range ( len ( features ) ) : feature = features [ i ] if type ( feature ) != list : feature = [ feature ] matching = recordRetriever ( feature ) for row in matching : mutation = row [ mutationColumnIndex ] index = mutations . index ( mutation ) rows [ index ] [ i ] = 1 responses = matrix . __getattr__ ( responseVariable ) responses = [ abs ( response ) for response in responses ] matrix = Core . Matrix . Matrix ( rows = rows , headers = features ) stream = open ( '.temp.csv' , 'w+' ) stream . write ( matrix . csvRepresentation ( ) ) stream . close ( ) matrix = numpy . loadtxt ( '.temp.csv' , delimiter = ',' , skiprows = 1 ) data = mvpa . datasets . Dataset ( samples = matrix , labels = responses ) os . remove ( '.temp.csv' ) return data
Creates a mvpva.dataset.Dataset instance from the provided data
Parameters:
matrix - A matrix where each row corresponds to a mutant.
Creates a mvpva . dataset . Dataset instance from the provided data Parameters : matrix - A matrix where each row corresponds to a mutant .
'''Creates a mvpva.dataset.Dataset instance from the provided data
    
        Parameters:
            matrix - A matrix where each row corresponds to a mutant.
                The mutant is identified by the column labeled 'Mutations'
                One of the other columns of the matrix must contain the data on the response variable to be examined
            features -
                A list containing a set of features. A feature is some property of each mutant.
                The point of the classifications is to see which features influence the response variable
            recordRetreiver -
                A function that take a feature and returns all mutants that have that feature.
            responseVariable -
                A string which identifies the column in matrix containing the response variable to tbe examined''' #Create the dataset matrix #Get all the mutants that have feature #Create the classifier data set
self
matrix
features
recordRetriever
responseVariable