Skip to main content
Glama

diversity_structure

Identifies population structure by performing PCA on genotype data followed by K-means clustering, selecting the optimal number of clusters using the Calinski-Harabasz index.

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 the number of markers analysed (evenly-spaced subsample); omit to use all.
variant_set_db_idYesBrAPI variantSetDbId identifying the run (MODULE§project§run); from list_variant_sets / list_content.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

No annotations are provided, so the description fully details the algorithm (PCA, K-means, pseudo-F), output file (structure_clusters.csv), and reporting of chosen K. It also clarifies the in-Python computation, which is a key behavioral trait. However, it does not discuss runtime or memory implications.

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

Conciseness5/5

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

The description is concise (5 sentences) with a clear front-loaded purpose statement. Every sentence adds value: algorithm overview, parameter range, output details, and implementation context.

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 7 parameters (1 required) and an output schema, the description covers the core functionality, output files, and algorithm choice. It does not detail the output schema fields, but the output schema exists. The mention of being consistent with the analysis layer is mildly vague.

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?

Schema description coverage is 100%, so the baseline is 3. The description adds context about k_min..k_max evaluation and the use of pseudo-F, but does not significantly enhance the meaning of individual parameters beyond the schema.

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 clearly states the tool performs population-structure clustering using PCA and K-means, with an explicit algorithm summary. It distinguishes itself from siblings like diversity_pca (PCA only) and diversity_by_group (maybe predefined groups) by specifying the full clustering pipeline.

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 description implies usage for in-Python lightweight clustering without external ADMIXTURE, but does not explicitly state when to use this tool versus siblings. There is no guidance on prerequisites or exclusion criteria.

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

Install Server

Other Tools

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