Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

bio-expression-matrix-counts-ingest

БесплатноЗапускает вложенные скриптыНе проверен

Load gene expression count matrices from various formats including CSV, TSV, featureCounts, Salmon, kallisto, and 10X. Use when importing quantification…

gabrielmoreiraот gabrielmoreira★ 23 звезды на GitHub

Об этом скилле

Version Compatibility

Reference examples tested with: pandas 2.2+, tximport 1.30+, tximeta 1.20+

Before using code patterns, verify installed versions match. If versions differ:

  • Python: pip show <package> then help(module.function) to check signatures
  • R: packageVersion('<pkg>') then ?function_name to verify parameters

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Count Matrix Ingestion

Expression Units Decision Table

Unit Source Use for DE Use for visualization Cross-sample comparison
Raw counts featureCounts, HTSeq, STAR Yes (DE tools normalize internally) No No
Estimated counts Salmon, kallisto (via tximport) Yes (with offset correction) No No
TPM Salmon, kallisto No Within-sample gene comparison Partially (same composition caveat)
FPKM/RPKM Cufflinks, legacy tools No Within-sample only No (composition bias)
Normalized counts DESeq2, edgeR Via DE tool Prefer VST/rlog Yes

For differential expression, always provide raw integer counts. DE tools (DESeq2, edgeR, limma-voom) model count distributions and handle normalization internally.

Transcript-Level vs Gene-Level Quantification

Salmon and kallisto quantify at the transcript level. Naive summation of transcript counts to gene level introduces length bias: if treatment causes a shift from short to long isoforms, the gene appears upregulated even if the number of mRNA molecules is unchanged. Use tximport in R (or equivalent offset handling in Python) to correct for this.

For detailed tximport workflows, see rna-quantification/tximport-workflow. Key decisions:

  • countsFromAbundance='no' (default): raw estimated counts with length offsets for DESeq2 (recommended)
  • countsFromAbundance='lengthScaledTPM': required for limma-voom, which cannot use offset matrices
  • countsFromAbundance='scaledTPM': prevents differential transcript usage from creating spurious DGE

Basic CSV/TSV Loading

Goal: Load a gene expression count matrix from a delimited text file into a pandas DataFrame.

Approach: Read CSV/TSV with gene IDs as the row index, handling comment lines if present.

"Load my count matrix" → Read a delimited file into a DataFrame with genes as rows and samples as columns.

import pandas as pd

# TSV with gene IDs as first column
counts = pd.read_csv('counts.tsv', sep='\t', index_col=0)

# CSV with header
counts = pd.read_csv('counts.csv', index_col=0)

# Skip comment lines
counts = pd.read_csv('counts.txt', sep='\t', index_col=0, comment='#')

featureCounts Output

Goal: Parse featureCounts output into a clean count matrix by stripping metadata columns.

Approach: Skip the 6 annotation columns (Chr, Start, End, Strand, Length) and clean BAM path suffixes from column names.

import pandas as pd

# featureCounts format has 6 metadata columns before counts
fc = pd.read_csv('featurecounts.txt', sep='\t', comment='#')
counts = fc.set_index('Geneid').iloc[:, 5:]  # Skip Chr, Start, End, Strand, Length
counts.columns = [c.replace('.bam', '').split('/')[-1] for c in counts.columns]

Salmon Quant Files

Goal: Combine per-sample Salmon quantification files into a single count or TPM matrix.

Approach: Iterate over quant directories, extract the desired column from each quant.sf, and merge into a DataFrame.

import pandas as pd
from pathlib import Path

def load_salmon_quants(quant_dirs, column='NumReads'):
    '''Load multiple Salmon quant.sf files into a count matrix.'''
    dfs = {}
    for qdir in quant_dirs:
        sample = Path(qdir).name
        sf = pd.read_csv(f'{qdir}/quant.sf', sep='\t', index_col=0)
        dfs[sample] = sf[column]
    return pd.DataFrame(dfs)

# Usage
quant_dirs = ['salmon_out/sample1', 'salmon_out/sample2', 'salmon_out/sample3']
counts = load_salmon_quants(quant_dirs, column='NumReads')
tpm = load_salmon_quants(quant_dirs, column='TPM')

STAR ReadsPerGene Files

Goal: Load STAR gene-level count output, selecting the correct strandedness column.

Approach: STAR outputs 4 columns per gene: gene ID, unstranded counts, sense-strand counts, antisense-strand counts. Selecting the wrong strand column silently halves the counts.

import pandas as pd
from pathlib import Path

def load_star_genecounts(filepaths, strandedness='reverse'):
    '''Load STAR ReadsPerGene.out.tab files.

    strandedness: 'unstranded' (col 1), 'forward' (col 2), 'reverse' (col 3)
    For Illumina TruSeq stranded libraries, use 'reverse'.
    '''
    col_map = {'unstranded': 1, 'forward': 2, 'reverse': 3}
    col_idx = col_map[strandedness]
    dfs = {}
    for fp in filepaths:
        sample = Path(fp).name.replace('_ReadsPerGene.out.tab', '')
        df = pd.read_csv(fp, sep
Полный SKILL.md на GitHub

Установить bio-expression-matrix-counts-ingest в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

examples/load_counts.pyusage-guide.md

FAQ

Что делает скилл bio-expression-matrix-counts-ingest?

Load gene expression count matrices from various formats including CSV, TSV, featureCounts, Salmon, kallisto, and 10X. Use when importing quantification results for downstream analysis.

Как установить скилл bio-expression-matrix-counts-ingest?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл bio-expression-matrix-counts-ingest запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить bio-expression-matrix-counts-ingest с