コード例 #1
0
    def on_setDriverThreshold_clicked(self):
        """ User input to change intensity threshold for masking samples from correlation calculation """

        x, ok = QInputDialog.getText(
            self, '',
            'Enter driver (relative) intensity threshold for defining sample set for correlation calculation:'
        )

        # Check that correlation threshold meets requirements
        try:
            x = float(x)

        except:
            x = 100  # Bit of a hack so it fails

        if not ((x < 1) & (x > 0)):
            _displayMessage(
                "Sample intensity threshold (relative intensity) must be a number between 0 and 1"
            )

        else:
            self.Attributes['sampleIntensityThreshold'] = x
            self.sampleIntensityThresholdText.setText(
                'Driver (relative) intensity threshold for defining sample set for correlation calculation: '
                + str(self.Attributes['sampleIntensityThreshold']))
コード例 #2
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_setDriver_clicked(self):
        """ User input to set driver feature """

        x, ok = QInputDialog.getText(self, '', 'Enter '
                                     'Feature Name'
                                     ' of driver:')

        # Check that driver is in dataset
        featureix = self.dataset.featureMetadata.index[
            self.dataset.featureMetadata['Feature Name'] == x]

        try:
            temp = featureix.values
            self.Attributes['driver'] = temp[0]
            self.Attributes['saveName'] = self.dataset.featureMetadata.loc[
                self.Attributes['driver'], 'Feature Name'].replace('/', '')
            self.Attributes['recalculateCorrelation'] = True

            # Check if changed and action result of change
            self.updatePlot()

        except:
            _displayMessage(
                "Driver must match an entry in the ''Feature Name'' column of the feature metadata file"
            )
            self.resetPlot()
コード例 #3
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_displayCorMap_clicked(self):
        """ Create interactive (plotly) heatmap of internal correlations between all features above correationThreshold to driver """

        if (self.Attributes['driver'] is not None):

            if ('Set' not in self.dataset.featureMetadata):

                _findStructuralSets(self)

            plotHeatmap(self,
                        savePath=os.path.join(
                            self.Attributes['saveDir'],
                            self.Attributes['saveName'] + '_plotSetsHeatmap'))

        else:
            _displayMessage(
                "Driver feature must be selected before plots can be displayed!"
            )
コード例 #4
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_displayCorScatter_clicked(self):
        """ Create interactive (plotly) scatter plot of driver to every other feature correlating above correationThreshold """

        if (self.Attributes['driver'] is not None):

            if ('Set' not in self.dataset.featureMetadata):

                _findStructuralSets(self)

            plotCorrelationScatter(
                self,
                sampleIDs='Sample ID',
                savePath=os.path.join(
                    self.Attributes['saveDir'],
                    self.Attributes['saveName'] + '_plotCorrelationScatter'))

        else:
            _displayMessage(
                "Driver feature must be selected before plots can be displayed!"
            )
コード例 #5
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_displaySetsPlot_clicked(self):
        """ Create interactive (plotly) structural sets plot """

        if (self.Attributes['driver'] is not None):

            if ('Set' not in self.dataset.featureMetadata):

                _findStructuralSets(self)

            plotScatter(
                self,
                colourBy='Set',
                mask=self.dataset.featureMetadata['Feature Mask'],
                savePath=os.path.join(
                    self.Attributes['saveDir'],
                    self.Attributes['saveName'] + '_plotStructuralSets'))

        else:
            _displayMessage(
                "Driver feature must be selected before plots can be displayed!"
            )
コード例 #6
0
    def on_setRANSACdegree_clicked(self):
        """  User input to set degree for RANSAC fit """

        x, ok = QInputDialog.getText(
            self, '', 'Enter required RANSAC degree (integer > 1):')

        # Check that correlation threshold meets requirements
        try:
            x = int(x)

        except:
            x = -1  # Bit of a hack so it fails

        if not ((x > 1)):
            _displayMessage(
                "RANSAC degree must be an integer greater than zero")

        else:
            self.Attributes['RANSACdegree'] = x
            self.setRANSACdegreeText.setText(
                'RANSAC degree: ' + str(self.Attributes['RANSACdegree']))
