@@ -114,7 +114,7 @@ we'll first add some mutations to our tree sequence with the
114114for each of the tree sequence's sample nodes:
115115
116116``` {code-cell}
117- ts_mut = msprime$sim_mutations(reduced_ts, rate=1e-4, random_seed=321)
117+ ts_mut <- msprime$sim_mutations(reduced_ts, rate=1e-4, random_seed=321)
118118paste(ts_mut$num_mutations, "mutations, genetic diversity is", ts_mut$diversity())
119119```
120120
@@ -123,15 +123,15 @@ sequence {meth}`~TreeSequence.genotype_matrix()` method to return the genotypes
123123the tree sequence as a matrix object in R.
124124
125125``` {code-cell}
126- G = ts_mut$genotype_matrix()
126+ G <- ts_mut$genotype_matrix()
127127G
128128is(G)
129129```
130130
131131We can then use R functions directly on the genotype matrix:
132132
133133``` {code-cell}
134- allele_frequency = rowMeans(G)
134+ allele_frequency <- rowMeans(G)
135135allele_frequency
136136```
137137
@@ -168,10 +168,10 @@ phylogenetic tree representation defined in the the popular
168168individual trees {meth}` exported in Newick format<Tree.as_newick> ` :
169169
170170``` {code-cell}
171- file = tempfile()
171+ file <- tempfile()
172172ts_mut$write_nexus(file)
173173# Warning - ape trees are stored independently, so this will use much more memory than tskit
174- trees <- ape::read.nexus(file, force.multi = TRUE) # return a set of trees
174+ trees <- ape::read.nexus(file, force.multi= TRUE) # return a set of trees
175175
176176# Or simply read in a single tree
177177tree <- ape::read.tree(text=ts_mut$first()$as_newick())
0 commit comments