~hms/gokstad

beautifully simple trees

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~hms/gokstad
read/write
git@git.sr.ht:~hms/gokstad

You can also use your local clone with git send-email.

#HMS gokstad

gokstad is intended for easy phylogenetic tree viewing in the terminal (with ASCII and colors) or making standard and circular svg files. These files are standard and easy to read and edit svg files. You can regex the text in the svg (e.g., remove underscores in your names, increase and decrease all font sizes, etc.). They can also be editing in standard svg software.

I am constantly updating things so if you have a feature or bug, please submit and check here.

#Installation

gokstad only relies on the svg.py project that you can install with pip install svg.py or as they suggest python3 -m pip install --user svg.py.

After installing this, you can just run python src/gokstad.py and you will get the options (see below).

#Tree input formats

  • gokstad takes newick files (so just the tree)
  • you can pipe trees (e.g., pxbdsim -e 10 | python gokstad or give as a file (e.g., python gokstad.py treefile))
  • colors will be done by internal labels (each label will get a color or you can use the -g argument if you want to use a gradient based on values)
  • if you want tips to have colors, either include the tip values as data in the newick as extended data (e.g., [&data=1.4])
  • if you want pie charts, then you need to include the information with the label pie (e.g., [&pie=1,2,3]). They will automatically be scaled. If you have internal labels as well then it needs to be like ...)2[&pie=1,2,3].

#Options

The options for godstad.py (at the moment are)

usage: gokstad [-h] [-o OUTFILE] [-i] [-d] [-u] [-l] [-c] [-s] [-g] [-b] [-bl]
               [-sc] [-cp] [-pie]
               [tree]

positional arguments:
  tree

options:
  -h, --help            show this help message and exit
  -o OUTFILE, --outfile OUTFILE
                        Output file if making svg. (default: test.svg)
  -i, --incorder        Increasing order of nodes. (default: False)
  -d, --decorder        Decreasing order of nodes. (default: False)
  -u, --unlabel         Dont show the tips (default: False)
  -l, --interlabels     Show internal labels. (default: False)
  -c, --circle          Circle tree to svg (give a filename). (default: False)
  -s, --standard        Standard tree to svg (give a filename). (default:
                        False)
  -g, --gradient        Do you want to use a gradient for colors (only svg)?
                        (default: False)
  -b, --scalebar        Do you want a scale bar? (default: False)
  -bl, --branchlenlab   Show branch length labels? (default: False)
  -sc, --scale          Scale branch lengths? (default: False)
  -cp, --coltippar      color tips the colors of their parents (default:
                        False)
  -pie, --pie           plot pie charts assuming information is as a note like
                        [&pie=3,2,1]. (default: False)

#Examples

These all assume that you have aliased gokstad.py as gk in the PATH.

  • simple terminal tree (gk 25.tree)
`                         ------------+ taxon_1   
       -------------------+                       
       :                  ------------+ taxon_2   
       :                                          
       :                        ----+ taxon_3     
       :                        +                 
       :                       -+---+ taxon_4     
       :                       ::                 
      -+                      -+-----+ taxon_5    
      ::                      ::                  
      ::                   ---+------+ taxon_6    
      ::                   :  :                   
      ::                  -+  --------+ taxon_7   
      ::                  ::                      
      ::                  ::       ---+ taxon_8   
------+-------------------+--------+              
:     :                   :        ---+ taxon_9   
:     :                   :                       
:     :                   -------------+ taxon_10 
:     :                                           
:     :           ---------------------+ taxon_11 
:     :           :                               
:     ------------+        -----------+ taxon_12  
:                 :--------+                      
:                 :        -----------+ taxon_13  
+                 +                               
:                 :            -------+ taxon_14  
:                 -------------+                  
:                              -------+ taxon_15  
:                                                 
:                 --------------------+ taxon_16  
:    -------------+                               
:    :            --------------------+ taxon_17  
:    :                                            
:    :                      ----------+ taxon_18  
:    :                      +                     
-----+                      :---------+ taxon_19  
     :   -------------------+                     
     :   :                  :        + taxon_20   
     :   :                  :      --+            
     :   :                  -------+ + taxon_21   
     ----+                         :              
         :                         ---+ taxon_22  
         :                                        
         :                ------------+ taxon_23  
         :              --+                       
         ---------------+ ------------+ taxon_24  
                        :                         
                        --------------+ taxon_25  

---- 0.266
       
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  • standard svg (gk -s 25.tree)

  • standard svg with colors (gk -s -l -i -cp 25.grad.tree)

  • standard svg with gradient colors (gk -s -g -l -i 25.grad.tree)

  • standard svg with tip colors (gk -s 25.tip.tree)

  • standard svg with tip colors of parents (gk -s -g -l -i -cp 25.grad.tree)

  • standard svg with branch length labels, scale bar (gk -s -l -i -b -g -bl 25.grad.tree)

  • standard svg with pie (gk -s -g -cp -pie results.pie)

  • circle svg with colors (gk -c 100.tree)

  • circle svg with tip colors (gk -c 25.tip.tree)

  • circle svg with tip colors of parents (gk -c -cp 25.grad.tree)

  • circle svg with branch length labels, scale bar (gk -c -cp -bl -b 25.grad.tree)

  • circle svg with pie (gk -c -pie -l -cp results.pie)

#Colors

You can customize which colors are used by editing the gokstad_conf.py file by changing the colorrotator values. These can be names or hex values. There is a random element to the assignment. However, if you need it to be non-random, let me know and I can add that.

There is a separate set of values for the gradient in the colorgrad variable. These are ordered and will be applied in a sorted manner to your data.

And there is a seperate set of values for the pie colors. Change as you like.

#Features to be added

#anlicnes

Gokstad

Gokstad was a beautiful and simple ship from the 9th century.

example

(modified from photo by Karamell, CC BY-SA 2.5)