MSCalculate

class MSCalculate.ISTD_Operations

A collection of functions to perform calculation relating to ISTD

read_ISTD_map(column_name, logger=None, ingui=False, doing_normalization=False, allow_multiple_istd=False)

Function to get the transition names annotation dataframe from the MS Template Creator annotation file.

Parameters:
  • filepath (str) – The file path to the MS Template Creator annotation file

  • column_name (str) – The name of the column given in the Output_Options.

  • logger (object) – logger object created by start_logger in MSOrganiser

  • ingui (bool) – if True, print analysis status to screen

  • doing_normalization (bool) – if True, check if input file has data. If no data, throws an error

  • allow_multiple_istd (bool) – if True, allow normalization of data by mulitple internal standards

Returns:

Transition_Name_Annot_df (pandas DataFrame) – A data frame of showing the transition names annotation

read_Sample_Annot(MS_FilePathList, column_name, logger=None, ingui=False)

Function to get the sample names annotation dataframe from the MS Template Creator annotation file.

Parameters:
  • filepath (str) – The file path to the MS Template Creator annotation file

  • MS_FilePathList (list) – A list of MRM transition name file names.

  • column_name (str) – The name of the column given in the Output_Options.

  • logger (object) – logger object created by start_logger in MSOrganiser

  • ingui (bool) – if True, print analysis status to screen

Note

The list of MRM transition name file names names is to help the program properly filter the Sample annotation such that we only pick rows whose Data_File_Name values is in the list. Currently, our input is set as [os.path.basename(self.MS_FilePath)] from MSAnalysis.

Returns:

Sample_Annot_df (pandas DataFrame) – A data frame of showing the sample names annotation

create_Transition_Name_dict(Transition_Name_Annot_df, logger=None, ingui=False, allow_multiple_istd=False)

Create a dictionary to map the Transition_Name to the Transition_Name_ISTD and an ISTD report to map Transition_Name_ISTD to Transition_Name

Parameters:
  • Transition_Name_df (pandas DataFrame) – A data frame of sample as rows and transition names as columns

  • Transition_Name_Annot_df (pandas DataFrame) – A data frame of showing the transition names annotation

  • logger (object) – logger object created by start_logger in MSOrganiser

  • ingui (bool) – if True, print analysis status to screen

  • allow_multiple_istd (bool) – if True, ISTD data can have mulitple internal standards for one transition

Returns:

(list)

list containing:

  • ISTD_report_list (pandas DataFrame): An updated ISTD report to map Transition_Name_ISTD to Transition_Name

  • Transition_Name_dict (dict): An updated python dictionary to map the Transition_Name to the Transition_Name_ISTD

expand_Transition_Name_df(Transition_Name_dict, logger=None, ingui=False)

Expand Transition_Name_df so that it can be normalised by multiple ISTD

Parameters:
  • Transition_Name_df (pandas DataFrame) – A data frame of sample as rows and transition names as columns

  • Transition_Name_dict (dict) – A python dictionary to map the Transition_Name to the Transition_Name_ISTD and an ISTD report to map Transition_Name_ISTD to Transition_Name

  • logger (object) – logger object created by start_logger in MSOrganiser

  • ingui (bool) – if True, print analysis status to screen

Returns:

(list)

list containing:
  • expanded_Transition_Name_df (pandas DataFrame): A data frame of sample as rows and transition names as columns suited for normalisation by multiple ISTD

normalise_by_ISTD(Transition_Name_dict, logger=None, ingui=False, allow_multiple_istd=False)

Perform normalisation using the values from the Transition_Name_ISTD

Parameters:
  • Transition_Name_df (pandas DataFrame) – A data frame of sample as rows and transition names as columns

  • Transition_Name_dict (dict) – A python dictionary to map the Transition_Name to the Transition_Name_ISTD and an ISTD report to map Transition_Name_ISTD to Transition_Name

  • logger (object) – logger object created by start_logger in MSOrganiser

  • ingui (bool) – if True, print analysis status to screen

  • allow_multiple_istd (bool) – if True, allow normalisation of Transition_Name_df mulitple internal standards (in development)

Returns:

(list)

list containing:
  • norm_Transition_Name_df (pandas DataFrame): A data frame of sample as rows and transition names as columns with the normalised values

  • ISTD_data (pandas DataFrame): A data frame of sample as rows and transition names as columns with the ISTD area as values. Output as excel only at testing mode

getConc_by_ISTD(ISTD_Annot_df, Sample_Annot_df, logger=None, ingui=False, allow_multiple_istd=False, allow_multiple_data_file_path=False)

Perform calculation of analyte concentration using values from Transition_Name_Annot_ISTD

Parameters:
  • Transition_Name_df (pandas DataFrame) – A data frame of sample as rows and transition names as columns

  • ISTD_Annot_df (pandas DataFrame) – A data frame showing the ISTD annotation

  • Sample_Annot_df (pandas DataFrame) – A data frame showing the sample name annotation

  • logger (object) – logger object created by start_logger in MSOrganiser

  • ingui (bool) – if True, print analysis status to screen

  • allow_multiple_istd (bool) – if True, allow normalisation of Transition_Name_df mulitple internal standards

  • allow_multiple_data_file_path (bool) – if True, allow calculation of concentration using Sample_Annot_df that has more than one data file name

Returns:

(list)

list containing:

  • Conc_df (pandas DataFrame): A data frame of sample as rows and transition names as columns with the transition name concentration as values

  • ISTD_Conc_df (pandas DataFrame): A data frame of sample as rows and transition names as columns with the ISTD concentration as values

  • ISTD_Samp_Ratio_df (pandas DataFrame): A data frame of with transition names, its corresponding ISTD and ISTD to Sample ratio as columns