Logo de Hierarchical Clustering Plot

Hierarchical Clustering Plot

OrganizaçãoPopular
aipoch
hierarchical-clustering-plot

Use when building a sample-level hierarchical clustering dendrogram from a bulk expression matrix and sample annotation table, especially for QC, batch inspection, or sample similarity assessment. Trigger keywords: hierarchical clustering, dendrogram, sample QC, batch inspection, sample similarity. NOT for: differential expression testing, gene clustering heatmaps, single-cell clustering workflows.

Visão geral

Publicado poraipoch
Repositóriomedical-research-skills
Nome da habilidadehierarchical-clustering-plot
Estrelas
1.9K
Forks
175
Arquivos incluídos
17
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    Habilidades de IA são Markdown simples, não código específico de um provedor, por isso funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • 17 arquivos incluídos

    Scripts, modelos de documentos e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente leitura e nunca são executados.

  • Código aberto

    Publicada por aipoch no GitHub. Leia o conteúdo-fonte antes de instalar.

Instalação

Instale a habilidade de IA Hierarchical Clustering Plot no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL da pasta da habilidade exibida abaixo e confirme.
    https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/hierarchical-clustering-plot
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Nova habilidade → Via URL GitHub, depois cole a URL da pasta e pressione Continuar.

Use no TypingMind

Ative Hierarchical Clustering Plot em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Hierarchical Clustering Plot automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Hierarchical Clustering Plot não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Hierarchical Clustering Plot

When to Use

Use this skill when you need a sample-level hierarchical clustering dendrogram from a bulk expression matrix and a sample annotation table.

  • Good fits: sample QC, batch inspection, sample similarity assessment, checking whether annotated sample groups cluster as expected.
  • Trigger keywords: hierarchical clustering, dendrogram, sample QC, batch inspection, sample similarity.
  • Not for: differential expression testing, gene clustering heatmaps, single-cell clustering workflows.

When to Read External Files

SituationFile to ReadPurpose
Need algorithm detailsreferences/algorithm.mdDistance calculation, linkage rules, and clustering assumptions
Need to run analysis or inspect CLI entrypoint behaviorscripts/main.RExecute the workflow and inspect argument parsing, defaults, required flags, and sourced modules
Need workflow implementation detailsscripts/run_analysis.RSee orchestration order, temp workspace handling, and output generation
Need logging or warning behaviorscripts/logging_utils.RSee standardized console log formatting and memory usage messages
Need file or parameter validation detailsscripts/validation_utils.RSee path checks, output-directory checks, and scalar validation
Need timeout, temp workspace, or session info behaviorscripts/runtime_utils.RSee timeout control, temp cleanup, output copying, and session-info export
Need expression/group input handlingscripts/input_functions.RSee CSV loading, sample matching, and label extraction
Need clustering logicscripts/clustering_functions.RSee distance calculation and hclust() generation
Need output-writing logicscripts/output_utils.RSee CSV export and PDF rendering
Encounter errors, warnings, or unexpected clustering patternsreferences/troubleshooting.mdCommon failures, warning follow-up, and interpretation guidance
Need CLI examples or common parameter combinationsreferences/cli-guide.mdDetailed command patterns for standard, variant, and test runs
Need example input files or schema-concrete fixturestests/data/Inspect sample CSV layouts for expression and group inputs
Need expected output names or artifact formats## Output Files and references/cli-guide.mdConfirm the files the workflow writes and inspect documented example previews
Need to run regression teststests/run_tests.RExecute the automated test suite
Need exact test assertions or edge casestests/testthat/test-clustering.RInspect validation, reproducibility, and output checks

Usage

bash
Rscript scripts/main.R \
  --input_file ./expression_matrix.csv \
  --group_file ./sample_groups.csv \
  --output_dir ./output/ \
  --distance_method euclidean \
  --linkage_method complete \
  --label_column batch \
  --timeout_seconds 300 \
  --seed 42

Arguments

ShortLongTypeDefaultDescription
-i--input_filecharacterrequiredExpression matrix file (features as rows, samples as columns)
-g--group_filecharacterrequiredSample annotation file (first column sample ID, one metadata column for labels)
-o--output_dircharacter./output/Output directory
-d--distance_methodcharactereuclideanDistance metric for dist(): euclidean, maximum, manhattan, canberra, binary, minkowski
-m--linkage_methodcharactercompleteLinkage method for hclust(): complete, single, average, mcquitty, median, centroid, ward.D, ward.D2
-l--label_columncharactersecond columnColumn used as dendrogram labels
-c--label_cexnumeric0.8Dendrogram label size, must be > 0
-t--timeout_secondsinteger300Elapsed time limit in seconds, must be > 0
-s--seedinteger42Random seed for reproducibility

