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
| Name | Required | Description | Default |
|---|---|---|---|
| k_max | No | Largest number of clusters (K) to evaluate. | |
| k_min | No | Smallest number of clusters (K) to evaluate. | |
| method | No | Genotype source: 'vcf' (full export, cached) or 'allelematrix' (paged, server-side subset). | vcf |
| region | No | Restrict analysis to a genomic window: 'chrom' or 'chrom:start-end' (1-based). | |
| output_dir | No | Directory for the output CSV(s) (default ./gigwa_results/<module>/). | |
| max_markers | No | Cap analysis to the first N markers in canonical Gigwa search order; omit to use all. | |
| variant_set_db_id | Yes | 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. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |