Skip to content

Commit

Permalink
Updated gotree collapse name doc
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlemoine committed Nov 13, 2023
1 parent de95a71 commit 9216c7b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/collapsebrname.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var collapsebrnameCmd = &cobra.Command{
Names (or ID) are defined in an input file (-b)
If an external branch name/id is given, then does not do anything.
Branch identifiers are defined by preorder traversal of the tree, sorted as described in the input newick file.
If the tree or its newick representation is modified, identifiers will be different.
`,
RunE: func(cmd *cobra.Command, args []string) (err error) {
var f *os.File
Expand Down
59 changes: 59 additions & 0 deletions docs/commands/collapse.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
This command removes branches from a set of input trees. They apply only to internal branches, and not to branches connected to the root (for rooted trees). Three subcommands :
* `gotree collapse clade` will remove a clade from the tree. The clade is defined by all the descendants of the least common ancestor of the set of given tips. The command outputs the tree with the collapsed clade (`-o`) replaced by a tip whose name is given on the command line, and the tree consisting of the collapsed clade only (`-c`);
* `gotree collapse length` will remove branches whose length is less than or equal to the specified length;
* `gotree collapse name` will remove branches having given name or ID;
* `gotree collapse support` will remove branches whose support is less than the specified support;
* `gotree collapse depth` will remove branches whose depth is between (or equal to) given min and max depths. Here, depth is defined as the number of taxa on the lightest side of the branch.
* `gotree collapse single` will remove internal nodes and branches that form linear internal paths. For example:
Expand Down Expand Up @@ -70,6 +71,21 @@ Global Flags:
-o, --output string Collapsed tree output file (default "stdout")
```

name sub-command
```
Usage:
gotree collapse name [flags]
Flags:
-b, --brfile string File with one branch name/id per line (default "none")
--id Input file contains branch ids (otherwise, branch names)
Global Flags:
--format string Input tree format (newick, nexus, phyloxml, or nextstrain) (default "newick")
-i, --input string Input tree (default "stdin")
-o, --output string Collapsed tree output file (default "stdout")
```

support sub-command
```
Usage:
Expand Down Expand Up @@ -207,3 +223,46 @@ $ gotree collapse clade -i tree.nw -n new -c clade.nw l4 l6
$ cat clade.nw
(l4:0.1,((l5:0.2,l7:0.3):0.3,l6:0.3):0.1);
```

5. Collapsing branches given their ids

```
$ echo "((Tip4,Tip7,Tip2),Tip0,((Tip8,Tip9,Tip3),(Tip1,Tip6,Tip5)));" | gotree stats edges
```


|tree|brid|length|support|terminal|depth|topodepth|rootdepth|rightname|comments|leftname|rightcomment|leftcomment|
|----|----|------|-------|--------|-----|---------|---------|---------|--------|--------|------------|-----------|
|0|0|N/A|N/A|false|1|3|-1||[]||[]|[]|
|0|1|N/A|N/A|true|0|1|-1|Tip4|[]||[]|[]|
|0|2|N/A|N/A|true|0|1|-1|Tip7|[]||[]|[]|
|0|3|N/A|N/A|true|0|1|-1|Tip2|[]||[]|[]|
|0|4|N/A|N/A|true|0|1|-1|Tip0|[]||[]|[]|
|0|5|N/A|N/A|false|1|4|-1||[]||[]|[]|
|0|6|N/A|N/A|false|1|3|-1||[]||[]|[]|
|0|7|N/A|N/A|true|0|1|-1|Tip8|[]||[]|[]|
|0|8|N/A|N/A|true|0|1|-1|Tip9|[]||[]|[]|
|0|9|N/A|N/A|true|0|1|-1|Tip3|[]||[]|[]|
|0|10|N/A|N/A|false|1|3|-1||[]||[]|[]|
|0|11|N/A|N/A|true|0|1|-1|Tip1|[]||[]|[]|
|0|12|N/A|N/A|true|0|1|-1|Tip6|[]||[]|[]|
|0|13|N/A|N/A|true|0|1|-1|Tip5|[]||[]|[]|


```
$ echo "((Tip4,Tip7,Tip2),Tip0,((Tip8,Tip9,Tip3),(Tip1,Tip6,Tip5)));" | ./gotree collapse name --id -b <(echo -e "0\n5\n6" ) |gotree stats edges
```

|tree|brid|length|support|terminal|depth|topodepth|rootdepth|rightname|comments|leftname|rightcomment|leftcomment|
|----|----|------|-------|--------|-----|---------|---------|---------|--------|--------|------------|-----------|
|0|0|N/A|N/A|true|0|1|-1|Tip0|[]||[]|[]|
|0|1|N/A|N/A|true|0|1|-1|Tip4|[]||[]|[]|
|0|2|N/A|N/A|true|0|1|-1|Tip7|[]||[]|[]|
|0|3|N/A|N/A|true|0|1|-1|Tip2|[]||[]|[]|
|0|4|N/A|N/A|false|1|3|-1||[]||[]|[]|
|0|5|N/A|N/A|true|0|1|-1|Tip1|[]||[]|[]|
|0|6|N/A|N/A|true|0|1|-1|Tip6|[]||[]|[]|
|0|7|N/A|N/A|true|0|1|-1|Tip5|[]||[]|[]|
|0|8|N/A|N/A|true|0|1|-1|Tip8|[]||[]|[]|
|0|9|N/A|N/A|true|0|1|-1|Tip9|[]||[]|[]|
|0|10|N/A|N/A|true|0|1|-1|Tip3|[]||[]|[]|

0 comments on commit 9216c7b

Please sign in to comment.