Input Format

Expression Matrix (input_file)

Features as rows, samples as columns, CSV format with feature IDs in the first column.

csv
,Sample01,Sample02,Sample03
TSPAN6,1.847876677,1.831755661,3.827625975
TNMD,0.034919984,0.053250385,1.388850793

Requirements:

  • The first column contains unique feature IDs.
  • All sample columns must be numeric.
  • Sample column names must be unique and non-empty.
  • At least two matched samples are required.

Sample Annotation (group_file)

CSV with sample IDs in the first column. The second column is used by default for leaf labels unless --label_column is provided.

csv
sample,batch
Sample01,batch1
Sample02,batch2
Sample03,batch1

Requirements:

  • Sample IDs must match expression matrix column names exactly.
  • The selected label column must exist and contain no empty values.
  • The file must contain at least one metadata column in addition to sample IDs.

Output Files

FileDescription
hierarchical_clustering_plot.pdfSample dendrogram plot
sample_distance_matrix.csvPairwise sample distance matrix
clustering_order.csvLeaf order shown in the dendrogram
matched_samples.csvSample-to-label table used for plotting
session_info.txtR session and package version info

Workflow

Step 1: Validate Input

WHEN checking file or parameter validation, READ: scripts/validation_utils.R

WHEN checking expression/group CSV handling, READ: scripts/input_functions.R

  • Check file existence
  • Reject empty files before parsing
  • Read the expression matrix and sample annotation CSV files
  • Validate required columns, unique IDs, and numeric expression values

Step 2: Align Samples

WHEN checking sample matching logic, READ: scripts/input_functions.R

  • Match sample IDs between the annotation file and expression matrix
  • Reorder matrix columns to the annotation file order
  • Select the label column used for plotting

Step 3: Build Hierarchical Clustering

WHEN interpreting distance or linkage behavior, READ: references/algorithm.md

WHEN checking clustering implementation, READ: scripts/clustering_functions.R

  • Transpose the expression matrix to sample-by-feature form
  • Compute pairwise sample distances with dist()
  • Build the dendrogram with hclust()

Step 4: Save Outputs

WHEN checking output staging and cleanup behavior, READ: scripts/run_analysis.R

WHEN checking PDF/CSV export behavior, READ: scripts/output_utils.R

WHEN checking timeout, session info, or final file copy behavior, READ: scripts/runtime_utils.R

  • Stage outputs in a temporary workspace
  • Export the pairwise distance matrix
  • Export the plotted leaf order
  • Render the dendrogram as PDF
  • Copy finalized outputs into the requested output directory

Methods

Distance Matrix

Sample distances are computed from the transposed expression matrix using base R dist().

Hierarchical Clustering

The clustering tree is built with base R hclust(). The default linkage method is complete, matching the source analysis script.


Examples

Basic Usage

bash
Rscript scripts/main.R \
  -i tests/data/sample_expression_matrix.csv \
  -g tests/data/sample_groups.csv \
  -o ./output/ \
  -t 300

Use Sample IDs as Labels

bash
Rscript scripts/main.R \
  -i tests/data/sample_expression_matrix.csv \
  -g tests/data/sample_groups.csv \
  -o ./output_sample_labels/ \
  -l sample

Use Average Linkage

bash
Rscript scripts/main.R \
  -i tests/data/sample_expression_matrix.csv \
  -g tests/data/sample_groups.csv \
  -o ./output_average/ \
  -m average

Error Handling

Common Errors

