featurecounts-rna-counting
Counts RNA-seq reads overlapping GTF gene features. Takes sorted STAR BAMs plus GTF; outputs a per-gene tab-delimited matrix across samples. Handles strandedness (0/1/2), paired-end, multi-sample batch counting in one command, and outputs assignment statistics.
Install / Use
npx skills add jaechang-hits/SciAgent-Skills --skill featurecounts-rna-countingInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
MarketingSupported Platforms
Tags
Our assessment of featurecounts-rna-counting
featurecounts-rna-counting scores 91/100 on our quality scale, 232nd of 649 Marketing skills we index (top 36%).
Its SKILL.md is 14 KB long, well organised into 46 sections with 11 code examples: a thorough specification that gives an agent plenty to work with.
It has 367 GitHub stars, a meaningful sign that others use it.
Maintenance, license and trust
- The repository was last updated about 3 months ago, so featurecounts-rna-counting is actively maintained.
- Our last check on 2026-11-20 found the source still online.
- No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
- Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-05. Automated pattern scan on 2026-10-05. It catches known dangerous patterns, not every risk — read a skill before letting an agent act on it.
featurecounts-rna-counting compared with similar skills
All 4 of these similar skills score higher than featurecounts-rna-counting; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| featurecounts-rna-counting (this skill)by jaechang-hits | 91 | 367 | 3mo ago | SKILL.md |
| algorithmic-artby anthropics | 100 | 177.9k | 58d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 58d ago | SKILL.md |
| prospectingby coreyhaines31 | 100 | 60.1k | 8d ago | SKILL.md |
| ad-creativeby coreyhaines31 | 100 | 60.1k | 8d ago | SKILL.md |
Frequently asked questions
- How do I install featurecounts-rna-counting?
- Run
npx skills add jaechang-hits/SciAgent-Skills --skill featurecounts-rna-counting. The install tabs above show the steps for each supported agent. - Which AI agents does featurecounts-rna-counting work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is featurecounts-rna-counting safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is featurecounts-rna-counting still maintained?
- The repository was last updated about 3 months ago, so featurecounts-rna-counting is actively maintained.
Skill content
View source on GitHubname: "featurecounts-rna-counting" description: "Counts RNA-seq reads overlapping GTF gene features. Takes sorted STAR BAMs plus GTF; outputs a per-gene tab-delimited matrix across samples. Handles strandedness (0/1/2), paired-end, multi-sample batch counting in one command, and outputs assignment statistics. Use Salmon for alignment-free quantification; use featureCounts when STAR BAMs already exist." license: "GPL-3.0"
featureCounts — RNA-seq Read Counting
Overview
featureCounts (part of the Subread package) assigns sequencing reads in BAM files to genomic features defined in a GTF/GFF annotation. It counts how many reads overlap each gene (or exon, intron, or custom feature), producing a gene × sample count matrix suitable for differential expression analysis with DESeq2 or edgeR. featureCounts processes multiple BAM files in a single command, reporting read assignment statistics (assigned, unassigned by category) alongside the count matrix. It is the standard counting step after STAR alignment in RNA-seq pipelines.
When to Use
- Generating gene-level count matrices from STAR-aligned BAM files for DESeq2 or edgeR
- Counting reads from multiple samples simultaneously in a single featureCounts command
- Handling stranded RNA-seq libraries where sense/antisense assignment matters
- Producing exon-level or custom-feature counts (e.g., for splicing analysis with DEXSeq)
- Verifying strandedness of an RNA-seq library when protocol documentation is unavailable
- Use Salmon instead when no BAM file exists and fast pseudoalignment is preferred
- Use HTSeq-count as an alternative with slower but more flexible counting modes
Prerequisites
- Software: Subread package (contains
featureCounts) - Input: Sorted BAM files from STAR or HISAT2, plus a matching GTF annotation file
Check before installing: The tool may already be available in the current environment (e.g., inside a
pixi/condaenv). Runcommand -v featureCountsfirst and skip the install commands below if it returns a path. When running inside a pixi project, invoke the tool viapixi run featureCountsrather than barefeatureCounts.
# Install with conda (recommended)
conda install -c bioconda subread
# Verify
featureCounts -v
# featureCounts v2.0.6
# Alternative: install via apt (Ubuntu/Debian)
sudo apt-get install subread
Pre-flight Interview
Settle these with the user before writing any analysis code.
decisions:
- id: D1
param: annotation
kind: required
source: upstream
ask: "Which GTF/GFF annotation file should be used, and does its assembly exactly match the BAM alignment reference?"
default: null
- id: D2
param: strandSpecific
kind: required
source: data
ask: "Which strandedness did the representative-alignment check infer, and does it agree with the library preparation?"
default: null
- id: D3
param: -t, -g
kind: optional
source: user
ask: "Should expression be summarized from exons to genes, or from another feature type for a specific downstream question?"
default: "-t exon -g gene_id"
- id: D4
param: -M, -O
kind: optional
source: user
ask: "Should reads with multiple genomic mappings or overlapping gene assignments be included in the count matrix?"
default: "exclude both multi-mappers and multi-overlap reads"
- id: D5
param: --minOverlap, --fracOverlap
kind: optional_conditional
source: user
ask: "Does the assay or feature definition require a minimum overlap stricter than one aligned base?"
default: "--minOverlap 1 --fracOverlap 0"
Incorrect library strandedness can substantially reduce or misassign counts; the magnitude varies by gene and annotation, so infer it from the data and treat an ambiguous result as a QC failure. Enabling multi-mapper counting can inflate counts for paralogs and repeat-associated genes. Neither setting necessarily produces a software error.
Quick Start
# Count reads for multiple samples (unstranded paired-end RNA-seq)
featureCounts \
-a gencode.v47.annotation.gtf \
-o counts/gene_counts.txt \
-T 8 \
-p --countReadPairs \
results/sample1/Aligned.sortedByCoord.out.bam \
results/sample2/Aligned.sortedByCoord.out.bam
echo "Count matrix: counts/gene_counts.txt"
head -3 counts/gene_counts.txt
Workflow
Step 1: Prepare BAM Files and GTF
Ensure BAM files are sorted and indexed, and the GTF matches the genome assembly.
# Verify BAM files are sorted
samtools view -H results/sample1/Aligned.sortedByCoord.out.bam | grep "SO:"
# Expected: SO:coordinate
# List BAMs to count
ls results/*/Aligned.sortedByCoord.out.bam | head -5
# Download GENCODE GTF (same version used for STAR indexing)
wget https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_47/gencode.v47.primary_assembly.annotation.gtf.gz
gunzip gencode.v47.primary_assembly.annotation.gtf.gz
echo "GTF lines: $(wc -l < gencode.v47.primary_assembly.annotation.gtf)"
Step 2: Determine Library Strandedness
Test strandedness using a small read count to set the -s parameter correctly.
# Quick strandedness check: count 1 sample with all 3 modes
# Compare assigned rates: highest = correct mode
for strand in 0 1 2; do
echo "=== Strandedness -s $strand ==="
featureCounts \
-a gencode.v47.primary_assembly.annotation.gtf \
-o /tmp/test_s${strand}.txt \
-T 4 \
-p --countReadPairs \
-s $strand \
results/sample1/Aligned.sortedByCoord.out.bam 2>&1 \
| grep "Successfully assigned"
done
# Rule: 0=unstranded if similar rates; 1 or 2 if one is much higher
Step 3: Count Unstranded Paired-End RNA-seq
Standard configuration for unstranded libraries (most polyA-selected RNA-seq).
mkdir -p counts
# Multi-sample batch counting: pass all BAMs as positional arguments
featureCounts \
-a gencode.v47.primary_assembly.annotation.gtf \
-o counts/gene_counts.txt \
-T 8 \
-p \
--countReadPairs \
-s 0 \
-t exon \
-g gene_id \
results/ctrl_1/Aligned.sortedByCoord.out.bam \
results/ctrl_2/Aligned.sortedByCoord.out.bam \
results/treat_1/Aligned.sortedByCoord.out.bam \
results/treat_2/Aligned.sortedByCoord.out.bam
echo "Count matrix: $(wc -l < counts/gene_counts.txt) genes"
# Also generates: counts/gene_counts.txt.summary (assignment stats)
cat counts/gene_counts.txt.summary
Step 4: Count Stranded Libraries
For strand-specific libraries (TruSeq Stranded, QuantSeq), set the correct strandedness.
# Reverse-stranded library (most TruSeq Stranded protocols): -s 2
featureCounts \
-a gencode.v47.primary_assembly.annotation.gtf \
-o counts/gene_counts_stranded.txt \
-T 8 \
-p --countReadPairs \
-s 2 \
results/*/Aligned.sortedByCoord.out.bam
# Forward-stranded (e.g., Lexogen QuantSeq, Takara SMARTer): -s 1
# featureCounts ... -s 1 ...
echo "Stranded count complete."
head -2 counts/gene_counts_stranded.txt
Step 5: Load Count Matrix into Python for DESeq2
Parse the featureCounts output file and prepare for differential expression.
import pandas as pd
# featureCounts output has 6 metadata columns before count columns
counts_raw = pd.read_csv("counts/gene_counts.txt", sep="\t", comment="#")
print(f"Columns: {list(counts_raw.columns)}")
# Metadata columns: Geneid, Chr, Start, End, Strand, Length
# Count columns start at index 6
count_cols = counts_raw.columns[6:] # BAM file paths as column names
counts = counts_raw.set_index("Geneid")[count_cols].copy()
# Rename columns to sample names (strip path and file extension)
import re
counts.columns = [re.sub(r".*/|Aligned\.sortedByCoord\.out\.bam", "", col)
for col in counts.columns]
print(f"Count matrix shape: {counts.shape}") # (genes × samples)
print(f"Samples: {list(counts.columns)}")
print(f"Genes with counts > 0: {(counts.sum(axis=1) > 0).sum()}")
counts.to_csv("gene_count_matrix.tsv", sep="\t")
print("Saved: gene_count_matrix.tsv")
Step 6: Run DESeq2 with featureCounts Matrix
Use the count matrix directly in pydeseq2 for differential expression.
import pandas as pd
from pydeseq2.dds import DeseqDataSet
from pydeseq2.default_inference import DefaultInference
from pydeseq2.ds import DeseqStats
# Load count matrix (genes × samples)
counts = pd.read_csv("gene_count_matrix.tsv", sep="\t", index_col=0).T
print(f"Count matrix: {counts.shape} (samples × genes)")
# Sample metadata
metadata = pd.DataFrame({
"condition": ["control", "control", "treated", "treated"]
}, index=counts.index)
# Filter low-count genes (recommended before DESeq2)
counts_filtered = counts.loc[:, counts.sum() > 10]
print(f"Genes after low-count filter: {counts_filtered.shape[1]}")
# Run DESeq2
dds = DeseqDataSet(counts=counts_filtered, metadata=metadata,
design_factors="condition",
inference=DefaultInference(n_cpus=8))
dds.deseq2()
stat_res = DeseqStats(dds, contrast=["condition", "treated", "control"],
inference=DefaultInference())
stat_res.summary()
results = stat_res.results_df
sig = results[results["padj"] < 0.05]
print(f"DE genes (padj < 0.05): {len(sig)}")
print(sig.sort_values("log2FoldChange", ascending=False).head())
Key Parameters
| Parameter | Default | Range/Options | Effect |
|-----------|---------|---------------|--------|
| -a | required | GTF/GFF3 path | Annotation file; must match genome assembly used for alignment |
| -o | required | file path | Output count table path (also creates <output>.summary) |
| -T | 1 | 1–64 | CPU threads; 8–16 is typical |
| -s | 0 | 0 (unstranded), 1 (stranded), 2 (reverse-stranded) | Library strandedness; wrong value causes major undercounting |
| -p | off | flag | Paired-end mode; reads counted as fragments not individual reads |
| --countReadPairs | off | flag | For PE: count pairs not reads (use with -p) |
| -t | exon | feature type string | Feature type to count from GTF column 3 |
| -g | gene_id | attribute string | GTF attribute to group features (use gene_id for genes) |
| --minOverlap | 1 | 1–100 | Minimum bases a read must overlap a feature to be counted |
| --fracOverlap | 0 | 0–1 | Fraction of read that must overlap; 0.2 for stricter counting |
| -O | off | flag | Allow reads to be assigned to multiple overlapping features |
| -M | off | flag | Count multi-mapping reads (default: only uniquely mapped) |
Common Recipes
Recipe 1: Count with Subread Package via Python subprocess
import subprocess
import re
from pathlib import Path
def run_featurecounts(bam_files: list, gtf: str, outfile: str,
threads: int = 8, strandedness: int = 0,
paired_end: bool = True) -> dict:
"""Run featureCounts and return assignment statistics."""
cmd = [
"featureCounts",
"-a", gtf,
"-o", outfile,
"-T", str(threads),
"-s", str(strandedness),
"-t", "exon",
"-g", "gene_id",
]
if paired_end:
cmd += ["-p", "--countReadPairs"]
cmd += bam_files
result = subprocess.run(cmd, capture_output=True, text=True)
# Parse summary from stderr
stats = {}
for line in result.stderr.splitlines():
if "Assigned" in line:
stats["assigned_pct"] = float(re.search(r"(\d+\.\d+)%", line).group(1))
return stats
bams = list(Path("results").glob("*/Aligned.sortedByCoord.out.bam"))
bam_list = [str(b) for b in sorted(bams)]
stats = run_featurecounts(bam_list, "gencode.v47.primary_assembly.annotation.gtf",
"counts/gene_counts.txt")
print(f"Assigned reads: {stats.get('assigned_pct', 'N/A')}%")
Recipe 2: Add featureCounts to a Snakemake Pipeline
# Snakefile — featureCounts rule after STAR ali
Truncated for display — read the full file on GitHub.
Related Skills
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
prospecting
60.1kWhen the user wants to find and qualify prospects for outbound, or asks who to target first, which signal to prioritize, or where to spot buyers with the problem: buying signals, enrichment, verification, account research.
ad-creative
60.1kWhen the user wants to write or judge ad creative, or asks which ad, hook, or angle to run or kill: headlines, primary text, and variations for Google, Meta, LinkedIn, and TikTok, fresh angles when creative fatigues. Test hypotheses name the metric, comparison, and expected direction.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
