Skip to main content
Glama

diversity_structure

Performs PCA-based K-means clustering on genotype data to determine population structure, selecting optimal K and outputting sample cluster assignments.

Instructions

Lightweight population-structure clustering (PCA + K-means, in-Python).

Reduces the alt-dosage matrix with PCA (Patterson scaling), then runs K-means for K in k_min..k_max and picks the K with the highest pseudo-F (Calinski-Harabasz) between/within variance ratio — a clear maximum when groups are well separated. Writes structure_clusters.csv (sample, assigned cluster at the best K, PC coords) and reports the chosen K with cluster sizes. (No external ADMIXTURE binary — computed entirely in Python, consistent with the rest of the analysis layer.)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
k_maxNoLargest number of clusters (K) to evaluate.
k_minNoSmallest number of clusters (K) to evaluate.
methodNoGenotype source: 'vcf' (full export, cached) or 'allelematrix' (paged, server-side subset).vcf
regionNoRestrict analysis to a genomic window: 'chrom' or 'chrom:start-end' (1-based).
output_dirNoDirectory for the output CSV(s) (default ./gigwa_results/<module>/).
max_markersNoCap analysis to the first N markers in canonical Gigwa search order; omit to use all.
variant_set_db_idYesBrAPI variantSetDbId identifying the run (MODULE§project§run) -- copy the exact string from list_variant_sets / list_content, never assemble one by hand: the middle segment is a numeric project index, not the project's name, and a wrong guess fails with an opaque HTTP 500 rather than a clear error.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed2 schema fields changedv1.9.1
    • changedInput schema / properties / max_markers / description
      Previous value: -"Cap the number of markers analysed (evenly-spaced subsample); omit to use all."New value: +"Cap analysis to the first N markers in canonical Gigwa search order; omit to use all."
    • changedInput schema / properties / variant_set_db_id / description
      Previous value: -"BrAPI variantSetDbId identifying the run (MODULE§project§run); from list_variant_sets / list_content."New value: +"BrAPI variantSetDbId identifying the run (MODULE§project§run) -- copy the exact string from list_variant_sets / list_content, never assemble one by hand: the middle segment is a numeric project index, not the project's name, and a wrong guess fails with an opaque HTTP 500 rather than a clear error."
  2. First observedv1.4.16

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the behavioral disclosure burden and does so well: it explains the PCA + K-means pipeline, how K is chosen, and what output file is written. It does not mention failure modes or resource costs, but the main observable behavior is clearly disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description opens with a compact one-line summary, then provides a focused paragraph of algorithm and output details. The parenthetical about being 'consistent with the rest of the analysis layer' is mildly extraneous, but overall the structure is efficient and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the rich input schema, the presence of an output schema, and no annotations, the description supplies enough operational context to invoke the tool correctly: algorithm, output artifacts, and K-selection behavior. It omits error handling and parameter interactions, but these are minor gaps for this complexity level.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already documents all 7 parameters with 100% coverage, so the baseline is 3. The description adds useful algorithmic context around k_min/k_max and the clustering method, but it does not materially clarify parameter semantics beyond the schema's own descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific operation: population-structure clustering via PCA + K-means on the alt-dosage matrix. It names the algorithm, output file, and K-selection criterion, making it clearly distinguishable from the broader diversity_* sibling family.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The 'Lightweight population-structure clustering' and 'in-Python' phrasing implies when this tool is appropriate, and the note about no external binary provides implementation context. However, it never explicitly contrasts this tool with sibling alternatives such as diversity_pca or diversity_kinship, leaving the agent to infer selection from the name and algorithm.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gkanogiannis/Gigwa-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server