27 lines
772 B
R
Executable File
27 lines
772 B
R
Executable File
#! /usr/bin/env Rscript
|
|
# DensiTree visualization of phylogenetic trees
|
|
args <- commandArgs(trailingOnly = TRUE)
|
|
if (length(args) != 6) {
|
|
stop("Usage: Rscript 05.densitree.r <tree_file> <tip_order_file> <root> <output_pdf> <width> <height>")
|
|
}
|
|
tree_file <- args[1]
|
|
tip_order_file <- args[2]
|
|
root <- args[3]
|
|
output_pdf <- args[4]
|
|
width <- as.numeric(args[5])
|
|
height <- as.numeric(args[6])
|
|
|
|
library(ape)
|
|
library(phangorn)
|
|
trees <- read.tree(tree_file)
|
|
pdf(output_pdf, width = width, height = height)
|
|
for(i in 1:length(trees)) {
|
|
trees[[i]] <- compute.brlen(root(trees[[i]], root))
|
|
}
|
|
tip_order <- rev(readLines(tip_order_file))
|
|
densiTree(trees, consensus=tip_order, alpha = 0.01,
|
|
col = "#009900", type = "cladogram",
|
|
label.offset = 0.02, scale.bar = FALSE
|
|
)
|
|
dev.off()
|