memo_ms.classes module
- class memo_ms.classes.FeatureTable(path: str, software: str)[source]
Bases:
object
Create a FeatureTable dataclass object from a feature table
- Args:
path (str): Path to a feature table file (.csv) software (str): One of [mzmine, xcms, msdial, memo]: the software used for feature detection.
- Returns:
self.feature_table (DataFrame): A cleaned feature quantification table
- export_matrix(path, sep=',')[source]
Export a given matrix
- Args:
path (str): path to export sep (str): separator
- Returns:
None
- filter(use_samples_pattern=False, samples_pattern='', max_occurence=None, min_rel_occurence=0, max_rel_occurence=1)[source]
Filter a feature table: remove samples matching samples_pattern AND remove features occuring in more than n = max_occurence samples matched by samples_pattern
- Args:
use_samples_pattern (bool): filter using a str pattern samples_pattern (str): the str pattern to match in samples to filter max_occurence (int): maximal number of occurence allowed in matched samples before removing a feature min_rel_occurence (float): remove features contained in less than (min_rel_occurence * 100) percent of the samples max_rel_occurence (float): remove features contained in more than (max_rel_occurence * 100) percent of the samples
- Returns:
self.filtered_feature_table (DataFrame): A filtered feature table
- class memo_ms.classes.MemoMatrix[source]
Bases:
object
Create an empty MemoMatrix dataclass object
- export_matrix(path, sep=',')[source]
Export a given matrix
- Args:
path (str): path to export sep (str): separator
- Returns:
None
- filter(use_samples_pattern=False, samples_pattern='', max_occurence=None, min_rel_occurence=0, max_rel_occurence=1)[source]
Filter a MEMO matrix: remove samples matching samples_pattern AND remove features occuring in more than n = max_occurence samples matched by samples_pattern
- Args:
use_samples_pattern (bool): filter using a str pattern samples_pattern (str): the str pattern to match in samples to filter max_occurence (int): maximal number of occurence allowed in matched samples before removing a word min_rel_occurence (float): remove words contained in less than (min_rel_occurence * 100 percent) of the samples max_rel_occurence (float): remove words contained in more than (max_rel_occurence * 100 percent) of the samples
- Returns:
self.memo_matrix (DataFrame): A filtered feature table matrix
- memo_from_aligned_samples(featuretable, spectradocuments) pandas.core.frame.DataFrame [source]
Use a featuretable and a spectradocuments to generate a MEMO matrix. Returns a pd.DataFrame MEMO matrix.
- Args:
featuretable (FeatureTable): a FeatureTable dataclass object spectradocuments (SpectraDocuments): a SpectraDocuments dataclass oject
- Returns:
self.memo_matrix (DataFrame): A MEMO matrix
- memo_from_unaligned_samples(path_to_samples_dir, pattern_to_match='.mgf', min_relative_intensity=0.01, max_relative_intensity=1.0, min_peaks_required=10, losses_from=10, losses_to=200, n_decimals=2)[source]
Generate a Memo matrix from a list of individual .mgf files
- Args:
path_to_samples_dir (str): Path to the directory where individual .mgf files are gathered. Subfolders will also be checked. pattern_to_match (str): Shared pattern between all spectra files to input. Will be removed in memo_matrix.index. min_relative_intensity (float): Minimal relative intensity to keep a peak max_relative_intensity (float): Maximal relative intensity to keep a peak min_peaks_required (int): Minimum number of peaks to keep a spectrum losses_from (int): minimal m/z value for losses losses_to (int): maximal m/z value for losses n_decimals (int): number of decimal when translating peaks/losses into words
- Returns:
self.memo_matrix (DataFrame): A MEMO matrix
- merge_memo(memomatrix_2, drop_not_in_common=False)[source]
Merge 2 MEMO matrix
- Args:
memocontainer2 (MemoContainer): MemoMatrix dataclass object containing the 2nd MEMO matrix to merge drop_not_in_common (bool): Drop peaks/losses not in common
- Returns:
MemoContainer (MemoContainer): A MemoMatrix dataclass object containing the merged MEMO matrix
- class memo_ms.classes.SpectraDocuments(path: str, min_relative_intensity: float = 0.01, max_relative_intensity: float = 1.0, min_peaks_required: int = 10, losses_from: int = 10, losses_to: int = 200, n_decimals: int = 2)[source]
Bases:
object
Create a SpectraDocuments dataclass object containing spectra documents and metadata from an MzMine 2 spectra file (.mgf)
- Args:
path (str): Path to spectra file (.mgf) min_relative_intensity (float): Minimal relative intensity to keep a peak max_relative_intensity (float): Maximal relative intensity to keep a peak min_peaks_required (int): Minimum number of peaks to keep a spectrum losses_from (int): minimal m/z value for losses losses_to (int): maximal m/z value for losses n_decimals (int): number of decimal when translating peaks/losses into words
- Returns:
self.document (DataFrame): A table containing spectra documents and metadata