R Bioinformatics Skill
Sub-skills
| Sub-skill |
Description |
| r-bio-genomics |
GenomicRanges, Biostrings, annotation |
| r-bio-rnaseq |
DESeq2, edgeR, differential expression |
| r-bio-phylo |
ape, ggtree, phylogenetics |
Bioinformatics and biostatistics in R.
Core Packages
| Package |
Description |
| Bioconductor ★ |
Genomic data analysis platform |
| GenomicRanges |
Genomic intervals |
| Biostrings |
DNA/RNA/protein sequences |
| SummarizedExperiment |
Assay data container |
Genetics & Phylogenetics
| Package |
Description |
| genetics |
Genetic data handling |
| gap |
Genetic data analysis |
| ape |
Phylogenetics and evolution |
| ggtree |
Phylogenetic tree visualization |
Mixed Effects (Biostatistics)
| Package |
Description |
| lme4 ★ |
Mixed-effects models |
| nlme |
Mixed-effects with custom covariance |
| glmmTMB |
Generalized mixed-effects |
Visualization
| Package |
Description |
| pheatmap |
Pretty heatmaps |
| ComplexHeatmap |
Advanced heatmaps |
| EnhancedVolcano |
Volcano plots |
Quick Examples
# Install Bioconductor
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install()
# Install packages
BiocManager::install(c("DESeq2", "edgeR", "GenomicRanges"))
# GenomicRanges
library(GenomicRanges)
gr <- GRanges(
seqnames = c("chr1", "chr1", "chr2"),
ranges = IRanges(start = c(100, 200, 150), width = 50),
strand = c("+", "-", "+"),
score = c(1.5, 2.0, 3.0)
)
findOverlaps(gr1, gr2)
subsetByOverlaps(gr1, gr2)
# RNA-seq with DESeq2
library(DESeq2)
dds <- DESeqDataSetFromMatrix(
countData = counts,
colData = sample_info,
design = ~ condition
)
dds <- DESeq(dds)
res <- results(dds, contrast = c("condition", "treated", "control"))
sig <- res[which(res$padj < 0.05), ]
# Volcano plot
library(EnhancedVolcano)
EnhancedVolcano(res,
lab = rownames(res),
x = 'log2FoldChange',
y = 'pvalue',
pCutoff = 0.05,
FCcutoff = 1
)
# Heatmap
library(pheatmap)
pheatmap(mat,
scale = "row",
clustering_distance_rows = "correlation",
annotation_col = annotation
)
# Phylogenetic analysis
library(ape)
tree <- read.tree("tree.nwk")
plot(tree)
# Gene annotation
library(org.Hs.eg.db)
mapIds(org.Hs.eg.db,
keys = gene_ids,
column = "SYMBOL",
keytype = "ENSEMBL"
)
Common Workflows
RNA-seq Analysis
# 1. Load counts
counts <- read.csv("counts.csv", row.names = 1)
coldata <- read.csv("samples.csv", row.names = 1)
# 2. Create DESeq object
dds <- DESeqDataSetFromMatrix(counts, coldata, ~ condition)
# 3. Filter low counts
keep <- rowSums(counts(dds)) >= 10
dds <- dds[keep,]
# 4. Run DESeq
dds <- DESeq(dds)
# 5. Get results
res <- results(dds, alpha = 0.05)
resOrdered <- res[order(res$padj),]
# 6. Visualize
plotMA(res)
plotPCA(vst(dds), intgroup = "condition")
Gene Set Enrichment
library(clusterProfiler)
library(org.Hs.eg.db)
# GO enrichment
ego <- enrichGO(
gene = sig_genes,
OrgDb = org.Hs.eg.db,
keyType = "ENSEMBL",
)
dotplot(ego)
# KEGG enrichment
ekegg <- enrichKEGG(
gene = entrez_ids,
organism = "hsa"
)
Resources
1---2name: r-bio3description: R bioinformatics packages. Use for genomic data analysis, RNA-seq, phylogenetics, and Bioconductor workflows.4metadata:5 source: https://skillmd.com/skills/leolin990405/r-bio6---78# R Bioinformatics Skill910## Sub-skills1112| Sub-skill | Description |13|-----------|-------------|14| [r-bio-genomics](r-bio-genomics/SKILL.md) | GenomicRanges, Biostrings, annotation |15| [r-bio-rnaseq](r-bio-rnaseq/SKILL.md) | DESeq2, edgeR, differential expression |16| [r-bio-phylo](r-bio-phylo/SKILL.md) | ape, ggtree, phylogenetics |1718Bioinformatics and biostatistics in R.1920## Core Packages2122| Package | Description |23|---------|-------------|24| **Bioconductor** ★ | Genomic data analysis platform |25| **GenomicRanges** | Genomic intervals |26| **Biostrings** | DNA/RNA/protein sequences |27| **SummarizedExperiment** | Assay data container |2829## Genetics & Phylogenetics3031| Package | Description |32|---------|-------------|33| **genetics** | Genetic data handling |34| **gap** | Genetic data analysis |35| **ape** | Phylogenetics and evolution |36| **ggtree** | Phylogenetic tree visualization |3738## Mixed Effects (Biostatistics)3940| Package | Description |41|---------|-------------|42| **lme4** ★ | Mixed-effects models |43| **nlme** | Mixed-effects with custom covariance |44| **glmmTMB** | Generalized mixed-effects |4546## Visualization4748| Package | Description |49|---------|-------------|50| **pheatmap** | Pretty heatmaps |51| **ComplexHeatmap** | Advanced heatmaps |52| **EnhancedVolcano** | Volcano plots |5354## Quick Examples5556```r57# Install Bioconductor58if (!require("BiocManager", quietly = TRUE))59 install.packages("BiocManager")60BiocManager::install()6162# Install packages63BiocManager::install(c("DESeq2", "edgeR", "GenomicRanges"))6465# GenomicRanges66library(GenomicRanges)67gr <- GRanges(68 seqnames = c("chr1", "chr1", "chr2"),69 ranges = IRanges(start = c(100, 200, 150), width = 50),70 strand = c("+", "-", "+"),71 score = c(1.5, 2.0, 3.0)72)73findOverlaps(gr1, gr2)74subsetByOverlaps(gr1, gr2)7576# RNA-seq with DESeq277library(DESeq2)78dds <- DESeqDataSetFromMatrix(79 countData = counts,80 colData = sample_info,81 design = ~ condition82)83dds <- DESeq(dds)84res <- results(dds, contrast = c("condition", "treated", "control"))85sig <- res[which(res$padj < 0.05), ]8687# Volcano plot88library(EnhancedVolcano)89EnhancedVolcano(res,90 lab = rownames(res),91 x = 'log2FoldChange',92 y = 'pvalue',93 pCutoff = 0.05,94 FCcutoff = 195)9697# Heatmap98library(pheatmap)99pheatmap(mat,100 scale = "row",101 clustering_distance_rows = "correlation",102 annotation_col = annotation103)104105# Phylogenetic analysis106library(ape)107tree <- read.tree("tree.nwk")108plot(tree)109110# Gene annotation111library(org.Hs.eg.db)112mapIds(org.Hs.eg.db,113 keys = gene_ids,114 column = "SYMBOL",115 keytype = "ENSEMBL"116)117```118119## Common Workflows120121### RNA-seq Analysis122```r123# 1. Load counts124counts <- read.csv("counts.csv", row.names = 1)125coldata <- read.csv("samples.csv", row.names = 1)126127# 2. Create DESeq object128dds <- DESeqDataSetFromMatrix(counts, coldata, ~ condition)129130# 3. Filter low counts131keep <- rowSums(counts(dds)) >= 10132dds <- dds[keep,]133134# 4. Run DESeq135dds <- DESeq(dds)136137# 5. Get results138res <- results(dds, alpha = 0.05)139resOrdered <- res[order(res$padj),]140141# 6. Visualize142plotMA(res)143plotPCA(vst(dds), intgroup = "condition")144```145146### Gene Set Enrichment147```r148library(clusterProfiler)149library(org.Hs.eg.db)150151# GO enrichment152ego <- enrichGO(153 gene = sig_genes,154 OrgDb = org.Hs.eg.db,155 keyType = "ENSEMBL",156 ont = "BP"157)158dotplot(ego)159160# KEGG enrichment161ekegg <- enrichKEGG(162 gene = entrez_ids,163 organism = "hsa"164)165```166167## Resources168169- Bioconductor: https://www.bioconductor.org/170- DESeq2: https://bioconductor.org/packages/DESeq2/171- edgeR: https://bioconductor.org/packages/edgeR/172- GenomicRanges: https://bioconductor.org/packages/GenomicRanges/