tima::get_example_files(example = "features")2 Preparing inputs
This vignette describes the main steps of the annotation process.
Structural annotations of your features
For the moment, we support 3 different types of annotations:
- Internal MS1 exact mass-based library search
- Internal MS2 library search (experimental and in silico)
- SIRIUS
If needed, you can get an example of what your minimal feature table should look like by running:
Then, you can prepare your features for the next steps:
tima::prepare_features_tables()MS1-based
These annotations are of the lowest possible quality. However, they allow to annotate unusual adducts, in-source fragments thanks to different small tricks implemented. Try to really restrict the adduct list and structure-organism pairs you want to consider as possibilities explode rapidly.
tima::annotate_masses()How MS1 adduct attribution works
annotate_masses() uses two levels:
- Primary (strict graph): each
feature_idgets one primary ion species. Edges are kept only when both nodes are strongly supported, and consistent with the same neutral massM(estimated via tolerance-bounded consensus mode rather than a raw median, avoiding breakdown on 2-feature components). - Secondary (coverage): additional non-conflicting ion-species hypotheses are kept as secondary.
- Physical charge and isotope modeling: multicharged isotopologues use exact
1.003355 / |z|m/zshifts, and mixed multivalent carriers (+2,+3) are enumerated by exact integer charge-balance (sum(c_i * q_i) = z). - Co-variance support: when sample intensities are available, feature pairs within the RT window are tested with one-sided Pearson correlation on
log1p(intensity)and Benjamini-Hochberg FDR control.
For unresolved nodes in a supported component, TIMA also tests direct forms from the component mass M (for example [M +/- loss + carrier]) and keeps valid ones as weak support.
Main output fields to inspect:
candidate_adductcandidate_adduct_origin(supported,supported_weak,baseline)candidate_annotation_level(primary,secondary)candidate_evidence_tier(supported_strong,supported_weak,baseline)
How adduct names and in-source losses are cleaned up
Before matching masses, harmonize_adducts() standardizes adduct notation and checks that loss adducts make chemical sense:
- One name per ion: Equivalent notations such as
[M+NH3+H]+,[M+H3N+H]+, and[M+H4N]+are merged into[M+H4N]+(and[M+2H]2+/[M+H2]2+is aligned with your configured adduct list), so the same ion never appears under two different names. - In-source loss vs. solvent cluster: Inside each RT window, mass differences are read from the heavier ion to the lighter ion. A
-18.01 Dastep below an[M+H]+peak is attributed as an in-source water loss ([M-H2O+H]+), whereas solvent clusters ([M+H2O+H]+) are only tested when explicitly enabled in your cluster list. - Formula check on neutral losses: A neutral loss (
[M-loss+carrier]) is only kept if the candidate’s molecular formula actually contains the lost atoms (for example,[M-H3N+H]+is rejected on structures without nitrogen).
Spectral
tima::annotate_spectra()
tima::prepare_annotations_spectra()There are multiple similarities available:
entropy: spectral entropy similarity (https://doi.org/10.1038/s41592-021-01331-z)cosine: unshifted direct fragment cosine similaritygnps: precursor-shifted modified cosine similarity, solved via exact connected-component bipartite matching on the direct + precursor-shifted peak graph (preventing greedy chain-stealing when peaks compete within tolerance)
GNPS
Optional
tima::prepare_annotations_gnps()Fingerprint-based
Sirius
As SIRIUS jobs are long to perform, we provide example SIRIUS workspaces (both SIRIUS 5 and 6). Note that spectral matches from SIRIUS are not supported for now. They have been generated on the 20 first lines of the example MGF with the following command:
# this is run on SIRIUS 6
sirius \
--noCite \
--input=data/source/example_spectra_mini.mgf \
--output=data/interim/annotations/example_sirius.sirius/ \
--maxmz=800 \
config \
--AlgorithmProfile=orbitrap \
--StructureSearchDB=BIO \
--Timeout.secondsPerTree=10 \
--Timeout.secondsPerInstance=10 \
formulas \
zodiac \
fingerprints \
classes \
structures \
denovo-structures \
summaries \
--chemvista \
--feature-quality-summary \
--full-summary
# this is run on SIRIUS 5
sirius \
--noCite \
--input data/source/example_spectra_mini.mgf \
--output data/interim/annotations/example_sirius/ \
--maxmz 800 \
config \
--AlgorithmProfile orbitrap \
--StructureSearchDB BIO \
--Timeout.secondsPerTree 10 \
--Timeout.secondsPerInstance 10 \
formula \
zodiac \
fingerprint \
structure \
compound-classes \
write-summaries \
--full-summaryThese parameters were not optimized and were only used to give an example output. If you are using the cli, do not forget to generate the summaries with the --full-summary option, or if you use the gui, generate them by clicking the corresponding icon. You can get an example running:
getFromNamespace("get_example_sirius", "tima")()The sirius workspace should ideally have yourPattern_sirius as name and be placed in data/interim/annotations (else it will not be found by default except you provide the right path).
tima::prepare_annotations_sirius()If you want to know how we attempt to combine the CSI score with other ones, see R/transform_score_sirius_csi.R Note that starting from SIRIUS 6, the approx confidence score is the one considered, and not the exact one.
Annotations are now prepared and can be used for further processing. Your features are not only informed with structural information but also, chemical class information. The latter might be corresponding or not to the chemical class of your annotated structure, depending on the consistency of your annotations.
Chemical class annotation of your features
Within our workflow, we offer a new way to attribute chemical classes to your features. It is analog to Network Annotation Propagation, but uses the edges of your network instead of the clusters. This makes more sense in our view, as also recently illustrated by CANOPUS.
We are currently also working on CANOPUS integration for chemical class annotation but this implies way heavier computations, and we want to offer our users a fast solution.
Generating a network
A network is generated during the process. The edges are created based on the spectral entropy similarity calculated between your spectra (see https://doi.org/10.1038/s41592-021-01331-z).
tima::create_edges_spectra()Prepare the edges:
tima::prepare_features_edges()Create and prepare the components (partitioned with Leiden modularity optimization, per-community adaptive edge pruning, and symmetric min(N_source, N_target) matched-peak scaling):
tima::create_components()tima::prepare_features_components()Biological source annotation
This step allows you to attribute biological source information to your features. If all your features come from a single extract, it will attribute the biological source of your extract to all your features. If you have multiple extracts aligned, it will take the n highest intensities of your aligned feature table (retaining attributions above the relative intensity threshold min_rel_intensity = 0.01 to ignore trace carry-over) and attribute the biological source of corresponding extracts (according to your parameters).
tima::prepare_taxa()Filter annotations (based on retention time)
This step allows you to filter out the annotation of all the tools used, based on your own internal (experimental or predicted) retention times library. It is optional. If you do not have one, it will simply group the annotations of all tools.
tima::filter_annotations()You are almost there! See already all the steps accomplished!
We now recommend you to read the next vignette.
Reuse
Citation
@online{rutz2026,
author = {Rutz, Adriano},
title = {2 {Preparing} Inputs},
date = {2026-11-21},
url = {https://taxonomicallyinformedannotation.github.io/tima/vignettes/articles/II-preparing.html},
langid = {en}
}