using CSV # read/write CSV and similar formats
using DataFrames # versatile tabular data format
using PhyloNetworks # includes many utilities
using PhyloPlots # for plotting networks: via R
using RCall # run R within Julia
using StatsBase, StatsModels # basic stat functions, e.g. to build regression formulas
using Distributions # to get probabilities and quantiles of common distributions
Getting started
load packages and get the data
Load the packages we will use:
We will use data on Polemonium from Rose et al. 2021 and Teo et al. 2023.
For a preview, we can first load the network topology. It was estimated with SNaQ, so its branch lengths are in coalescent units, and it will need to be rooted correctly later.
= readnewick("data/polemonium_network_fromSNaQ.phy");
net_snaq "par"(mar=[0,0,0,0], cex=0.7); # 0 margins, cex<1 for smaller 'character expansion'
Rplot(net_snaq; showedgelength=true, xlim=[0,18]); # increased limit to see full taxon labels

then the trait data
= CSV.File("data/polemonium_traits_individual.csv") |> DataFrame
traits_indiv size(traits_indiv) # number of rows and number of columns
(1757, 6)
how to get help
help mode: type
?
then the name of the function (or package) you’d like information about. For example, if you type?
thenreadnewick
you should see this:> readnewick help?: readnewick readmultinewick writenewick readeach readlink readuntil readdir readline writemultinewick search readnewick(file name) readnewick(parenthetical description) readnewick(IO) Read tree or network topology from parenthetical format (extended Newick). If the root node has a single: ignore (i.e. delete from the topology) the root node and its child edge. child : text file or parenthetical format directly. The file name may not start with a left parenthesis, Input-style comments otherwise the file name itself would be interpreted as the parenthetical description. Nexus&...]) are ignored, and may be placed after (or instead) of a node name, and before/after an edge length. ([ A root edge, not enclosed within a pair a parentheses, is ignored. If the root node has a single edge, this one edge is removed.
Julia will automatically turn back to julian mode. If you don’t know the exact function name, give it your best try. Julia will indicate functions with similar names.
shell mode: type
;
to type a shell command. When you are done using the shell, type “delete” or “backspace” to return to julian mode.package mode: type
]
to access this mode, which provides quick ways to install a package withadd ...
, change the version of a package you already installed, check what packages and what version you’re currently using withstatus
, etc. Type backspace to return to julian mode.R mode, after using the RCall package: type
$
to access R. This R session has access to the variables created by Julia, and vice versa. Type backspace to return to julian mode. Doing@rlibrary ggplot2
within julia provides access to the R package ggplot2 package outside the R mode and with easy syntax.