small-rna-seq/mirge3-analysis/SKILL.md
Quantifies known miRNAs, isomiRs, tRFs, and A-to-I editing fast with miRge3.0 by aligning collapsed reads to curated miRBase or MirGeneDB libraries. Use when choosing miRBase versus MirGeneDB as the reference; deciding whether to collapse isomiRs to the parent miRNA or keep 5'-isomiRs separate (they shift the seed and retarget); confirming the organism is among the six supported species; or remembering that RPM output is for display only and raw counts go to DESeq2/edgeR.
npx skillsauth add GPTomics/bioSkills bio-small-rna-seq-mirge3-analysisInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reference examples tested with: miRge3.0 0.1.4+, numpy 1.26+, pandas 2.2+
Before using code patterns, verify installed versions match. If versions differ:
miRge3.0 annotate --help to confirm flag names (they have drifted across versions)pip show <package> then help(module.function) to check signaturesIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
"Quantify my miRNAs and isomiRs fast" -> Align collapsed reads to a hierarchy of curated small-RNA libraries and tabulate per-miRNA counts, isomiR variants, tRFs, and A-to-I editing.
miRge3.0 annotate -s sample.fastq.gz -lib LIBS -on human -db miRBase -a illumina -gff -ai -cpu 8 -o out/miRge3.0 does not do genome-wide de novo discovery as its main job; it Bowtie-aligns collapsed reads against small curated libraries (mature miRBase or MirGeneDB, hairpin, tRNA, rRNA, snoRNA, mRNA, spike-ins) hierarchically and assigns each read to the first matching class. That is why it is fast, and why it is the default for a routine differential-expression study on a supported species - and why it cannot help on an unsupported organism (it ships pre-built libraries for only six species: human, mouse, rat, zebrafish, nematode, fruitfly). For serious NOVEL discovery prefer miRDeep2; miRge3's optional -nmir SVM module is a convenience, not its strength.
Two judgments carry the analysis. First, isomiRs are real biology, not noise: a 5' isomiR shifts the seed (positions 2-7) and therefore the target set, so collapsing all isomiRs to the canonical miRNA can hide function - keep 5' isomiRs separate when isomiR identity is the question, and collapse to the parent only for a standard "which miRNAs changed" analysis. But the precision floor cuts the other way: low-count 3' and internal isomiRs are frequently sequencing/ligation artifacts (per-base error ~0.1-1% plus ligation bias), so filter them aggressively and demand replicate or UMI support, and trust 5' isomiRs more. A germline seed SNP (a polymiR) masquerades as an isomiR or edit; with genotypes available, fold them into the reference (e.g. OptimiR) rather than calling them isomiRs. Second, miRge3 emits both raw counts and RPM, but RPM is for display and cross-sample viewing only; differential testing takes RAW counts into DESeq2/edgeR, which model the count distribution themselves.
-db)| Reference | Size | Character | Choose when | |-----------|------|-----------|-------------| | miRBase (v22) | large (~1900 human miRNAs) | permissive; includes many dubious entries (mis-annotated tRFs/fragments) | maximizing recall / comparability with legacy studies | | MirGeneDB | small (~550 human genes) | conservatively curated; every entry passes the biogenesis signature | conservative, high-confidence claims; cleaner DE feature set |
The reference choice changes results: counting against miRBase yields more "miRNA" rows, some of which are not bona fide miRNAs; against MirGeneDB the rows are fewer and defensible. miRge3 can emit both side by side - report which one a result came from, and pin the version.
# miRge3.0 has NO '--download-library' subcommand. Fetch the pre-built libraries from
# SourceForge and extract them, then point -lib at the extracted directory.
wget https://sourceforge.net/projects/mirge3/files/miRge3_Lib/human.tar.gz
tar -xzf human.tar.gz # creates a 'human' library tree
# For an unsupported organism, build a custom library with the separate miRge3_build tool.
Goal: Produce a per-miRNA count matrix with isomiR and editing detail for one or more samples.
Approach: Run miRge3.0 annotate with the curated library, organism, database, and adapter, switching on mirGFF3 isomiR output and A-to-I detection.
miRge3.0 annotate \
-s sample1.fastq.gz,sample2.fastq.gz \
-lib /path/to/miRge3_Lib \
-on human \
-db miRBase \
-a illumina \
-gff \
-ai \
-cpu 8 \
-o output_dir
# -s: comma-separated FASTQs (raw or already adapter-known)
# -on: organism (human|mouse|rat|zebrafish|nematode|fruitfly)
# -db: miRBase or MirGeneDB
# -a: adapter as a name ('illumina') OR a raw sequence (e.g. TGGAATTCTCGGGTGCCAAGG)
# -gff: emit isomiR results in mirGFF3 (the community-standard isomiR format)
# -ai: A-to-I editing. A seed A->I edit RETARGETS the miRNA (inosine reads as G), and
# mismatch-permissive alignment silently merges edited reads into the canonical
# count - keep -ai on and treat seed edits as distinct species, not noise.
# -cpu: threads
# QIAseq UMI library: -qumi removes Qiagen PCR duplicates; -umi gives the 5',3' trim lengths
miRge3.0 annotate -s qiaseq.fastq.gz -lib LIBS -on human -db miRBase \
-a AACTGTAGGCACCATCAAT -umi 0,12 -qumi -o out_umi
# Optional novel-miRNA prediction (SVM); needs the genome; prefer miRDeep2 for real discovery
miRge3.0 annotate -s sample.fastq.gz -lib LIBS -on human -db miRBase -a illumina -nmir -o out_novel
| File | Description |
|------|-------------|
| miR.Counts.csv | Raw read counts per miRNA (this feeds DESeq2/edgeR) |
| miR.RPM.csv | RPM-normalized counts (display only, NOT for DE testing) |
| *.gff3 | isomiR variants in mirGFF3 (with -gff) |
| annotation.report.html / .csv | RNA-class composition and QC report |
| a2i / editing report | A-to-I editing sites and frequencies (with -ai) |
Goal: Orchestrate miRge3 from a Python pipeline and load its outputs.
Approach: miRge3.0 is a command-line tool with no documented Python API, so invoke it with subprocess, then read the CSV outputs with pandas.
import subprocess
def run_mirge3(samples, lib_path, out_dir, organism='human', db='miRBase', adapter='illumina', threads=8):
cmd = ['miRge3.0', 'annotate',
'-s', ','.join(samples),
'-lib', lib_path,
'-on', organism,
'-db', db,
'-a', adapter,
'-gff', '-ai',
'-cpu', str(threads),
'-o', out_dir]
subprocess.run(cmd, check=True)
Goal: Read the miRge3 count matrix and remove near-zero noise before downstream analysis.
Approach: Load miR.Counts.csv, then filter to miRNAs with a minimum total count (most miRBase entries are near-zero noise).
import pandas as pd
def load_mirge3_counts(output_dir):
return pd.read_csv(f'{output_dir}/miR.Counts.csv', index_col=0)
def filter_low_counts(counts, min_total=10):
# Lower than an mRNA threshold because miRNA libraries have fewer total counts;
# hand the SURVIVING RAW counts (not RPM) to DESeq2/edgeR for testing.
return counts[counts.sum(axis=1) >= min_total]
Goal: Decide whether to collapse isomiRs to the parent miRNA or keep seed-shifting 5' variants separate.
Approach: Parse the mirGFF3 isomiR table, classify each variant by 5' vs 3' change, and aggregate to the parent only for variants that preserve the seed.
def summarize_isomirs(isomir_counts):
# 5' isomiRs shift the seed and retarget -> keep separate when isomiR identity is
# the biology; 3' isomiRs mostly tune stability -> safe to collapse to the parent.
# KEEP the -5p/-3p arm in the parent key: the two arms have different seeds and
# targets and must never be merged (the dominant arm also switches across tissues).
# .values assigns positionally - index.str.extract returns a fresh RangeIndex that
# would otherwise misalign to all-NaN against the string index.
isomir_counts['miRNA'] = isomir_counts.index.str.extract(r'(hsa-\w+-\d+[a-z]*(?:-[35]p)?)')[0].values
summary = isomir_counts.groupby('miRNA').agg(
total_reads=('count', 'sum'),
n_isomirs=('count', 'count'),
dominant_isomir=('count', lambda x: x.idxmax()))
return summary
| Symptom | Cause | Fix |
|---------|-------|-----|
| unrecognized arguments: --isomir | Flag does not exist | isomiR counts are produced by default; use -gff for mirGFF3 output |
| unrecognized arguments: --download-library | No such subcommand | Download libraries from SourceForge and tar -xzf; point -lib at the tree |
| ModuleNotFoundError: mirge3.annotate | No documented Python API | Call the CLI with subprocess.run([...]) |
| Empty or tiny count matrix | Wrong -on, wrong -db case, or wrong adapter | Confirm a supported species; -db miRBase/MirGeneDB; check the adapter name/sequence |
| Organism not supported | Only six species ship libraries | Build a custom library with miRge3_build, or use miRDeep2/sRNAbench |
| Inflated DE significance on tiny miRNAs | RPM fed to the DE test | Feed RAW miR.Counts.csv, not miR.RPM.csv, to DESeq2/edgeR |
tools
End-to-end CLIP-seq pipeline from FASTQ to ENCODE-compliant binding sites, single-nucleotide crosslink maps, annotation, motifs, and (optionally) differential binding. Use when running the full Yeo lab eCLIP / iCLIP / iCLIP2 / iCLIP3 / irCLIP / PAR-CLIP analysis with SMInput control, protocol-specific UMI extraction, ENCODE STAR parameters, CLIPper or Skipper peak calling with stringent log2 FC and -log10 p thresholds, IDR rescue and self-consistency QC, and downstream motif registration with mCross or PEKA.
development
Detect, date, and contextualize whole-genome duplication (WGD / paleopolyploidy) events using wgd v2 (Chen et al 2024), KsRates (Sensalari 2022 substitution-rate-corrected Ks dating), DupGen_finder (Qiao 2019), MAPS (Li 2018 phylogenomic), POInT (Conant 2008 ordered-block), SLEDGe (2024 ML-based), Whale.jl (Bayesian DL+WGD), and synteny-anchored paranome construction. Use when identifying ancient polyploidy from Ks distributions and synteny block analysis, positioning WGD events relative to speciation, distinguishing tandem from segmental from WGD duplications, dating the 2R/3R vertebrate / fish / salmonid WGDs, building paranome and Ks-age mixture models, applying KsRates substitution-rate correction across lineages, or testing alternative biased-fractionation / dosage-balance models post-WGD.
tools
Build whole-genome alignments using Progressive Cactus (Armstrong 2020 reference-free clade-level WGA), Minigraph-Cactus (Hickey 2024 pangenome-aware), LASTZ chain/net (UCSC pipeline), MUMmer4 (Marçais 2018 pairwise), minimap2 -x asm5/10/20 (Li 2018 fast pairwise), AnchorWave (Song 2022 WGD-aware), and Mauve / progressiveMauve (bacterial). Operates the HAL toolkit (Hickey 2013) for downstream extraction including halSynteny, halLiftover, halBranchMutations, and hal2maf. Use when constructing multi-species alignments for comparative-annotation projection (TOGA), synteny detection, conservation analyses (phyloP / PhastCons), or pangenome graph construction; selecting between reference-free (Cactus) and reference-anchored (LASTZ chains/nets) approaches; tuning sensitivity for closely vs distantly related genomes; or producing HAL files for genome-wide downstream tools.
development
Detect syntenic blocks and structural rearrangements between genomes using MCScanX (Wang 2012), JCVI/MCScan (Tang 2008 Python), GENESPACE (Lovell 2022) for orthology-anchored riparian visualization, SyRI for structural variation, AnchorWave for sequence-level synteny, i-ADHoRe 3.0 for highly diverged species, SynNet for synteny networks, and ntSynt for multi-genome macrosynteny. Use when identifying collinear gene blocks across species, distinguishing macrosynteny from microsynteny, detecting inversions/translocations/duplications, anchoring orthology in WGD lineages, producing publication riparian plots, computing synteny block age via Ks (cross-references whole-genome-duplication), or running synteny-aware ortholog inference in polyploids.