Skip to content
Back to skills

Phangorn

ASecurity

R phangorn package for phylogenetic analysis. Use for phylogenetic reconstruction and analysis.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added June 4, 2026
datago

Security analysis

A100/100

Scanned June 4, 2026

npx -y skills add LeoLin990405/r-analytics-skill --skill phangorn --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Phangorn?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Phangorn
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/leolin990405-phangorn/badge)](https://www.skillsdirectory.com/skills/leolin990405-phangorn)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: phangorn
description: R phangorn package for phylogenetic analysis. Use for phylogenetic reconstruction and analysis.
---

# phangorn

Phylogenetic analysis in R.

## Reading Data

```r
library(phangorn)

# Read alignment
alignment <- read.phyDat("alignment.fasta", format = "fasta")

# Read Nexus
alignment <- read.phyDat("alignment.nex", format = "nexus")

# From ape
library(ape)
dna <- read.dna("alignment.fasta", format = "fasta")
alignment <- as.phyDat(dna)
```

## Distance Methods

```r
# Compute distance matrix
dm <- dist.ml(alignment)

# Different models
dm <- dist.ml(alignment, model = "JC69")
dm <- dist.ml(alignment, model = "K80")
dm <- dist.ml(alignment, model = "F81")
dm <- dist.ml(alignment, model = "GTR")

# Neighbor-joining tree
tree_nj <- NJ(dm)

# UPGMA tree
tree_upgma <- upgma(dm)
```

## Maximum Parsimony

```r
# Parsimony score
parsimony(tree, alignment)

# Parsimony search
tree_mp <- pratchet(alignment)

# With rearrangements
tree_mp <- pratchet(alignment,
  minit = 100,
  maxit = 1000,
  k = 10)
```

## Maximum Likelihood

```r
# Fit model
fit <- pml(tree, alignment)

# Optimize
fit_opt <- optim.pml(fit,
  model = "GTR",
  optInv = TRUE,
  optGamma = TRUE)

# Model test
mt <- modelTest(alignment)
```

## Bootstrap

```r
# Bootstrap analysis
bs <- bootstrap.pml(fit_opt,
  bs = 100,
  optNni = TRUE)

# Plot with bootstrap values
plotBS(tree, bs, type = "phylogram")
```

## Tree Manipulation

```r
# Root tree
tree_rooted <- root(tree, outgroup = "species1")

# Midpoint rooting
tree_mid <- midpoint(tree)

# Consensus tree
consensus_tree <- consensus(trees, p = 0.5)
```

## Ancestral States

```r
# Ancestral state reconstruction
anc <- ancestral.pml(fit_opt, type = "ml")

# Plot
plotAnc(anc, 1)
```

## Model Comparison

```r
# AIC comparison
AIC(fit1, fit2)

# Likelihood ratio test
anova(fit1, fit2)
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…