94 个版本 (35 个稳定版)
2.2.7 | 2024年5月30日 |
---|---|
2.1.8 | 2024年2月22日 |
2.1.5 | 2023年5月23日 |
2.1.2 | 2022年9月7日 |
0.29.0 | 2021年7月30日 |
#44 in 生物学
每月109 次下载
在 4 crates 中使用
605KB
4.5K SLoC
light_phylogeny 是一个专注于系统发育的 Rust 库。
您可以
-
读取、构建、修改并以 SVG 形式显示协调的系统发育树。
-
绘制允许 1、2 或 3 个协调级别的协调系统发育树
-
构建系统发育协调(或非协调)树的事件(丢失、复制、物种形成、转移)的 SVG 表示形式。
-
读取 recphyloxml 文件:创建基因树和关联物种树的 SVG 表示形式。
-
读取 2 个嵌套 recphyloxml 文件:创建基因树、关联共生树和关联物种树的 SVG 表示形式。
-
读取 newick 或 phyloxml 文件:仅创建基因树的 SVG 表示形式。
您可以使用 light_phylogeny 函数和方法构建、操作、修改或绘制系统发育树。
您可以使用基于 'light_phylogeny' 的 "thirdkind" 软件 https://github.com/simonpenel/thirdkind/wiki 以 1、2 或 3 个协调级别表示树
关键词:系统发育、协调树、系统发育树
格式
phyloXML、recPhyloXML、带根 newick(NHX 标签将不予考虑)。
输出示例
具有物种树的单一基因协调
没有物种树的相同基因协调
多基因协调
具有“自由生活”物种的示例
具有冗余转移的多基因树协调。仅显示 1 个基因树和红色转移,透明度根据转移的丰度而变化
有关更多示例,请参阅“thirdkind”软件 https://github.com/simonpenel/thirdkind。
使用API
https://crates.io/crates/light_phylogeny
您可以在“examples”目录中找到代码示例。
简单的Rust示例:读取newick.txt文件并创建svg
use light_phylogeny::{ArenaTree,Options,Config,read_newick,phyloxml_processing};
fn main() {
let mut tree: ArenaTree<String> = ArenaTree::default();
let options: Options = Options::new();
let config: Config = Config::new();
read_newick("examples/newick.txt".to_string(), &mut tree);
phyloxml_processing(&mut tree, &options, &config,"read_newick-clado.svg".to_string());
println!("Please open output file 'read_newick-clado.svg' with your browser");
let mut tree: ArenaTree<String> = ArenaTree::default();
let mut options: Options = Options::new();
options.real_length_flag = true;
let config: Config = Config::new();
read_newick("examples/newick.txt".to_string(), &mut tree);
phyloxml_processing(&mut tree, &options, &config,"read_newick-real-clado.svg".to_string());
println!("Please open output file 'read_newick-real-clado.svg' with your browser");
}
一些newick示例在此处可用: https://github.com/simonpenel/light_phylogeny/tree/master/newick_examples
简单的Rust示例:构建一个基因树,创建svg,修改树并创建一个新的svg
use light_phylogeny::{ArenaTree,Options,Config,Event,add_child,move_child,phyloxml_processing,
summary,reset_pos};
fn main() {
let mut tree: ArenaTree<String> = ArenaTree::default();
let mut options: Options = Options::new();
let config: Config = Config::new();
// Create a new node root
let root = tree.new_node("root".to_string());
// Create new nodes
let a1 = tree.new_node("a1".to_string());
let a2 = tree.new_node("a2".to_string());
let a = tree.new_node("a".to_string());
let b1 = tree.new_node("b1".to_string());
let b2 = tree.new_node("b2".to_string());
let b = tree.new_node("b".to_string());
let c = tree.new_node("c".to_string());
let d = tree.new_node("d".to_string());
println!("Initial tree :");
summary(&mut tree);
// Set names
tree.arena[root].name = "MyRoot".to_string();
tree.arena[a].name = "Gene A".to_string();
tree.arena[a1].name = "Gene A1".to_string();
tree.arena[a2].name = "Gene A2".to_string();
tree.arena[b].name = "Gene B".to_string();
tree.arena[b1].name = "Gene B1".to_string();
tree.arena[b2].name = "Gene B2".to_string();
tree.arena[c].name = "Gene C".to_string();
tree.arena[d].name = "Gene D".to_string();
println!("");
println!("Tree after name attribution:");
summary(&mut tree);
// Set hierarchy
// a1 and a2 are children of a
add_child(&mut tree,a,a1);
add_child(&mut tree,a,a2);
// a1 and a2 are children of a
add_child(&mut tree,b,b1);
add_child(&mut tree,b,b2);
// a and b are children of c
add_child(&mut tree,c,a);
add_child(&mut tree,c,b);
// c and d are children of root
add_child(&mut tree,root,c);
add_child(&mut tree,root,d);
println!("");
println!("Tree after hierarchy attribution:");
summary(&mut tree);
// Display internal nodes
options.gene_internal = true ;
phyloxml_processing(&mut tree, &options, &config,"modify_tree_ini.svg".to_string());
println!("Add a loss to C");
let loss = tree.new_node("loss".to_string());
tree.arena[loss].name = "Loss".to_string();
tree.arena[loss].e = Event::Loss;
add_child(&mut tree,c,loss);
println!("Add a node up to B");
let add = tree.new_node("add".to_string());
tree.arena[add].name = "Added up to B".to_string();
println!("Move A to new node ");
move_child(&mut tree, a, add);
println!("Move B to new node ");
move_child(&mut tree, b, add);
println!("Move new node to C ");
add_child(&mut tree, c, add);
println!("Tree after hierarchy modification:");
summary(&mut tree);
reset_pos(&mut tree);
phyloxml_processing(&mut tree, &options, &config,"modify_tree_mod.svg".to_string());
println!("Please open output files 'modify_tree_ini.svg' and 'modify_tree_mod.svg' with your browser");
println!("OK.");
}
代码示例
您可以在“examples”目录中尝试这些代码
cargo run --example read_newick
cargo run --example build_tree
cargo run --example lca
cargo run --example modify_tree
从recPhyloXML文件中读取和显示一个协调树
https://github.com/simonpenel/light_phylogeny/blob/master/examples/read_recphyloxml.rs
源文档
请参阅Rust文档: https://docs.rs/light_phylogeny/
“thirdkind”软件
https://github.com/simonpenel/thirdkind
recPhyloXML文档
请参阅: http://phylariane.univ-lyon1.fr/recphyloxml/
recPhyloXML论文: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6198865/
phyloXML文档
phyloXML论文: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2774328/
开发中
- 与过时的recPhyloXML格式可能存在问题(speciationLoss受支持,speciationOutLoss和speciationOut尚不支持)
树绘制算法和结构
“Arena”树结构受到以下代码的启发: 此处
许可证
依赖项
~4MB
~69K SLoC