예제 #1
0
    def __init__(self, *args, **kwargs):
        QWidget.__init__(self)

        self.fcList = db.getFlowcytometerList()
        self.setWindowIcon(QIcon('logo.png'))
        self.setWindowTitle('Flow cytometer configuration')
        self.resize(300, 300)
        self.move(500, 200)
        self.label = QLabel('Select the active flow cytometer')
        self.label.setFont(QFont('Arial', 13, QFont.Bold))
        db.updateFc()
        self.labelClass = QLabel('\nConfigure a flow cytometer')
        self.aClassQ = QComboBox()
        for a in self.fcList:
            self.aClassQ.addItem(a)
        # todo del the fc name if id not in channels column fcid

        v = db.getFcValue()
        if v != []:
            self.aClassQ.setCurrentIndex(self.fcList.index(v))

        self.buttonAdd = QPushButton('Add a flow cytometer')
        self.buttonAdd.clicked.connect(self.addClass)
        self.buttonDel = QPushButton('Delete a flow cytometer')
        self.buttonDel.clicked.connect(self.delClass)
        self.ok = QPushButton('Update a flow cytometer')
        self.ok.clicked.connect(self.updateFc)
        self.ok1 = QPushButton('OK')
        self.ok1.clicked.connect(self.validate)
        self.closeB = QPushButton('Exit')
        self.closeB.clicked.connect(self.closeW)
        layout = QGridLayout()
        layout.addWidget(self.label, 0, 0, 1, 2)
        layout.addWidget(self.aClassQ, 1, 0, 1, 2)
        layout.addWidget(self.labelClass, 2, 0)
        layout.addWidget(self.ok, 4, 0, 1, 2)
        layout.addWidget(self.buttonAdd, 3, 0, 1, 2)
        layout.addWidget(self.buttonDel, 5, 0, 1, 2)
        layout.addWidget(self.closeB, 6, 1)
        layout.addWidget(self.ok1, 6, 0)
        self.setLayout(layout)
        self.show()
예제 #2
0
    def __init__(self, state):
        QWidget.__init__(self)
        v = db.getFcValue()
        if v == []:
            msg = QMessageBox.warning(
                self, 'Error',
                'Please select a flow cytometer to launch the program')
            self.show()
            self.close()
            return
        self.setWindowIcon(QIcon('logo.png'))
        self.state = state
        if self.state == 'clustering':
            self.setWindowTitle('Clustering step 1/4')
            self.title = QLabel(
                'Cluster prediction of community\n    \n')  #TODO
        elif self.state == 'assessment':
            self.setWindowTitle('Predict step 1/4')
            self.title = QLabel(
                'Species prediction\nfor in-silico community\n    \n')
        else:
            self.setWindowTitle('Predict step 1/4')
            self.title = QLabel('Species prediction\nin community\n    \n')
        self.resize(400, 100)
        self.move(500, 200)

        self.title.setFont(QFont('Arial', 13, QFont.Bold))
        self.title.setAlignment(Qt.AlignCenter)
        classList = db.getClassNames(True)
        self.classes = QComboBox()
        for a in classList:
            self.classes.addItem(a)
        self.ok1 = QPushButton('OK')
        self.ok1.clicked.connect(self.classUpdate)
        self.grid = QGridLayout()
        self.grid.addWidget(self.title, 0, 0, 1, 2)
        self.labelClass = QLabel('Class   ')
        self.grid.addWidget(self.labelClass, 2, 0)
        self.grid.addWidget(self.classes, 2, 1)
        self.grid.addWidget(self.ok1, 3, 1)
        self.setLayout(self.grid)
예제 #3
0
 def validate(self):
     db.desactivateFc()
     db.saveFc(self.fcList[self.aClassQ.currentIndex()])
     db.removeUnusedParam()
     if db.getFcValue() != []:
         self.aClassQ.setCurrentIndex(self.fcList.index(db.getFcValue()))
