From 70a6c44262029a6813dd666e57b269afed7d5e6a Mon Sep 17 00:00:00 2001 From: Caroline Sands Date: Tue, 6 Aug 2024 18:10:59 +0100 Subject: [PATCH] sample summary report updated to show study samples missing any metadata --- nPYc/reports/_generateSampleReport.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/nPYc/reports/_generateSampleReport.py b/nPYc/reports/_generateSampleReport.py index af93d86..3b8d613 100644 --- a/nPYc/reports/_generateSampleReport.py +++ b/nPYc/reports/_generateSampleReport.py @@ -55,10 +55,15 @@ def _generateSampleReport(dataTrue, withExclusions=False, destinationPath=None, # Sample type masks acquiredMasks = generateTypeRoleMasks(data.sampleMetadata) - NotInCSVmask = data.sampleMetadata['Metadata Available'] == False + # Masks for any study samples with missing metadata (this can be from basic CSV, LIMS, or Sample Manifest) + NoMetadata = data.sampleMetadata['Metadata Available'] == False + if 'LIMS Present' in data.sampleMetadata.columns: + NoMetadata = (NoMetadata == True) | (data.sampleMetadata['LIMS Present'] == False) + if 'SubjectInfoData' in data.sampleMetadata.columns: + NoMetadata = (NoMetadata == True) | (data.sampleMetadata['SubjectInfoData'] == False) + NoMetadata[data.sampleMetadata['SampleClass'] != 'Study Sample'] = False # Samples marked for exclusion (either as marked as skipped or as False in sampleMask) - try: markedToExclude = (data.sampleMetadata['Skipped'].values == True) | (data.sampleMask == False) except: @@ -94,9 +99,14 @@ def _generateSampleReport(dataTrue, withExclusions=False, destinationPath=None, if (sum(markedToExclude) != 0): sampleSummary['MarkedToExclude Details'] = data.sampleMetadata[['Sample File Name', 'Exclusion Details']][markedToExclude] - # Save details of samples of unknown type - if (sum(NotInCSVmask) != 0): - sampleSummary['NoMetadata Details'] = data.sampleMetadata[['Sample File Name']][NotInCSVmask] + # Save details of samples with no associated metadata + if (sum(NoMetadata) != 0): + sampleSummary['NoMetadata Details'] = data.sampleMetadata[['Sample File Name']][NoMetadata] + +# if 'LIMS Present' in data.sampleMetadata.columns: +# if (sum(((data.sampleMetadata['LIMS Present'] == False) & (data.sampleMetadata['SampleClass'] == 'Study Sample'))) > 0): +# sampleSummary['NoMetadata Details'].append(data.sampleMetadata.loc[((data.sampleMetadata['LIMS Present'] == False) & ( +# data.sampleMetadata['SampleClass'] == 'Study Sample')), 'Sample File Name']) # Save details of samples of unknown type if (sum(acquiredMasks['Unknownmask']) != 0): @@ -211,9 +221,6 @@ def _generateSampleReport(dataTrue, withExclusions=False, destinationPath=None, # Update 'All', 'Missing/Excluded' to only reflect sample types present in data sampleSummary['Acquired'].loc['All', 'Missing/Excluded'] = sum(sampleSummary['Acquired']['Missing/Excluded'][1:]) - # TODO - CAZ sampleSummary table 'Missing/Excluded' number is wrong - - # Generate html report if destinationPath: # Set up template item and save required info