Browse code

Add an example and more return statements

dunstone-a authored on 28/09/2023 12:04:21
Showing 13 changed files

... ...
@@ -1,8 +1,8 @@
1 1
 Package: QTLExperiment
2 2
 Type: Package
3
-Date: 2022-11-08
3
+Date: 2023-09-28
4 4
 Title: S4 classes for QTL summary statistics and metadata
5
-Version: 0.99.0
5
+Version: 0.99.1
6 6
 Authors@R: c(
7 7
     person("Christina", "Del Azodi", role=c("aut"), email="[email protected]"), 
8 8
     person("Davis","McCarthy", role=c("ctb"), email="[email protected]"),
... ...
@@ -12,6 +12,8 @@
12 12
 #' @name QTLe-coerce
13 13
 #' @rdname mash2qtle
14 14
 #'
15
+#' @returns A \linkS4class{QTLExperiment} object.
16
+#'
15 17
 #' @examples
16 18
 #' nStates <- 6
17 19
 #' nQTL <- 40
... ...
@@ -14,9 +14,13 @@
14 14
 #' nStates <- 6
15 15
 #' nQTL <- 40
16 16
 #'
17
+#' # Mock QTLExperiment data
18
+#'
17 19
 #' qtle <- mockQTLE(nStates, nQTL)
18 20
 #' dim(qtle)
19 21
 #'
22
+#' @returns an object containing simulated data.
23
+#'
20 24
 #' @author Christina B Azodi, Amelia Dunstone
21 25
 #' @export
22 26
 #'
... ...
@@ -20,6 +20,8 @@
20 20
 #'
21 21
 #' @example man/examples/qtle_load_example.R
22 22
 #'
23
+#' @returns A \linkS4class{QTLExperiment} object.
24
+#'
23 25
 #' @author
24 26
 #' Christina B Azodi, Amelia Dunstone
25 27
 #'
... ...
@@ -62,7 +64,7 @@ sumstats2qtle <- function(input, feature_id = "gene_id",
62 64
     } else{
63 65
         data <- vroom(input$path, id="path", show_col_types = FALSE,
64 66
                       n_max = n_max,
65
-                      col_select=list(path, feature_id = all_of(feature_id),
67
+                      col_select=list(all_of(path), feature_id = all_of(feature_id),
66 68
                                       variant_id = all_of(variant_id),
67 69
                                       betas = all_of(betas),
68 70
                                       errors = all_of(errors),
... ...
@@ -5,6 +5,40 @@
5 5
 #'
6 6
 #' @param object QTLExperiment object
7 7
 #'
8
+#' @returns A \linkS4class{QTLExperiment} object with recovered rowData or colData.
9
+#'
10
+#' @examples
11
+#'
12
+#' # Recover a column in colData
13
+#'
14
+#' qtle <- mockQTLE()
15
+#'
16
+#' head(colData(qtle))
17
+#'
18
+#' new_colData <- DataFrame(list(some_info1 = LETTERS[1:ncol(qtle)],
19
+#'                               some_info2 = c(1:ncol(qtle))))
20
+#'
21
+#' # colData is overwritten
22
+#' colData(qtle) <- new_colData
23
+#' head(colData(qtle))
24
+#'
25
+#' # colData is recovered
26
+#' qtle <- recover_qtle_ids(qtle)
27
+#' head(colData(qtle))
28
+#'
29
+#' # Recover information from rowData
30
+#'
31
+#' head(rowData(qtle))
32
+#'
33
+#' # variant_id are shuffled accidentally
34
+#' rowData(qtle)$variant_id <- sample(rowData(qtle)$variant_id, nrow(qtle))
35
+#' head(rowData(qtle))
36
+#'
37
+#' # Recover rowData
38
+#' qtle <- recover_qtle_ids(qtle)
39
+#' head(rowData(qtle))
40
+#'
41
+#'
8 42
 #' @name QTLe-recover
9 43
 #' @rdname recover_qtle_ids
10 44
 #' @docType methods
... ...
@@ -33,6 +33,8 @@
33 33
 #' passed to the corresponding \linkS4class{SummarizedExperiment} method.}
34 34
 #' }
35 35
 #'
36
+#' @returns A \linkS4class{QTLExperiment} object.
37
+#'
36 38
 #' @author
37 39
 #' Christina B Azodi
38 40
 #'
... ...
@@ -4,7 +4,7 @@
4 4
 #' the class structure. This is usually called by internal methods rather than
5 5
 #' by users or downstream packages.
6 6
 #'
7
-#' @param object A old \linkS4class{QTLExperiment} object.
7
+#' @param object An old \linkS4class{QTLExperiment} object.
8 8
 #' @param ... Additional arguments that are ignored.
9 9
 #' @param verbose Logical scalar indicating whether a message should be emitted
10 10
 #'        as the object is updated.
... ...
@@ -19,6 +19,12 @@
19 19
 #' @return
20 20
 #' An updated version of \code{object}.
21 21
 #'
22
+#' @examples
23
+#' qtle <- mockQTLE()
24
+#' objectVersion(qtle)
25
+#'
26
+#' qtle_new <- QTLExperiment::updateObject(qtle)
27
+#'
22 28
 #' @author Christina B Azodi
23 29
 #'
24 30
 #' @seealso
... ...
@@ -23,6 +23,9 @@ mash2qtle(data, sep = NULL, rowData = NULL, verbose = FALSE)
23 23
 
24 24
 \item{verbose}{Logical.}
25 25
 }
26
+\value{
27
+A \linkS4class{QTLExperiment} object.
28
+}
26 29
 \description{
27 30
 Function to coerce a mashr object (class list or mashr) into a QTLe object.
28 31
 }
... ...
@@ -23,6 +23,9 @@ mockMASHR_FIT(nStates = 10, nQTL = 100)
23 23
 
24 24
 \item{names}{Logical to include column and row names}
25 25
 }
26
+\value{
27
+an object containing simulated data.
28
+}
26 29
 \description{
27 30
 Functions to create fake input data for QTLExperiments.
28 31
 }
... ...
@@ -30,6 +33,8 @@ Functions to create fake input data for QTLExperiments.
30 33
 nStates <- 6
31 34
 nQTL <- 40
32 35
 
36
+# Mock QTLExperiment data
37
+
33 38
 qtle <- mockQTLE(nStates, nQTL)
34 39
 dim(qtle)
35 40
 
... ...
@@ -11,7 +11,43 @@ recover_qtle_ids(object)
11 11
 \arguments{
12 12
 \item{object}{QTLExperiment object}
13 13
 }
14
+\value{
15
+A \linkS4class{QTLExperiment} object with recovered rowData or colData.
16
+}
14 17
 \description{
15 18
 Function to recover protected rowData (feature_id, variant_id)
16 19
 and colData (state_id) from internal structure.
17 20
 }
21
+\examples{
22
+
23
+# Recover a column in colData
24
+
25
+qtle <- mockQTLE()
26
+
27
+head(colData(qtle))
28
+
29
+new_colData <- DataFrame(list(some_info1 = LETTERS[1:ncol(qtle)],
30
+                              some_info2 = c(1:ncol(qtle))))
31
+
32
+# colData is overwritten
33
+colData(qtle) <- new_colData
34
+head(colData(qtle))
35
+
36
+# colData is recovered
37
+qtle <- recover_qtle_ids(qtle)
38
+head(colData(qtle))
39
+
40
+# Recover information from rowData
41
+
42
+head(rowData(qtle))
43
+
44
+# variant_id are shuffled accidentally
45
+rowData(qtle)$variant_id <- sample(rowData(qtle)$variant_id, nrow(qtle))
46
+head(rowData(qtle))
47
+
48
+# Recover rowData
49
+qtle <- recover_qtle_ids(qtle)
50
+head(rowData(qtle))
51
+
52
+
53
+}
... ...
@@ -8,6 +8,9 @@
8 8
 \alias{[,QTLExperiment,ANY,ANY,ANY-method}
9 9
 \alias{[<-,QTLExperiment,ANY,ANY,QTLExperiment-method}
10 10
 \title{Subsetting and replacing data in QTLExperiment objects}
11
+\value{
12
+A \linkS4class{QTLExperiment} object.
13
+}
11 14
 \description{
12 15
 Includes methods to subset a \linkS4class{QTLExperiment} object by
13 16
 row and/or column and methods to replace all data for the specified rows
... ...
@@ -37,6 +37,9 @@ for testing purposes.}
37 37
 
38 38
 \item{verbose}{logical. Whether to print progress messages.}
39 39
 }
40
+\value{
41
+A \linkS4class{QTLExperiment} object.
42
+}
40 43
 \description{
41 44
 A suite of methods to extract QTL mapping summary statistics from common
42 45
 QTL workflow output files.
... ...
@@ -8,7 +8,7 @@
8 8
 \S4method{updateObject}{QTLExperiment}(object, ..., verbose = FALSE)
9 9
 }
10 10
 \arguments{
11
-\item{object}{A old \linkS4class{QTLExperiment} object.}
11
+\item{object}{An old \linkS4class{QTLExperiment} object.}
12 12
 
13 13
 \item{...}{Additional arguments that are ignored.}
14 14
 
... ...
@@ -29,6 +29,13 @@ internal class representation. Changes are as follows:
29 29
 \itemize{
30 30
 \item No updates yet.
31 31
 }
32
+}
33
+\examples{
34
+qtle <- mockQTLE()
35
+objectVersion(qtle)
36
+
37
+qtle_new <- QTLExperiment::updateObject(qtle)
38
+
32 39
 }
33 40
 \seealso{
34 41
 \code{\link{objectVersion}}, which is used to determine if the object is up-to-date.