예제 #4
0
    def __init__(self, *args, **kwargs):
        QWidget.__init__(self)
        v = db.getFcValue()
        if v == []:
            msg = QMessageBox.warning(
                self, 'Error',
                'Please select a flow cytometer to launch the program')
            self.show()
            self.close()
            return
        self.setWindowIcon(QIcon('logo.png'))
        self.layout = QHBoxLayout(self)
        self.scrollArea = QScrollArea(self)
        self.scrollArea.setWidgetResizable(True)
        self.scrollAreaWidgetContents = QWidget()
        self.grid = QGridLayout(self.scrollAreaWidgetContents)
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
        self.layout.addWidget(self.scrollArea)

        title = QLabel('Advanced parameters')
        title.setAlignment(Qt.AlignCenter)
        title.setFont(QFont("Century Gothic", 15, QFont.Bold))
        self.fig = ['Save', 'Show', 'None']
        self.gat = ['None', 'Line', 'Machine']
        self.met = [
            'Neural network', 'Random forest', 'Logistic regression',
            'Random guess'
        ]
        #self.graphOption = ['FSC-A', 'SSC-A', 'FL1-A', 'FL2-A', 'FL3-A', 'FL4-A', 'FSC-H', 'SSC-H', 'FL1-H', 'FL2-H',
        #   'FL3-H', 'FL4-H', 'Width']
        channels, self.graphOption, dic = db.getChannels()

        repeatL = QLabel('Number of runs ')
        self.repeat = QSpinBox(self)
        self.repeat.setRange(1, 50)

        averageL = QLabel('Create average prediction from runs')
        self.average = QCheckBox()
        doubtL = QLabel(
            'Percentage minimum of appearance \nto validate a prediction')
        self.doubt = QSpinBox(self)
        self.doubt.setRange(0, 100)
        nbCl = QLabel('Training:\n Number of cells per record')
        self.nbC = QSpinBox(self)
        self.nbC.setRange(100, 10000)
        nbC2l = QLabel('Tool analysis:\n Number of cells per record')
        self.nbC2 = QSpinBox(self)
        self.nbC2.setRange(0, 10000)
        ratioL = QLabel('Ratio learning/test')
        self.ratio = QDoubleSpinBox()
        self.ratio.setRange(0, 2)
        self.ratio.setStepType(QAbstractSpinBox.AdaptiveDecimalStepType)
        figureL = QLabel('Figures view mode')
        self.figure = QComboBox()
        self.figure.addItems(self.fig)
        gatingL = QLabel('Gating type ')
        self.gating = QComboBox()
        self.gating.addItems(self.gat)
        self.ok = QPushButton('Save Settings')
        self.ok.clicked.connect(self.saveParam)
        self.default = QPushButton('Back on default')
        self.default.clicked.connect(partial(self.maj, True))
        self.methodL = QLabel("Machine learning method")
        self.method = QComboBox()
        self.method.addItems(self.met)
        self.showGat = QCheckBox()
        self.showGatL = QLabel('Show gating effect')
        self.clustDist = QDoubleSpinBox(self)
        self.clustDist.setRange(0, 5)
        self.clustDist.setStepType(QAbstractSpinBox.AdaptiveDecimalStepType)
        self.clustDistL = QLabel('Cluster distance %')

        self.axesL = QLabel('Select 3D graph axes')
        self.axe1 = QComboBox()
        self.axe1.addItems(self.graphOption)
        self.axe2 = QComboBox()
        self.axe2.addItems(self.graphOption)
        self.axe3 = QComboBox()
        self.axe3.addItems(self.graphOption)

        self.grid.addWidget(title, 0, 0, 1, 4)
        self.grid.addWidget(repeatL, 1, 0)
        self.grid.addWidget(self.repeat, 1, 1)
        self.grid.addWidget(averageL, 2, 0)
        self.grid.addWidget(self.average, 2, 1)
        self.grid.addWidget(doubtL, 3, 0)
        self.grid.addWidget(self.doubt, 3, 1)
        self.grid.addWidget(figureL, 4, 0)
        self.grid.addWidget(self.figure, 4, 1)
        self.grid.addWidget(gatingL, 1, 2)
        self.grid.addWidget(self.gating, 1, 3)
        self.grid.addWidget(nbCl, 3, 2)
        self.grid.addWidget(self.nbC, 3, 3)
        self.grid.addWidget(nbC2l, 4, 2)
        self.grid.addWidget(self.nbC2, 4, 3)
        self.grid.addWidget(self.methodL, 5, 2)
        self.grid.addWidget(self.method, 5, 3)
        self.grid.addWidget(ratioL, 6, 2)
        self.grid.addWidget(self.ratio, 6, 3)
        self.grid.addWidget(self.showGatL, 2, 2)
        self.grid.addWidget(self.showGat, 2, 3)
        self.grid.addWidget(self.axesL, 5, 0)
        self.grid.addWidget(self.axe1, 5, 1)
        self.grid.addWidget(self.axe2, 6, 1)
        self.grid.addWidget(self.axe3, 7, 1)
        self.grid.addWidget(self.clustDistL, 8, 0)
        self.grid.addWidget(self.clustDist, 8, 1)

        self.grid.addWidget(self.ok, 9, 0, 2, 2)
        self.grid.addWidget(self.default, 9, 2, 2, 2)
        self.setWindowTitle("Settings")
        self.resize(900, 500)
        self.move(50, 200)
        self.maj(False)
