stat-pca
Perform PCA on a numeric data matrix to reduce dimensionality, visualize sample structure, and identify top contributing features.
- License 许可
- MIT
- 最近更新
- 2026-11-03
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- stat-pca
- description
- Perform PCA on a numeric data matrix to reduce dimensionality, visualize sample structure, and identify top contributing features.
02 资源文件 3
- 参考文档agents/claude.yaml366 B
- 参考文档agents/openai.yaml367 B
- 参考文档config.yaml301 B
03 SKILL.md 正文
Skill: Principal Component Analysis
Use When
- User wants to explore sample structure or batch effects in high-dimensional data (RNA-seq, proteomics, metabolomics)
- User needs dimensionality reduction before clustering or modeling
- User wants to identify which features (genes, proteins) drive sample separation
- User wants a PCA plot colored by sample metadata
Inputs
- Required:
- Data matrix (CSV or TSV): rows = samples, columns = features (or transposed — specify orientation)
- Optional:
- Matrix orientation:
samples_as_rows(default) orsamples_as_columns - Number of PCs to compute (default:
10or min(n_samples, n_features)) - Metadata table (CSV or TSV) with sample annotations for plot coloring (must share sample IDs)
- Color-by column from metadata (default: first metadata column)
- Scale features before PCA:
true(default) orfalse - Output directory (default:
./pca_output)
- Matrix orientation:
Workflow
- Read data matrix; orient so rows = samples.
- Check for and remove zero-variance features; log-transform if all values are non-negative and range > 100 (log1p).
- Center and optionally scale features (z-score standardization).
- Compute PCA using singular value decomposition.
- Report variance explained per PC; plot scree plot.
- Extract sample coordinates on PC1–PC10 and feature loadings on PC1–PC5.
- Plot PC1 vs. PC2 scatter; if metadata provided, color by specified annotation column; label outlier samples.
- Report top 20 features with highest absolute loading on PC1 and PC2.
- Write PC coordinates (TSV), loadings (TSV), variance explained (TSV), scree plot (PDF), and PCA scatter plot (PDF) to output directory.
- Save the executable analysis script (
analysis_code.pyoranalysis_code.R) and software version manifest (session_info.txt) used to produce results.
Output Contract
- PC coordinates table (TSV): sample_id, PC1, PC2, ..., PC10
- Feature loadings table (TSV): feature_id, PC1_loading, PC2_loading, ..., PC5_loading
- Variance explained table (TSV): PC, variance_explained, cumulative_variance
- Scree plot (PDF)
- PCA scatter plot (PDF, PC1 vs. PC2)
- Reproducibility artifacts:
analysis_code.pyoranalysis_code.R, plussession_info.txt
Limits
- PCA is a linear method; nonlinear structure may not be captured — use
stat-nonlinear-embeddingfor t-SNE/UMAP. - Features must outnumber the number of components requested; otherwise reduce n_components.
- Scaling is critical when features have different units or dynamic ranges.
- Common failure: sample ID mismatch between data matrix and metadata table.
04 同仓库更多 Skills
structured-intelligence-skill-creator
Create or update repository skills that conform to local templates, provider metadata requirements, registry rules, and validation workflows.
stat-survival-analysis
Estimate and compare survival functions using Kaplan-Meier curves and log-rank test, with optional Cox proportional hazards regression.
stat-pairwise-correlation
Compute pairwise correlations and significance tests across all numeric variables, and produce a correlation heatmap.
stat-nonlinear-embedding
Embed high-dimensional data into 2D using t-SNE or UMAP for exploratory visualization of sample or cell relationships.
stat-logistic-regression
Fit a logistic regression model for binary outcomes, report odds ratios and model performance (AUC-ROC, confusion matrix).
stat-learn-bayesian-network
Learn the structure and conditional probabilities of a Bayesian network from observational data for causal discovery or dependency modeling.