@@ -27,7 +27,74 @@ The key files you should study are:
2727You can install and test this package by running:
2828
2929```
30+ # Install from GitHub
3031remotes::install_github("HighlanderLab/RcppTskitTestLinking")
32+
33+ # Load the package
3134library(RcppTskitTestLinking)
32- ?ts_num_individuals2
35+
36+ # Check the help page for one implemented function
37+ ?ts_num_individuals_ptr2
38+ ```
39+
40+ Now run the example from the help page.
41+ Below we mark it up to explain what is what.
42+
3343```
44+ # Find an example tree sequence file in RcppTskit package
45+ > ts_file <- system.file("examples", "test.trees", package = "RcppTskit")
46+ > ts_file
47+ [1] "/Users/ggorjanc/Library/R/arm64/4.5/library/RcppTskit/examples/test.trees"
48+
49+ # Load tree sequence into R workspace
50+ > ts <- RcppTskit::ts_load(ts_file)
51+
52+ # Check summary of the tree sequence
53+ > ts
54+ Object of class 'TreeSequence'
55+ $ts
56+ property value
57+ 1 num_samples 160
58+ 2 sequence_length 10000
59+ 3 num_trees 26
60+ 4 time_units generations
61+ 5 min_time 0
62+ 6 max_time 7.47028168974859
63+ 7 has_metadata FALSE
64+
65+ $tables
66+ table number has_metadata
67+ 1 provenances 2 NA
68+ 2 populations 1 TRUE
69+ 3 migrations 0 FALSE
70+ 4 individuals 80 FALSE
71+ 5 nodes 344 FALSE
72+ 6 edges 414 FALSE
73+ 7 sites 2376 FALSE
74+ 8 mutations 2700 FALSE
75+
76+ # Note that we have 80 individuals in ts
77+
78+ # We can obtain the same number by running
79+ > ts$num_individuals()
80+ [1] 80
81+
82+ # This demo package implemented the same function
83+ # that is available in RcppTskit, but since we here
84+ # focus just on C++ code, we have to work with the
85+ # pointer object (externalptr) `ts$pointer` and
86+ # not with the tree sequence object (TreeSequence) `ts`
87+ > ts_num_individuals_ptr2(ts$pointer)
88+ [1] 80
89+ ```
90+
91+ ## Wrap up
92+
93+ Hopefully this demo package shows you sufficiently well on how
94+ to leverage ` RcppTskit ` for your package.
95+
96+ If we develop any methods that should work on
97+ the tree sequence object (` TreeSequence ` ),
98+ then the methods could go into ` RcppTskit::TreeSequence ` or
99+ new packages could inherit from this class and add their
100+ methods.
0 commit comments