예제 #5
0
def run(self):
    """
    Function from the interface launching the machine learning program
    :param self:
    :return:
    """
    channels, replaced, dicChannels = db.getChannels()
    # prediction ou assessment
    typeA = self.state
    # Species
    species = []
    sp = self.selectedSpecies

    # reference file from the database
    files = []
    for s in sp:
        ref = db.getReferences(s, self.parent.aClass)
        for i in range(len(ref)):
            files = files + ['references/' + ref[i]]
            species = species + [s]
    # Analysis files:
    files2 = self.files
    # Parameter from the database : gating number repeat...
    repeat = int(db.getParamValue('reapt'))
    param = [
        db.getParamValue('graph1'),
        db.getParamValue('graph2'),
        db.getParamValue('graph3')
    ]
    doubt = int(db.getParamValue('doubt')) / 100
    fc = db.getFcValue()
    nbC = int(db.getParamValue('nbC'))
    ratio = float(db.getParamValue('ratio'))
    var = float(db.getParamValue('clustDist'))

    average = db.getParamValue('average')
    if average in ['True', '1', 1, True]:
        average = True
    else:
        average = False

    figure = db.getParamValue('figure')
    if figure == 'None':
        figure = None
    elif figure == 'Save':
        figure = 'save'
    else:
        figure = 'show'

    gating = db.getParamValue('gating')
    if gating == 'None' or gating is None or gating == 0:
        gating = None
    elif gating == 'Line':
        gating = 'line'
    else:
        gating = 'machine'

    method = db.getParamValue('method')
    if method == 'Neural network':
        method = 'neur'
    elif method == 'Random forest':
        method = 'rand'
    elif method == 'Logistic regression':
        method = 'log'
    elif method == 'Random guess':
        method = 'rdguess'

    showGating = db.getParamValue('showGat')
    if showGating in [True, 1, 'True', '1']:
        showgat = True
    else:
        showgat = False

    nbC2 = int(db.getParamValue('nbC2'))
    if nbC2 == 0:
        nbC2 = None

    if typeA == 'prediction':
        files2 = files2[0]
        species2 = ['unknown'] * len(files2)
        directory = predictions(files,
                                species,
                                files2,
                                species2,
                                nbC,
                                None,
                                gating=gating,
                                showgat=showgat,
                                predAn='prediction',
                                predtype=method,
                                ratio=ratio,
                                repeat=repeat,
                                average=average,
                                doubt=doubt,
                                random_state=0,
                                save=figure,
                                fc=fc,
                                param=param,
                                channels=replaced,
                                dicChannels=dicChannels)
    elif typeA == 'assessment':  # case of assessment
        species2 = []
        nf = []
        for i in range(len(files2)):
            nf = nf + files2[i]
            species2 = species2 + ([sp[i]] * len(files2[i]))
        files2 = nf.copy()
        directory = predictions(files,
                                species,
                                files2,
                                species2,
                                nbC,
                                nbC2,
                                gating=gating,
                                showgat=showgat,
                                predAn='analysis',
                                predtype=method,
                                ratio=ratio,
                                repeat=repeat,
                                average=average,
                                doubt=doubt,
                                random_state=0,
                                save=figure,
                                fc=fc,
                                param=param,
                                channels=replaced,
                                dicChannels=dicChannels)
    elif typeA == 'clustering':
        files2 = files2[0]
        species2 = ['unknown'] * len(files2)
        directory = c.clustering(files,
                                 species,
                                 files2,
                                 species2,
                                 predAn='prediction',
                                 param=param,
                                 nbC=nbC,
                                 nbC2=None,
                                 save=figure,
                                 var=var,
                                 gating=gating,
                                 showgat=showgat,
                                 fc=fc,
                                 method=2,
                                 channels=replaced,
                                 dicChannels=dicChannels)
    elif typeA == 'clustA':
        species2 = []
        nf = []
        for i in range(len(files2)):
            nf = nf + files2[i]
            species2 = species2 + ([sp[i]] * len(files2[i]))
        files2 = nf.copy()
        directory = c.clustering(files,
                                 species,
                                 files2,
                                 species2,
                                 predAn='analysis',
                                 param=param,
                                 nbC=nbC,
                                 nbC2=nbC2,
                                 save=figure,
                                 var=var,
                                 method=2,
                                 gating=gating,
                                 showgat=showgat,
                                 fc=fc,
                                 channels=replaced,
                                 dicChannels=dicChannels)
    else:
        directory = 'None'

    return directory