Skip to content

Commit

Permalink
sample summary report updated to show study samples missing any metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinesands committed Aug 6, 2024
1 parent 50e047c commit 70a6c44
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions nPYc/reports/_generateSampleReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 70a6c44

Please sign in to comment.