Consensus Clustering Analysis logo

Consensus Clustering Analysis

OrganizationPopular
aipoch
consensus-clustering-analysis

Use when identifying stable sample subtypes from bulk expression matrices with ConsensusClusterPlus, including PAC-based model selection and consensus matrix/CDF visualization. NOT for: differential expression analysis, single-cell clustering workflows, or non-expression tables.

Overview

Publisheraipoch
Repositorymedical-research-skills
Skill nameconsensus-clustering-analysis
Stars
1.9K
Forks
175
Bundled files
19
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 19 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by aipoch on GitHub. Read the source before you install it.

Installation

Install the Consensus Clustering Analysis AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.

Use it in TypingMind

Enable Consensus Clustering Analysis in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Consensus Clustering Analysis on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Consensus Clustering Analysis is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Source: https://github.com/aipoch/medical-research-skills

Consensus Clustering Analysis

When to Use

Use this skill when you need to identify stable sample subtypes from a bulk expression matrix with ConsensusClusterPlus, compare candidate clustering settings with PAC, and export consensus matrix/CDF visualizations.

Do not use this skill for differential expression analysis, single-cell clustering, or non-expression tabular data.

When to Read External Files

SituationFile to ReadPurpose
Need algorithm detailsreferences/algorithm.mdConsensus clustering, PAC scoring, and preprocessing assumptions
Need to run analysisscripts/main.RExecute: Rscript scripts/main.R --input_file ... --group_file ...
Encounter errorsreferences/troubleshooting.mdCommon errors and solutions
Need CLI examplesreferences/cli-guide.mdDetailed CLI usage examples with verified local runs

Usage

bash
Rscript scripts/main.R \
  --input_file ./expression_matrix.csv \
  --group_file ./groups.csv \
  --disease_group case \
  --max_k 4 \
  --output_dir ./output/ \
  --gene_selection highly_variable \
  --top_n 5000 \
  --reps 1000 \
  --p_item 0.8 \
  --p_feature 1.0 \
  --timeout_seconds 3600 \
  --seed 42

Arguments

ShortLongTypeDefaultDescription
-i--input_filecharacterrequiredExpression matrix file (genes as rows, samples as columns)
-g--group_filecharacterrequiredGroup information file (sample ID + group columns)
-d--disease_groupcharactercaseGroup label retained for clustering
-k--max_kinteger4Maximum cluster count to evaluate
-o--output_dircharacter./output/Output directory
-m--gene_selectioncharacterhighly_variableGene selection mode: highly_variable or custom
-n--top_ninteger5000Number of top variable genes to keep
-l--gene_listcharacterNULLCustom gene list file when gene_selection=custom
-c--center_datalogicalTRUEMedian-center each gene before clustering
-r--repsinteger1000Consensus resampling repetitions
--p_itemdouble0.8Sample resampling proportion
--p_featuredouble1.0Feature resampling proportion
-t--timeout_secondsinteger3600Elapsed timeout in seconds
-s--seedinteger42Random seed for reproducibility

Input Format

Expression Matrix (input_file)

Genes as rows, samples as columns, CSV/TSV/TXT format with gene ID in the first column.

csv
,Sample01,Sample02,Sample03
TSPAN6,1.8479,1.8318,3.8276
TNMD,0.0349,0.0533,1.3889

Group File (group_file)

Delimited text file with sample ID and group columns.

csv
sample,group
Sample01,case
Sample02,control
Sample03,case

Gene List (gene_list)

Optional plain text or single-column CSV file with one gene symbol per line.

csv
TNMD
DPM1
SCYL3

Output Files

FileDescription
Cluster_res.csvPAC summary for each distance/algorithm combination with is_best marking the selected model
genes_for_clustering.csvSelected genes and gene selection mode
samples_for_clustering.csvSamples retained after disease-group filtering
result_<distance>_<algorithm>/Method-specific consensus outputs and PAC_scores.csv
Consensus Matrix Plot.pdfConsensus matrix heatmap for the optimal model
CDF curve Plot.pdfCDF curves for the optimal method
session_info.txtR session and package version info

Workflow

