Logo Hierarchical Clustering Plot

Hierarchical Clustering Plot

Tổ chứcPhổ biến
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.

Tổng quan

Nhà phát hànhaipoch
Kho mãmedical-research-skills
Tên kỹ nănghierarchical-clustering-plot
Sao
1.9K
Bản fork
175
Tệp đi kèm
17
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 17 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được aipoch công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Hierarchical Clustering Plot trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/hierarchical-clustering-plot
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.

Sử dụng trong TypingMind

Bật Hierarchical Clustering Plot trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Hierarchical Clustering Plot ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Hierarchical Clustering Plot không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Hierarchical Clustering Plot làm được gì?

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.

Vì sao nên dùng Hierarchical Clustering Plot trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Hierarchical Clustering Plot là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Hierarchical Clustering Plot trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/aipoch/medical-research-skills/tree/main/awesome-med-research-skills/Data%20Analysis/hierarchical-clustering-plot. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Hierarchical Clustering Plot?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Hierarchical Clustering Plot với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Hierarchical Clustering Plot với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Hierarchical Clustering Plot có miễn phí không?

Có. Kỹ năng này được aipoch phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