11# ' @title Table collection R6 class (TableCollection)
2- # ' @description An R6 class holding an external pointer to a table collection
3- # ' object. As an R6 class, its methods look Pythonic and therefore resemble the
4- # ' tskit Python API. Since the class only holds the pointer, it is lightweight.
5- # ' Currently there is a limited set of R methods for working the tree sequence.
2+ # ' @description An \code{R6} class holding an external pointer to
3+ # ' a table collection object. As an \code{R6} class, method-calling looks Pythonic
4+ # ' and hence resembles the \code{tskit Python} API. Since the class only
5+ # ' holds the pointer, it is lightweight. Currently there is a limited set of
6+ # ' \code{R} methods for working with the table collection object.
67# ' @export
78TableCollection <- R6Class(
89 classname = " TableCollection" ,
@@ -16,7 +17,7 @@ TableCollection <- R6Class(
1617 # ' @param skip_reference_sequence logical; if \code{TRUE}, skip loading
1718 # ' reference genome sequence information.
1819 # ' @param xptr an external pointer (\code{externalptr}) to a table collection.
19- # ' @details See the corresponding Python function at
20+ # ' @details See the \code{tskit Python} equivalent at
2021 # ' \url{https://github.com/tskit-dev/tskit/blob/dc394d72d121c99c6dcad88f7a4873880924dd72/python/tskit/tables.py#L3463}.
2122 # ' TODO: Update URL to TableCollection.load() method #104
2223 # ' https://github.com/HighlanderLab/RcppTskit/issues/104
@@ -65,7 +66,7 @@ TableCollection <- R6Class(
6566
6667 # ' @description Write a table collection to a file.
6768 # ' @param file a string specifying the full path of the tree sequence file.
68- # ' @details See the corresponding Python function at
69+ # ' @details See the \code{tskit Python} equivalent at
6970 # ' \url{https://tskit.dev/tskit/docs/latest/python-api.html#tskit.TableCollection.dump}.
7071 # ' @return No return value; called for side effects.
7172 # ' @examples
@@ -86,7 +87,7 @@ TableCollection <- R6Class(
8687 },
8788
8889 # ' @description Create a \code{\link{TreeSequence}} from this table collection.
89- # ' @details See the corresponding Python function at
90+ # ' @details See the \code{tskit Python} equivalent at
9091 # ' \url{https://tskit.dev/tskit/docs/latest/python-api.html#tskit.TableCollection.tree_sequence}.
9192 # ' @return A \code{\link{TreeSequence}} object.
9293 # ' @examples
@@ -102,7 +103,88 @@ TableCollection <- R6Class(
102103 TreeSequence $ new(xptr = ts_xptr )
103104 },
104105
106+ # ' @description Get the number of provenances in a table collection.
107+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
108+ # ' @examples
109+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
110+ # ' tc <- tc_load(tc_file)
111+ # ' tc$num_provenances()
112+ num_provenances = function () {
113+ rtsk_table_collection_get_num_provenances(self $ xptr )
114+ },
115+
116+ # ' @description Get the number of populations in a table collection.
117+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
118+ # ' @examples
119+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
120+ # ' tc <- tc_load(tc_file)
121+ # ' tc$num_populations()
122+ num_populations = function () {
123+ rtsk_table_collection_get_num_populations(self $ xptr )
124+ },
125+
126+ # ' @description Get the number of migrations in a table collection.
127+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
128+ # ' @examples
129+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
130+ # ' tc <- tc_load(tc_file)
131+ # ' tc$num_migrations()
132+ num_migrations = function () {
133+ rtsk_table_collection_get_num_migrations(self $ xptr )
134+ },
135+
136+ # ' @description Get the number of individuals in a table collection.
137+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
138+ # ' @examples
139+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
140+ # ' tc <- tc_load(tc_file)
141+ # ' tc$num_individuals()
142+ num_individuals = function () {
143+ rtsk_table_collection_get_num_individuals(self $ xptr )
144+ },
145+
146+ # ' @description Get the number of nodes in a table collection.
147+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
148+ # ' @examples
149+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
150+ # ' tc <- tc_load(tc_file)
151+ # ' tc$num_nodes()
152+ num_nodes = function () {
153+ rtsk_table_collection_get_num_nodes(self $ xptr )
154+ },
155+
156+ # ' @description Get the number of edges in a table collection.
157+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
158+ # ' @examples
159+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
160+ # ' tc <- tc_load(tc_file)
161+ # ' tc$num_edges()
162+ num_edges = function () {
163+ rtsk_table_collection_get_num_edges(self $ xptr )
164+ },
165+
166+ # ' @description Get the number of sites in a table collection.
167+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
168+ # ' @examples
169+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
170+ # ' tc <- tc_load(tc_file)
171+ # ' tc$num_sites()
172+ num_sites = function () {
173+ rtsk_table_collection_get_num_sites(self $ xptr )
174+ },
175+
176+ # ' @description Get the number of mutations in a table collection.
177+ # ' @return A signed 64 bit integer \code{bit64::integer64}.
178+ # ' @examples
179+ # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
180+ # ' tc <- tc_load(tc_file)
181+ # ' tc$num_mutations()
182+ num_mutations = function () {
183+ rtsk_table_collection_get_num_mutations(self $ xptr )
184+ },
185+
105186 # ' @description Get the sequence length.
187+ # ' @return A numeric.
106188 # ' @examples
107189 # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
108190 # ' tc <- tc_load(tc_file)
@@ -112,6 +194,7 @@ TableCollection <- R6Class(
112194 },
113195
114196 # ' @description Get the time units string.
197+ # ' @return A character.
115198 # ' @examples
116199 # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
117200 # ' tc <- tc_load(tc_file)
@@ -121,6 +204,7 @@ TableCollection <- R6Class(
121204 },
122205
123206 # ' @description Get whether the table collection has edge indexes.
207+ # ' @return A logical.
124208 # ' @examples
125209 # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
126210 # ' tc <- tc_load(tc_file)
@@ -130,7 +214,7 @@ TableCollection <- R6Class(
130214 },
131215
132216 # ' @description Build edge indexes for this table collection.
133- # ' @details See the corresponding Python function at
217+ # ' @details See the \code{tskit Python} equivalent at
134218 # ' \url{https://tskit.dev/tskit/docs/latest/python-api.html#tskit.TableCollection.build_index}.
135219 # ' @return No return value; called for side effects.
136220 # ' @examples
@@ -146,7 +230,7 @@ TableCollection <- R6Class(
146230 },
147231
148232 # ' @description Drop edge indexes for this table collection.
149- # ' @details See the corresponding Python function at
233+ # ' @details See the \code{tskit Python} equivalent at
150234 # ' \url{https://tskit.dev/tskit/docs/latest/python-api.html#tskit.TableCollection.drop_index}.
151235 # ' @return No return value; called for side effects.
152236 # ' @examples
@@ -160,6 +244,7 @@ TableCollection <- R6Class(
160244 },
161245
162246 # ' @description Get whether the table collection has a reference genome sequence.
247+ # ' @return A logical.
163248 # ' @examples
164249 # ' tc_file1 <- system.file("examples/test.trees", package = "RcppTskit")
165250 # ' tc_file2 <- system.file("examples/test_with_ref_seq.trees", package = "RcppTskit")
@@ -171,9 +256,10 @@ TableCollection <- R6Class(
171256 rtsk_table_collection_has_reference_sequence(self $ xptr )
172257 },
173258
174- # ' @description Get the file UUID string.
175- # ' @details Returns the UUID of the file the table collection was loaded from.
176- # ' If unavailable, returns \code{NA_character_}.
259+ # ' @description Get the UUID string of the file the table collection was
260+ # ' loaded from.
261+ # ' @return A character; \code{NA_character_} when file is information is
262+ # ' unavailable.
177263 # ' @examples
178264 # ' tc_file <- system.file("examples/test.trees", package = "RcppTskit")
179265 # ' tc <- tc_load(tc_file)
@@ -182,14 +268,15 @@ TableCollection <- R6Class(
182268 rtsk_table_collection_get_file_uuid(self $ xptr )
183269 },
184270
185- # ' @description This function saves a table collection from R to disk and
186- # ' loads it into reticulate Python for use with the \code{tskit} Python API.
187- # ' @param tskit_module reticulate Python module of \code{tskit}. By default,
188- # ' it calls \code{\link{get_tskit_py}} to obtain the module.
271+ # ' @description This function saves a table collection from \code{R} to disk
272+ # ' and loads it into reticulate \code{Python} for use with the
273+ # ' \code{tskit Python} API.
274+ # ' @param tskit_module reticulate \code{Python} module of \code{tskit}.
275+ # ' By default, it calls \code{\link{get_tskit_py}} to obtain the module.
189276 # ' @param cleanup logical; delete the temporary file at the end of the function?
190277 # ' @details See \url{https://tskit.dev/tutorials/tables_and_editing.html#tables-and-editing}
191278 # ' on what you can do with the tables.
192- # ' @return Table collection in reticulate Python.
279+ # ' @return \code{TableCollection} object in reticulate \code{ Python} .
193280 # ' @seealso \code{\link{tc_py_to_r}}, \code{\link{tc_load}}, and
194281 # ' \code{\link[=TableCollection]{TableCollection$dump}}.
195282 # ' @examples
@@ -222,7 +309,9 @@ TableCollection <- R6Class(
222309 # ' @description Print a summary of a table collection and its contents.
223310 # ' @return A list with two data.frames; the first contains table collection
224311 # ' properties and their values; the second contains the number of rows in
225- # ' each table and the length of their metadata.
312+ # ' each table and the length of their metadata. All columns are characters
313+ # ' since output types differ across the entries. Use individual getters
314+ # ' to obtain raw values before they are converted to character.
226315 # ' @examples
227316 # ' ts_file <- system.file("examples/test.trees", package = "RcppTskit")
228317 # ' tc <- tc_load(file = ts_file)
0 commit comments