コード例 #7
0
    def on_setCorrelationThreshold_clicked(self):
        """ User input to change correlation threshold """

        x, ok = QInputDialog.getText(self, '',
                                     'Enter required correlation threshold:')

        # Check that correlation threshold meets requirements
        try:
            x = float(x)

        except:
            x = 100  # Bit of a hack so it fails

        if not ((x < 1) & (x > 0)):
            _displayMessage(
                "Correlation threshold must be a number in the range 0 to 1")

        else:
            self.Attributes['correlationThreshold'] = x
            self.correlationThresholdText.setText(
                'Correlation threshold ' +
                str(self.Attributes['correlationThreshold']))
コード例 #8
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_displayCorPlot_clicked(self):
        """ Create interactive (plotly) correlation to selected peak plot """

        if (self.Attributes['driver'] is not None):

            if self.Attributes['showAllFeatures'] == False:

                mask = self.dataset.featureMetadata['Feature Mask']

            else:
                mask = None

            plotScatter(self,
                        colourBy='Correlation',
                        mask=mask,
                        savePath=os.path.join(
                            self.Attributes['saveDir'],
                            self.Attributes['saveName'] + '_plotCorrelation'))

        else:
            _displayMessage(
                "Driver feature must be selected before plots can be displayed!"
            )
コード例 #9
0
    def on_setMzThreshold_clicked(self):
        """ User input to change LC-MS m/z ppm tolerance for defining match to annotations file """

        x, ok = QInputDialog.getText(
            self, '', 'Enter required m/z ppm tolerance (annotation match):')

        # Check that correlation threshold meets requirements
        try:
            x = float(x)

        except:
            x = -1.0  # Bit of a hack so it fails

        if (x < 0):
            _displayMessage(
                "LC-MS m/z ppm tolerance (annotation match) must be a number greater than zero"
            )

        else:
            self.Attributes['mzThreshold'] = x
            self.mzThresholdText.setText(
                'LC-MS m/z ppm threshold (annotation match): ' +
                str(self.Attributes['mzThreshold']))
コード例 #10
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_setDriverPair_clicked(self):
        """ User input to set driver-pair feature """

        x, ok = QInputDialog.getText(
            self, '', 'Enter '
            'Feature Name'
            ' of driver pair:')

        # Check that driver is in dataset
        featureix = self.dataset.featureMetadata.index[
            self.dataset.featureMetadata['Feature Name'] == x]

        try:
            temp = featureix.values
            self.Attributes['driverPair'] = temp[0]

        except:
            _displayMessage(
                "Driver Pair must match an entry in the ''Feature Name'' column of the feature metadata file"
            )
            self.resetPlot()

        try:

            self.Attributes['saveName'] = self.dataset.featureMetadata.loc[
                self.Attributes['driver'], 'Feature Name'].replace(
                    '/', ''
                ) + ' correlation to ' + self.dataset.featureMetadata.loc[
                    self.Attributes['driverPair'], 'Feature Name'].replace(
                        '/', '')

        except:
            _displayMessage("Driver must be set")
            self.resetPlot()

        # Update plot
        self.updatePlot()
コード例 #11
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_exportButton_clicked(self):
        """ Correlating features button click - save feature list to csv """

        if ('driver' in self.Attributes):

            # Determine putative structural sets
            if ('Set' not in self.dataset.featureMetadata):

                _findStructuralSets(self)

            # Set mask
            if self.Attributes['showAllFeatures'] == False:

                mask = self.dataset.featureMetadata['Feature Mask']

            else:
                mask = None

            _writeOutput(self, mask)

        else:

            _displayMessage(
                "Driver must be set before results can be exported!!")
コード例 #12
0
    def on_setRtThreshold_clicked(self):
        """ User input to change LC-MS retention time tolerance for defining structural associations and match to annotations file """

        x, ok = QInputDialog.getText(
            self, '',
            'Enter required retention time tolerance (structural sets):')

        # Check that correlation threshold meets requirements
        try:
            x = float(x)

        except:
            x = -1.0  # Bit of a hack so it fails

        if (x < 0):
            _displayMessage(
                "LC-MS retention time tolerance (structural sets and annotation match) must be a number greater than zero"
            )

        else:
            self.Attributes['rtThreshold'] = x
            self.rtThresholdText.setText(
                'LC-MS RT threshold (structural sets and annotation match): ' +
                str(self.Attributes['rtThreshold']))