ErrorCauseSolutionRead More
SKILL_DEPENDENCY_MISSINGRequired R package is not installedInstall the missing package and rerunreferences/troubleshooting.md#skill_dependency_missing
SKILL_FILE_NOT_FOUNDInput file does not exist or output directory could not be createdCheck the path and permissionsreferences/troubleshooting.md#skill_file_not_found
SKILL_EMPTY_FILEInput file is emptyRe-export the CSV and confirm it contains datareferences/troubleshooting.md#skill_empty_file
SKILL_EMPTY_DATACSV parsed successfully but contains no data rowsConfirm the CSV has at least one data rowreferences/troubleshooting.md#skill_empty_data
SKILL_PARSE_ERRORCSV parsing failedCheck encoding, delimiters, and CSV structurereferences/troubleshooting.md#skill_parse_error
SKILL_MISSING_COLUMNSExpected columns or headers are missingCheck CSV headers and metadata columnsreferences/troubleshooting.md#skill_missing_columns
SKILL_INVALID_TYPEExpression values or parameters have the wrong typeEnsure numeric fields are numericreferences/troubleshooting.md#skill_invalid_type
SKILL_SAMPLE_MISMATCHSample IDs do not matchEnsure the first column in group_file matches matrix column namesreferences/troubleshooting.md#skill_sample_mismatch
SKILL_INVALID_DATAExpression or annotation data is malformedCheck duplicate IDs, missing labels, and numeric valuesreferences/troubleshooting.md#skill_invalid_data
SKILL_INVALID_PARAMETERUnsupported distance, linkage, or label parameterUse one of the documented parameter valuesreferences/troubleshooting.md#skill_invalid_parameter
SKILL_TIMEOUTAnalysis exceeded the time limitIncrease --timeout_seconds and rerunreferences/troubleshooting.md#skill_timeout
SKILL_PLOT_ERRORPlot device failed while writing PDFCheck output directory permissions and rerunreferences/troubleshooting.md#skill_plot_error
SKILL_WRITE_ERROROutput or intermediate files could not be writtenCheck output directory permissions and free disk spacereferences/troubleshooting.md#skill_write_error
SKILL_WARNINGNon-fatal warning occurred during executionInspect console warnings and verify output qualityreferences/troubleshooting.md#skill_warning
SKILL_MEMORY_WARNINGMemory usage exceeded the warning thresholdReduce input size or rerun with more memoryreferences/troubleshooting.md#skill_memory_warning

IF error persists, READ: references/troubleshooting.md


Testing

Test with Sample Data

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

# Run with sample data
Rscript scripts/main.R \
  -i tests/data/sample_expression_matrix.csv \
  -g tests/data/sample_groups.csv \
  -o ./output/

# Run unit tests (requires testthat and data.table)
Rscript tests/run_tests.R

Validation Commands

bash
# Check main output plot exists
ls -la ./output/hierarchical_clustering_plot.pdf

# Inspect clustering order
wc -l ./output/clustering_order.csv

Implementation Checklist

  • CLI parsing with optparse
  • set.seed() for reproducibility
  • Input validation (file existence, emptiness, types, required columns)
  • Try-catch based fatal error handling
  • Standardized SKILL_* error classification
  • Timeout control with setTimeLimit()
  • Standardized console-only logging
  • Base R clustering implementation
  • Session info recording with sink()
  • Temporary workspace cleanup with on.exit()
  • Memory usage reporting with gc()
  • File reading instructions in SKILL.md
  • Modular script structure across scripts/
  • Test template added under tests/testthat/
  • Test data provided
  • Error handling with SKILL_* codes
  • get_script_dir() defined before use
  • Scripts in scripts/ directory
  • References in references/ directory

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

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Hierarchical Clustering Plot faz?

Use when building a sample-level hierarchical clustering dendrogram from a bulk expression matrix and sample annotation table, especially for QC, batch inspection, or sample similarity assessment. Trigger keywords: hierarchical clustering, dendrogram, sample QC, batch inspection, sample similarity. NOT for: differential expression testing, gene clustering heatmaps, single-cell clustering workflows.

Por que usar Hierarchical Clustering Plot no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. Hierarchical Clustering Plot é escrito em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. O TypingMind usa suas próprias chaves de API, então o pagamento é feito diretamente aos provedores, em vez de uma assinatura por licença de usuário, e suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Hierarchical Clustering Plot no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/hierarchical-clustering-plot. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Hierarchical Clustering Plot?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Hierarchical Clustering Plot?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Hierarchical Clustering Plot com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Hierarchical Clustering Plot é gratuita?

Sim. A habilidade é publicada no GitHub por aipoch sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, modelos de documento ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas para chamar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA fornece conhecimento e um processo ao modelo: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver todos

Crie seu próprio espaço de IA agora

Inscreva-se na nossa newsletter para receber novidades sobre recursos e futuros sorteios 👇