single-cell-rna-qc
Performs quality control on single-cell RNA-seq data (.h5ad or .h5 files) using scverse best practices with MAD-based filtering and comprehensive visualizations. Use when users request QC analysis, filtering low-quality cells, assessing data quality, or following scverse/scanpy best practices for single-cell analysis.
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o single-cell-rna-qc.zip https://jpskill.com/download/22573.zip && unzip -o single-cell-rna-qc.zip && rm single-cell-rna-qc.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22573.zip -OutFile "$d\single-cell-rna-qc.zip"; Expand-Archive "$d\single-cell-rna-qc.zip" -DestinationPath $d -Force; ri "$d\single-cell-rna-qc.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
single-cell-rna-qc.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
single-cell-rna-qcフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 6
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
シングルセル RNA-seq 品質管理
scverse のベストプラクティスに従った、シングルセル RNA-seq データの自動 QC ワークフローです。
このスキルを使用する場面
ユーザーが以下のような場合に利用します。
- シングルセル RNA-seq データの品質管理 (QC) を要求する場合
- 低品質な細胞をフィルタリングしたり、データ品質を評価したりしたい場合
- QC の可視化やメトリクスが必要な場合
- scverse/scanpy のベストプラクティスに従うよう依頼する場合
- MAD ベースのフィルタリングや外れ値検出を要求する場合
サポートされている入力形式:
.h5adファイル (scanpy/Python ワークフローからの AnnData 形式).h5ファイル (10X Genomics Cell Ranger 出力)
デフォルトの推奨事項: ユーザーが特定のカスタム要件を持っている場合や、非標準のフィルタリングロジックを明示的に要求しない限り、アプローチ 1 (完全なパイプライン) を使用してください。
アプローチ 1: 完全な QC パイプライン (標準ワークフローに推奨)
scverse のベストプラクティスに従った標準的な QC には、コンビニエンススクリプト scripts/qc_analysis.py を使用します。
python3 scripts/qc_analysis.py input.h5ad
# または 10X Genomics の .h5 ファイルの場合:
python3 scripts/qc_analysis.py raw_feature_bc_matrix.h5
このスクリプトはファイル形式を自動的に検出し、適切に読み込みます。
このアプローチを使用する場面:
- 調整可能な閾値を持つ標準的な QC ワークフロー (すべての細胞が同じ方法でフィルタリングされます)
- 複数のデータセットの一括処理
- 迅速な探索的解析
- ユーザーが「ただ動けばよい」ソリューションを求めている場合
要件: anndata, scanpy, scipy, matplotlib, seaborn, numpy
パラメーター:
コマンドラインパラメーターを使用して、フィルタリング閾値と遺伝子パターンをカスタマイズします。
--output-dir- 出力ディレクトリ--mad-counts,--mad-genes,--mad-mt- counts/genes/MT% の MAD 閾値--mt-threshold- ミトコンドリア % の厳密なカットオフ--min-cells- 遺伝子フィルタリング閾値--mt-pattern,--ribo-pattern,--hb-pattern- 異なる種に対する遺伝子名パターン
現在のデフォルト値を確認するには --help を使用してください。
出力:
すべてのファイルは、デフォルトで <input_basename>_qc_results/ ディレクトリ (または --output-dir で指定されたディレクトリ) に保存されます。
qc_metrics_before_filtering.png- フィルタリング前の可視化qc_filtering_thresholds.png- MAD ベースの閾値オーバーレイqc_metrics_after_filtering.png- フィルタリング後の品質メトリクス<input_basename>_filtered.h5ad- ダウンストリーム解析に利用できる、クリーンでフィルタリングされたデータセット<input_basename>_with_qc.h5ad- QC アノテーションが保持された元のデータ
ユーザーがアクセスできるように出力をコピーする場合は、ユーザーが直接プレビューできるように、個々のファイル (ディレクトリ全体ではない) をコピーしてください。
ワークフローステップ
スクリプトは以下のステップを実行します。
- QC メトリクスの計算 - カウント深度、遺伝子検出、ミトコンドリア/リボソーム/ヘモグロビン含有量
- MAD ベースのフィルタリングの適用 - counts/genes/MT% の MAD 閾値を使用した許容的な外れ値検出
- 遺伝子のフィルタリング - 検出された細胞が少ない遺伝子を除去
- 可視化の生成 - 閾値オーバーレイを含む包括的な前/後プロット
アプローチ 2: モジュール式ビルディングブロック (カスタムワークフロー向け)
カスタム解析ワークフローや非標準の要件には、scripts/qc_core.py および scripts/qc_plotting.py のモジュール式ユーティリティ関数を使用します。
# scripts/ ディレクトリから実行するか、必要に応じて scripts/ を sys.path に追加してください
import anndata as ad
from qc_core import calculate_qc_metrics, detect_outliers_mad, filter_cells
from qc_plotting import plot_qc_distributions # 可視化が必要な場合のみ
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# ... ここにカスタム解析ロジック
このアプローチを使用する場面:
- 異なるワークフローが必要な場合 (ステップをスキップする、順序を変更する、サブセットに異なる閾値を適用する)
- 条件付きロジック (例: ニューロンと他の細胞で異なるフィルタリングを行う)
- 部分的な実行 (メトリクス/可視化のみで、フィルタリングは行わない)
- より大きなパイプライン内の他の解析ステップとの統合
- コマンドラインパラメーターがサポートする範囲を超えるカスタムフィルタリング基準
利用可能なユーティリティ関数:
qc_core.py から (コア QC 操作):
calculate_qc_metrics(adata, mt_pattern, ribo_pattern, hb_pattern, inplace=True)- QC メトリクスを計算し、adata にアノテーションを付与しますdetect_outliers_mad(adata, metric, n_mads, verbose=True)- MAD ベースの外れ値検出、ブールマスクを返しますapply_hard_threshold(adata, metric, threshold, operator='>', verbose=True)- 厳密なカットオフを適用し、ブールマスクを返しますfilter_cells(adata, mask, inplace=False)- ブールマスクを適用して細胞をフィルタリングしますfilter_genes(adata, min_cells=20, min_counts=None, inplace=True)- 検出によって遺伝子をフィルタリングしますprint_qc_summary(adata, label='')- 要約統計量を表示します
qc_plotting.py から (可視化):
plot_qc_distributions(adata, output_path, title)- 包括的な QC プロットを生成しますplot_filtering_thresholds(adata, outlier_masks, thresholds, output_path)- フィルタリング閾値を可視化しますplot_qc_after_filtering(adata, output_path)- フィルタリング後のプロットを生成します
カスタムワークフローの例:
例 1: メトリクスを計算して可視化するだけで、まだフィルタリングしない場合
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
plot_qc_distributions(adata, 'qc_before.png', title='Initial QC')
print_qc_summary(adata, label='Before filtering')
例 2: MT% フィルタリングのみを適用し、他のメトリクスは許容的に保つ場合
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# 高 MT% の細胞のみをフィルタリング
high_mt = apply_hard_threshold(adata, 'pct_counts_mt', 10, operator='>')
adata_filtered = filter_cells(adata, ~high_mt)
adata_filtered.write('filtered.h5ad')
例 3: 異なるサブセットに異なる閾値を適用する場合
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# タイプ固有の QC を適用 (cell_type メタデータが存在することを前提とします)
neurons = adata.obs['cell_type'] == 'neuron'
other_cells = ~neurons
# ニューロンはより高い MT% を許容し、他の細胞はより厳密な閾値を使用します
neuron_qc = apply_hard_threshold(adata[neurons], 'pct_counts_mt', 15, operator='>')
other_qc = apply_hard_thresho 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Single-Cell RNA-seq Quality Control
Automated QC workflow for single-cell RNA-seq data following scverse best practices.
When to Use This Skill
Use when users:
- Request quality control or QC on single-cell RNA-seq data
- Want to filter low-quality cells or assess data quality
- Need QC visualizations or metrics
- Ask to follow scverse/scanpy best practices
- Request MAD-based filtering or outlier detection
Supported input formats:
.h5adfiles (AnnData format from scanpy/Python workflows).h5files (10X Genomics Cell Ranger output)
Default recommendation: Use Approach 1 (complete pipeline) unless the user has specific custom requirements or explicitly requests non-standard filtering logic.
Approach 1: Complete QC Pipeline (Recommended for Standard Workflows)
For standard QC following scverse best practices, use the convenience script scripts/qc_analysis.py:
python3 scripts/qc_analysis.py input.h5ad
# or for 10X Genomics .h5 files:
python3 scripts/qc_analysis.py raw_feature_bc_matrix.h5
The script automatically detects the file format and loads it appropriately.
When to use this approach:
- Standard QC workflow with adjustable thresholds (all cells filtered the same way)
- Batch processing multiple datasets
- Quick exploratory analysis
- User wants the "just works" solution
Requirements: anndata, scanpy, scipy, matplotlib, seaborn, numpy
Parameters:
Customize filtering thresholds and gene patterns using command-line parameters:
--output-dir- Output directory--mad-counts,--mad-genes,--mad-mt- MAD thresholds for counts/genes/MT%--mt-threshold- Hard mitochondrial % cutoff--min-cells- Gene filtering threshold--mt-pattern,--ribo-pattern,--hb-pattern- Gene name patterns for different species
Use --help to see current default values.
Outputs:
All files are saved to <input_basename>_qc_results/ directory by default (or to the directory specified by --output-dir):
qc_metrics_before_filtering.png- Pre-filtering visualizationsqc_filtering_thresholds.png- MAD-based threshold overlaysqc_metrics_after_filtering.png- Post-filtering quality metrics<input_basename>_filtered.h5ad- Clean, filtered dataset ready for downstream analysis<input_basename>_with_qc.h5ad- Original data with QC annotations preserved
If copying outputs for user access, copy individual files (not the entire directory) so users can preview them directly.
Workflow Steps
The script performs the following steps:
- Calculate QC metrics - Count depth, gene detection, mitochondrial/ribosomal/hemoglobin content
- Apply MAD-based filtering - Permissive outlier detection using MAD thresholds for counts/genes/MT%
- Filter genes - Remove genes detected in few cells
- Generate visualizations - Comprehensive before/after plots with threshold overlays
Approach 2: Modular Building Blocks (For Custom Workflows)
For custom analysis workflows or non-standard requirements, use the modular utility functions from scripts/qc_core.py and scripts/qc_plotting.py:
# Run from scripts/ directory, or add scripts/ to sys.path if needed
import anndata as ad
from qc_core import calculate_qc_metrics, detect_outliers_mad, filter_cells
from qc_plotting import plot_qc_distributions # Only if visualization needed
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# ... custom analysis logic here
When to use this approach:
- Different workflow needed (skip steps, change order, apply different thresholds to subsets)
- Conditional logic (e.g., filter neurons differently than other cells)
- Partial execution (only metrics/visualization, no filtering)
- Integration with other analysis steps in a larger pipeline
- Custom filtering criteria beyond what command-line params support
Available utility functions:
From qc_core.py (core QC operations):
calculate_qc_metrics(adata, mt_pattern, ribo_pattern, hb_pattern, inplace=True)- Calculate QC metrics and annotate adatadetect_outliers_mad(adata, metric, n_mads, verbose=True)- MAD-based outlier detection, returns boolean maskapply_hard_threshold(adata, metric, threshold, operator='>', verbose=True)- Apply hard cutoffs, returns boolean maskfilter_cells(adata, mask, inplace=False)- Apply boolean mask to filter cellsfilter_genes(adata, min_cells=20, min_counts=None, inplace=True)- Filter genes by detectionprint_qc_summary(adata, label='')- Print summary statistics
From qc_plotting.py (visualization):
plot_qc_distributions(adata, output_path, title)- Generate comprehensive QC plotsplot_filtering_thresholds(adata, outlier_masks, thresholds, output_path)- Visualize filtering thresholdsplot_qc_after_filtering(adata, output_path)- Generate post-filtering plots
Example custom workflows:
Example 1: Only calculate metrics and visualize, don't filter yet
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
plot_qc_distributions(adata, 'qc_before.png', title='Initial QC')
print_qc_summary(adata, label='Before filtering')
Example 2: Apply only MT% filtering, keep other metrics permissive
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# Only filter high MT% cells
high_mt = apply_hard_threshold(adata, 'pct_counts_mt', 10, operator='>')
adata_filtered = filter_cells(adata, ~high_mt)
adata_filtered.write('filtered.h5ad')
Example 3: Different thresholds for different subsets
adata = ad.read_h5ad('input.h5ad')
calculate_qc_metrics(adata, inplace=True)
# Apply type-specific QC (assumes cell_type metadata exists)
neurons = adata.obs['cell_type'] == 'neuron'
other_cells = ~neurons
# Neurons tolerate higher MT%, other cells use stricter threshold
neuron_qc = apply_hard_threshold(adata[neurons], 'pct_counts_mt', 15, operator='>')
other_qc = apply_hard_threshold(adata[other_cells], 'pct_counts_mt', 8, operator='>')
Best Practices
- Be permissive with filtering - Default thresholds intentionally retain most cells to avoid losing rare populations
- Inspect visualizations - Always review before/after plots to ensure filtering makes biological sense
- Consider dataset-specific factors - Some tissues naturally have higher mitochondrial content (e.g., neurons, cardiomyocytes)
- Check gene annotations - Mitochondrial gene prefixes vary by species (mt- for mouse, MT- for human)
- Iterate if needed - QC parameters may need adjustment based on the specific experiment or tissue type
Reference Materials
For detailed QC methodology, parameter rationale, and troubleshooting guidance, see references/scverse_qc_guidelines.md. This reference provides:
- Detailed explanations of each QC metric and why it matters
- Rationale for MAD-based thresholds and why they're better than fixed cutoffs
- Guidelines for interpreting QC visualizations (histograms, violin plots, scatter plots)
- Species-specific considerations for gene annotations
- When and how to adjust filtering parameters
- Advanced QC considerations (ambient RNA correction, doublet detection)
Load this reference when users need deeper understanding of the methodology or when troubleshooting QC issues.
Next Steps After QC
Typical downstream analysis steps:
- Ambient RNA correction (SoupX, CellBender)
- Doublet detection (scDblFinder)
- Normalization (log-normalize, scran)
- Feature selection and dimensionality reduction
- Clustering and cell type annotation
同梱ファイル
※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。
- 📄 SKILL.md (7,980 bytes)
- 📎 LICENSE.txt (10,254 bytes)
- 📎 references/scverse_qc_guidelines.md (7,587 bytes)
- 📎 scripts/qc_analysis.py (9,533 bytes)
- 📎 scripts/qc_core.py (6,675 bytes)
- 📎 scripts/qc_plotting.py (8,501 bytes)