コード例 #13
0
ファイル: runISTOCSY.py プロジェクト: phenomecentre/ISTOCSY
    def on_batchButton_clicked(self):
        """ Load batch file for automatically running ISTOCSY from named drivers or between defined drivers and driver-pairs"""

        # Open window to load new batch file
        w = _batchDialog(batchFilePath=self.Attributes['batchFilePath'])

        results = w.getResults()

        # Overwrite results
        self.Attributes['batchFilePath'] = results['batchFilePath']

        # Load the batch file
        _loadBatchFile(self)

        if hasattr(self, 'dataset'):

            # If Driver-Pair format
            if 'DriverPair' in self.batchData:

                # Copy data for final csv output
                output = self.batchData.copy()

            # Generate correlations and plots for every driver feature in file
            for ix in self.batchData.index:

                # Check that driver is in dataset
                featureix = self.dataset.featureMetadata.index[
                    self.dataset.featureMetadata['Feature Name'] ==
                    self.batchData.loc[ix, 'Driver']]

                try:
                    temp = featureix.values
                    self.Attributes['driver'] = temp[0]
                    self.Attributes[
                        'saveName'] = self.dataset.featureMetadata.loc[
                            self.Attributes['driver'],
                            'Feature Name'].replace('/', '')
                    self.Attributes['recalculateCorrelation'] = True

                except:
                    _displayMessage(
                        "Driver must match an entry in the ''Feature Name'' column of the feature metadata file"
                    )

                # If Driver-Pair format
                if 'DriverPair' in self.batchData:

                    # Check that driver pair is in dataset
                    featureix = self.dataset.featureMetadata.index[
                        self.dataset.featureMetadata['Feature Name'] ==
                        self.batchData.loc[ix, 'DriverPair']]

                    try:
                        temp = featureix.values
                        self.Attributes['driverPair'] = temp[0]

                    except:
                        _displayMessage(
                            "Driver Pair must match an entry in the ''Feature Name'' column of the feature metadata file"
                        )

                    self.Attributes['saveName'] = self.dataset.featureMetadata.loc[
                        self.Attributes['driver'], 'Feature Name'].replace(
                            '/', ''
                        ) + ' correlation to ' + self.dataset.featureMetadata.loc[
                            self.Attributes['driverPair'],
                            'Feature Name'].replace('/', '')

                # Set up masks
                if self.Attributes['showAllFeatures'] == False:

                    mask = self.dataset.featureMetadata['Feature Mask']

                else:
                    mask = None

                # Update plot
                self.updatePlot()

                # Calculate sets
                _findStructuralSets(self)

                # If Driver-All format, write output for every driver in file
                if 'DriverPair' not in self.batchData:

                    # Write output
                    _writeOutput(self, mask)

                    # Save scatter plot coloured by correlation
                    plotScatter(
                        self,
                        colourBy='Correlation',
                        mask=mask,
                        savePath=os.path.join(
                            self.Attributes['saveDir'],
                            self.Attributes['saveName'] + '_plotCorrelation'),
                        autoOpen=False)

                # If Driver-Pair format, save output for every pair to write combined file at end
                else:

                    output.loc[
                        ix, 'Correlation'] = self.dataset.featureMetadata.loc[
                            self.Attributes['driverPair'], 'Correlation']
                    output.loc[ix, 'RANSAC Number of Outliers'] = sum(
                        self.RANSAC['outliers'].
                        loc[:, self.dataset.featureMetadata.loc[
                            self.Attributes['driverPair'], 'Feature Name']])
                    output.loc[
                        ix,
                        'RANSAC Intercept'] = self.dataset.featureMetadata.loc[
                            self.Attributes['driverPair'], 'RANSAC Intercept']
                    output.loc[
                        ix, 'RANSAC Slope'] = self.dataset.featureMetadata.loc[
                            self.Attributes['driverPair'], 'RANSAC Slope']
                    output.loc[
                        ix, 'RANSAC SSE'] = self.dataset.featureMetadata.loc[
                            self.Attributes['driverPair'], 'RANSAC SSE']

                # Save scatter plot with RANSAC fit
                plotCorrelationScatter(self,
                                       sampleIDs='Sample ID',
                                       savePath=os.path.join(
                                           self.Attributes['saveDir'],
                                           self.Attributes['saveName'] +
                                           '_plotCorrelationScatter'),
                                       autoOpen=False)

                # Write output - CAZ need to save which are outliers for each pair
                #_writeOutput(self, mask)

        # If Driver-Pair format, export final csv
        if 'DriverPair' in self.batchData:

            temp = os.path.split(self.Attributes['batchFilePath'])
            temp = temp[1].replace('.csv', '')

            output.to_csv(os.path.join(self.Attributes['saveDir'],
                                       temp + '_batchCorrelationResults.csv'),
                          encoding='utf-8')

        self.resetPlot()