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 生物学

Download history 260/week @ 2024-05-14 753/week @ 2024-05-21 371/week @ 2024-05-28 16/week @ 2024-06-04 16/week @ 2024-06-11 5/week @ 2024-06-18 14/week @ 2024-07-09 95/week @ 2024-07-16

每月109 次下载
4 crates 中使用

CECILL-2.1

605KB
4.5K SLoC

light_phylogeny at crates.io light_phylogeny at docs.rs light_phylogeny at docs.rs light_phylogeny at docs.rs License: GPL v2

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 标签将不予考虑)。

输出示例

具有物种树的单一基因协调

https://raw.githubusercontent.com/simonpenel/thirdkind/74b9c84a5b2ed84ff5230fc3a52af856b9aba53d/output_examples/thirdkind_example1.svg

没有物种树的相同基因协调

https://raw.githubusercontent.com/simonpenel/thirdkind/74b9c84a5b2ed84ff5230fc3a52af856b9aba53d/output_examples/thirdkind_example1_bis.svg

多基因协调

https://raw.githubusercontent.com/simonpenel/thirdkind/70a7a11aa89eda61926c5cabf221f47bb44e3409/output_examples/thirdkind_example4.svg

具有“自由生活”物种的示例

https://raw.githubusercontent.com/simonpenel/thirdkind/9eb47ce644998164ff56cc68eb765c0c8a24d389/output_examples/thirdkind_fl_example.svg

具有冗余转移的多基因树协调。仅显示 1 个基因树和红色转移,透明度根据转移的丰度而变化

https://raw.githubusercontent.com/simonpenel/thirdkind/70a7a11aa89eda61926c5cabf221f47bb44e3409/output_examples/thirdkind_example2.svg

有关更多示例,请参阅“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文档

请参阅: http://www.phyloxml.org/

phyloXML论文: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2774328/

开发中

  • 与过时的recPhyloXML格式可能存在问题(speciationLoss受支持,speciationOutLoss和speciationOut尚不支持)

树绘制算法和结构

“Arena”树结构受到以下代码的启发: 此处

树绘制算法在此处和 此处 以及 此处 有详细解释

许可证

CECILL: https://choosealicense.com/licenses/cecill-2.1/

依赖项

~4MB
~69K SLoC