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, peak_dict, adduct_search_patterns_extended, mz_tolerance_ppm=5, rt_tolerance=2)[source]¶
Update khipus by extended adduct search. Returns updated khipu_list and list_assigned_peaks.
- khipu.extended.graphs_to_khipu_list(subnetworks, WeavorInstance, mz_tolerance_ppm)[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.
- 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, 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')], mz_tolerance_ppm=5, rt_tolerance=2)[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’.
- 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')], mz_tolerance_ppm=5, rt_tolerance=2, mode='pos')[source]¶
A wrapper function easier for local data analysis. peaklist : list of input peaks/features in JSON notion as defined in Khipu or MetDataModel. return khipu_list, all_assigned_peaks