2.2. khipu extended

To-do: add extended_adducts to function arguments.

khipu.extended.export_empCpd_khipu_list(khipu_list)[source]

Export all khipus in khipu_list to a list of empirical compounds, which is JSON compatible. Wrapper of khipu.format_to_epds(). A small number of features are “undetermined”, as they came due to initial edges but violate DAG rules. They are sent off for a new khipu.

khipu.extended.export_khipu_table(outfile, peak_dict, json_khipu_list, singleton_ion='M+H+', delta_mz=1.0073)[source]

Write tab delimited file of khipu_list. delta_mz is +proton if pos mode, -protone if neg mode, for singletons.

khipu.extended.extend_khipu_list(khipu_list, peaklist, dict_extended_adducts, mz_tolerance_ppm=5, rt_tolerance=2)[source]

Update khipus by extended adduct search. Returns updated khipu_list and list_assigned_peaks. New in version 0.7: multiple charges are accommodated via dict_extended_adducts.

khipu.extended.graphs_to_khipu_list(subnetworks, WeavorInstance, mz_tolerance_ppm, id_start=0)[source]

Generate full khipu_list from subnetworks, including iterative khipus based on features pruned out of initial subnetwork.

khipu.extended.khipu_annotate(args)[source]

Automated pre-annotation using Khipu on a feature table. args as from parser.parse_args().

One can follow the steps here to construct a custom workflow, using scripting or notebooks.

See also

epdsConstructor.epdsConstructor for similar but embedded workflow.

class khipu.extended.khipu_diagnosis(subnetwork)[source]

Added diagnostic and exploratory functions to khipu class. They should be run after khipu.build_khipu().

build_diagnostic_tree(input_network, depth_limit=10)[source]

Build diagnostic tree using input nodes.

Updates:

self.diagnostic_tree as an instance of treelib.Tree.

Examples

(tree here is diagnostic_tree)

>>> KP = model.khipu()
>>> KP.build_tree(big[0], peak_dict, edge_dict)
>>>
>>> KP.tree.show()
116.0707@138.3
└── 117.0741@138.5
    ├── 120.084@136.8
    └── 121.0874@136.8
>>> KP = model.khipu()
>>>
>>> KP.build_tree(big[10], peak_dict, edge_dict)
[]
>>>
>>> KP.tree.show()
85.0744@110.6
└── 126.1009@110.6
    └── 127.1043@110.6
        ├── 121.0842@109.9
        ├── 121.0842@110.6
        ├── 122.0876@109.7
        │   ├── 120.0808@109.9
        │   └── 120.0808@110.6
        ├── 122.0876@110.4
        ├── 124.0943@110.8
        └── 125.0976@110.6

Note

A minimum_spanning_tree will have all necessary patterns to cover full khipu, but not unique pattern.

show_trimming()[source]

Show what nodes are removed from input_network. After running self.build_khipu.

snap_features_to_grid_by_best_mz(expected_grid_mz_values)[source]

Alternative method to create khipu_grid, by best matching each feature to the expected_grid_mz_values. This has major problems when there’s confusion btw close values, as expected_grid_mz_values can also be shifted by measurement error in root m/z.

khipu.extended.local_read_file(infile, start_col=3, end_col=6)[source]

The input feature table must be a tab delimited file, with the first four columns as: ID, m/z, retention_time, intensity. Example data at ‘../testdata/full_Feature_table.tsv’. Returns peaklist

khipu.extended.peaklist_to_khipu_list(peaklist, isotope_search_patterns=[(1.003355, '13C/12C', (0, 0.8)), (2.00671, '13C/12C*2', (0, 0.8)), (3.010065, '13C/12C*3', (0, 0.8)), (4.01342, '13C/12C*4', (0, 0.8)), (5.016775, '13C/12C*5', (0, 0.8)), (6.02013, '13C/12C*6', (0, 0.8)), (7.023485, '13C/12C*7', (0, 0.8)), (8.02684, '13C/12C*8', (0, 0.8)), (9.030195, '13C/12C*9', (0, 0.8)), (10.03355, '13C/12C*10', (0, 0.8)), (11.036905, '13C/12C*11', (0, 0.8)), (12.04026, '13C/12C*12', (0, 0.8))], adduct_search_patterns=[(21.982, 'Na/H'), (41.026549, 'ACN'), (35.9767, 'HCl'), (37.955882, 'K/H')], extended_adducts=[(1.0078, 'H'), (-1.0078, '-H'), (1.9972, '37/35Cl'), (-17.02655, '-NH3'), (17.02655, 'NH3'), (-18.0106, '-H2O'), (18.0106, 'H2O'), (18.033823, 'NH4'), (27.01089904, 'HCN'), (27.99492, 'CO'), (32.026215, 'MeOH'), (-35.037114, '-NH3-H2O'), (37.94694, 'Ca/H2'), (43.96389, 'Na2/H2'), (46.00548, 'CO2H2'), (-46.00548, '-CO2H2'), (67.987424, 'NaCOOH'), (83.961361, 'KCOOH'), (97.96737927, 'H2SO4'), (97.97689507, 'H3PO4')], mz_tolerance_ppm=5, rt_tolerance=2, mode='pos', charges=[1, 2, 3], has_parent_masstrack=False)[source]

A wrapper function easier for local data analysis. peaklist : list of input peaks/features in JSON notion as defined in Khipu or MetDataModel. charges : multiple-charged ions considered. return khipu_list, all_assigned_peaks