agentsclimarketplace

Ggplot2 geom treemap rendering

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v1/skills/ggplot2-geom-treemap-rendering

Use when after running qc_summary() on a filtered mpactr object and aggregating ion counts by filter status category (passed/failed).From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill ggplot2-geom-treemap-rendering

Assembled 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.2 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

ggplot2-geom-treemap-rendering

Summary

Render hierarchical ion filtering results as a treemap visualization using ggplot2's geom_treemap() and geom_treemap_text() layers, scaled by ion counts and annotated with filter status labels and percentages. This skill transforms aggregated qc_summary() data into a publication-ready treemap that communicates the distribution and relative abundance of ions across filter outcome categories.

When to use

After running qc_summary() on a filtered mpactr object and aggregating ion counts by filter status category (passed/failed). Use this skill when you need to communicate the proportional breakdown of ions retained vs. removed by filtering, and when a compact, area-encoded visualization is preferred over bar charts for showing multiple hierarchical dimensions (status, count, percentage) simultaneously.

When NOT to use

  • Input contains only a single filter status category (treemap loses hierarchical meaning with one rectangle).
  • Ion count data is not pre-aggregated by status; raw feature-level data will produce an uninterpretable treemap with too many small tiles.
  • Audience requires precise numerical comparison across many status categories; bar charts or tables are more readable than area encoding when exact values matter more than proportional intuition.

Inputs

  • mpactr object (filtered)
  • data.table from qc_summary() output containing ion status (passed/failed filters)
  • aggregated ion counts by filter status category

Outputs

  • ggplot2 treemap object
  • PNG file of rendered treemap visualization

How to apply

Extract the qc_summary() data.table, aggregate ion counts by filter status using data.table syntax, and calculate the percentage of total ions per status. Initialize a ggplot() call mapping status to fill aesthetic and ion count to the area parameter. Layer geom_treemap() to render rectangles sized by ion count, then geom_treemap_text() to overlay status labels and percentage annotations. Customize with scale_fill_brewer() (e.g., Greens palette) to distinguish status categories, suppress the legend, and apply ggplot2 theme() functions for publication formatting. Save the rendered plot to PNG.

Related tools

  • ggplot2 (Core graphics framework for treemap layer specification and customization)
  • treemapify (Provides geom_treemap() and geom_treemap_text() layers for rectangular treemap rendering)
  • mpactr (Generates qc_summary() data.table containing ion filter status used as input) — https://github.com/mums2/mpactr
  • data.table (Efficient aggregation and percentage calculation from qc_summary() output)
  • scale_fill_brewer() (Applies categorical color palette (e.g., Greens) to distinguish filter status)

Examples

qc_dt <- qc_summary(filtered_mpactr_obj)[, .(ion_count = .N, pct = 100*.N/nrow(qc_summary(filtered_mpactr_obj))), by=status]; ggplot(qc_dt, aes(area=ion_count, fill=status, label=paste0(status, '\n', ion_count, ' (', round(pct,1), '%)'))) + geom_treemap() + geom_treemap_text(place='centre') + scale_fill_brewer(palette='Greens') + theme(legend.position='none') + ggsave('ion_filter_treemap.png')

Evaluation signals

  • Treemap renders with exactly one rectangle per filter status category, sized proportional to ion count.
  • geom_treemap_text() labels are legible and correctly display status name, ion count, and percentage (sum to 100%).
  • Color palette is applied consistently and legend is suppressed when specified.
  • PNG file is written to disk with expected dimensions and no rendering artifacts.
  • Ion counts in treemap match aggregated values from qc_summary() data.table (no data loss or duplication).

Limitations

  • Treemap readability degrades with more than ~6–8 status categories; extremely granular status hierarchies may require faceting or hierarchical treemaps.
  • Text labels may overlap or become unreadable if rectangles are too small; aggregate data or increase figure dimensions as needed.
  • Treemapify's geom_treemap() does not natively support interactive tooltips; use plotly::ggplotly() for interactivity or plotly treemaps for hover annotations.
  • Color blindness accessibility depends on palette choice; scale_fill_brewer() Greens is red–green colorblind-safe, but confirm with CVD simulators for other palettes.

Evidence

  • [other] Ion counts and percentages by status are computed from qc_summary() output using data.table syntax, then rendered as a treemap with geom_treemap() and geom_treemap_text() to display status labels, ion counts, and percentages: "Ion counts and percentages by status are computed from qc_summary() output using data.table syntax, then rendered as a treemap with geom_treemap() and geom_treemap_text() to display status labels,"
  • [other] Create a treemap using ggplot2 geom_treemap() and geom_treemap_text() with Greens palette, no legend, sized by ion count and labeled with status and percentage.: "Create a treemap using ggplot2 geom_treemap() and geom_treemap_text() with Greens palette, no legend, sized by ion count and labeled with status and percentage"
  • [other] The visualization can be customized with ggplot2 scale_fill_brewer() and theme() functions.: "The visualization can be customized with ggplot2 scale_fill_brewer() and theme() functions"

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.