Feature frequency filtering imaging
Use when after peak alignment across all spectra in an imaging dataset, use this skill when you have detected many peaks but need to reduce false positives and sparse features.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill feature-frequency-filtering-imagingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.8 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
feature-frequency-filtering-imaging
Summary
Filter mass spectrometry imaging features (peaks) by their frequency of occurrence across the spatial dataset, retaining only those present in a minimum fraction of pixels. This skill reduces noise and feature dimensionality while preserving biologically relevant peaks in MSImagingExperiment objects.
When to use
After peak alignment across all spectra in an imaging dataset, use this skill when you have detected many peaks but need to reduce false positives and sparse features. Apply it when you want to retain only peaks that appear consistently across >10% (or another threshold) of pixels, ensuring the final feature set reflects reproducible spectral signatures rather than noise or instrument artifacts.
When NOT to use
- Input peaks have not been aligned across spectra; run peakAlign() first.
- You are filtering based on intensity, m/z range, or other criteria unrelated to spatial frequency.
- Your analysis requires all detected peaks, including rare or unique spatial signatures; frequency filtering may discard biologically meaningful minority features.
Inputs
- MSImagingExperiment object with aligned peaks from peakAlign()
- featureData containing detected and aligned peaks across all spectra
Outputs
- Filtered MSImagingExperiment object with reduced featureData
- Subset of peaks passing the frequency threshold (e.g., 37 retained peaks)
How to apply
First, load the MSImagingExperiment object containing aligned peaks from peakAlign(). Then apply subsetFeatures() with a frequency threshold (e.g., > 0.1 for >10% pixel occurrence). The function filters featureData to retain only peaks meeting the frequency criterion. Verify the result by checking that the resulting MSImagingExperiment's featureData contains the expected number of peaks (e.g., 37 in the reference workflow). The frequency threshold should be tuned based on your imaging resolution, sample heterogeneity, and downstream analysis goals—higher thresholds yield more conservative, spatially robust feature sets.
Related tools
- Cardinal (Provides peakAlign() for spectral peak alignment and subsetFeatures() for frequency-based filtering of MSImagingExperiment objects) — github.com/kuwisdelu/Cardinal
- Cardinal 3.6 (Updated MSImagingExperiment class and spectral processing functions supporting peak alignment and feature subsetting workflows) — github.com/kuwisdelu/Cardinal
- BiocParallel (Optional: enables parallel processing of filtering operations across large imaging datasets)
Examples
# After peakAlign() has been applied:
data_filtered <- subsetFeatures(data_aligned, features = which(featureFrequency(data_aligned) > 0.1))
# Verify result:
nrow(featureData(data_filtered)) # Should equal 37 or target count
Evaluation signals
- The resulting MSImagingExperiment contains exactly the expected number of peaks (verify featureData row count matches target, e.g., 37 peaks).
- All retained peaks have frequency values ≥ the threshold (e.g., all > 0.1); spot-check a random sample of featureData.
- Spatial distribution of retained peaks is consistent across pixels; visualize using image() to confirm peaks are not concentrated in isolated regions.
- The filtering step removes spurious or low-frequency noise peaks; compare featureData before and after to confirm dimensionality reduction.
- Downstream statistical analysis (e.g., PCA, clustering via spatialKMeans) produces interpretable spatial patterns using the filtered feature set.
Limitations
- Frequency filtering is conservative and may discard rare but biologically meaningful peaks present in <10% of pixels; tune the threshold carefully for your application.
- The method assumes peak alignment was successful; misaligned peaks will have artificially reduced frequencies and may be incorrectly filtered out.
- Frequency filtering does not account for peak intensity, signal-to-noise ratio, or biological relevance; combine with intensity-based or annotation-based filtering for more refined feature selection.
- Very heterogeneous samples with spatially localized metabolites may lose important features if the frequency threshold is set too high.
Evidence
- [other] Subset features using subsetFeatures() with a frequency threshold of > 0.1 to retain only peaks present in >10% of pixels.: "Subset features using subsetFeatures() with a frequency threshold of > 0.1 to retain only peaks present in >10% of pixels."
- [other] After filtering to peaks with frequencies > 0.1, the resulting MSImagingExperiment contains exactly 37 peaks in featureData.: "After filtering to peaks with frequencies > 0.1, the resulting MSImagingExperiment contains exactly 37 peaks in featureData."
- [other] Apply peakAlign() to align detected peaks across all spectra in the imaging dataset.: "Apply peakAlign() to align detected peaks across all spectra in the imaging dataset."
- [intro] Updated MSImagingExperiment class with a new counterpart MSImagingArrays class for better representing raw spectra: "Updated MSImagingExperiment class with a new counterpart MSImagingArrays class for better representing raw spectra"
- [intro] Parallel processing support via the BiocParallel package for all pre-processing methods and any statistical analysis methods with a BPPARAM option: "Parallel processing support via the BiocParallel package for all pre-processing methods and any statistical analysis methods with a BPPARAM option"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.