Step 1: Validate Input

  • Check file existence
  • Detect sample and group columns in the group file
  • Validate sample matching between expression matrix and group file

Step 2: Prepare Clustering Matrix

  • Filter samples by the requested disease group
  • Select genes using highly_variable or custom
  • Median-center genes if requested

Step 3: Run Consensus Clustering

  • Evaluate supported distance and clustering algorithm combinations
  • Compute PAC scores across candidate K values
  • Select the optimal model by minimum PAC

Step 4: Generate Outputs

  • Save result tables
  • Generate consensus matrix and CDF plots
  • Record session information for reproducibility

Methods

ConsensusClusterPlus

Repeated subsampling is used to estimate cluster stability across candidate K values and clustering settings.

PAC Score

The proportion of ambiguous clustering is computed as CDF(0.9) - CDF(0.1) from lower-triangle consensus values. Lower PAC indicates more stable clustering.

Gene Selection

  • highly_variable: rank genes by median absolute deviation
  • custom: use the intersection of the provided gene list and matrix row names

Examples

Basic Usage

bash
Rscript scripts/main.R \
  -i expression_matrix.csv \
  -g groups.csv \
  -d case \
  -k 3 \
  -r 20 \
  -o output/example_basic \
  -t 120

With a Custom Gene List

bash
Rscript scripts/main.R \
  -i expression_matrix.csv \
  -g groups.csv \
  -d case \
  -m custom \
  -l genes.csv \
  -k 4 \
  -r 20 \
  -o output/example_custom \
  -t 120

Without Median Centering

bash
Rscript scripts/main.R \
  -i expression_matrix.csv \
  -g groups.csv \
  -d case \
  -c FALSE \
  -k 3 \
  -r 20 \
  -o output/example_rawscale \
  -t 120

Error Handling

Common Errors

ErrorCauseSolution
SKILL_FILE_NOT_FOUNDInput file does not existCheck file path and permissions
SKILL_MISSING_COLUMNSGroup file lacks sample/group columnsVerify column names in the group file
SKILL_SAMPLE_MISMATCHSample names do not matchEnsure group file sample IDs match matrix columns
SKILL_INVALID_PARAMETERCLI value is invalidCheck allowed options and numeric ranges
SKILL_INVALID_DATAToo few samples/genes remain after filteringLower max_k or review the input data
SKILL_TIMEOUTRun exceeded the configured timeoutIncrease timeout_seconds or reduce reps
SKILL_DEPENDENCY_MISSINGRequired R package is not installedInstall missing packages before rerunning

IF error persists, READ: references/troubleshooting.md


Testing

Smoke Check

bash
# Check help
Rscript scripts/main.R --help

# Run analysis
Rscript scripts/main.R \
  -i tests/data/expression_matrix.csv \
  -g tests/data/groups.csv \
  -d case \
  -k 3 \
  -r 20 \
  -o output/example_basic \
  -t 120

Validation Commands

bash
# Inspect selected model
cat output/example_basic/Cluster_res.csv

# Check output plots exist
ls -la output/example_basic

Implementation Checklist

  • CLI parsing with optparse
  • set.seed() for reproducibility
  • requireNamespace() dependency checks
  • Session info recording
  • data.table::fread() input reading
  • File reading instructions in SKILL.md
  • Modular script structure (<150 lines per file)
  • Test data provided
  • Error handling with SKILL_* codes
  • Scripts in scripts/ directory
  • References in references/ directory

Last updated: 2026-04-17 | Version: 1.0.0

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Consensus Clustering Analysis AI skill do?

Use when identifying stable sample subtypes from bulk expression matrices with ConsensusClusterPlus, including PAC-based model selection and consensus matrix/CDF visualization. NOT for: differential expression analysis, single-cell clustering workflows, or non-expression tables.

Why use Consensus Clustering Analysis on TypingMind?

Because you install it once and use it with any model. Consensus Clustering Analysis is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Consensus Clustering Analysis in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/consensus-clustering-analysis. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Consensus Clustering Analysis?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Consensus Clustering Analysis?

As many as you like. As long as a model supports skills, you can use Consensus Clustering Analysis with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Consensus Clustering Analysis AI skill free?

Yes. It is published on GitHub by aipoch under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