diff --git a/nPYc/reports/_finalReportPeakPantheR.py b/nPYc/reports/_finalReportPeakPantheR.py index 1c3b962..bc7366d 100644 --- a/nPYc/reports/_finalReportPeakPantheR.py +++ b/nPYc/reports/_finalReportPeakPantheR.py @@ -155,15 +155,15 @@ def _finalReportPeakPantheR(dataset, destinationPath=None): if sum(dataset.corrExclusions) != dataset.noSamples: temp = ', '.join(dataset.sampleMetadata.loc[dataset.corrExclusions == False, 'Sample File Name'].values) - FeatureSelectionTable = FeatureSelectionTable.append( - pandas.DataFrame(data=temp, index=['Correlation to Dilution: Sample Exclusions'], columns=['Value Applied'])) + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, + pandas.DataFrame(data=temp, index=['Correlation to Dilution: Sample Exclusions'], columns=['Value Applied'])]) else: - FeatureSelectionTable = FeatureSelectionTable.append( - pandas.DataFrame(data=['none'], index=['Correlation To Dilution: Sample Exclusions'], columns=['Value Applied'])) - FeatureSelectionTable = FeatureSelectionTable.append( + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, + pandas.DataFrame(data=['none'], index=['Correlation To Dilution: Sample Exclusions'], columns=['Value Applied'])]) + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, pandas.DataFrame(data=['yes', dataset.Attributes['rsdThreshold'], 'yes'], index=['Relative Standard Devation (RSD)', 'RSD of SR Samples: Threshold', - 'RSD of SS Samples > RSD of SR Samples'], columns=['Value Applied'])) + 'RSD of SS Samples > RSD of SR Samples'], columns=['Value Applied'])]) item['FeatureSelectionTable'] = FeatureSelectionTable diff --git a/nPYc/reports/_generateReportMS.py b/nPYc/reports/_generateReportMS.py index 408f4e7..749dedb 100644 --- a/nPYc/reports/_generateReportMS.py +++ b/nPYc/reports/_generateReportMS.py @@ -210,26 +210,26 @@ def _finalReport(dataset, destinationPath=None, pcaModel=None, reportType='final if sum(dataset.corrExclusions) != dataset.noSamples: temp = ', '.join(dataset.sampleMetadata.loc[dataset.corrExclusions == False, 'Sample File Name'].values) - FeatureSelectionTable = FeatureSelectionTable.append( - pandas.DataFrame(data=temp, index=['Correlation to Dilution: Sample Exclusions'], columns=['Value Applied'])) + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, + pandas.DataFrame(data=temp, index=['Correlation to Dilution: Sample Exclusions'], columns=['Value Applied'])]) else: - FeatureSelectionTable = FeatureSelectionTable.append( - pandas.DataFrame(data=['none'], index=['Correlation To Dilution: Sample Exclusions'], columns=['Value Applied'])) - FeatureSelectionTable = FeatureSelectionTable.append( + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, + pandas.DataFrame(data=['none'], index=['Correlation To Dilution: Sample Exclusions'], columns=['Value Applied'])]) + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, pandas.DataFrame(data=['yes', dataset.Attributes['filterParameters']['rsdThreshold'], 'yes'], index=['Relative Standard Devation (RSD)', 'RSD of SR Samples: Threshold', - 'RSD of SS Samples > RSD of SR Samples'], columns=['Value Applied'])) + 'RSD of SS Samples > RSD of SR Samples'], columns=['Value Applied'])]) if 'blankFilter' in dataset.Attributes: if dataset.Attributes['featureFilters']['blankFilter'] == True: - FeatureSelectionTable = FeatureSelectionTable.append( - pandas.DataFrame(data=['yes'], index=['Blank Filtering'], columns=['Value Applied'])) + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, + pandas.DataFrame(data=['yes'], index=['Blank Filtering'], columns=['Value Applied'])]) if (dataset.Attributes['featureFilters']['artifactualFilter'] == True): - FeatureSelectionTable = FeatureSelectionTable.append(pandas.DataFrame( + FeatureSelectionTable = pandas.concat([FeatureSelectionTable, pandas.DataFrame( data=['yes', dataset.Attributes['filterParameters']['deltaMzArtifactual'], dataset.Attributes['filterParameters']['overlapThresholdArtifactual'], dataset.Attributes['filterParameters']['corrThresholdArtifactual']], index=['Artifactual Filtering', 'Artifactual Filtering: Delta m/z', 'Artifactual Filtering: Overlap Threshold', 'Artifactual Filtering: Correlation Threshold'], - columns=['Value Applied'])) + columns=['Value Applied'])]) item['FeatureSelectionTable'] = FeatureSelectionTable @@ -1729,45 +1729,5 @@ def batchCorrectionTest(dataset, nFeatures=10, window=11): # Do batch correction postData = correctMSdataset(preData) - # Do batch correction - #featureList = [] - #correctedData = numpy.zeros([dataset.intensityData.shape[0], nFeatures]) - #fits = numpy.zeros([dataset.intensityData.shape[0], nFeatures]) - #featureIX = 0 - #parameters = dict() - #parameters['window'] = window - #parameters['method'] = 'LOWESS' - #parameters['align'] = 'median' - - #for feature in maskNum: - # correctedP = _batchCorrection(dataset.intensityData[:, feature], - # dataset.sampleMetadata['Run Order'].values, - # SPmask, - # dataset.sampleMetadata['Correction Batch'].values, - # range(0, 1), # All features - # parameters, - # 0) - - # if sum(numpy.isfinite(correctedP[0][1])) == dataset.intensityData.shape[0]: - # correctedData[:, featureIX] = correctedP[0][1] - # fits[:, featureIX] = correctedP[0][2] - # featureList.append(feature) - # featureIX = featureIX + 1 - - # if featureIX == nFeatures: - # break - - # Create copy of dataset and trim - #preData = copy.deepcopy(dataset) - #preData.intensityData = dataset.intensityData[:, featureList] - #preData.featureMetadata = dataset.featureMetadata.loc[featureList, :] - #preData.featureMetadata.reset_index(drop=True, inplace=True) - #preData.featureMask = preData.featureMask[featureList] - - # Run batch correction - #postData = copy.deepcopy(preData) - #postData.intensityData = correctedData - #postData.fit = fits - # Return results return preData, postData, maskNum #featureList \ No newline at end of file diff --git a/nPYc/reports/multivariateReport.py b/nPYc/reports/multivariateReport.py index 11bad79..8393419 100644 --- a/nPYc/reports/multivariateReport.py +++ b/nPYc/reports/multivariateReport.py @@ -23,6 +23,7 @@ import shutil from IPython.display import display from warnings import warn +from ..utilities._errorHandling import npycToolboxError from ..__init__ import __version__ as version @@ -139,8 +140,8 @@ def multivariateReport(dataTrue, pcaModel, reportType='analytical', withExclusio if hasattr(pcaModel, '_npyc_dataset_shape'): if pcaModel._npyc_dataset_shape['NumberSamples'] != data.intensityData.shape[0] \ or pcaModel._npyc_dataset_shape['NumberFeatures'] != data.intensityData.shape[1]: - raise ValueError('Data dimension mismatch: Number of samples and features in the nPYc Dataset do not match' - 'the numbers present when PCA was fitted. Verify if withExclusions argument is matching.') + raise npycToolboxError('Data dimension mismatch: Number of samples and features in the nPYc Dataset do not match' + ' the numbers present when PCA was fitted. Verify if withExclusions argument is matching.') else: raise ValueError('Fit a PCA model beforehand using exploratoryAnalysisPCA.')