Skip to content

Commit

Permalink
added SampleClass for NMR and targeted
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinesands committed Mar 7, 2024
1 parent 4068f23 commit bdf8192
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nPYc/objects/_msDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ def _getSampleMetadataFromFilename(self, filenameSpec):
fileNameParts.loc[
fileNameParts['groupingKind'].str.match('E?IC', na=False).astype(bool), 'SampleType'] = SampleType.StudyPool

# Standardised NPC types based on SampleType/AssayRole combinations
# Define `SampleClass` - standardised NPC types based on SampleType/AssayRole combinations
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.StudySample) & (
fileNameParts['AssayRole'] == AssayRole.Assay), 'SampleClass'] = 'Study Sample'
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.StudyPool) & (
Expand Down
6 changes: 6 additions & 0 deletions nPYc/objects/_nmrDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(self, datapath, fileType='Bruker', pulseProgram='noesygppr1d', sop=

self.sampleMetadata['AssayRole'] = None
self.sampleMetadata['SampleType'] = None
self.sampleMetadata['SampleClass'] = None
self.sampleMetadata['Dilution'] = 100
self.sampleMetadata['Batch'] = numpy.nan
self.sampleMetadata['Correction Batch'] = numpy.nan
Expand Down Expand Up @@ -184,6 +185,11 @@ def _matchDatasetToLIMS(self, pathToLIMSfile):
self.sampleMetadata.loc[self.sampleMetadata.loc[:, 'Status'].str.match('Study Reference', na=False).astype(bool), 'SampleType'] = SampleType.StudyPool
self.sampleMetadata.loc[self.sampleMetadata.loc[:, 'Status'].str.match('Long Term Reference', na=False).astype(bool), 'SampleType'] = SampleType.ExternalReference

# Define `SampleClass` - standardised NPC types based on SampleType/AssayRole combinations
self.sampleMetadata.loc[:,'SampleClass'] = 'Study Sample'
self.sampleMetadata.loc[self.sampleMetadata.loc[:, 'Status'].str.match('Study Reference', na=False).astype(bool), 'SampleClass'] = 'Study Reference'
self.sampleMetadata.loc[self.sampleMetadata.loc[:, 'Status'].str.match('Long Term Reference', na=False).astype(bool), 'AssayRole'] = 'Long-Term Reference'

# Update Sampling ID values using new 'SampleType', special case for Study Pool, External Reference and Procedural Blank
self.sampleMetadata.loc[(((self.sampleMetadata['Sample ID'] == 'Not specified') | (self.sampleMetadata['Sample ID'] == 'Present but undefined in the LIMS file')) & (self.sampleMetadata['SampleType'] == SampleType.StudyPool)).tolist(), 'Sample ID'] = 'Study Pool Sample'
self.sampleMetadata.loc[(((self.sampleMetadata['Sample ID'] == 'Not specified') | (self.sampleMetadata['Sample ID'] == 'Present but undefined in the LIMS file')) & (self.sampleMetadata['SampleType'] == SampleType.ExternalReference)).tolist(), 'Sample ID'] = 'External Reference Sample'
Expand Down
16 changes: 16 additions & 0 deletions nPYc/objects/_targetedDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3248,6 +3248,22 @@ def _getSampleMetadataFromFilename(self, filenameSpec):
fileNameParts.loc[fileNameParts['groupingKind'].str.match('Blank', na=False).astype(bool), 'SampleType'] = SampleType.ProceduralBlank
fileNameParts.loc[fileNameParts['groupingKind'].str.match('E?IC', na=False).astype(bool), 'SampleType'] = SampleType.StudyPool

# Define `SampleClass` - standardised NPC types based on SampleType/AssayRole combinations
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.StudySample) & (
fileNameParts['AssayRole'] == AssayRole.Assay), 'SampleClass'] = 'Study Sample'
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.StudyPool) & (
fileNameParts['AssayRole'] == AssayRole.PrecisionReference), 'SampleClass'] = 'Study Reference'
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.ExternalReference) & (
fileNameParts['AssayRole'] == AssayRole.PrecisionReference), 'SampleClass'] = 'Long-Term Reference'
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.StudyPool) & (
fileNameParts['AssayRole'] == AssayRole.LinearityReference), 'SampleClass'] = 'Linearity Reference'
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.MethodReference) & (
fileNameParts['AssayRole'] == AssayRole.PrecisionReference), 'SampleClass'] = 'Method Reference'
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.ProceduralBlank) & (
fileNameParts['AssayRole'] == AssayRole.Blank), 'SampleClass'] = 'Blank'
fileNameParts.loc[(fileNameParts['SampleType'] == SampleType.UnknownType) & (
fileNameParts['AssayRole'] == AssayRole.UnknownRole), 'SampleClass'] = 'Unknown'

# Skipped runs
fileNameParts['Skipped'] = fileNameParts['exclusion'].str.match('[Xx]', na=False)

Expand Down

0 comments on commit bdf8192

Please sign in to comment.